chmod command
Change file and directory permissions.
- Users & permissions
- Package coreutils
- 5 options · 7 examples
Syntax
chmod [options] mode file…Provided by the coreutils package. Run man chmod for the full manual.
Common options
| Option | What it does |
|---|---|
-R | Apply recursively |
-v | Print each change |
u g o a | User, group, others, all |
+ - = | Add, remove or set permissions |
r w x | Read (4), write (2), execute (1) |
Examples
Make a script executable
chmod +x deploy.shOwner read/write, others read
chmod 644 index.htmlOwner full, others read and execute
chmod 755 /usr/local/bin/toolPrivate file
chmod 600 ~/.ssh/id_ed25519Remove write for group and others
chmod go-w file.txtDirectories 755 and files 644
find /var/www -type d -exec chmod 755 {} + -o -type f -exec chmod 644 {} +Recursive change
chmod -R 750 /opt/app
No example matches. Check the options table or search the guides.
Tips
- Avoid
chmod 777; give the web server user ownership instead.
chmod guides
- Find All files with 777 permission in Linux Linux Commands · Updated Apr 2025
- How to Set all directories to 755 And all files to 644 Linux Commands · Updated Apr 2025
- Chmod Command in Linux (Change File Permissions) Linux Commands · Updated Apr 2025
- Restricting Users from Running `chmod 777` Security · Updated Apr 2025
