Technical skill

Linux access rights

Who may use a file

Imagine a folder shared by several people. Each file has an owner and an owning group, plus a third set of rules for everyone else. A user account represents a person or service running a program. Linux checks that account and its groups against the file's rules when the program tries to read, change, or run it.

A permission mode is a compact way to write those rules. For example, mode 0640 lets the owner read and write, lets members of the group read, and gives no access to other users. The first digit in this example is zero because it has no special permission bits; the other digits describe owner, group, and other access.

Directories have their own permissions. Read lets a user list names. Write allows names to be added, removed, or renamed. Execute means search: the user can pass through the directory to look up an item inside it. Removing a file usually depends on write and search permission on its parent directory, not write permission on the file. Every directory in a path must be searchable, so a file can look readable while an earlier directory blocks it.

When a command says “Permission denied,” inspect the account and every part of the path before changing rules:

id
namei -l /srv/app/config.ini
stat -c '%A %a %U:%G %n' /srv/app/config.ini
getfacl /srv/app/config.ini

id shows the current account and its groups. namei -l lists permissions along the path. stat reports the file's owner, group, and mode. getfacl shows access-control-list entries when the tool is installed. For a service, check the account and groups that service actually runs as; they may differ from your shell.

Extra access rules

An Access Control List (ACL) can grant named users or groups access in addition to the basic owner, group, and other classes. With extended ACL entries, ls -l commonly shows a + after the mode. An ACL mask limits effective permissions for named users and group entries, so getfacl may show a grant beside a narrower effective permission. A directory can also set a default ACL that shapes permissions on new files inside it.

Linux checks a matching named-user ACL before the group class. If the account matches one or more group entries, the kernel checks that group class and applies its mask. A denial there does not fall through to the “other” permissions. That explains why giving other users more access may not help an account already covered by a group ACL.

chmod changes mode bits; chown and chgrp change the owner or group. Use a shared group when several accounts need the same access, or an ACL for one additional account. chmod 777 grants read, write, and execute to everyone, removing useful boundaries and often hiding the original mismatch. Verify the change and test as the account that needs access.

For ordinary file creation without a directory default ACL, the process umask removes selected permission bits from the requested mode. It does not alter existing files. Mount options, Linux capabilities, ACLs, and security modules such as SELinux can also affect access. If mode bits look right, check those controls and the program's actual credentials before widening permissions.

Interactive exercises

Skillsets
Skillset Devops preview
image descriptionDevops
by Dio
3 users
Skillset Linux administrator preview
image descriptionLinux administrator
by Infinite Education
3080 users
Skillset Devops preview
image descriptionDevops
by Ajay Kumar
2004 users
Skillset Linux for backend developer preview
image descriptionLinux for backend developer
by Artem Naumenko (fb)
16 users
Skillset Skyeng linux system administrator preview
image descriptionSkyeng linux system administrator
by Vitaliy Okulov
3 users
Do you know that ...?
Any useful or interesting facts about the skill. Any peace of information would be useful