Linux — File permission in details

priyanka kumari
3 min readNov 1, 2023

--

Linux file permissions

Linux is a multi-user operating system, so it has security to prevent people from accessing each other’s confidential files.

File permissions are core to the security model used by Linux systems. They determine who can access files and directories on a system and how.

Linux File Ownership

Every file and directory on your Unix/Linux system is assigned 3 types of owner, given below.

· User(u)

A user is the owner of the file. By default, the person who created a file becomes its owner. Hence, a user is also sometimes called an owner.

· Group(g)

A user- group can contain multiple users. All users belonging to a group will have the same Linux group permissions access to the file.

· Other(o)

Any other user who has access to a file. This person has neither created the file, nor he belongs to a usergroup who could own the file. Practically, it means everybody else.

Linux File Permissions

Every file and directory in your UNIX/Linux system has following 3 permissions defined for all the 3 owners discussed above.

Read(r): This permission give you the authority to open and read a file. Read permission on a directory gives you the ability to lists its content.

Write(w): The write permission gives you the authority to modify the contents of a file. The write permission on a directory gives you the authority to add, remove and rename files stored in the directory.

Execute(x): In Windows, an executable program usually has an extension “.exe” and which you can easily run. In Unix/Linux, you cannot run a program unless the execute permission is set. If the execute permission is not set, you might still be able to see/modify the program code(provided read & write permissions are set), but not run it.

No permission(-)

There are 2 ways to use the commands

1. Absolute mode

2. Symbolic mode

  1. Absolute(Numeric) Mode in Linux

2.Symbolic Mode in Linux

you can change permissions for using all 3 owners.

There are 3 type of file permission commands

Changing file/directory permissions in Linux Using ‘chmod’ command

Syntax:

Chmod permission filename

Changing Ownership

for changing the ownership of a file/directory, you can use the following command:

syntax

Chown filename

Changing group in linux

Chownuser :-group filename

Example

r (read): 4

w (write): 2

x (execute): 1

a file might have read, write, and execute permissions for its owner, and only read permission for all other users. That looks like this:

Owner: rwx = 4+2+1 = 7

Group: r — = 4+0+0 = 4

Others: r — = 4+0+0 = 4

Thanks for reading

I hope found this useful?

✅Reshare this with others so that it helps more people

✅Tag your colleagues and friends who you think will need this

--

--

priyanka kumari
priyanka kumari

Written by priyanka kumari

Cloud || Devops enthusiast|| Learning & helping

No responses yet