Delinea Blog > Linux file permissions explained: chmod, chown, umask

Linux file permissions explained: chmod, chown, umask

Published May 2025
Read time 8 minutes
What you will learn
Linux file permissions control who can read, write or execute files. But special bits, ACLs and recursive commands make them easy to get wrong. This guide explains how permissions work, how to manage them safely, and how least privilege and centralized access control reduce the risk of managing them by hand.

A single chmod 777 or a forgotten setuid binary can give an account far more access than it needs. On a shared Linux server, that one setting can be enough for a cyber criminal to move from a low-privilege account to root. 

File permissions are where least privilege starts on Linux. Every user, group and process should only have the access it requires for its job. Below are the commands that control those permissions, the mistakes that undo them and how to manage access as your server count grows.

What are Linux file permissions?

Linux file permissions define which users and groups can read, write or execute a file or directory. Each file has permissions assigned to the owner, group and others, using combinations of read (r), write (w) and execute (x) rights to control access and enforce system security.

How Linux users and groups work

In Linux, a user is more than just a name; it's a distinct identity defined by a user ID (UID). Permissions on files and processes are checked against that identity and its groups. To streamline access control, users can be grouped under a group ID (GID), which allows administrators to manage permissions for multiple users at once, an approach called group-based access control. 

Each user is assigned to a primary group, typically created automatically with the same name as the user account (a user private group). This group sets the default group ownership of files and processes the user creates. Beyond that, users can be added to one or more secondary groups, enabling access to additional shared files and directories across the system. 

Most major distributions, including Debian, Ubuntu and RHEL, default to the user private group model, though administrators can configure this differently. 

User and group information lives in plain text files:

  • /etc/passwd. Stores basic user account details.
  • /etc/group. Tracks group memberships.

To inspect user details and group memberships, use these commands:

  • id username. Shows the UID, GID and all associated groups.
  • groups username. Lists only the group names the user belongs to.

Group membership is where least privilege starts. Every secondary group adds access, so review memberships regularly and remove the ones a user no longer needs. 

Types of file and directory permissions

Linux permissions fall into three types: read (r), write (w) and execute (x). They mean slightly different things for files and directories.

Permission On a file On a directory
Read (r) View the contents List the contents
Write (w) Change the contents Create, delete and rename entries inside (also requires execute)
Execute (x) Run the file as a program Enter and navigate the directory

Deleting a file depends on write permissions in the directory that contains it, not on the file itself. 

Reading the rwx permission string

The rwx permission triplet represents the permissions for each category: owner, group and others. This representation using letters is called symbolic mode. 

Take this permission string, for example:

-rwxr-xr--

  • The first character (-) shows the file type: - for a regular file, d for a directory.
  • rwx is the owner's permissions.
  • r-x is the group's permissions.
  • r-- is everyone else's (others') permissions.

The permission triplet can also use octal notation, which represents permissions as r = 4, w = 2, x = 1, and - = 0. The values of each triplet are added together to form a single digit. 

In octal, -rwxr-xr-- becomes:

  • rwx = 4 + 2 + 1 = 7
  • r-x = 4 + 0 + 1 = 5
  • r-- = 4 + 0 + 0 = 4

Together, that's 754.

How to change permissions with chmod

As an admin, you can change Linux permissions for files and directories through the chmod command-line utility. chmod stands for “change mode,” and you can use it in both symbolic and octal modes. 

Symbolic mode

In symbolic mode, use chmod with the symbols +, - and = to add, remove or set specific permissions, followed by the file name. The letters u, g and o stand for the owner, group and others. 

For instance:

chmod u+x filename.txt

This adds execute permissions for the owner only, without affecting the group or others.

Numeric mode

In numeric mode, chmod is followed by the octal permissions and the file name:

chmod 754 filename.txt

This translates to  -rwxr-xr--, which means the file owner can read, write and execute, the group can read and execute, and others can only read the file. 

Recursive changes

To update the permissions of a directory and everything inside it, use the recursive (-R) option with chmod:

chmod -R 754 my_dir

This sets my_dir and every file and directory inside it to 754 (read, write and execute for the owner; read and execute for the group; read for others).

A numeric recursive mode applies the same permissions to files and directories, which can make every file in the tree executable. To avoid that, use the symbolic X, which adds execute only to directories and files that are already executable:

chmod -R u=rwX,g=rX,o=r my_dir

NOTE: Use recursive chmod cautiously. One mistake can change permissions across thousands of files and grant far more access than intended.

Default permissions and umask

When you create a new file or directory on Linux, its default permissions automatically apply. Before umask is applied, the default for files is 666 (rw-rw-rw-) and for directories it's 777 (rwxrwxrwx). 

