What Does chmod 777 Mean

What Does chmod 777 Mean

Linux operating systems, like most others, offer multiple users to use the same system. This requires implementing different permissions for different files and folders to ensure the privacy of operation.

The chmod command is used for changing these permissions for the files and folders.

Chmod stands for change mode, and “mode” means permissions in Linux terminologies.

In this tutorial, we’ll cover what chmod 777 means and what the command does.

If you want an in-depth comprehensive tutorial about the chmod command and Linux permissions, we suggest you check out our full length tutorial on the subject – How To Change File & Folder Permissions on Linux Using Chmod.

However, we will still quickly go over some of the basics you must understand before learning about the chmod 777 command.

The Basics

In Linux, there are three classes of users. They are as follows:

  1. Owner: The user who created the file or the folder.
  2. Group: Users who are in any group.
  3. Others: Any user that falls outside the Owner and the Group category.

These user classes will have different permissions for different files/folders. There are also three types of permissions any class of user can have:

  1. Read permission (r): A user can read files with this permission.
  2. Write permission (w): This permission allows a user to modify the file.
  3. Execution permission (x): It allows a user to execute the file.

You can take a look at what permissions a file or a folder have by using the ls -l command:

ls -l
Output
total 20
drwxr-xr-x 2 root root   4096 Sep 21  2017  BUET_INFO
-rw-r--r – 1 root root     18 Sep 28  2016  Default_MAC.txt

Here, the file permissions for a folder and a file are marked in green color. The leftmost character represents whether the permission refers to a file or a directory.

The next 9 characters indicate the permissions for three user classes. It’ll become clear once we decode the two file permissions shown:

drwxr-xr-x

[d] [rwx] [r-x] [r-x]
 |    |	 |     |
 |    |	 |     |
 |    |	 |     +---------- Others permissions (Read, Execute)
 |    |	 +---------------- Group permissions (Read, Execute)
 |    +----------------------- Owner permissions (Read, Write, Execute)
 +--------------------------- Indicates a directory (BUET_INFO)

So, in this example, the permissions for the directory are as follows:

  1. The owner can read, write, and execute (rwx).
  2. Group users can read and execute (r-x).
  3. Other users can also read and execute (r-x).

In other words, if you are a group user, and you try to create a file inside the directory BUET_INFO, you will get a message saying Permission Denied.

This is simply because you, as a group user, do not have the permission to write in this directory. Only the directory owner can do that. But if you have root privilege, you can change the permission of this directory and grant yourself the ability to do whatever you want.

-rw-r--r--

[-] [rw-] [r--] [r--]
 |    |	 |     |
 |    |	 |     |
 |    |	 |     +---------- Others permissions (Read only)
 |    |	 +---------------- Group permissions (Read only)
 |    +---------------------- Owner permissions (Read, Write)
 +--------------------------- Indicates a file (Default_MAC.txt)

Numbers Associated With the Permissions

For assigning different permissions to different users with the “chmod” command, we can use a numeric method. The numeric method is a very fast and efficient way to change file/folder permissions.

To use this method, we must learn the specific numbers that are associated with each permission:

  1. Read permission, [r] = 4
  2. Write permission, [w] = 2
  3. Execute permission, [x] = 1
  4. No permission, [] = 0

Now, with these numbers, we can create any permissions we want. For example, if we only want execute permission, we’ll use the number 1. We can use 4 if we want read only permission. If we want to combine multiple permissions, we just add the specific numbers associated with the permissions:

  • r + w = 4 + 2 = 6
  • w + x = 2 + 1 = 3
  • r + w + x = 4 + 2 + 1 = 7

So, if we use the number 7, we can specify all the permissions together [rwx]. Now, to assign these permissions to different classes of users, we just construct a 3-digit number. The leftmost digit represents the permissions for the “owner”, the middle digit is the permission for the “group users”, and the rightmost digit indicates the permissions for “other users”. This is shown with some examples below:

