Read, write, and execute

Users and groups are used as the first two layers of protection for accessing a file. The user that owns a file has a set of permissions that differs from the file group. Whoever is not the owner and does not belong to the group has different permissions. These three sets of permissions are known as owner, group, and other.

For each element of the set there are three actions that may be carried out: reading, writing, and executing. This is very straightforward for files but it means something different for directories. Read makes it possible to list the contents, write is used to add new links inside, and execute is used to navigate it.

Three permissions are represented by an octal value, where the first bit is read permission, the second is write, and the third is execute. They can also be represented by the letters r, w, and x in sequence and the possible values are as follows:

  • 0 or ---: No permissions
  • 1 or --x: Execute permission (execute a file or navigate to a directory)
  • 2 or -w-: Write permission (write a file or add new files in a directory)
  • 3 or -wx: Write and execute
  • 4 or r--: Read permission (read a file or list the contents of a directory)
  • 5 or r-x: Read and execute
  • 6 or rw-: Read and write
  • 7 or rwx: Read, write, and execute

The sequence of three octal values represent permission for user, group, and others:

  • 777: Everyone can read, write, and execute.
  • 700: Owner can read, write, and execute.
  • 664: Owner and group can read and write.
  • 640: Owner can read and write and group can read.
  • 755: Owner can read, write, and execute, while group and others can read and execute.

The ls command with the -l flag (or its alias, ll) shows the list of files and the folder for the current directory with their permissions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.80.3