Chmod review.
With more and more people using the command line, changing permissions is a must. Chmod (chmod) is used to change permissions of a file. Do not use it that much except when setting permissions on the .ssh folder or on a web server application directories
i.e.
$ sudo chmod -R 755 appdirectory
or
$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/*
Explanation examples:
| Permissions | Command | ||
| User | Group | World | |
| rwx | rwx | rwx | chmod 777 filename |
| rwx | rwx | r-x | chmod 775 filename |
| rwx | r-x | r-x | chmod 755 filename |
| rw- | rw- | r-- | chmod 664 filename |
| rw- | r-- | r-- | chmod 644 filename |
r = readable w = writable x = executable - = no permission
Here is another way of looking at it:
| ugw | --- | function |
| 400 | r-- | read by owner |
| 040 | -r- | read by group |
| 004 | --r | read by anybody (other) |
| 200 | w-- | write by owner |
| 020 | -w- | write by group |
| 002 | --w | write by anybody |
| 100 | x-- | execute by owner |
| 010 | -x- | execute by group |
| 001 | --x | execute by anybody |
To get a combination, just add them up. For example, to get read, write, execute by owner, read, execute, by group, and execute by anybody, you would add 400+200+100+040+010+001 to give 751.
There is also a nice web based calculator you can use on a web page of your own making: http://wsabstract.com/script/script2/chmodcal.shtml
Note: Some people like to use:
chmod ugo=rwx myfile
Where the nerds use:
chmod 777 myfile


Comments
Post a Comment