Examples Using chmod#

Below are examples of making changes to permissions:
  • chmod u+x myfile - Gives the user execute permission on myfile.
  • chmod +x myfile - Gives everyone execute permission on myfile.
  • chmod ugo+x myfile - Same as the above command, but specifically specifies user, group and other.
  • chmod 400 myfile - Gives the user read permission, and removes all other permission. These permissions are specified in octal, the first char is for the user, second for the group and the third is for other. The high bit (4) is for read access, the middle bit (2) os for write access, and the low bit (1) is for execute access.
  • chmod 764 myfile - Gives user full access, group read and write access, and other read access.
  • chmod 751 myfile - Gives user full access, group read and execute permission, and other, execute permission.
  • chmod +s myfile - Set the setuid bit.
  • chmod go=rx myfile - Remove read and execute permissions for the group and other.

Chmod for changing on Subdirectories#

chmod on subdirectories or Files:
Operate on directories only:
find . -type d -exec chmod 770 {} \;

Operate on files only:
find . -type f -exec chmod 660 {} \;

Owner and Groups can Read#

Operate on directories only:
find . -type d -exec chmod 770 {} \;

Operate on files only:
find . -type f -exec chmod 660 {} \;

More Information#

There might be more information for this subject on one of the following: