chmod
Quick Reference
Command Name:
chmod
Category:
file permissions
Platform:
linux
Basic Usage:
Common Use Cases
Syntax
chmod [OPTION]... MODE[,MODE]... FILE... chmod [OPTION]... OCTAL-MODE FILE... chmod [OPTION]... --reference=RFILE FILE...
Options
Option | Description |
---|---|
-c, --changes | Like verbose but report only when a change is made |
-f, --silent, --quiet | Suppress most error messages |
-v, --verbose | Output a diagnostic for every file processed |
--no-preserve-root | Do not treat '/' specially (the default) |
--preserve-root | Fail to operate recursively on '/' |
--reference=RFILE | Use RFILE's mode instead of specifying a MODE value |
-R, --recursive | Change files and directories recursively |
--help | Display help message and exit |
--version | Output version information and exit |
Permission Modes:
Mode | Description |
---|---|
u | User who owns the file |
g | Group that owns the file |
o | Others (not owner or group) |
a | All (user, group, others) |
r | Read permission |
w | Write permission |
x | Execute permission |
s | Set user or group ID on execution |
t | Sticky bit |
+ | Add the specified permissions |
- | Remove the specified permissions |
= | Set the specified permissions and remove all others |
Examples
How to Use These Examples
The examples below show common ways to use the chmod
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Give the owner read, write, and execute permissions chmod u+rwx filename.sh
Advanced Examples:
# Set permissions recursively for a directory and its contents chmod -R 755 /var/www/html