How-to

Linux File Permissions, Explained for Server Admins

Every access check on your machine goes through the same small model: an owner, a group, nine bits and a few extras. Understand it once and most access errors explain themselves.

How do I read a permission listing?

Run ls -l and look at the first column:

-rw-r----- 1 deployer www-data  4210 Dec  3 08:40 settings.php
drwxr-s--- 5 deployer www-data  4096 Dec  3 08:40 storage
lrwxrwxrwx 1 root     root        23 Dec  1 17:02 current -> /srv/releases/2026-12-01

The first character is the type: - file, d folder, l symlink. Then come three groups of three: owner, group, others. In the first line, the owner deployer can read and write, the group www-data can read, and others have nothing. The s in the second line is the setgid bit, so new files in storage inherit the www-data group.

How does Linux decide whether I may access a file?

It checks in order and stops at the first match. If you are the owner, the owner bits apply, and only those. Otherwise, if you belong to the file's group, the group bits apply. Otherwise, the others bits apply. That first-match rule produces a classic surprise: an owner with --- cannot read a file even if the group and others bits allow it.

Root skips this check for reading and writing, which is why a mistake as root has such reach. Execute is the exception: root may only run a file if at least one execute bit is set.

What do the bits mean on files and folders?

BitOn a fileOn a folder
r (4)Read contentsList names inside
w (2)Change contentsCreate, delete and rename entries
x (1)Run as a programEnter and reach items by name

One consequence: deleting a file depends on the folder's write bit, not the file's. A read-only file in a writable folder can still be removed by anyone who can write the folder, unless the sticky bit is set on that folder.

Where do default permissions come from?

From the umask, a mask of bits removed from every new file and folder. Programs ask for 666 on files and 777 on folders; the umask takes bits away. With the common umask 022, new files get 644 and folders 755. With 027, they get 640 and 750, so others get nothing.

umask                 # show the current mask
umask 027             # stricter for this shell session

For services, set the mask in the unit file with UMask=0027 under [Service], so files they create are private by default. For login users, the system default lives in /etc/login.defs.

What are ACLs and when do I need them?

Access control lists add extra entries beyond one owner and one group. They help when two unrelated groups need different access to the same folder, for example a developers group with write access and a monitoring account with read access:

setfacl -R -m g:devteam:rwX,u:monitor:rX /srv/app
setfacl -R -d -m g:devteam:rwX /srv/app      # default ACL for new files
getfacl /srv/app/config

A + at the end of the mode column in ls -l shows that a file has ACLs. Every file system on our images supports them. Use them sparingly; plain owner and group rules are easier to reason about.

What does SELinux add on Rocky Linux and AlmaLinux?

A second, independent check. Even when mode bits allow access, SELinux can deny it if the file's label does not fit the process. A web server may read files labeled httpd_sys_content_t but not files labeled for home folders. When an access error makes no sense from ls -l, check labels with ls -Z and recent denials with ausearch -m avc -ts recent. Fix labels with restorecon rather than disabling SELinux.

Which permissions matter most on a fresh server?

  • SSH keys: ~/.ssh 700 and authorized_keys 600, or key login fails.
  • Secrets such as .env files and API tokens: 600 or 640 with a service group.
  • Web roots: folders 755 or 750, files 644 or 640, writable folders owned by the service.
  • No file anywhere writable by others: find / -xdev -type f -perm -0002 -ls should print nothing outside /tmp-like places.

To change modes, see The chmod command; to change owners, The chown command.

Keep Reading

The chmod command

Change file modes with numbers or letters, understand what each bit does and use special bits like setgid and sticky correctly.

Open

The chown command

Every useful form of chown: owner, group, both, numeric IDs, reference files and the rules about who may change ownership.

Open

chmod 755 explained

What mode 755 grants, where it belongs on a server, where it does not, and how it compares with 750, 775 and 644.

Open

Rocky Linux

Rocky Linux 9, a free Red Hat compatible rebuild focused on staying bug for bug identical to its upstream.

Open

FAQ

Quick Answers

Owner can read, write and execute; group can read and execute; others have no access. Numerically it is 750.

Deleting depends on the folder's write bit, not the file's. The sticky bit on a folder limits this.

A mask of bits removed from new files and folders. With 022, files are created as 644 and folders as 755.

The file has an access control list with extra entries; view them with getfacl.

On Rocky Linux and AlmaLinux, SELinux labels may block it. Check ls -Z and fix labels with restorecon.