How to Recursively Set Directory and File Permissions in Linux

The chmod  command can change permissions for all subdirectories. Here are 2 methods:
Change permissions for a single file: chmod mode file|dir
Change permissions for all subdirectories: chmod mode dir -R    Note the -R parameter added at the end.

The parameter is the permission mode mode = 777 or 752 , 666,,,

The three digits of mode represent the permissions for owner, group, and others respectively.

1 = x execute 2 = w write 4 = r read. For example, if the owner has all permissions, 1+2+4=7,

Or if the group has read and execute permissions, 1+4 = 5

Change the owner to wang and the group to users for the directory /his and all files and subdirectories under it.

  $ chown – R wang.users /his

Leave a Comment

Your email address will not be published.