Setting Setuid Permission
The setuid permission allows a program to run with the permissions of the file owner.
chmod u+s file
u+s
: This sets the setuid permission for the user.
For example, to set the setuid permission on an executable file named program
, you can use:
chmod u+s program
Setting Setgid Permission
The setgid permission ensures that files created in a directory inherit the group ownership of the directory, rather than the user’s default group.
chmod g+s directory
g+s
: This sets the setgid permission for the group.
For example, to set the setgid permission on a directory named shared
, you can use:
chmod g+s shared
Setting the Sticky Bit
The sticky bit ensures that only the file owner can delete or rename their files in a directory.
chmod +t directory
+t
: This sets the sticky bit.
For example, to set the sticky bit on a directory named uploads
, you can use:
chmod +t uploads
These commands and options are fundamental to managing permissions on a Linux system. Understanding them allows you to control access and secure your system effectively.