eolas/zk/chmod.md

42 lines
1.2 KiB
Markdown
Raw Normal View History

2025-05-04 18:01:46 +01:00
---
tags: [permissions, Linux]
created: Friday, April 11, 2025
---
# chmod
Modify file permissions.
We can use symbols or numbers.
For example:
```sh
chmod +x filename
```
To make a file executable.
When we use numbers this is called an _absolute_ change, because all permission
bits are being set at once in octal notation.
Best just to memorise the most common sequences. Bear in mind that some only
apply to files, rather than directories or executable programs.
| Mode | Meaning | Applied to |
| ---- | --------------------------------- | --------------------- |
| 644 | user: r/w, group/other: r | files |
| 600 | user: r/w, group/other: none | files |
| 755 | user: r/w/e, group/other: r/e | directories, programs |
| 700 | user: r/w/e, group/other: none | directories, programs |
| 711 | user: r/w/e, group/other: execute | directories |
### Useful options
`-v` → verbose: tell the user what `chmod` is doing
`-r` → work recursively, i.e apply the action to directories as well as files
> You can list the contents of a directory if it's readable but you can only
> access a file in a directory if the directory is executable!