Command referencechmod
chmod command (Linux / bash / sh / zsh)
What it does
Change file permission bits and special modes. When people search for the chmod command linux permissions, they usually want chmod's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Change file permission bits and special modes.
Syntax
chmod [OPTION]... MODE FILE...
Common options
| Flag / option | Meaning |
|---|---|
| -R | Change permissions recursively. |
| -v | Report every processed file. |
| --reference=FILE | Copy the mode from another file. |
| u+x | Symbolically add execute permission for the owner. |
Practical examples
Make executable
chmod u+x deploy.sh
Lets the owner execute the script.
Set a private mode
chmod 600 secrets.env
Allows only the owner to read and write.
Copy permissions
chmod --reference=template.conf app.conf
Applies the reference file's mode.
Linux ↔ Windows equivalent
Closest match: attrib (Windows / CMD). View or change read-only, hidden, system, and archive file attributes.
attrib changes Windows file attributes, not Unix ownership or rwx permission bits.
Common mistakes
- Using `chmod -R 777` as a blanket fix, exposing every file.
- Confusing numeric mode order: owner, group, then others.
Related commands
FAQ
What does chmod do in Linux?
Change file permission bits and special modes.
How do I use chmod from the terminal?
Start with `chmod [OPTION]... MODE FILE...`, then choose only the options needed for the task.
What is a practical chmod example?
Try `chmod u+x deploy.sh` — Lets the owner execute the script.
Can I use chmod in a shell script?
Yes. chmod works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.