Home Linux How to change file/directory permissions in Linux

How to change file/directory permissions in Linux

Key Points:
1. How to identify is file or directory?
2. Read permissions.
3. Change file/directory permissions.


In Linux file permissions are very important. Every directory and file has permissions for owner, groups and others. Now I will let you know, who are the owner, groups assigned and other.

FIle/Directory Permissions

  1. User (Owner) – By defaults, a user who creates the file or directory known as the owner.
  2. Group –  I will explain this with the example. Assume you are the member of IT team of 8 people and your manager wants to share a file or directory with IT team then he will not share this individually with everyone. Instead of that, he will make one group with name IT and assign a group to that file or directory. By default, a user who creates file or directory, that user becomes the group of that file.
  3. Other –  The person who neither created a file or even not a member of the group but needs to access the file. Then Other permissions play an important role.
File permission in Linux
File permission in Linux

How to find which one is a directory or which one is a file?

for directory
: for file

Example: see the picture, first 3 rwx permission for owner, next 3 for the group and last three for other.

File permissions output
File permissions output

r = read, w = write , x = execute.

How To read permissions of file/directory ?

  • I will show you simplest method to read the permissions of file or directory with the example. To assign permissions, we will use the numeric method here. In this method always remember this :

r = 4

w = 2

x = 1

– = 0

775 directory permission
775 directory permission

Change directory/file permission

Here I am assuming a user is the member of sudo group a user has root level privileges. Chmod command is used to change the permissions. Syntax is:

# chmod permission filename

[arun@localhost ~]$ chmod 770 centos/
chmod command output
chmod command output

Assign permissions recursively to sub- folders

Use -R to assign permission on subfolders. Note in Linux, capital and small alphabets have significant meaning. In this example, 770 permission would be assigned to subfolders under “centos” directory.

 [arun@localhost ~]$ chmod   -R  770   centos/ 

Key Notes:
By default permissions (Remember these for an Interview purposes):
1. When root user creates, directory = 755 and file = 644
2. normal user creates, directory = 775 and file = 664
3. /home/user = 700
4. /root = 550
5. /tmp = 777

Perfect !!! You have learned about file permissions.In the next tutorial I will explain how to enabled Special Permissions SUID, SGID and Sticky bits.


Please enter your comment!
Please enter your name here