To set the sticky bit on a directory in a Unix-like operating system, you can use the chmod command. Here are the steps to do so:
-
Open Terminal: Access your terminal or command line interface.
-
Use
chmodCommand: You can set the sticky bit using either symbolic or octal notation.-
Using Symbolic Notation:
chmod +t directory_nameReplace
directory_namewith the name of the directory where you want to set the sticky bit. -
Using Octal Notation:
You can also set the sticky bit along with other permissions using octal notation. For example, to set the sticky bit along with read, write, and execute permissions for everyone:chmod 1777 directory_nameHere,
1represents the sticky bit, and777represents read, write, and execute permissions for the owner, group, and others.
-
-
Verify Sticky Bit: After setting the sticky bit, you can verify it by listing the directory's permissions:
ls -ld directory_nameLook for a
tat the end of the permission string, indicating that the sticky bit is set.
Example
To set the sticky bit on a directory named shared_dir, you would run:
chmod +t shared_dir
or
chmod 1777 shared_dir
This will ensure that only the owners of files within shared_dir can delete or rename their files.
