The chmod command is used to modify permissions of files or directories. These permissions control the actions which can be performed on a file or directory, like reading, writing, and executing. It comes from “coreutils-x.x” package.
Examples:
1. To change the file permissions
$ chmod r+x,g-x,o=r– file.txt |
2. To change the file permissions using the octal values
$ chmod 777 file.txt |
3. To see if the changes have been taken affect or not after firing the command
$ chmod -c 777 file.txt |
4. To apply the changes recursively
$ chmod -R 777 /mydir/ |
5. To set the verbose mode
$ chmod -v 777 /mydir/ |
6. To change the MODE of each file to preserve root
$ chmod –preserve-root FILE |
7. To change the MODE of each file not to preserve root
$ chmod –no-preserve-root FILE |
8. To set MODE from reference file
$ chmod –reference=RFILE FILE |
9. To see the help for chmod
$ chmod –help |
10. To see the version for the chmod
$ chmod –verbose |