Showing posts with label Linux Concepts. Show all posts
Showing posts with label Linux Concepts. Show all posts

Friday, October 25, 2013


Sticky bit is a bit set in permission of a file or directory to give special access –rights to user. When we set the sticky bit for any executable file, it will remain in swap space after the process exited. It will help to reduce time of execution in repeatedly used programs. So, we can set this sticky bit for frequently used programs like editors, commands etc. So, execution of them will be faster as compared to without sticky bit.
Main important use of sticky bit is on directory, when we set sticky bit for directory then files reside in the directory can delete or rename by owner only. This is helpful not to give access for renaming or deletion to unauthorized user. When sticky bit is not set for directory then any user having permission to write and execute on directory can rename and delete files inside the directory.

Sticky bit behavior or feature changes as per operating system. Linux Kernel ignores the sticky bit on files, it considers only on directories. In HP-UX work on sticky bit as above mentioned. In AIX, if we set the sticky bit for directory then only owner can link or unlink the directory or files specified in the directory.

How to set Sticky bit on file/directory in Linux?

We will set sticky bit by chmod command. For this purpose, we can use octal mode or by its symbol ‘t’. lets go through the example.

//Check the permissions of directory sticky
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-x 2 redhat adm 4096 2013-10-24 15:36 sticky
redhat@localhost:~/mywork$ ls -l sticky/                            //inside directory permissions
total 8
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:35 stickybit.sh
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:36 stickybit.sh_bak
//Adding sticky bit in permission by below syntax ..or use - chmod 1755 sticky
redhat@localhost:~/mywork$ chmod +t sticky/                         
redhat@localhost:~/mywork$ ls -l sticky/
total 8
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:35 stickybit.sh
-rwxr-xr-x 1 redhat adm 57 2013-10-24 15:36 stickybit.sh_bak
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
//In above line sticky bit added in permissions
redhat@localhost:~/mywork$


Now we have set the sticky bit to directory. Now we will try to remove file or script inside the directory.

//Changing the user. Sandeep and redhat having same group.
redhat@localhost:~/mywork/sticky$ su - Sandeep
Password:
Sandeep@localhost:~$
Sandeep@localhost:~$ pwd
/home/Sandeep
Sandeep@localhost:~$ cd ../redhat            //Change Directory to that sticky bit directory
Sandeep@localhost:/home/redhat$ ls
mywork
Sandeep@localhost:/home/redhat$ ls -l
total 4
drwxr-xr-x 3 redhat adm 4096 2013-10-24 15:39 mywork
Sandeep@localhost:/home/redhat$ cd mywork/
Sandeep@localhost:/home/redhat/mywork$ ls -l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
Sandeep@localhost:/home/redhat/mywork$
Sandeep@localhost:/home/redhat/mywork$ cd sticky/
Sandeep@localhost:/home/redhat/mywork/sticky$ ls
stickybit.sh  stickybit.sh_bak
//Trying to remove sticky bit set directory content ..getting error permission denied
Sandeep@localhost:/home/redhat/mywork/sticky$ rm stickybit.sh
rm: remove write-protected regular file `stickybit.sh'? y
rm: cannot remove `stickybit.sh': Permission denied
Sandeep@localhost:/home/redhat/mywork/sticky$

Permission denied while removing the file which resides into the directory whose sticky bit has been set already. This is the actual use of sticky bit on directory.

How to remove sticky bit of directory/file ?

We need to login by redhat or root user before removing sticky bit then only we can remove the Sticky bit.

redhat@localhost:~/mywork$ ls –l
total 4
drwxr-xr-t 2 redhat adm 4096 2013-10-24 15:36 sticky
//use below syntax or use – chmod 755 sticky
redhat@localhost:~/mywork$ chmod -t sticky/
redhat@localhost:~/mywork$ ls -l
total 4
drwxr-xr-x 2 redhat adm 4096 2013-10-24 15:36 sticky
redhat@localhost:~/mywork$


Drop an email if you have any query regarding the Linux issue or like our page on Facebook and post a query.
Posted by Machindra Dharmadhikari On 10/25/2013 09:29:00 PM No comments READ FULL POST

Monday, June 3, 2013

Netstat Command in Linux                                                               vmstat Command in Linux

It is very easy to check local network speed in Windows but if you have putty access to Linux machine then we are facing issues to check the network speed. There are some tools are available to check network speed iin Linux but it is not possible to install this tools on client machine or our secured machine.

Network speed in linux is depend on the Ethernet card or network interface card which you are using for this machine. Might be there are multiple Ethernet cards already configured, we can check network speed for each separately.

Generally, Ethernet cards are configured. If we see the the output of below command then we will get all NICs.

root@hello:~# ifconfig -a
eth0   Link encap:EthernetHWaddr 1c:6f:65:0b:00:eb
          inet addr:10.136.25.42  Bcast:10.136.25.255  Mask:255.255.255.0
          inet6 addr: fe80::1e6f:65ff:fe0b:eb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1133376 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34516 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:11234117 (113.8 MB)  TX bytes:9056744 (9.0 MB)
          Interrupt:16 Memory:fc500000-fc520000

lo       Link encap:Local Loopback     
          inet addr:127.0.0.1  Mask:255.255.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:20442 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20442 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2356951 (2.3 MB)  TX bytes:2356951 (2.3 MB)
root@hello:~#

If we see in above output, there are two cards configured. But eth0 is the main. So we need to check network speed for it only.

For Ethernet card,

root@hello:~# ethtool eth0 | less

If this command is not found then go for below command

root@hello:~# dmesg  | grep -i duplex
[   16.773492] e100e: eth0 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
root@hello:~#

Above command will be helpful to check system is half duplex or full duplex. Dmesg command gives lots of information but it is not that much of useful for us just grep needed information.

                We can check network speed of wireless card and chipset information.

                root@hello:~#lspci | grep -i wireless

                To test internet connection speed from the console over ssh command line, we need to install lftp and iperf packages. They are easily available. We can download rpm of them or install it from yum repository.

After installation, download or upload data by lftp, pget command or check network speed between two IPs by iperf command.


I got some useful information regarding this topic on one site. Please go through it.

Check CPU usage in Linux                                                                usermod command in Linux
Posted by Machindra Dharmadhikari On 6/03/2013 08:38:00 PM 3 comments READ FULL POST
  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube

    Chitika Ads 2

    Histat

    About

    Enter your email address:

    Delivered by FeedBurner