```html Linux File Permissions Explained: chmod & chown Simply — LinuxDistroFinder
Home › Guides › Linux File Permissions
Beginner

Understanding Linux File Permissions (chmod, chown Explained Simply)

📖 11 min read🗓 Updated November 2026✍️ LinuxDistroFinder Team

Disclosure: some links on this page are affiliate links. If you sign up through them we may earn a commission at no extra cost to you. It helps keep LinuxDistroFinder free.

Linux file permissions are one of those topics that look intimidating at first glance — a string like -rwxr-xr-- seems cryptic until you understand the pattern. Once it clicks, you'll realise it is a beautifully logical system. This guide walks you through everything: reading the permission string, using chmod and chown, octal (numeric) notation, special bits like setuid and sticky bit, and common real-world mistakes to avoid.

Why File Permissions Matter

Linux is a multi-user operating system. Permissions control who can read, write, or execute a file or directory. They are the first line of defence on any Linux system — from your Raspberry Pi at home to a production web server. Getting them wrong in either direction causes problems: too open and you expose sensitive data; too restrictive and your applications break.

Tip: Even if you are the only user on your laptop, understanding permissions matters. Many configuration files, scripts, and web apps depend on precise permission settings to function correctly or securely.

Reading the Permission String

Run ls -l in any directory and you will see something like this:

-rwxr-xr--  1 alice devs  4096 Oct 12 09:14 deploy.sh
drwxr-x---  2 alice devs  4096 Oct 12 09:00 config/
-rw-r--r--  1 root  root  1024 Sep  5 14:30 /etc/hostname

The first column is the permission string. It has 10 characters, broken into four parts:

PositionCharactersMeaning
1- or d or lFile type: - = regular file, d = directory, l = symlink
2–4rwxOwner (user) permissions
5–7r-xGroup permissions
8–10r--Others (everyone else) permissions

The Three Permission Bits

Within each of the three groups (owner, group, others), there are always exactly three bits:

LetterNameOn a FileOn a Directory
rReadView file contentsList directory contents (ls)
wWriteModify or delete the fileCreate, rename, or delete files inside
xExecuteRun the file as a programEnter the directory (cd)
-(none)That permission is not granted
Note: On a directory, the execute bit (x) is required to enter it. You can have r without x on a directory and be able to list file names but not access them. This catches many people off guard.

The Three Identities: User, Group, Others

Every file has exactly one owner user and one owner group. The permission system then checks which of three categories the person trying to access the file falls into:

  • User (u): The owner of the file. Bits 2–4 apply.
  • Group (g): Any user who belongs to the file's group. Bits 5–7 apply.
  • Others (o): Everyone else. Bits 8–10 apply.

Linux checks these in order and uses the first matching category — it does not combine them. If you are the owner, only the owner bits apply, even if the group or others bits would give more permissions.

Using chmod — Changing Permissions

chmod (change mode) is the command you use to modify file permissions. It has two modes: symbolic and octal (numeric). Both are worth knowing.

Symbolic Mode

Symbolic mode is the most readable. The syntax is chmod [who][operator][permissions] file.

  • Who: u (user/owner), g (group), o (others), a (all three)
  • Operator: + (add), - (remove), = (set exactly)
  • Permissions: r, w, x
# Give the owner execute permission
chmod u+x script.sh

# Remove write permission from group and others
chmod go-w sensitive.conf

# Set group to read-only, others to nothing
chmod g=r,o= myfile.txt

# Give everyone read permission
chmod a+r readme.txt

Octal (Numeric) Mode

Octal notation represents all three bits of a permission group as a single digit (0–7). Each bit has a value: r = 4, w = 2, x = 1. You add them up for each group.

OctalBinaryPermissionsMeaning
7111rwxRead, write, execute
6110rw-Read and write
5101r-xRead and execute
4100r--Read only
3011-wxWrite and execute (rare)
2010-w-Write only (rare)
1001--xExecute only (rare)
0000---No permissions

You chain three digits together — one for owner, one for group, one for others. So 755 means owner=rwx, group=r-x, others=r-x.

# 755: common for scripts and directories
chmod 755 deploy.sh

# 644: common for config files and web assets
chmod 644 index.html

# 600: private files (SSH keys, secrets)
chmod 600 ~/.ssh/id_rsa

# 700: private directories
chmod 700 ~/.ssh

# Apply recursively to a directory
chmod -R 755 /var/www/html
Tip: The -R flag applies permissions recursively. Be careful — using chmod -R 777 on a web root is a severe security risk and you should never do it in production.

Common Permission Presets Explained

644 Standard file (config, HTML, text) Most Common

Owner can read and write. Group and others can only read. Perfect for configuration files, web pages, log files. The file is not executable by anyone.

755 Scripts and directories Very Common

Owner can read, write, and execute. Group and others can read and execute but not write. Standard for shell scripts you want others to run, and for directories that need to be navigable by all users.

600 Private files (SSH keys, .env) Security Critical

Only the owner can read and write. Group and others have zero access. SSH will refuse to use a private key that is more permissive than 600. Also ideal for .env files holding API secrets.

700 Private directories Security Critical

Only the owner can list, create files in, or enter the directory. Used for ~/.ssh, personal credential stores, and application secret directories.

664 Collaborative group files Team Use

Owner and group can read and write. Others can only read. Useful when multiple users in the same group need to edit a shared file (e.g. a development team sharing a project directory).

Using chown — Changing Ownership

chown (change owner) lets you change who owns a file and/or which group it belongs to. Only root (or a user with sudo) can change file ownership.

# Change owner to alice
sudo chown alice myfile.txt

# Change owner to alice and group to devs
sudo chown alice:devs myfile.txt

# Change only the group (note the colon prefix)
sudo chown :devs myfile.txt

# Recursively change ownership of a directory
sudo chown -R www-data:www-data /var/www/html

# Change owner using a numeric UID and GID
sudo chown 1001:1001 myfile.txt

Checking Current Ownership

# Detailed listing with owner and group
ls -l myfile.txt

# Show numeric UID and GID
ls -ln myfile.txt

# Find files owned by a specific user
find /var/www -user alice

# Find files with no valid owner (orphaned)
find / -nouser 2>/dev/null

The umask — Default Permissions

When you create a new file or directory, its starting permissions are determined by the umask (user file-creation mask). The umask subtracts permissions from the maximum defaults: 666 for files and 777 for directories.

The most common umask is 022. This means:

  • New files get 666 - 022 = 644 (rw-r--r--)
  • New directories get 777 - 022 = 755 (rwxr-xr-x)
# Check your current umask
umask

# Set umask to 027 (stricter: others get nothing)
umask 027

# Set umask permanently in ~/.bashrc or ~/.profile
echo "umask 027" >> ~/.bashrc
Note: A umask of 027 is recommended for servers — new files are 640, new directories are 750. Others get absolutely no access by default.

Special Permission Bits

Beyond the standard nine permission bits, Linux has three special bits that go in a fourth octal position at the front.

Setuid (SUID) — Bit value 4

When set on an executable file, it runs as the file's owner rather than the user who launched it. The classic example is /usr/bin/passwd — it needs to write to /etc/shadow (owned by root) but must be run by ordinary users.

# Set SUID on a file (symbolic)
chmod u+s /usr/bin/myapp

# Set SUID using octal (4 prepended)
chmod 4755 /usr/bin/myapp

# Find all SUID files on the system
find / -perm -4000 -type f 2>/dev/null
Tip: SUID on a shell or any script is extremely dangerous. Regularly audit SUID files, especially after installing new software.

Setgid (SGID) — Bit value 2

On a file, it runs with the file's group. On a directory, new files created inside inherit the directory's group rather than the creator's primary group — very useful for shared project directories.

# Set SGID on a shared project directory
chmod g+s /srv/project

# Using octal
chmod 2775 /srv/project

Sticky Bit — Bit value 1

On a directory, the sticky bit means users can only delete or rename their own files, even if they have write permission on the directory. The canonical example is /tmp — everyone can write there, but you can't delete someone else's files.

# Check /tmp — note the 't' at the end
ls -ld /tmp
# drwxrwxrwt 15 root root 4096 Nov  1 08:00 /tmp

# Add sticky bit to a shared uploads directory
chmod +t /srv/uploads

# Using octal
chmod 1777 /srv/uploads

Practical Real-World Scenarios

Setting Up a Web Server Directory

# Nginx/Apache typically run as www-data
sudo chown -R www-data:www-data /var/www/mysite

# Directories need execute to be traversable
sudo find /var/www/mysite -type d -exec chmod 755 {} \;

# Files readable by web server, writable only by owner
sudo find /var/www/mysite -type f -exec chmod 644 {} \;

Securing SSH Keys

# SSH is strict — these exact permissions are required
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts

Making a Script Executable

# Write your script
nano backup.sh

# Make it executable by owner only
chmod u+x backup.sh

# Or executable by everyone (careful on shared systems)
chmod 755 backup.sh

# Run it
./backup.sh

🚀 Practice on a Real Linux VPS

The best way to truly learn file permissions is to practise on a live Linux server. Spin up a VPS, break things, and fix them without worrying about your local machine.

Get $100 Free Credit on Vultr →

Prefer a managed option? Hostinger VPS plans start under $5/month and come with a clean Ubuntu or Debian image ready to go.

Frequently Asked Questions

What does chmod 777 actually do, and why is it bad?

chmod 777 gives read, write, and execute permission to everyone — owner, group, and all other users on the system. On a web server or any shared environment this is dangerous: any user (or compromised web process) can modify or delete the file. Never use it in production. Use the minimum permissions required for your app to function.

What is the difference between chmod and chown?

chmod changes the permission bits on a file — what operations (read, write, execute) are allowed for which category of user. chown changes the ownership of a file — which user account and which group "own" it. You often need both: set the right owner with chown, then set the right permissions with chmod.

Why can I write to a directory but still can't delete a file inside it?

The sticky bit (t) is likely set on that directory (common on /tmp and shared directories). With the sticky bit active, you can only delete files you own, even if you have write permission on the directory itself. Check with ls -ld /path/to/dir and look for a t at the end of the permission string.

Can I use chmod on a file I do not own?

No. Only the file's owner or root can change its permissions. If you try, you will get a "Operation not permitted" error. Use sudo chmod if you have sudo access and there is a legitimate reason to change it.

What does "ls -l" show in the second column (the number after permissions)?

That number is the hard link count — how many directory entries point to this inode. For regular files it is usually 1. For directories it counts the directory itself, its . entry, and one for each subdirectory it contains (because each subdirectory has a .. entry pointing back). It is not related to permissions.

How do I find files with a specific permission on my system?

Use find with the -perm flag. For example, to find all world-writable files (a common security audit task), run the command below. The leading - before the octal means "at least these bits set".

# Find world-writable files (security audit)
find /var/www -perm -o+w -type f

# Find all SUID executables
find / -perm -4000 -type f 2>/dev/null

# Find files with exact permission 644
find . -perm 644 -type f

What is the ACL system and is it different from standard permissions?

POSIX Access Control Lists (ACLs) are an extension on top of the standard permission system. They let you grant permissions to specific users or groups beyond the owner/group/others model — for example, giving one specific user read access to your file without changing the group. Use getfacl filename and setfacl to work with ACLs. They are not enabled by default on all filesystems but are supported on ext4, XFS, and btrfs.

```
🐧
Chippy
Your Linux distro assistant