Linux is a multi-user system, so every file and directory carries permissions that decide who can read, change or run it. Understanding Linux file permissions is essential for administrators, developers and anyone securing a server. This guide explains how permissions work, how to read them and how to change them safely.

Owners and classes
Each file has:
- an owner (user);
- a group;
- permissions for three classes: user (u), group (g) and others (o).
The three permissions
| Permission | On a file | On a directory |
|---|---|---|
| Read (r) | View the contents | List the names of files inside |
| Write (w) | Change the contents | Create, delete or rename files inside |
| Execute (x) | Run it as a program or script | Enter the directory (cd) and access files inside |
The directory meanings surprise many people. For example, a user can delete a file they cannot write to if they have write permission on the directory containing it.
Reading permissions
$ ls -l report.sh
-rwxr-x--- 1 asha devops 512 Oct 20 10:15 report.sh- The first character shows the type:
-file,ddirectory,llink. rwx: the owner (asha) can read, write and execute.r-x: the group (devops) can read and execute.---: others have no access.
Changing permissions with chmod
Symbolic mode
chmod u+x script.sh # add execute for the owner
chmod g-w report.txt # remove write for the group
chmod o= secret.txt # remove all permissions for others
chmod u=rw,go=r notes.txt # set exact permissionsNumeric (octal) mode
Each permission has a value: read = 4, write = 2, execute = 1. Add them for each class.
| Number | Permissions | Common use |
|---|---|---|
| 644 | rw-r–r– | Regular files |
| 600 | rw——- | Private files, such as SSH keys |
| 755 | rwxr-xr-x | Programs and public directories |
| 750 | rwxr-x— | Team directories |
| 700 | rwx—— | Private directories, such as ~/.ssh |
chmod 640 config.ini
chmod -R 750 /srv/projectUse -R carefully, because it changes everything beneath a directory.
Changing ownership with chown and chgrp
sudo chown asha report.txt
sudo chown asha:devops report.txt
sudo chgrp devops report.txt
sudo chown -R www-data:www-data /var/www/siteDefault permissions: umask
The umask removes permissions from new files and directories. With the common umask 022, new files get 644 and new directories get 755. A stricter umask of 027 gives 640 and 750.
umask # show the current value
umask 027 # set it for this sessionCommon mistakes
- Using 777. It lets anyone change or replace the file. Fix ownership or group membership instead.
- Wrong SSH permissions. SSH refuses keys if
~/.sshorauthorized_keysare too open. - Web files owned by the web server. If the web server can write to its code, an attacker who compromises it can too.
Going further
For special permissions (SUID, SGID and the sticky bit) and access control lists, read Linux special permissions and ACLs. To manage who belongs to which group, see Linux user and group management.
Sources
Running Linux servers in production? Our Linux server hardening & security audit checks configuration, patching, SSH and logging. You can also use our free Linux server hardening checklist, or contact us.

Pingback: Linux File & Directory Advance Permission - Youngster Company
Pingback: Linux User & Group Management - Youngster Company
Pingback: Linux Interview Questions - Youngster Company
Pingback: What is Swap Partition and how to create it on Linux