When working in relative mode, you have to use the following values for the permissions that are available:
Read: r Write: w Execute: x SUID: u+s SGID: g+s Sticky bit: t
The relative mode is useful when changing permissions that apply to everyone. For example, you can easily make a script file executable by using chmod +x myscript. Because u, g, or o are not used in this command to refer to the entity the permissions are applied to, the file will be made executable for everyone. You can, however, be more specific; for example, just remove the write permission for the others entity by using chmod o-w somefile.
SUID is set with u+s, and SGID is set with g+s. In the output of the ls -l command, however, there is no reserved permission to display this permission alone. As the result, you will see the SUID permission at the position of the x for users and the SGID permission at the position of the x for groups. You can see this in Listing 6-2 where the first file has SUID applied and the second file has
SGID applied. Both permissions really make sense only in combination with the execute permission; therefore, I won't discuss the hypothetical situation of a file having SUID applied but not execute for the owner or having SGID but not execute for the group.
Listing 6-2. Displaying SUID and SGID with ls -l
-rwsr-xr-x 2 root root 48782 2006-03-09 11:47 somefile -rwxr-sr-x 2 root root 21763 2006-03-09 11:48 someotherfile
Was this article helpful?