Checking, reviewing, and modifying file permissions
We have learned so far how to create users and groups, and even provide administrative capabilities to them. It's time now to see how permissions work at the files and directories level.
As you'll remember, in Chapter 3, Basic Commands and Simple Shell Scripts, we already saw how to see the permissions that are applied to a file. Let's review them now and dive deeper.
Let's get the permissions info for some example files by listing it with the –l
, for long, option. Remember to run this as the root
user (or using sudo
):
[root@rhel8 ~]# ls -l /usr/bin/bash -rwxr-xr-x. 1 root root 1150704 jun 23 2020 /usr/bin/bash [root@rhel8 ~]# ls -l /etc/passwd -rw-r--r--. 1 root root 1324 ene 24 21:35 /etc/passwd [root@rhel8 ~]# ls -l /etc/shadow ----------. 1 root root 1008 ene 24 21:35 /etc/shadow [root@rhel8 ~]# ls -ld /tmp drwxrwxrwt. 8 root root 172 ene 25 17:35 /tmp
Remember that, in Linux...