Permissions

What are file permissions?

In Linux/Unix, every file and folder has permissions that control:

  • Who can read it (see its contents)

  • Who can write to it (modify or delete it)

  • Who can execute it (run it as a program or script)

There are three groups for permissions:

  1. User (u) — the owner

  2. Group (g) — users in the same group

  3. Others (o) — everyone else

Each group has three permissions:

  • r = read

  • w = write

  • x = execute


How does the number system work (like 777)?

Each permission has a number value — these are called octal values -->

Permission
Value

read (r)

4

write (w)

2

execute (x)

1

You add up the values to get the permission number:

Example:

  • rwx = 4 + 2 + 1 = 7

  • rw- = 4 + 2 + 0 = 6

  • r-- = 4 + 0 + 0 = 4

So when you see something like chmod 777, it means:

Group
Permissions
Meaning

User

7 (rwx)

Read, write, and execute

Group

7 (rwx)

Read, write, and execute

Others

7 (rwx)

Read, write, and execute

In short:

EVERYONE can do ANYTHING to the file!


Example:

If you do:

chmod 777 myfile

then:

  • You (user) can read/write/execute myfile

  • Your group can read/write/execute myfile

  • Any other random user on the system can also read/write/execute myfile


Why is chmod 777 dangerous?

  • Anyone can modify or delete the file.

  • If it’s a script or executable, anyone can inject malicious code.

  • It’s basically giving full control to everyone — like leaving your front door wide open!

That's why you should almost never set 777 permissions unless you're doing it in a controlled/test environment (and you understand the risks).


Cheatsheet for Common chmod:

chmod
Meaning

755

Owner: all (rwx), Group/Others: read and execute (r-x)

700

Owner: all (rwx), Group/Others: no permissions

644

Owner: read/write (rw-), Group/Others: read (r--)

600

Owner: read/write (rw-), Group/Others: no permissions

777

Everyone: full permissions (rwx) — dangerous!


Permissions Visualization:

For example, 755 would look like this when you do ls -l:

-rwxr-xr-x  1 user group 12345 Apr 27 10:00 myfile

Breaking that down:

  • rwx → owner can read/write/execute

  • r-x → group can read/execute

  • r-x → others can read/execute

Last updated