Understanding Octal Permission Bits in Linux

As a user of a system, to access a file in Linux and UNIX, it is important that a user has the required permission for that specific file or directory. Every file in UNIX or Linux has an owner and an associated group. It also has a set of permissions (read, write, and execute) with respect to the user, group, and others.

How to view permissions of a file in Linux

The ls command with the -l option is used to view the ownership and permission of a file:

# ls -l file01
-rw-r----- 1 root root 0 Feb  5 02:12 file01

Here, the first column of ls contains the permission information—that is, -rw-r—–. The letters r(read), w(write), and x(execute) specify permissions. The octal-mode specifies the rwx permission of a user together in octal format, which can be from 0 to 7. The following table explains the octal representation of a permission to a specific user:

Octal Value Binary representation Meaning
0 0 No read, write, and execute permissions (—)
1 1 Only execute permission (–x)
2 10 Only write permission (-w-)
3 11 Write and execute permissions (-wx)
4 100 Only read permission (r–)
5 101 Read and execute permissions (r-x)
6 110 Read and write permissions (rw-)
7 111 Read, write, and execute permissions (rwx)

Changing permission

The permissions bits applied to a file system object correspond directly to the values which can be specified in the 4 digit tuple supplied to the chmod utility in the following command:

# chmod abcd [file/dir]

Each value in the digit set abcd is made up of a sum of the values 1 2 and 4. By adding these values together for each digit, a value can be generated to set all file object attributes:

a - This digit controls special attribute settings. the value 1 sets the setuid bit, the value 2 sets the setgid bit, and the value 4 sets the sticky bit on the object

b, c and d - These digits control read write and execute permissions for the file owner, the file owners primary group, and all other users. The value 4 enables read permission, the value 2 enables write permission, and the value 1 enables execute permission.


To set a file file to be sticky, readable and writeable by the owner, readable by their primary group and inaccessible by everyone else:

# chmod 4610 filename

To give all permission to everyone on the system:

# chmod 0777 filename

For more information on chmod, see the chmod man page.

# man chmod