glugt-mgl

 

File permissions

Page history last edited by msk 2 yrs ago

 

Every file or folder in Linux has access permissions. There are three types of permissions (what allowed to do with a file):

  • read access
  • write access
  • execute access

Permissions are defined for three types of users:

  • the owner of the file
  • the group that the owner belongs to
  • other users

Thus, Linux file permissions are nine bits of information (3 types x 3 type of users), each of them may have just one of two values: allowed or denied.

Simply put, for each file it can be specified who can read or write from/to the file. For programs or scripts it also can be set if they are allowed to be executed.

 

It is used in Linux long directory listings. It consists of 10 characters. The first character shows the file type. Next 9 characters are permissions, consisting of three groups: owner, group, others. Each group consists of three symbols: rwx (in this order), if some permission is denied, then a dash "-" is used instead. Example:

-rwxr--r--
0123456789
  • Symbol in the position 0 ("-")is the type of the file. It is either "d" if the item is a directory, or "l" if it is a link, or "-" if the item is a regular file.
  • Symbols in positions 1 to 3 ("rwx") are permissions for the owner of the file.
  • Symbols in positions 4 to 6 ("r--") are permissions for the group.
  • Symbols in positions 7 to 9 ("r--") are permissions for others.

r Read access is allowed
w Write access is allowed
x Execute access is allowed
- Replaces "r", "w" or "x" if according access type is denied

 

Access permissions for files and folders mean different things from the user standpoint.

The table below shows the difference.

 

Access type File Folder
Read If the file contents can be read If the directory listing can be obtained
Write If user or process can write to the file (change its contents) If user or process can change directory contents somehow: create new or delete existing files in the directory or rename files.
Execute If the file can be executed If user or process can access the directory, that is, go to it (make it to be the current working directory)

 

For information on how to change the permissions for the file, check "Intermediate shell operation"

 

Comments (0)

You don't have permission to comment on this page.