Methods of payment Abuse

How to change file permissions in Linux

05.12.2023, 23:24

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.

Command syntax

chmod [options] file permissions

Options:

  1. -R - recursively change permissions for all files and folders in a specified directory
  2. -v - output of information about each change of rights
  3. -c - display information only about files that have had their permissions changed

Rights:

r - reading

w - entry

x - fulfillment

Examples

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. 

How to change file permissions in Linux

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.