Bytes of Awareness

Linux

Linux File Permissions for Beginners

A beginner-friendly guide to understanding and changing Linux file permissions.


What are file permissions?

Linux is a multi-user system. Many people can use the same computer.

File permissions decide who can read, write, or run each file. Without them, anyone could read your private files or change your work.

Read, write, and execute

Every file has three basic permissions:

For a directory, these permissions work a little differently. Read lets you list its contents. Write lets you create or delete files inside it. Execute lets you enter it with cd.

User, group, and others

Each permission applies to three scopes of people:

The letter a stands for all three at once.

Reading permissions from ls -l

Run ls -l to see a detailed listing of the current directory.

ls -l

You will see output similar to this:

-rw-r--r--  1 alice dev  120 Aug  4 10:32 notes.txt
drwxr-xr-x  2 alice dev 4096 Aug  4 10:30 project

The first column is the permission string. Let’s read -rw-r--r-- left to right.

The directory project starts with d. It shows rwxr-xr-x. The owner can do everything. Group and others can read and enter, but cannot modify it.

chmod with symbolic notation

The chmod command changes permissions. Symbolic notation lets you say who (u, g, o, or a), what to add or remove (+ or -), and which permission (r, w, or x). The letter a stands for all three: user, group, and others.

Make a file executable for its owner:

chmod u+x script.sh

Remove write permission for the group:

chmod g-w notes.txt

Give everyone read access:

chmod a+r notes.txt

Remove execute permission for everyone:

chmod a-x script.sh

chmod with numeric notation

Numeric (octal) notation is a shortcut. It sets all permissions at once. Each permission has a value:

Add the values to build a three-digit number. For example, rwxr-xr-x is 755. User is 7 (4+2+1). Group is 5 (4+1). Others is 5 (4+1).

chmod 755 script.sh

Common combinations:

Hands-on exercise

Let’s practice in a dedicated directory. This keeps you from accidentally modifying an important file.

Create a permission-practice directory, enter it, and make a script:

mkdir permission-practice
cd permission-practice
touch hello.sh

Give the script read and write permissions for yourself only, then check the result:

chmod 600 hello.sh
ls -l

You should see -rw------- for hello.sh. Now make it readable by everyone and executable by you. Check again:

chmod 644 hello.sh
chmod u+x hello.sh
ls -l

You should now see -rwxr--r--. When you are done, you can clean up:

cd ..
rm -rf permission-practice

What’s next?

Now that you can read and change permissions, learn about file ownership with chown and chgrp. Special permissions such as setuid, setgid, and the sticky bit are also useful. If you need a refresher, review the essential Linux commands and files and directories tutorials.