To change file access rights in Linux, use the command chmod (change mode)
. It allows you to change read, write, and execute permissions for the owner, group, and other users.
chmod [options] file permissions
Options:
-R
- recursively change permissions for all files and folders in a specified directory-v
- output of information about each change of rights-c
- display information only about files that have had their permissions changedRights:
r
- reading
w
- entry
x
- fulfillment
The action can be one of two, either add - the "+" sign, or remove - the "-" sign. As for the access rights themselves, they are similar to the output of the ls
utility.
For example, all users have full access to the test5 file:
chmod ugo+rwx test0
Or take away all rights from the group and the rest of the users:
chmod go-rwx test0
Give the group the right to read and execute:
chmod g+rx test0
The rest of the users are read-only:
chmod o+r test0
Set SUID for file test6:
chmod u+s test1
And for test7, it's SGID:
chmod g+s test2
Let's see what we got:
ls -l
As you can see, it's simple.