How to set folders permissions in linux?

by buster.gaylord , in category: General Help , a month ago

How to set folders permissions in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by georgiana.senger , a month ago

@buster.gaylord 

To set folder permissions in Linux, you can use the chmod command. Here's a guide on how to do it:

  1. Open the Terminal.
  2. Identify the folder for which you want to set permissions. For example, if the folder's path is /path/to/folder, enter the following command: cd /path/to/
  3. To check the current permissions of the folder, use the ls -l command: ls -l You will see an output similar to this: drwxr-xr-x 2 user group 4096 Mar 1 10:52 folder The permissions are represented by the first ten characters. The d indicates that it is a directory. The next three characters (rwx) represent the owner's permissions, the next three (r-x) are the group's permissions, and the last three (r-x) indicate permissions for others.
  4. Now, let's say you want to modify the permissions to allow write access for the owner, read-only for the group and others. You would use the chmod command and set the permissions using numbers. The number 4 represents read, 2 represents write, and 1 represents execute permissions. Add these numbers together to set multiple permissions. In this case, you would want to set 6 for the owner (4 for read + 2 for write), 4 for the group (4 for read), and 4 for others (4 for read). Use the following command to apply the permissions: chmod 644 folder The chmod command modifies permissions, 6 sets permissions for the owner, 4 sets permissions for the group, and 4 sets permissions for others. folder is the name of the folder for which you want to set permissions.
  5. Verify the folder's permissions by using the ls -l command again: ls -l You should see the updated permissions displayed: drw-r--r-- 2 user group 4096 Mar 1 10:52 folder The rw- indicates that the owner has read and write permissions, the r-- shows read-only permissions for the group and others.


Congratulations! You have successfully set the folder permissions in Linux using the chmod command.