Thursday, February 5, 2015

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:


PermissionsCommand
UserGroup World
rwx rwx rwx chmod 777 filename
rwxrwxr-x chmod 775 filename
rwxr-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
400r--read by owner
040-r-read by group
004--rread by anybody (other)
200w--write by owner
020-w-write by group
002--wwrite by anybody
100x--execute by owner
010-x-execute by group
001--xexecute 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

No comments:

Post a Comment