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 Set-UID
Let's review how Set-UID applies to files and directories:
- Set-UID 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.
- Set-UID permission applied to a directory: No effect.
Let's check a file with Set-UID:
[root@rhel8 ~]# ls -l /usr/bin/passwd -rwsr-xr-x. 1 root root 33544 dic 13 2019 /usr/bin/passwd
The passwd
command requires root
permissions to change hashes in the /etc/shadow
file.
To apply this permission, we can use the chmod
command, applying u+s
permissions:
[root@rhel8 ~]# touch testsuid [root@rhel8 ~]# ls -l testsuid -rw-r--r--. 1 root root 0 ene 28 05:16 testsuid...