How to change directory and subdirectory permissions in Linux?

To change the permissions of a directory and its subdirectories, you can use the chmod command. Here are the steps to modify the permissions:

  1. Open the terminal window.
  2. You can use the cd command to navigate to the directory where you want to modify permissions.
  3. Use the ls -l command to view the current permissions of a directory and its subdirectories.
  4. To change permissions using the chmod command, the syntax is as follows:
  5. change the permission mode for the directory at
  6. The permission mode can be represented in two ways: using either numbers or symbols.
  7. Digital representation: Each digit represents a permission bit, corresponding to user, group, and other users. The number 0 represents no permission, the number 1 represents execute permission, the number 2 represents write permission, and the number 4 represents read permission. By adding these three numbers, various permission combinations can be created. For example, the number 755 represents the user having read, write, and execute permissions, while the group and other users have read and execute permissions.
  8. Symbolic representation: The symbol + indicates adding permission, the symbol – indicates removing permission, and the symbol = indicates setting permission. The symbol representation can use u for users, g for groups, o for other users, and a for all users; r for read permission, w for write permission, x for execute permission. For example, u+rwx indicates adding read, write, and execute permissions for the user.
  9. For example, to change the permissions of the directory /home/user/documents and its subdirectories to 755, you can use the following command:
  10. Give read, write, and execute permissions to the user for all files and directories in the “/home/user/documents” directory.
  11. The ‘-R’ option here signifies recursive modification, namely changing the permissions of both the directory and its subdirectories.
  12. Use the “ls -l” command to review the permissions of the directory and its subdirectories again to confirm that the changes have taken effect.
Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds