Manage Linux File Permissions and Ownership

Read and change file permissions with chmod and ownership with chown, and understand why 'permission denied' happens in the first place.

beginner8 minlinuxUpdated August 2026
#linux#permissions#chmod#chown#sudo

Requirements

  • A Linux terminal — local, VM, or over SSH
0/4 steps · 0%
01

Read permissions with ls -l

bash
$ ls -l

Expected output

-rwxr-xr-- 1 alice devs 220 Aug 24 09:12 deploy.sh

The first character is the file type (- for a regular file, d for a directory). The next nine characters are three groups of rwx — read, write, execute — for the owner, the group, and everyone else, in that order.

02

Change permissions with chmod

chmod accepts either symbolic or octal notation. Symbolic is easier to reason about for a single change:

bash
$ chmod u+x deploy.sh

This adds execute permission for the owner only. Octal notation sets all three groups at once — each digit is a sum of read (4), write (2), and execute (1):

bash
$ chmod 755 deploy.sh

755 means owner gets read+write+execute (7), group and others get read+execute (5).

03

Change ownership with chown

Only root (or the current owner, in limited cases) can change who owns a file, so this needs sudo.

bash
$ sudo chown alice:devs deploy.sh

This sets the owner to alice and the group to devs. Omit the group (sudo chown alice deploy.sh) to change only the owner.

04

Apply changes recursively

Add -R to apply a change to a directory and everything inside it.

bash
$ sudo chown -R alice:devs /var/www/myapp

Tip

Double-check the path before running a recursive chown or chmod — it's easy to point it at more than you meant to.

Troubleshooting

The file doesn't have execute permission set, even though you can read it.

bash
$ chmod +x ./script.sh
$ ./script.sh