ownership and permissions in linux

We all have at some point experienced permission denied error, isn’t it frustrating so let’s understand how permissions in linux work.

Linux like many other operating system is multi-user OS therefore to keep each users data safe and block unauthorized access linux enforces 2 level guard

  1. Ownership
  2. Permission

Before we talk about how to get information about files security , to get current info about files security permission you can use ls -al this list all files and directories in current directory with its permissions and ownership details

Let’s talk about Ownership of a file/directory

There are three types of owners

Owner : these permissions only apply to owner of a file/directory and not other users

Group : each file/directory is assigned a group, these permission affect all users in that group

Others : these are the permissions for all users which are not owner or part of group

Owner denotations

u : user/owner

g : group

o : other

a : all

Changing Ownership and Groups

To change the ownership of a file or a directory use chown user’s-name filename

To change the group of a file or a directory use chown group-name filename

To change both user and group at the same time use chown user:group filename

Now let’s talk about file/directory permissions

So Permissions are generally represented through the use of the letters r, w and x but they can also be represented numerically.

The table below gives us number for all permission types

To change permission of a file/directory you can use

chmod permissions file

In numeric mode you can change permission for all three types of user at once as each digit represents owner,group,others respectively.

While using symbolic mode you can change permission for specific user by using mathematical symbols



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store