You can control these default permissions by setting the umask, which clears permission bits from the defaults. The umask is a bitmask, usually written as three or four octal digits (for example, 022  or  0025), where each digit marks the permissions to deny for the owner, group and others. The result is the default with the umask bits cleared.

Permissions = Default AND NOT umask

For instance, an umask of  022 gives new files 644 (rw-r--r--) and new directories 755 (rwxr-xr-x). A umask of  027  gives new files 640 (rw-r-----) and new directories  750 (rwxr-x---), so other users can't read anything new by default. 

Special permission bits

Special permission bits change how programs and directories behave. Setuid and setgid allow a program to run with the privileges of its owner or group, which is why they require careful auditing. The bits are:

  • setuid. Set user ID lets a file run with the permissions of the file's owner, not the user running it. 
  • setgid. For files, setgid causes the process to run with the file's group ID. For directories, it makes newly created files inherit the directory’s group. 
  • Sticky bit. This setting applies only to directories, not to individual files. It means only the file owner, directory owner or root can delete or rename files in that directory.  It is usually used for public directories like  /tmp  so users don’t accidentally delete files they don’t own.

Access control lists (ACLs)

Access control lists (ACLs) give you finer control over permissions than the traditional owner, group and others model. They let you define specific access rights for individual users or groups without changing base file ownership. That makes them useful for least privilege: you can give one user access to one file without exposing the whole group.

On current distributions, ACL support is enabled by default on common file systems such as ext4 and XFS. On older systems, you may need to enable it with the  acl  mount option.

ACLs have two main commands:  getfacl  and  setfacl.  getfacl lets you view the ACLs on a file or directory and  setfacl  lets you modify or add ACL entries.

For instance, to view the ACLs for a file named fidel.txt, use:

getfacl fidel.txt

To give a user read and write access, use this basic syntax:

setfacl -m u:alice:rw testfile.txt

How to change ownership with chown and chgrp

Changing file ownership and group in Linux is another way to control permissions and access. To do this, you can use either the chown or  chgrp  command. Keep in mind that changing ownership requires you to have sudo or root privileges.

For instance:

sudo chown esther filename.txt

This changes the ownership of the file filename.txt to the user esther. 

To change the group ownership of filename.txt to the expats group, use  chgrp:

sudo chgrp expats filename.txt

You can also change both the owner and the group with one command:

sudo chown esther:expats filename.txt

Common mistakes and best practices for Linux permissions

Mistakes happen, especially when permissions are managed by hand. These are the most common ones and how to avoid them:

  • Over-permissive settings. Some settings, like  chmod 777, can expose your Linux system to cyber criminals if they are not monitored. Avoid them, except in rare cases, like in the  /tmp  directory, which is world-writable but protected by the sticky bit. You can also use  umask  to restrict default Linux permissions. 
  • Incorrect ownership. If you give the wrong user ownership of a file or directory, it can lead to serious security issues like privilege escalation. Review ownership regularly with the  ls -l  command, and use ACLs for granular control, especially for collaborative environments. 
  • Not auditing special bits. Setuid and setgid bits are a target for cyber criminals because a setuid-root program runs with root privileges. If they go unmonitored, cyber criminals can use them to escalate their privileges and cause serious damage to your system. To find them, search the file system and review the results regularly, or use file integrity monitoring tools. For example, this command lists setuid files:

    find / -perm -4000 -type f 2>/dev/null

  • Standing root and sudo access. Accounts that keep root or broad sudo rights all the time give a cyber criminal more to work with if one is compromised. Grant elevated access only when it's needed, limit it to the commands the task requires and remove it when the task is done. 

How Delinea applies least privilege on Linux servers

Linux file permissions will always matter, but they shouldn't be your only line of defense. They control what an account can do once it's on a server. Privilege Control for Servers adds controls around who gets privileged access to your Linux servers, how much they get and for how long:

  • Discover servers and accounts. Privilege Control for Servers discovers servers, accounts and permissions across your environment, so you can see who has privileged access before you tighten it. 
  • Use one identity across Linux and Windows. Active Directory bridging joins Linux and Unix servers to your AD domain, so admins sign in with their AD accounts instead of separate local accounts.
  • Elevate privileges just-in-time. Just-in-time, just-enough privilege elevation gives admins elevated rights only when a task requires them, reducing standing privilege on your servers. 
  • Verify identity at login and elevation. Multi-factor authentication (MFA) at server login and during privilege elevation adds identity assurance before anyone is granted elevated rights. 
  • Record privileged activity. Audit logs and session recordings on each server capture privileged activity for forensic review, so access is auditable and defensible.

File permissions still decide what each account can do on the host, so keep managing them carefully. With least privilege enforced around them, a single permission mistake is less likely to lead to a breach. 

See how it works: try an interactive demo  of Privilege Control for Servers.

Related Topics