Explain linux file permission like I'm Five

Updated: 2th June 2023
Tags: ubuntu linux

linux file permissions

image credits to blog.bytebytego.com

To understand Linux file permissions, we need to understand Ownership and Permission.

Ownership

Every file or directory is assigned 3 types of owner:

Owner: the owner is the user who created the file or directory.

Group: a group can have multiple users. All users in the group have the same permissions to access the file or directory.

Other: other means those users who are not owners or members of the group.

Permission

There are only three types of permissions for a file or directory.

Read (r): the read permission allows the user to read a file.

Write (w): the write permission allows the user to change the content of the file.

Execute (x): the execute permission allows a file to be executed.

The most common permission is 755.

Examples

sudo chmod 755 -R laravel_app
sudo chmod rwxr-xr-x -R laravel_app

As you see working with numbers is easier.

Symbolic representation

There is third way to adjust permission. If you want to change permission for owner or group or other without touching else there is a way.

The syntax is

chmod UserWhatPermission filename

Where,

Let us remove read and write permission for group and other on bash.sh script:

sudo chmod go-rw bash.sh

Or add write permission to all for laravel folders

sudo chmod -R o+w laravel_app/storage
sudo chmod -R o+w laravel_app/bootstrap/cache