Checking,
reviewing, and modifying file permissions
155
And to remove
read permissions from others, we run the following:
[root@rhel-instance
]# chmod or file.txt[root@rhel-instance
]# ls -l file.txt-rw-rw----. 1 root root 0 Mar 11 22:30 file.txtThe permissions are stored in four octal digits. This means that special permissions are stored in a number from 0 to 7, the same way user, group, and
other permissions are stored, each one of them with a number from 0 to Some examples are shown as follows:
Table 5.2 – Example file permissions
How does it work We assign a number (power of 2)
for each permission Read: 2^2 = 4
•
Write: 2^1 = 2
•
Execute: 2^0 = 1
•
Nothing: We add them:
rwx = 4 + 2 + 1 = 7
rw- = 4 + 2 = 6
r-x = 4 + 1 = r- = 4
--- = This is how we can assign permissions using numbers. Now, let’s try it:
Share with your friends: