UNIX – What is a sticky bit ?

History

The sticky bit was first introduced in 1974 within the UNIX operating system. Its purpose was to instruct the operating system to place the process into swap once completed. Thus reducing the startup time of the process during further executions. However nowdays this usage is obsolete.

Usage

Instead, the sticky bit is now set on a directory. With the intention to limit only the directory owner, the item owner or root to rename or delete any child items.
The sticky bit is represented by either a ‘t’ or ‘T’ and is displayed within the execute permission section for ‘others’.

[root@server ~]# ls -ld /tmp
drwxrwxrwt 11 root root 4096 Oct 24 22:09 /tmp

Difference between T`s

So you may be asking. What is the difference between ‘t’ and ‘T’ ?
A lowercase ‘t’ represents the “x” being unset, whereas ‘T’ represents the ‘x’ being unset.

-rwxrwxrwt - sticky bit and others execute bit set
-rwxrwxr-T - sticky bit is set and others execute bit is not set

Configuration

To configure sticky on a directory the following command is used.

[root@server ~]# chmod +t /tmp/test/

[root@server ~]# ls -ld /tmp/test/
drwxrwxrwt 11 root root 4096 Oct 24 22:09 /tmp/test
Rick Donato

Want to become a UNIX expert?

Here is our hand-picked selection of the best courses you can find online:
UNIX Administration Fundamentals
Vim Masterclass
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial