Simplified Linux File Permissions Concept

In Linux, file permissions determine who can read, write, or execute a file or directory. Each file or directory has an associated set of permissions for three categories of users:

  1. Owner (user who owns the file)
  2. Group (group of users who share the file)
  3. Others (everyone else)

Permissions Types:

  • Read (r): Allows reading the contents of a file or listing the contents of a directory.
  • Write (w): Allows modifying or deleting a file or directory.
  • Execute (x): Allows running a file (if it’s a program/script) or accessing a directory.

File Permission Representative:

  • Symbolic Notation: The file permissions are represented using letters. Example: rwxr-xr — The first rwx refers to the owner’s permissions: read, write, execute. The second r-x refers to the group’s permissions: read and execute. The third r — refers to others’ permissions: only read.
  • Numeric Notation: Permissions are also represented by numbers, where: Read = 4 Write = 2 Execute = 1

The permissions are calculated by adding these values together.

For example:

  • rwx (read, write, execute) = 4 + 2 + 1 = 7
  • r — (read only) = 4
  • r-x (read and execute) = 4 + 1 = 5
  • A permission like rwxr-xr — would be written as 755.

Viewing File Permissions:

To view file permissions, use the ls -l command in the terminal:

$ ls -l

rwxr-xr — 1 owner group 1024 Oct 22 10:00 file.txt

The first part (-rwxr-xr — ) shows the permissions. The next fields show the owner, group, file size, date modified, and file name.

Thats a wrap!!

I hope this article is useful to you. See you in the next post.