Showing posts with label Debian. Show all posts
Showing posts with label Debian. Show all posts

Wednesday, May 8, 2019

How to view httpd.conf file or any config files in Linux without coments

Hello,

Have you ever wondered how to view the Linux configurations files without those comments? Well those comments are indeed helpful, but think about configuration files such as httpd.conf and squid.conf files. These files have good amount of commented lines.

The issue with the httpd.conf file in particular is that not all commented lines starts with #. Some commented lines start after a tab.

Example:
# Further relax access to the default document root:

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
You could remove those tabbed comments as well using "sed" or using "egrep" with proper Regex.


# egrep -v "^$|*#" /etc/httpd/conf/httpd.conf

Or

# sed '/ *#/d; /^ *$/d' /etc/httpd/conf/httpd.conf


Hope this helps.

Regards,
Jay

Thursday, April 25, 2013

Set Setuid, Setgid and Sticky bit in Linux

Special permissions on files and directories in linux are : SetUID, SetGID and Sticky bit.

With the help of “chmod” command  we can implement the special permissions on file and directories.

SUID / Set User ID : A program is executed with the file owner's permissions (rather than with the permissions of the user who executes it).

SGID / Set Group ID : Files created in the directory inherit its GID, i.e When a directory is shared between the users , and sgid is implemented on that shared directory , when these users creates  directory, then the created directory has the same gid or group owner of its parent directory.

Sticky Bit :  It is used mainly used on folders in order to avoid deletion of a folder and its content by other user though he/she is having write permissions. If Sticky bit is enabled on a folder, the folder is deleted by only owner of the folder and super user(root). This is a security measure to suppress deletion of critical folders where it is having full permissions by others.

Tuesday, April 13, 2010

Set multiple IPs in single nic.

Hello guys...
Ever wondered how to set multiple IPs in a single network card? Here is the solution.

Multiple IP binded in a single network card allows you run different services in different IPs, for example you can run HTTP on one IP and SMTP on another IP or a private LAN using a local IP and the alias holding your Public IP. The major benifit here is that you do not need an additional physical adaptor, you can bind many virtual IPs to a single network card. Here I have explained the procedure for creating multiple IPs for RedHat based and Debian bases systems

Redhat based systems.

Let me assume that your NIC is bound with a static IP address. Go to the folder /etc/sysconfig/network-scripts/, there you will find your network configuration files.

# cd /etc/sysconfig/network-scripts/

Let me also guess that your machine has only one network card (can be onboard too!!!), then you will find a file ifcfg-eth0 in the folder. This file holds the IP information for the first nic. If your machine has more nics you will have ifcfg-eth1, ifcfg-eth2 and so on... Now open the ifcfg-eth0 file, you can view the network configuration as below:

# cat ./ifcfg-eth0# File: ifcfg-eth0


DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.120
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
NETWORK=192.168.1.0
HWADDR=xx:xx:xx:xx:xx:xx


Now to bind another IP address to the same network card, you just have to copy the ifcfg-eth0 file to ifcfg-eth0:1.
 
# cp ./ifcfg-etho ./ifcfg-eth0:1

Wednesday, March 3, 2010

Labeling a Linux partition - Volume Labels

Here we shall discuss about labeling a Linux partition and its advantages. 

You might have seen labeled partitions if you have opened and viewed the /etc/fstab file. There you can see that the 'root', 'home', 'boot, and other system partitions are labeled and are mounted using the label rather than referring the device name. The advantage is that, the root partition will be the same even if the device name got changed in an unlikely event during the system startup. The volume labels make the partition retain a consistent name regardless of where they are connected and what else are connected. And for your information such an unlikely event of changing the device name is quiet often if you are mounting mounting multiple iSCSI drives to your system. 

Hope you know about the iSCSI target and initiator stuffs, it is the low cost, high efficient alternative for costly storage solutions. Hope I could give you an elaborate post about iSCSI soon coz that too is one of my hot favorite topic.  However here we will discuss about labeling the Linux partition labeling.

setuid File Permission in UNIX/Linux

In this post I am going to describe you about the 'setuid' in UNIX and Linux.

setuid or 'set user ID upon execution' and setgid or 'set group ID upon execution' are UNIX access right flags which are used to allow users to run an executable file with the permission of the executable file's owner or group. If the setuid is enabled for an executable file, the user executing the file will get permissions of the user or group that owns the executable file. This is very useful for allowing users on a computer system to run programs with temporarily elevated privileges for performing a particular task. 

These programs are needed for performing some tasks like 'ping' from an unprivileged user. The ping executable in /usr/bin folder is set with setuid bit on and consider its owner is root. So that whenever the ping command is used it is executed with elevated privileges and hence all the unprivileged users can use the ping command unless they are explicitly blocked form using it via some other means. By this hope you got the concept of setuid. Please continue reading for knowing more about setting, listing and more about setuid.