The chmod command
Change file permissions. Changes who may read (r), write (w) and execute (x) a file. MODE is either symbolic, such as u+x (add execute for the owner, the user), g-w (remove write for the group), o=r (others may only read) or +x (execute for everyone), or three octal digits for owner, group and others, where read = 4, write = 2 and execute = 1, so 7 = rwx, 6 = rw-, 5 = r-x and 4 = r--. Only a file’s owner can change its permissions.
Usage
chmod [OPTION]... MODE FILE...
Options
| -R, --recursive | change folders and everything inside them |
|---|---|
| -v, --verbose | say what changed |
Examples
chmod u+x backup.shLet yourself run a scriptchmod 600 diary.txtOnly you can read and write it (rw-------)chmod 755 binYou can do anything; others can read and enter (rwxr-xr-x)chmod go-w shared.txtNobody but you can change it
Learn it step by step
Related commands
learner@sandbox: ~bash (practice)
Note: Try chmod here: your home directory has sample files. Press Try beside an example, or type your own.
Enter runs · Tab completes names · ↑ ↓ step through history · Ctrl+L clears · type help for every command
A practice shell in your browser that behaves like bash on Linux for these commands. Nothing you type leaves the page.