How to Use the Chmod Command in Linux

Command-line have an important role in the Linux OS. You can do everything through the terminal. There are so many Linux commands you can use. Chmod is one of those Linux commands. It’s a very important command. You might need to use this command occasionally. This is why I am here with a beginner’s guide on how to use the chmod command in Linux.

The main purpose of this command is to modify file permissions. File permissions control how a file should behave. Linux control every directory and file using the permissions. Chmod can modify these permissions. It is an essential part of the Linux OS. Therefore, if you want to learn chmod then you are in the right place. Here I will explain the different ways to use the chmod command in Linux. So let us get started.

you might also like: How To kill Process in Ubuntu Linux

What are file permissions and chmod command in Linux

Chmod is an easy command in Linux. However, it becomes difficult when you use all of its variations. This command executes in so many ways. Nevertheless, you need to know about file permissions. File permissions decide whether a file is readable, writable, or both.

Understanding file permissions attributes

To use the chmod command in Linux. First, you should know what permissions a file has. You need to execute ls –l command. Go to file location using the cd command and then execute ls –l command. Here you can see the file permission attributes given to a file or folder.

From the left-hand side, you will see characters like “drwx –rw-xw” or “–rwx –rw r-“. These are the file permission attributes that the chmod command uses in Linux. Here is what the mean.

  • If the line starts from “d” then it is a directory. If it starts from “-” then it is a file.
  • After ‘”d” or first “-”, first three characters are the permission given to the user.
  • The second three characters are the permissions given to the group of users.
  • The last three characters are the permission given to public account or other permissions.

You got the idea about the line that determines permissions. And how the chmod command determines what to do in Linux.  Now it’s time to understand what these attributes stand for.

  • “r” means the file is readable.
  • “w” means the file is writable.
  • “x” means the file is executable.
  • “-” means no permissions have been assigned to the file or folder.
  • If you see all the attributes “rwx” then all the permissions are there for the file or folder.

It is all you need to know about file permission. Now it is time to learn how to use the chmod command.

Before you start using chmod command in Linux

These three things you need to keep in mind. First, the user to which you are giving the command. Second, a sign that determines what permissions you want to add or remove. Third, the permission itself that you want to set. First, you need to know about the attributes that determine the output of the command.

First, is the user or group of users whom you want to give permissions.

To choose a user you want to give permission using the chmod command in Linux.

  • “u” means the user himself.
  • “g” means a group that you want to give permissions.
  • “o” means other users that are under the above two.
  • “a” means all the users.

Second, is the sign that determines the addition or removal of permission.

To add or remove permission.

  • “+” means that you want to grant permission.
  • “-” means you want to remove the permission.
  • “=” means to set the given permission and remove others.

Third, you need to know what permissions you can give.

To choose what permission to give.

  • “r” means only readable.
  • “w” means only writable.
  • “x” means only executable.

Phew!! That’s all about it. You are all set to use the chmod command. Now I will explain how to use the chmod command in Linux.

How to use the chmod command in Linux

  • First, open terminal.
  • Then use the cd command to go to the directory where the file you want edit is.
  • Now use the following command to see the permission granted to the file.

Ls –l filename

  • Now you just need to use the attributes explained above. Use the following example to execute the chmod command in Linux.

Chmod {user}{add or remove permission}{permoission}

  • Now to add permission for group users.

chmod g+rw filename

  • To remove

chmod g-rw filename

  • To add the given permission and remove others

chmod g=x filename

This is how you can use the chmod command in Linux. you can also use this method to set permission for other users.

  • To add or remove permission form admin user or other users.

chmod u+rw filename


chmod u-r filename


chmod o=x filename

  • You can use “a” attribute to give permission to all the users.

chmod a=rw filename

Using numbers to use the chmod command in Linux

You can also use numbers instead of “r” “w” “x” to use chmod. Here are the numbers that determine the permission.



















Above is the table you can use to determine what number dos what.

You can use the following command to give all permissions to all users.

chmod 777 filename

How To Delete Trusted Installer Files In Windows 10

That is it, folks!

This is about everything you need to know. Chmod is an essential command in Linux. You can set or change permission using this command. It is easy to use the command once you have learned the attributes. So go and start trying this on your own. I hope you find this article helpful.