Methods of payment Abuse

How to change file permissions in Linux

05.12.2023, 23:24

To change file access rights in Linux, the chmod (change mode) command is used. It allows you to change read, write, and execute permissions for the owner, group, and other users.

Syntax

of the chmod command [options] file rights

Options:

-R - recursively change permissions for all files and folders in the specified directory

-v - output information about each change of rights

-c - displays information only about files whose permissions have been changed

Rights:

r - reading

w - record

x - execution

Examples

The action can be one of two things, 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 we will take away all rights from the group and other users:

chmod go-rwx test0

Let's give the group the right to read and execute:

chmod g+rx test0

For other users, read only:

chmod o+r test0

For the test6 file, set the SUID:

chmod u+s test1

And for test7 - SGID:

chmod g+s test2

Let's see what happened:

ls -l

As you can see, everything is simple.