Set the permissions for a file or directory by using the chmod
command. Each row has 2 examples, one for setting that permission for a file, and one for a directory named ‘dir’. This works in any linux distro, such as Ubuntu, etc.
Permission | Command Examples | Description |
---|---|---|
rwx rwx rwx | chmod 777 filename chmod -R 777 dir |
Anybody can read, write, execute. |
rwx rwx r-x | chmod 775 filename chmod -R 775 dir |
Owner & Group can read, write, execute. Everyone else can read, execute. |
rwx rwx r– | chmod 774 filename chmod -R 774 dir |
Owner & Group can read, write, execute. Everyone else can read. |
rwx r-x r-x | chmod 755 filename chmod -R 755 dir |
Owner can read, write, execute. Everyone else can read, execute. |
rwx — — | chmod 700 filename chmod -R 700 dir |
Owner can read, write, execute. No one else has any rights. |
rw- rw- rw- | chmod 666 filename chmod -R 666 dir |
Everyone can read, write. |
rw- rw- r– | chmod 664 filename chmod -R 664 dir |
Owner & Group can read, write. Everyone else can read. |
rw- r– r– | chmod 644 filename chmod -R 644 dir |
Owner can read, write. Everyone else can read. |
kasoka
August 16th, 2016 at 7:53 am
very helpful peace of information. helped me overcome a major obstacle in my assignment
Isabel
August 18th, 2016 at 10:07 pm
Thank you. Glad to help.
randy
August 28th, 2019 at 7:18 am
thank you for the help this was a great cheat sheet I put it in my linux notes great Job
Sam
May 24th, 2017 at 5:29 pm
Nice one thnaks
Snickasaurus
November 28th, 2017 at 1:06 am
This is super helpful. Going to print this out and keep it taped, stapled and glued to the wall next to my monitor.
Santiago
July 5th, 2018 at 5:27 pm
Very helpful nice and straight to the point, thank you 🙂
Roy Guisinger
November 8th, 2018 at 10:40 am
This is a good list for the basics. It would be even better if you expanded it to include examples for changing the suid, sgid, and sticky-bit flags.
John
November 9th, 2018 at 5:20 pm
What about the first digit?
4 – Set UID
2 – Set GID
1 – Restricted Deletion (or sticky bit)
hemant singh
March 26th, 2019 at 3:07 am
thank you