Skip to main content

Linux file permissions explained

In this article, we will cover about different Linux file permissions. As you know LINUX is a multi-user system and file permissions are one way the system protects against malicious tampering. For example, if you try to enter root’s home directory as a normal user by entering the command “cd /root/” you will get an error message as shown below.

[email protected]:~$ cd /root/
-bash: cd: /root/: Permission denied

Linux File Permissions

Linux has three types of access permissions.

  • read (r)
  • write (w)
  • execute (x)

Also, each file in Linux consists of three sets of user classes as follows.

  • user (u)
  • group (g)
  • others (o)

Checking permissions assigned to a file or directory

You can use the long listing option in ls command to view the permission of a file.

[email protected]:~$ ls -al Desktop/Pictures/wallpaper/runnow.jpg
-rw-r–r– 1 admin admin 163896 Sep 30 2013 Desktop/Pictures/wallpaper/runnow.jpg

  • First of all, the very first character identifies the file type. A dash ( – ) represents a normal file while a “d” represents a directory.
  • The next 3 characters represent the owner permissions. Each letter represents the presence of a permission and a dash ( – ) represents the absence of a permission. In the above example, the owner has read and write permissions.
  • The next 3 characters represent the group permission. So, in the above example, you can see that the “group” has the ability to read but not write or execute.
  • Also, finally the last 3 characters represent the permissions for others. In the above example, the file has only execute permission for “others”.

Changing permissions

chmod command is used to change the permissions of a file or directory.Check the syntax below.

$ chmod {mode} {path-to-file-name}

We can grant or revoke permissions using a plus ( + ) or minus ( – )
To grant read permission to “others”

[email protected]:~/Desktop/Pictures/wallpaper$ chmod o+r runnow.jpg
[email protected]:~/Desktop/Pictures/wallpaper$ ll runnow.jpg
-rw-r–r-x 1 admin admin 163896 Sep 30 2013 runnow.jpg*

So, to revoke a permission to “others”

[email protected]:~/Desktop/Pictures/wallpaper$ chmod o-x runnow.jpg
[email protected]:~/Desktop/Pictures/wallpaper$ ll runnow.jpg
-rw-r–r– 1 admin admin 163896 Sep 30 2013 runnow.jpg


Octal Representation

Another way to change permissions uses numeric representations(Octal). Octal use base 8 (0-7). With 3 different permissions and each being on or off, we have 8 possible combinations i.e, (2^3).
Octal Permissions

Symbolic Binary Octal
rwx 111 7
rw- 110 6
r-x 101 5
r – – 100 4
-wx 011 3
-w- 010 2
– – x 001 1
– – – 000 0
  • r: 4
  • w: 2
  • x: 1

So, to setup file permission 644 you need to use chmod command as follows:

chmod 644 file

Similarly, to setup a directory readable & executable by everyone and writable by the owner use:

chmod 755 directory

If you want to assign permissions recursively on a directory use option “-R”.

chmod -R 755 directory

Linux special permissions are explained in the following link:
Special permissions (SUID,SGID and sticky bit)

Rate this post


TheGeeksAlive is all about Linux, Server Administration, Web Hosting and other Open Source Technologies.