160 likes | 315 Views
Unix Permissions. File & Directory Permissions. ls –l command will show full details, including file name, owner name, modification date, size and permission sequence. Unix Permissions. Permission sequence found at the beginning of a directory listing (first 10 characters): d rwx r-x r-x.
E N D
File & Directory Permissions • ls –l command will show full details, including file name, owner name, modification date, size and permission sequence.
Unix Permissions • Permission sequence found at the beginning of a directory listing (first 10 characters): d rwx r-x r-x Owner’s Permissions Group’s Permissions World’s Permissions Directory
Unix Permissions • The first character represents whether the listing is a directory. If it is a directory, a “d” will appear in the first character; otherwise, you should normally see a dash (-). d rwx r-x r-x
Unix Permissions • The remaining nine characters are divided into three triplets. • The first triplet represents the owner’s permissions. • The second is the group’s permissions. • The third triplet represents the World’s permissions.
Read Permission • 1st position in a triplet: r stands for Read; grants permission to view the contents of a file or directory (Value is ‘r’ or ‘-’).
Write Permission • 2nd position in a triplet: w stands for Write; grants permission to modify a file or the contents of a directory (Value is ‘w’ or ‘-’).
Execute Permission • 3rd position in a triplet: x stands for eXecute; grants permission to run an application or open a directory (Value is ‘x’ or ‘-’).
Unix Permissions • When changing permissions, we must first decide what number will represent the permissions for a triplet. • We can do this by determining whether or not a permission is turned on or off. • If turned on, a permission gets a value of 1; if turned off, it gets a value of 0.
Unix Permissions • After deciding whether the three permissions in a triplet are on or off, we will have a binary number • We can convert the binary number to its octal equivalent
The chmod Command • Once you’ve established the octal number representing the permission for each triplet, you can then use the change mode (chmod) command to give a directory or file proper permissions
chmod Syntax & Example • Syntax:chmod permissionMask file/dir • Example:chmod 755 public_html • Typically, directories and executable files are given “755” permissions, while other files are given “644” permissions