2014-10-02 03:39:28 +01:00
|
|
|
# chmod
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Change the access permissions of a file or directory.
|
2021-04-01 16:54:26 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/chmod>.
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2016-08-30 17:47:11 +01:00
|
|
|
- Give the [u]ser who owns a file the right to e[x]ecute it:
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod u+x {{path/to/file}}`
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2020-01-11 22:10:48 +00:00
|
|
|
- Give the [u]ser rights to [r]ead and [w]rite to a file/directory:
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod u+rw {{path/to/file_or_directory}}`
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2020-01-11 22:10:48 +00:00
|
|
|
- Remove e[x]ecutable rights from the [g]roup:
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod g-x {{path/to/file}}`
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2020-01-11 22:10:48 +00:00
|
|
|
- Give [a]ll users rights to [r]ead and e[x]ecute:
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod a+rx {{path/to/file}}`
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2020-01-11 22:10:48 +00:00
|
|
|
- Give [o]thers (not in the file owner's group) the same rights as the [g]roup:
|
2014-10-02 03:39:28 +01:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod o=g {{path/to/file}}`
|
2017-11-24 14:01:12 +00:00
|
|
|
|
2020-01-11 22:10:48 +00:00
|
|
|
- Remove all rights from [o]thers:
|
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod o= {{path/to/file}}`
|
2020-01-11 22:10:48 +00:00
|
|
|
|
2020-10-27 06:30:32 +00:00
|
|
|
- Change permissions recursively giving [g]roup and [o]thers the ability to [w]rite:
|
2017-11-24 14:01:12 +00:00
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod -R g+w,o+w {{path/to/directory}}`
|
2021-09-03 21:43:28 +01:00
|
|
|
|
|
|
|
- Recursively give [a]ll users [r]ead permissions to files and e[X]ecute permissions to sub-directories within a directory:
|
|
|
|
|
2022-08-06 04:11:59 +01:00
|
|
|
`chmod -R a+rX {{path/to/directory}}`
|