Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
16.08.2025
No categories

How to Check Permissions of a File in Linux ?

Linux is one of the most popular operating systems powering VPS servers, web hosting platforms, and virtual machines across the world. At the core of Linux security lies its file permission system — rules that define who can read, modify, or execute a file. Knowing how to check permissions in Linux is essential for managing a VPS, setting up secure hosting environments, or working inside a virtual machine.

The Basics of File Permissions

Each file and directory in Linux has three types of permissions:

  • Read (r) → view file contents or list a directory.
  • Write (w) → modify or delete a file, add or remove files in a directory.
  • Execute (x) → run a file (if it’s a program) or enter a directory.

And these permissions apply to three categories of users:

  • Owner (user) → usually the creator of the file.
  • Group → users belonging to the file’s group.
  • Others → everyone else.

Checking Permissions with ls -l

The simplest way is to use the ls -l command:

ls -l file.txt

Example output:

-rw-r--r-- 1 user group 1024 Aug 16 12:30 file.txt
  • -rw-r–r– → permissions
  • user → owner
  • group → group
  • file.txt → filename

Here, -rw-r–r– means:

  • Owner: read, write
  • Group: read
  • Others: read

Detailed Information with stat

For more details, use:

stat file.txt

Example:

Access: (0644/-rw-r--r--) Uid: (1000/user) Gid: (1000/group)

Now you see permissions in two forms: symbolic (-rw-r–r–) and numeric (0644).

Understanding Numeric Values

Permissions can be represented as numbers:

  • Read = 4
  • Write = 2
  • Execute = 1

Adding them gives the permission value:

  • rw- = 6
  • r-x = 5
  • rwx = 7

So 0644 = Owner: 6 (read/write), Group: 4 (read), Others: 4 (read).

Permissions for Directories

For directories, the rules are slightly different:

  • r → list the names of files.
  • w → create or delete files (if x is also set).
  • x → enter the directory.

Example:

ls -ld myfolder
drwxr-x---

Here, the owner has full rights, the group can read/enter, and others have no access.

Special Permission Bits

Linux also supports advanced permissions:

  • setuid (s) → run file with the owner’s privileges.
  • setgid (s) → run file with group’s privileges.
  • sticky bit (t) → in directories, only the file owner can delete their files (common in /tmp).

Example:

drwxrwxrwt /tmp

The t at the end means sticky bit.

Quick Reference Table

SymbolicNumericMeaning (File)Meaning (Directory)
0No accessNo access
–x1ExecuteEnter
-w-2WriteCreate/delete (with x)
-wx3Write + ExecuteModify + enter
r–4ReadList names (with x)
r-x5Read + ExecuteList + enter
rw-6Read + WriteView + modify contents
rwx7Full accessFull control

Examples You’ll See Often

  • -rw-r–r– (0644) → owner can read/write; others can only read.
  • -rwxr-xr-x (0755) → owner can do everything; others can run but not modify.
  • drwxrwxrwt (1777) → world-writable folder with sticky bit (like /tmp).

Conclusion

To check file permissions in Linux:

  • Use ls -l for a quick look.
  • Use stat for detailed output.
  • Learn to read both symbolic (rwx) and numeric (755, 644) notations.
  • Remember that directories follow the same rules but interpret x differently.

Once you understand these basics, permissions become a powerful and easy-to-read part of Linux security.

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills

Похожие записи не найдены.