Access rights in the file system under Linux determine which actions users are allowed to perform on files and directories. These rights are a central part of security and access management in Linux. They determine who can read, write or execute files.
1. The three basic access rights:
2. The three user classes:
3. Representation of access rights:
4. Changing access rights:
5. Changing ownership rights:
1.) The three basic access rights:
- Read ( r for "read" )
: The right to read the contents of a file or to list the contents of a directory.
- Write ( w for "write" )
: The right to change the contents of a file or to add or delete files in a directory.
- Execute ( x for "execute" )
: The right to execute a file as a program or to change to a directory ( "enter" the directory ).
2.) The three user classes:
- Owner ( user or u )
: The user who owns the file.
- Group ( group or g )
: The group of users who have certain rights to the file.
- Others ( others or o )
: All other users who are not the owner or part of the group.
3.) Representation of access rights:
Access rights are represented in a 10-character string, e.g. -rwxr-xr-- . The meaning of the characters:
- The first character indicates the type of file ( - for normal file, d for directory).
- The next three characters ( rwx ) stand for the owner's rights.
- The following three characters ( rx ) stand for the group's rights.
- The last three characters ( r-- ) stand for the other users' rights.
An example:
-rwxr-xr--Means:
- A regular file ( - ).
- The owner can read, write and execute ( rwx ).
- The group can read and execute ( rx ).
- Other users can only read ( r-- ).
4.) Changing access rights:
The access rights can be changed using the chmod command . There are two methods:
- Symbolic method
: Rights are changed using symbols. Example: chmod u+x file adds the execute right for the owner.
- Numeric method
: Rights are specified as numeric values (octal notation). Example: chmod 755 file sets the rights to rwxr-xr-x .
5.) Change ownership rights:
- Change Owner : The chown
command can be used to change the owner of a file. Example: chown user file . - Change Group : The chgrp command can be used to change the group. Example: chgrp group file . Access rights are important to ensure security and correct access to files and directories under Linux.