MEWBIES@: Facebook Twitter G+ YouTube DeviantArt Forum Wall
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
██ ██
█▌ - CHMOD QUICK REFERENCE - █▌
█▌ █▌
█ chmod script by javascriptkit.com: ▐▌
█ When you view a list of contents, for example doing 'ls -al', next to each ▐▌
█ item it will state the type and permissions; the attributes. This is ▐▌
█ stated by characters such as: drwxr-xr-x. The meaning of each character is:▐▌
█ ▐▌
█ 7 = rwx = read, write, and execute (full perms) ▐▌
█ 6 = rw = read and write ▐▌
█ 5 = rx = read and execute ▐▌
█ 4 = r = read only ▐▌
█ 3 = wx = write and execute ▐▌
█ 2 = w = write only ▐▌
█ 1 = x = execute only ▐▌
█ 0 = - = remove all other permissions ▐▌
█ ▐▌
█ File/Directory ▐▌
█ ↑ ▐▌
█ |read User User ▐▌
█ |↑write User ↑Group ▐▌
█ ||↑execute User |↑Other ▐▌
█ |||↑ ↓↓↕ ▐▌
█ ||||read Group chmod 777 = all have rwx perms = ▐▌
█ ||||↑write Group -rwxrwxrwx ▐▌
█ |||||↑execute Group ▐▌
█ ||||||↑ ▐▌
█ |||||||read Other ▐▌
█ |||||||↑write Other ▐▌
█ ||||||||↑execute Other ▐▌
█ ↓↓↓↓↓↓↓↓↓↕ ▐▌
█ -rwxrwxrwx ▐▌
█ ▐▌
█ ATTRIBUTES - SOME DETAILS ▐▌
█ NUMBERS: ▐▌
█ Just to point out the logic of the above assigned numbers in case you ▐▌
█ missed it, you don't need to memorize or even read this: ▐▌
█ 2=w and 1=x. 2+1=3. w+x=wx 3=wx ▐▌
█ rwx = 7 = 4+3 (r+wx), or 5+2 (rx+w), or 4+2+1 (r+w+x) ▐▌
█ ▐▌
█ FIRST CHARACTER: ▐▌
█ There are always *ten characters to indicate the type and permissions, for ▐▌
█ example: -rwxr-xr-x. ▐▌
█ The FIRST character indicates type: ▐▌
█ d: directory p: named pipe ▐▌
█ -: regular file c: character (un-buffered) device file ▐▌
█ l: symbolic link b: block (buffered) device file ▐▌
█ s: socket ▐▌
█ ▐▌
█ *If you are accessing your server using a FTP program for example and it ▐▌
█ only shows nine characters; the missing character is the first one. ▐▌
█ ▐▌
█ NEXT NINE CHARACTERS: ▐▌
█ The next THREE/THREE/THREE characters are the permissions for each group: ▐▌
█ USER/GROUP/OTHER ▐▌
█ The basic permissions are r: read w: write x: execute (there are others ▐▌
█ such as s: setuid, -: no permission, t: sticky) ▐▌
█ For example: drwxrwxrwx (would chmod 777) full perms for all; read, write ▐▌
█ and execute: ▐▌
█ TYPE USER GROUP OTHER (aka owner, group, public) ▐▌
█ d rwx rwx rwx ▐▌
█ ▐▌
█ TO WHOM THE PERMISSIONS ARE APPLIED TO: ▐▌
█ The typical three numbers in a chmod command are in order of the group ▐▌
█ it will be applied to. ▐▌
█ For example 'chmod 754'. The first number (7) is applied to USER, the ▐▌
█ second number (5) is applied to GROUP, and the third number (4) applied to ▐▌
█ OTHER. ▐▌
█ The chmod 754 would look like this for a file: ▐▌
█ -rwxr-xr-- (meaning: file/7 User/5 Group/4 Other: -/rwx/r-x/r--) ▐▌
█ So the User (owner) has full perms, the Group has read and execute and the ▐▌
█ Other has read only. ▐▌
█ ▐▌
█ EXAMPLES: ▐▌
█ chmod 550 = -r-xr-x--- = User & Owner read and write, Group no perms ▐▌
█ chmod 777 = -rwxrwxrwx = All have read write and execute perms ▐▌
█ chmod 0777 = -rwxrwxrwx = All have read write and execute perms ▐▌
█ chmod 4777 = -rwxrwxrwx = 4 sets user ID (setuid), rest same ▐▌
█ chmod 2777 = -rwxrwxrwx = 2 sets group ID (setgid), rest same ▐▌
█ These can also be expressed with letters, for example: ▐▌
█ chmod ugo+x = All have execute perms added (ugo=user group other) ▐▌
█ chmod a+x = All have execute perms added (a=all) ▐▌
█ chmod ugo-x = All have execute perms subtracted (user group other) ▐▌
█ chmod +x = All have execute perms ▐▌
█ ▐▌
█ To allow the web server to access a directory and provide the content ▐▌
█ published by users for example in their ~/public_html change DIR_MODE ▐▌
█ to 0751. ▐▌
█ ▐▌
█ To not allow public to browse contents of a directory that doesn't contain ▐▌
█ an index.html file: chmod 711 directory ▐▌
█ ▐▌
█ To recursively change execute permissions on all subdirectories in the ▐▌
█ current directory, but not the files: chmod u+X * ▐▌
█ ▐▌
█ To chmod all the files in working directory, for example: chmod 755 * ▐▌
█ ▐▌
█ To chmod all the files in a directory recursively, for example: ▐▌
█ chmod -R 755 directoryname/ ▐▌
█ ▐▌
█ To recursively chmod all files and directories in working directory: ▐▌
█ chmod -R 711 * ▐▌
█ ▐▌
█ man chmod ▐▌
█ ▐▌
█ - OTHER MISC - ▐▌
█ ▐▌
█ CHANGE OWNERSHIP AND GROUP: ▐▌
█ Directories and files have a UID (user ID); who owns it and a GID ▐▌
█ (group ID); which group it is in. For example: ▐▌
█ ls -l / | grep jail ▐▌
█ My output: ▐▌
█ drwxrwx--- 4 root mew 4096 Mar 4 11:04 jail ▐▌
█ ↑ ↑ ↑ ▐▌
█ owner / UID GID / group directory ▐▌
█ ▐▌
█ To change ownership (chown) and group (chgrp) of a file(s) and or ▐▌
█ directory(ies) use chown and chgrp. For example change /jail and all ▐▌
█ its files and subdiretories (-R) from root root, to root mew: ▐▌
█ chown -R root /jail ; chgrp -R mew /jail ▐▌
█ Or you could: ▐▌
█ chown -R root.mew /jail ▐▌
█ ▐▌
█ TO PROTECT A FILE: ▐▌
█ For example to not allow anyone, even root, to read (open), write ▐▌
█ (modify), execute, delete, move etc. a file (handy to protect files that ▐▌
█ could be removed during an upgrade or other: chattr +a myfile ▐▌
█ Only root can modify that setting by removing chattr +a first. ▐▌
█ To list attributes for chattr: lsattr myfile ▐▌
█ To remove an 'a' attribute: chattr -a myfile ▐▌
█ Or if lsattr replied with an 'i' then -i. The i attribute is immutable- no ▐▌
█ append ability. ▐▌
█ HERE is more about chattr and man chattr ▐▌
█ ▐▌
█ //---------------------------------------------------------------------- ▐▌
█ ▐▌
█ If you find mistakes, have suggestions, and or questions please post at ▐▌
█ mewbies forum HERE - thank you. ▐▌
█ ▐▌
█ Last update on 06 Dec '13 ▐▌
█ ▐▌
█▌ █▌
█▌ - mewbies.com - █▌
█▌ █▌
██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██