Linux file permissions

Linux operating system uses license regime specify user rights to each file. This set of permissions:

-Who can read the file. If the file is a directory, read the contents of the directory means the list.
-Who can write / edit files. If the file is a directory, this permission determines whether you can make changes to the contents of the directory, for example, create or delete files.
-What can execute the file. If the file is a directory, this permission determines whether you can enter the directory and access its contents, for example, search the directory or run a program in it.

Permissions are assigned to the file owner, the owner of the file, and for all users. For example, you can configure your document readable and writable by the owner only, and can only be read by others.

When you run the command ls-l to get a list of all the contents of the directory, you will see the file permissions like this next to each file:

-Rwxrwxrwx

This means that it is readable, writable and executable by anyone. The first dash means that the file is not a directory. For a directory, there will be no advertising letters dashes.

The first series of “rwx” means the owner of the file. The second series, with the owners. The last set for all other users. Look at some examples:

-Rwxr – r -
This file can be read, written and signed by the holder. It can not be read by other users. If permission is not set, you see the dashboard in place.

-Rw-rw-r -
This file can be read and written by the owner and the group. It can not be read by other users.

You can set these permissions by using the chmod command. For example, the following command:

chmod ugo = rwx file

assigned to read, write and execute permissions to the user who owns the file (u), group (g) and others (o). Here is another example:

chmod ug = rw, o = r filename

assigned reading and writing for users and groups, and only read permission for others.

Permissions can also be expressed and defined by using octal number system. Allow each corresponding to the numbers:

Read = 4
Writing = 2
Run = 1

You must come up with a number for the owner of the file, another number for the group and the last for other users. If you want to assign read, write and execute permissions for the file owner, you add the three values ​​to obtain 7. If you want to give the same permissions for group and others, you come with September 3 You can set these permissions as follows:

chmod 777 file

If you set permissions for a file with the following command:

chmod 764 file

then you set the permissions: read, write and execute permissions for the file owner (4 +2 +1 = 7), read and write for the group (4 +2 = 6) and just read for others (4) .

The following commands are equivalent:

chmod ug = rw, o = r filename
chmod 664 file

Permissions on the schema files allow you to apply security policies. This is not a good idea to set permissions of files is large (eg, 777) for all files. It is important to reflect and set the permissions for the file, so that users can do their work, and we believe that all the files are accessible only by the right people.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>