Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
It seems that there's a confusion between the "stick bit" and the "sticky bit." The term "stick bit" is not valid in Linux. Instead, the term "sticky bit" refers to a special file permission used in Linux and other Unix-like operating systems. In this tutorial, we will discuss the sticky bit, its purpose, and how to set and remove it.
The sticky bit is a special permission that can be set on directories. When it is set on a directory, it restricts file deletion within the directory, allowing only the file owner, directory owner, or the root user to delete or rename files. The sticky bit is commonly used on shared directories, such as /tmp
and /var/tmp
, to prevent users from accidentally or maliciously deleting files owned by other users.
The chmod
command can be used to set the sticky bit on a directory. The sticky bit is represented by the letter t
in the permissions string or the octal value 1000
. To set the sticky bit using the symbolic method, use the following command:
sudo chmod +t /path/to/directory
To set the sticky bit using the octal method, add 1000
to the existing octal permissions value. For example, if the current permissions are 755
(rwxr-xr-x), use the following command:
sudo chmod 1755 /path/to/directory
To check if the sticky bit is set on a directory, use the ls
command with the -l
option:
ls -ld /path/to/directory
If the sticky bit is set, you will see a t
at the end of the permissions string:
drwxrwxr-t 2 user group 4096 May 11 10:00 /path/to/directory
To remove the sticky bit from a directory, use the chmod
command with the -t
option (for the symbolic method) or subtract 1000
from the existing octal permissions value:
Symbolic method:
sudo chmod -t /path/to/directory
Octal method:
sudo chmod 0755 /path/to/directory
In this tutorial, we've discussed the sticky bit, its purpose in Linux systems, and how to set, check, and remove it using the chmod
command. Understanding and properly using the sticky bit can help enhance security and prevent unauthorized file deletion in shared directories.
How to set and view the sticky bit in Linux: The sticky bit is represented by a 't' in the last position of the permission string. To set it:
chmod +t filename
Sticky bit and directory permissions in Linux: When applied to a directory, the sticky bit ensures that only the owner of a file within the directory can delete or rename that file.
chmod +t directory
Using chmod
to apply the sticky bit in Unix:
Use the chmod
command with the octal notation to set the sticky bit. For example:
chmod 1777 directory