Linux permissions

Linux has a comprehensive permission system to ensure that the computer is secure. Each file and directory has three groups of permissions: owner, group and all users. Each of these groups has three types of permissions: read write and execute. Using the right permissions is a necessity for servers and other devices connected to the internet.

Groups

There are three different groups:

Types

Each of these groups has three basic permission types:

The permission of a file or directory is given with three numbers: owner, group and other respectively. Each of these numbers contains the read, write and execute permissions. The execute permission is represented by the number 1, the write permission by the number 2 and the read permission by the number 4. These numbers are summed up to form one digit. For example, if we want to combine a read and execute permission, the number would be 1 + 4 = 5.

Change permissions

The permissions can be altered by the chmod, chown and chgrp commands.

The permissions are changed with the chmod command. The chmod command expects at least two arguments: the three digit code and the name of the file.

chmod 777 file.txtSelect

The owner of the file is changed with the chown command. This commands also expects at least two arguments: the name of the new owner and the name of the file.

chown user file.txtSelect

The group of the file is changed with the chgrp command. This commands also expects at least two arguments: the name of the new group and the name of the file.

chgrp mygroup file.txtSelect

The -R option applies the command recursively:

chmod 644 mydirectory -RSelect