This article will discuss everything you need to know about Linux file permissions. It’s important to know this to understand the chmod command and the numbers that correspond to certain access levels. Whether you use Ubuntu, Fedora, or a more exotic Linux distro you should understand when it’s okay to set permissions to 777 using the CHMOD command and when you should use a different setting.

How Linux File Permissions Work

In Linux, the operating system determines who can access a certain file based on file permission, ownership, and attributes. The system allows you, the owner or admin, to enable access restrictions to various files and directories. You can improve the security of your system by giving access only to users and programs you trust.

Understanding User Classes

A specific user and a group own every single file and directory. This means there are three categories of users to which you can assign a certain level of access. These users are classified as follows:

OwnerGroupOthers

You can see these groups visually in Ubuntu by right-clicking on any directory, selecting Properties, and going to the Permissions tab. The Owner is the person with all the power. Usually, they have full access to every file and directory and can change the file permissions of other users as well. The Group consists of a number of users that have a certain level of access to a file or directory given by the Owner. For example, a group of users can be excluded from modifying a file while being granted access to view that file. The Others class simply represents guest users that don’t fall into the other two categories. By default, their level of access is usually restricted. It’s up to the Owner to determine what guests users can or can’t do.

Understanding File Permission Levels

As the Owner you can assign three levels of access to your files and directories: By combining Classes and Permissions, you can control how much access a specific user has to a file or directory.

Permission Symbols and Numbers Explained

File permissions are represented numerically or symbolically. You can use both symbols and numbers to change file and directory permissions. The easiest method is with numbers, but you should also understand the symbols. So let’s take a look at the symbols behind file permissions first.

File Permission Symbols

You can view your permissions for all content in a certain directory if you type the following command in the terminal: ls -l You can navigate to any directory by using the cd command. If you’re a complete beginner, check out our article on basic Linux commands. In our example, the directory contains two other directories and one file. The permissions are written using (1+) 9 symbols that can be split into triplets for an easier understanding. Let’s examine the first set of permissions for the Books directory: drwxrwxr-x Let’s split it for readability: d rwx rwx r-x The first symbol is d, and it stands for directory. It can also be a dash symbol if it’s a file, as you can see in the third set of permissions for the Outline.docx file. Next, we have three groups of symbols. The first group represents the Owner’s permission levels, the second group is for the Group class, and the third represents Others. Each set of 3 symbols means read, write, execute – in that order. So the Owner has permission to read, write, and execute all files and directories found inside the Test directory. Here’s a visual representation: When you see a dash symbol instead of r, w, or x, it means that permission doesn’t exist.

File Permission Numbers

The numeric format for file permissions is simple. In essence, the file permission codes have three digits:

The first one is for the file owner.The second one represents the file’s group.The last digit is for everyone else.

The digits range from 0 to 7 where:

4 = read.2 = write.1 = execute.0 = no permission.

The permission digit of each class is determined by summing up the values of the permissions. In other words, each digit for each class can be the sum of 4, 2, 1, and 0. Here’s a full list of permissions:

0 (0 + 0 + 0) = The user class doesn’t have any permissions.1 (0 + 0 + 1) = Execute permission only.2 (0 + 2 + 0) = Write permission only.3 (0 + 2 + 1) = Write and execute permissions.4 (4 + 0 + 0) = Read permission only.5 (4 + 0 + 1) = Read and execute permissions.6 (4 + 2 + 0) = Read and write permissions.7 (4 + 2 + 1) = All permissions.

For example, a 644 permission means that the file owner has read and write permissions, while the other two classes have only read permission. Setting permissions by using the number format requires only basic math.

Permission 777

As you’ve probably already guessed, a 777 permission gives read, write, and execute permissions to all three user classes. In other words, anyone who has access to your system can read, modify, and execute files. Use it only when you trust all your users and don’t need to worry about security breaches. Permission 777 is used often because it’s convenient, but you should use it sparingly. In fact, we recommend never using it because the security risks are too great. An unauthorized user could compromise your system or, for example, change your website to distribute malware. You should give permission 755 instead. That way, you as the file owner have full access to a certain file or directory, while everyone else can read and execute, but not make any modifications without your approval.

Modifying File Permissions with Chmod

You can change file permission with the help of the chmod command. The most basic way of using this command without any other variables is as follows: chmod 777 filename Replace “filename” with the name of the file and its path. Keep in mind that the only users with the power to change file permissions are those with root access, the file owners, and anyone else with sudo powers.

Linux File Permissions   What Is Chmod 777 and How to Use It - 88Linux File Permissions   What Is Chmod 777 and How to Use It - 42Linux File Permissions   What Is Chmod 777 and How to Use It - 12