761

[7] 	[6]	 [1]
 |	   |	   |
 |	   |	   |
 |	   |	   +----- Other users permissions (Execute)          [--x]
 |	   +------------- Group users permissions (Read, Write)      [rw-]
 +--------------------- Owner’s permissions (Read, Write, Execute) [rwx]

402

[4] 	[0]	 [2]
 |	   |	   |
 |	   |	   |
 |	   |	   +----- Other users permissions (Write) [-w-]
 |	   +------------- Group users permissions (None)  [---]
 +--------------------- Owner’s permissions (Read)      [r--]

Now, let’s look at another example:

777

[7] 	[7]	 [7]
 |	   |	   |
 |	   |	   |
 |	   |	   +----- Other users permissions (Read, Write, Execute) [rwx]
 |	   +------------- Group users permissions (Read, Write, Execute) [rwx]
 +--------------------- Owner’s permissions (Read, Write, Execute)     [rwx]

Does this look familiar? Yes! We were trying to figure out what the chmod 777 command means. So, this should be pretty obvious to you by now. The number that comes after chmod is the permissions number.

So, the chmod 777 command will grant all permissions [rwx] to all the users. Now it’s time to see the command in action.

Chmod 777 in Action

You must have root access to change the permissions of a file/folder. You can also change the permissions of a file/folder permissions if you are the owner of that specific file/folder.

Let’s list out what files we have in our directory with their permissions using the ls -l command:

ls -l
Output
total 32
-rw-r--r – 1 root   root     147   May  5 03:02 file
-rw-rw-rw- 1 edxd   edxd     1806  May 13 15:00 file.log
-rw-rw-rw- 1 edxd   edxd     1807  May 13 15:00 file.log.save
-rw-r--r – 1 root   root     151   May  5 03:02 file.txt
-rw-rw-rw- 1 edxd   edxd     24226 May 13 13:48 tutorial.firstpage.php

Let’s try to change the permissions of the file.log using the “chmod 777” command:

sudo chmod 777 file.log

Now let’s look at the permissions using ls -l again:

ls -l
Output
total 32
-rw-r--r – 1 root   root     147   May  5 03:02 file
-rwxrwxrwx 1 edxd   edxd     1806  May 13 15:00 file.log
-rw-rw-rw- 1 edxd   edxd     1807  May 13 15:00 file.log.save
-rw-r--r – 1 root   root     151   May  5 03:02 file.txt
-rw-rw-rw- 1 edxd   edxd     24226 May 13 13:48 tutorial.firstpage.php

As you can see from the results, the file named file.log has all the permissions [rwx] to be used by all the users.

A Word of Caution on Using the chmod 777 Command

This should be pretty self-explanatory at this point. You should not use chmod 777 as an alternative to any other permissions for the file/folder.

You might think that what’s the point in using any other permissions when you can just use chmod 777 to solve all the problems whenever you cannot access a file/folder due to permission issues. However, if you grant all permissions to all the users for some crucial files, you might get exposed to security risks.

For example, if you grant all users access to write or modify root files, your system might become compromised easily. Any user using your system will be able to see, modify, and even remove root/system files that would otherwise never get modified.

Keep this in mind, and practice caution when changing file permissions. Learn what permissions you require and only allow those permissions to the designated users.

Conclusion

In this tutorial, you learned what does chmod 777 command means and what it does. In short, chmod 777 allows any users to do whatever they want to that specific file/folder.

If you want to learn more about the chmod command and the Linux file/folder permissions, please take a look at our tutorial on “How to Change File & Folder Permissions on Linux using Chmod“.

We hope this tutorial was helpful for you. Feel free to ask any questions down in the comments, and we’ll get back to you as soon as possible.

8 Shares:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
You May Also Like
Usermod Command in Linux
Read More

Usermod Command in Linux

The usermod command allows us to modify an existing user account. With the usermod command, we can make…