chmod
Quick Reference
Command Name:
chmod
Category:
file permissions
Platform:
linux
Basic Usage:
Common Use Cases
- 1
Permission management
Change file and directory permissions
- 2
Security configuration
Set appropriate permissions for security
- 3
System administration
Manage access permissions for files and directories
- 4
Multi-user setup
Configure permissions for shared access
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:
chmod u+rwx filename.sh
chmod go-w important_file.txt
chmod a+rx script.sh
chmod 755 program.bin
chmod +x install.sh