Home Command line tools drwxr-x-r-x or rwxr-x-r-x: A Step by Step Explanation

drwxr-x-r-x or rwxr-x-r-x: A Step by Step Explanation

by The Linux Digest Guy
drwxr-xr-x

When you execute the command ls -l in a Linux shell or other Unix-like environment, you’ll encounter a series of characters that represent file permissions. Initially, these strings made up of dashes, letters, and occasionally other symbols, can appear perplexing. However, you only need to know a few details to be able to decipher them like a pro.

For example, consider the permission set drwxr-xr-x. This is a frequently seen pattern, especially for directories. Let’s begin by breaking down its meaning in a simple manner.

What Does the Linux Permission drwxr-x-r-x Mean?

By deciphering this permission string, we can tell that this is a directory. The owner of the directory has read, write, and execution permission, the owning group has only read and execution permission and everyone else also has read and execute permission.

The Directory Value

The first character of the string is d. This means that this is a directory. If it were a regular file the string would be rwxr-x-r-x.

The Three Different Groups

Each file permission string represents three different groups of users. Each group is represented by three characters.

  • The owner of the file. This is usually the user that created the file. But the owner can be changed afterward. In this case, the owner has the permission string “rwx“. This means the owner can read the file, write to it and also run it as an executable, either as a script or a program.
  • The owning group of the file. This is also usually the group the file’s creator belongs to. But as before, it can be changed afterwards. In this example, the group’s permission is represented by “r–x“ which means that members of the group can only read the file or run it as an executable.
  • Others. This is the permission that is applied to every user who is not a member of the owning group and is not the owner of the file. In our example, these users are represented by the “r-x“ which means that they can only read the file or run it as an executable They can not write to it.

Use the chmod Command to Change Permissions

If your user has write permission to a file or directory, you can change its permissions. To do that you would use the chmod command.

To change the permission of a directory to the permissions in our example, “drwxr-xr-x” we could call chmod in this way:

chmod u=rwx,g=rx,o=rx name_of_file

drwxr-xr-x in Octal Format

You can also call chmod with an octal value of the permissions you want to set. This can be much quicker to type if you know the value you want to set. To set the permission to rwxr-xr-x:

chmod 0755 name_of_file

What You Should Know Now

This article has hopefully helped you to get a better understanding of Linux file permissions. If not, you can always come back to this article if you are unsure.

If you want to see an explanation of other file permissions you can check out some of my other articles like: “-rw-r–r–“: Step by Step Explanation.

On the other hand, if you have no problems with simple permissions you can check out a more advanced topic like setting permissions through setfacl.

0

Related Posts

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy