15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started
28.01.2026

Understanding Linux File Permissions and How to Manage Them

One of the key foundations of Linux system security and multi-user architecture is its file permission model. Unlike Windows, Linux strictly enforces ownership and access control for every file and directory in the system. Mastering file permissions isn’t just about security — it’s essential for managing servers, deploying software, running scripts, and automating tasks.

The Linux File Permission Model

Every file and directory in Linux has three types of access rights, assigned to three types of users:

User ClassDescription
ownerThe user who owns the file
groupUsers in the file’s group
othersAll other users on the system

Each class can be given three types of permissions:

PermissionSymbolMeaning
readrView file contents / list dir
writewModify file or directory
executexRun file or access directory

 

Viewing Permissions with ls -l

Use the ls -l command to display file permissions:

ls -l myscript.sh

Output:

-rwxr-xr-- 1 alice devs 2048 Jan 25 10:00 myscript.sh

Breakdown:

  • – → regular file
  • rwx → owner (read/write/execute)
  • r-x → group (read/execute)
  • r– → others (read only)

 

Changing Permissions with chmod

📌 Symbolic Mode:

chmod u+x myscript.sh # Add execute to user chmod g-w myscript.sh # Remove write from group chmod o=r myscript.sh # Set read-only for others

📌 Numeric Mode:

chmod 755 myscript.sh # rwx for owner, rx for group, rx for others
OctalMeaning
7rwx
6rw-
5r-x
4r–
0

Example:

chmod 644 file.txt # owner: rw-, group: r--, others: r-- chmod 700 script.sh # owner: rwx, group/others: ---

 

Managing Ownership with chown and chgrp

Change file owner:

chown alice file.txt

Change group:

chgrp devs file.txt

Change both:

chown bob:admins file.txt

Use -R to apply changes recursively:

chown -R www-data:www-data /var/www/

 

Special Permission Bits

Linux supports three special modes that modify default behavior:

1. SUID (Set User ID)

  • Applies to executable files
  • Runs with owner’s privileges, not caller’s
chmod u+s /usr/bin/passwd

🔍 ls -l output: -rwsr-xr-x

Use case: /usr/bin/passwd must run as root to update /etc/shadow.

SGID (Set Group ID) s

  • On files: run with file’s group privilege
  • On directories: new files inherit the group
chmod g+s /opt/project

🔍 ls -l output: drwxr-sr-x

Useful in shared development folders.

Sticky Bit t

  • On directories: only owner can delete/rename their files
  • Common in /tmp to protect user files
chmod +t /shared/folder

ls -ld /tmp

drwxrwxrwt 10 root root 4096 Jan 28 12:00 /tmp

Understanding umask

The umask sets default permissions for new files/directories:

Check current value: umask

Common value: 0022

FileDefault permsWith umask 0022
File666 → 644rw-r–r–
Dir777 → 755rwxr-xr-x

Set temporary umask:

umask 0077 # Files: 600, Dirs: 700

 

Recursive Permission Fixes

Set folder and file permissions separately:

find /my/project -type d -exec chmod 755 {} \; find /my/project -type f -exec chmod 644 {} \;

Conclusion

Linux file permissions provide fine-grained access control for security, multi-user environments, and automation. Understanding how to view, change, and enforce permissions empowers you to manage servers confidently, protect data, and collaborate safely.

Whether you’re deploying web applications, managing cloud servers, or building shell scripts — knowing your way around chmod, chown, umask, and special permission bits is essential.

 

15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started