Using special permissions
As we’ve seen in the previous section, there are special permissions that could be applied to files and directories. Let’s start by reviewing Set-UID (or SUID) and Set-GUID (or SGID).
Understanding and applying SUID
Let’s review how SUID applies to files and directories:
- SUID permission applied to a file: When applied to an executable file, this file will run as if the owner of the file was running it, applying the permissions.
- SUID permission applied to a directory: No effect.
Let’s check a file with SUID:
[root@rhel-instance ~]# ls -l /usr/bin/passwd -rwsr-xr-x. 1 root root 32648 Aug 10 2021 /usr/bin/passwd
Tip
In this example, s
in the executable bit of the user block is lowercase because the executable bit is set – if the executable bit isn’t set, it will be in uppercase (S
).
The passwd
command requires root
permissions to change hashes in the /etc/shadow
file.