Skip to main content
Every file and directory on a Linux system has an associated owner, a group, and a set of access permissions that control who can read, write, or execute it. This model, inherited from Unix, provides a straightforward but powerful security boundary between users and system resources. Understanding how to read permission strings and how to manipulate them with chmod, chown, and chgrp is one of the most important skills for anyone working on a Linux system.

Reading Permission Strings

When you run ls -la, you see a permission string at the start of each line — for example, -rwxr-xr--. Break it down like this:
PositionCharactersMeaning
1- or d or lFile type: - = regular file, d = directory, l = symlink
2–4rwxOwner (user) permissions: read, write, execute
5–7r-xGroup permissions: read, write, execute
8–10r--Other (world) permissions: read, write, execute
A - in any permission slot means that permission is not granted.

Octal Notation

Permissions are commonly expressed as three octal digits, one per scope (owner, group, other). Each digit is the sum of the values for the granted permissions.
OctalBinaryPermissions
7111rwx
6110rw-
5101r-x
4100r--
3011-wx
2010-w-
1001--x
0000---
So 755 means rwxr-xr-x: the owner can read, write, and execute; the group and others can read and execute.

Changing Permissions with chmod

Use chmod to set or modify the permission bits on a file or directory.
chmod 755 script.sh          # rwxr-xr-x
chmod 644 config.txt         # rw-r--r--
chmod +x deploy.sh           # add execute for all
chmod u+w,g-w file.txt       # symbolic mode
chmod -R 750 /var/www/html   # recursive
Specify all three permission scopes in one numeric argument. This is the most concise form and is commonly used in scripts.
chmod 755 script.sh    # owner: rwx | group: r-x | other: r-x
chmod 600 private.key  # owner: rw- | group: --- | other: ---

Changing Ownership with chown

Use chown to change the user owner, the group owner, or both at once.
chown alice file.txt
chown alice:developers file.txt
chown -R www-data:www-data /var/www

Changing Group Ownership with chgrp

Use chgrp when you only need to change the group without touching the owner.
chgrp developers project/
chgrp -R staff /opt/app

Special Permission Bits

Beyond the standard read/write/execute bits, Linux supports three special permission flags.
chmod u+s /usr/bin/program   # setuid
chmod g+s /shared/dir        # setgid
chmod +t /tmp                # sticky bit
BitEffect on FilesEffect on Directories
setuid (u+s)File executes with the owner’s privilegesNo common effect
setgid (g+s)File executes with the group’s privilegesNew files inherit the directory’s group
sticky bit (+t)No common effectOnly the file owner can delete their files (used on /tmp)
Changing permissions on files in system directories like /etc, /usr, or /var typically requires sudo. Running chmod or chown without elevated privileges on files you do not own will result in a “Permission denied” error.