How to Set the Permission drwxr-xr-x to Folders?

Linux Operating System (OS) consists of different system files, and only a skilled administrator is authorized to manipulate them. To keep the files/folders secure, Linux allows setting different permissions to various users, groups, etc. This post aims to set the permission drwxr-xr-x to folders in Linux.

We will show you how to grant everything to the main users or admins and remove the right to write anything for the group/other users by discussing the two main topics listed below:

Let’s discuss them one by one in more detail.

What are Permissions in Linux?

You can see the list of permission of files/directories in PWD by typing the following command in the terminal:

$ ls -l
Top 10 Linux Distros

When you look at the above image closely, you will find different characters such as “d”, “r”, “w” and “x” written at the start. A total of 10 dashes are available where “d” stands for the directory, “r” stands for read, “w” stands for write, and “x” stands for execute. Now let’s discuss what these permissions do in detail.

Read: If the “r” is written, then the user has permission to read else the user cannot read. .

Write: You can either have permission to write on a file and do some modifications or you cannot perform any changes on the file/directory.

Execute: Shows the executable permissions of a file/directory by the user.

Also, the letter ‘d’ written at the start stands for the directory.

Note: You can give these permissions to a different set of users that belong to three different categories, which are User, Group, and Owner, which will be discussed in the next section. The letter‘ d’ on the first slot represents the directory.

What are Different Users in Linux?

As mentioned earlier, the permissions are granted on three different levels explained below:

User: Linux users are also considered system administrators since they are the primary owners of the operating system. Linux (OS) gives ownership of files to anyone who creates them.

Group: The system administrator might need to give separate rights to each user when several people are accessing the same Linux OS. The right of the group comes second, and an administrator can create groups and assign the same rights to all users in that group.

Other: Others are neither a user nor are they in the group and are considered separate entities and are not usually allowed to create any files. Their permission comes the third place.

To give you a complete picture of what everything has been discussed till now, please see the below image.

How to Set the Permission drwxr-xr-x to Folders?

Let’s come to the main topic where we need to give ‘drwxr-xr-x’ to any folder. This first letter, “d” means a directory or folder followed by providing the main user’s read, write and execute rights. Now both Group users and other users have only the read and execute rights and cannot modify them by writing anything that can be seen below:

Let’s suppose you want to give these rights to the “Document” folder. Currently, the permissions set to the “Documents” directory can be viewed using the command:

$ ls -ld Documents

You can see that there is no permission given to any user as all the dash (-) are empty. To give the exact permission for each user, you may use the alphabet or the numeric representation of the permissions. Let’s practice both methods:

Method 1: Using Alphabetic Representation of Permissions

The commands provided below will set the desired permissions to the folder named “Documents”:

$ chmod u+rwx Documents 
$ chmod g+rx Documents 
$ chmod o+rx Documents

In the above image,

  • ‘u+rwx’ means that we are giving user permission to read, write and execute.
  •  ‘g+rx’ means that a group has permission to read and execute.
  • The same goes for other users because we also wrote ‘o+rx’ to give them permission to read and execute.

There is another variation where you can set your desired permission by writing a single command mentioned below:

$ chmod u+rwx,g+rx,o+rx Documents

Method 2: Using Numeric Values of Permissions

The second method of doing the same thing is by using the numeric value that’s been assigned to them which are mentioned below

Read → 4

Write → 2

Execute → 1

For a user the numeric value would be:

User (Read, Write, Execute) (4+2+1 = 7)

For Group users the numeric value would be:

Group Users (Read and Execute) → (4+1 = 5)

For other users the numeric value would be:

Other Users(Read and Execute) →(4+1 = 5)

A detailed illustration of what been discussed above is mentioned below:

To give this desired permission (rwxr-xr-x), the command provided below will be executed:

$ chmod 755 Documents

That’s all for this article.

Conclusion

To set the permission “drwxr-xr-x” permissions to the folders, you can utilize the commands “chmod 755 path/of/folder” or chmod u+rwx,g+rx,o+rx path/of/folder. In Linux OS, there are three types of users: users, group users, and others, and they can be granted permission to read, write, and execute a specific file/folder. This post has demonstrated the methods to set the permission of the folders to “drwxr-xr-x”.