Cheatsheet: Difference between revisions

Line 790:
== File permission ==
 
;Linux File Permission Basics
File Type User Group Global
 
d Directory rwx r-x r-x
* The first character represents the type of file.
* The remaining nine bits in groups of three represent the permissions for the user, group, and global respectively.
 
File Type User Group Global
d Directory rwx r-x r-x
- Regular file rw- r-- r--
l Symbolic Link rwx rwx rwx
 
* Targeted Users:
Who (Letter) Meaning
u user
g group
o others
a all
 
*Permissions Table:
Binary Octal Permission
000 0 —
Line 805 ⟶ 817:
110 6 rw-
111 7 rwx
 
;chmod Command Syntax and Options
chmod [who][+,-,=][permissions] filename
 
*Example:
chmod g+w ~/group-project.txt
 
* The + operator grants permissions whereas the - operator takes away permissions.
* Copying permissions is also possible:
chmod g=u ~/group-project.txt
 
* The parameter g=u means grant group permissions to be same as the user’s.
 
* Multiple permissions can be specified by separating them with a comma, as in the following example:
chmod g+w,o-rw,a+x ~/group-project-files/
 
* Owner of the file is referred to as the user (e.g. u+x).
 
* The -R option applies the modification to the permissions recursively to the directory specified:
chmod -R +w,g=rw,o-rw, ~/group-project-files/
 
 
;Octal Notation for File Permissions:
 
* The permissions to be set for file:
chmod u=rwx,g=rx,o= group-project.txt
chmod 750 group-project.txt
 
* Disregarding the first bit, each bit that is occupied with a - can be replaced with a 0 while r, w, or x is represented by a 1:
111 101 000
- rwx r-x ---
 
* This is called octal notation because the binary numbers are converted to base-8 by using the digits 0 to 7
 
* Typical default permission: 744
Allows R,W,X permissions for the owner
R permissions for the group and “world” users
 
== Commands ==