Basics of Linux - Basic File Permissions



File Permissions

Basic File Permissions
Permission Classes
Each file and directory has three permission classes:
  • owner - The Owner permissions apply only the owner of the file or directory, they will not impact the actions of other users.
  • group - The Group permissions apply only to the group that has been assigned to the file or directory, they will not affect the actions of other users.
  • all users - The All Users permissions apply to all other users on the system, this is the permission group that you want to watch the most.

Permission Modes

Each file or directory has three basic permission types:
  • read - The Read permission refers to a user's capability to read the contents of the file.
  • write - The Write permissions refer to a user's capability to write or modify a file or directory.
  • execute - The Execute permission affects a user's capability to execute a file or view the contents of a directory.

Viewing the Permissions

You can view the permissions by viewing the output of the \"ls -l\" command while in the terminal and while working in the directory which contains the file or folder.
The permission in the command line is displayed as: _rwxrwxrwx 1 owner:group


Another way to view permission is using the stat command.

Changing the Permissions

+/-r : add/remove read privilege

+/-w: add/remove write privilege

 +/-x: add/remove execute privilege

 

Can also use the bit notation to change permissions. 

RWX = 111 = 2^2 + 2^1 + 2^0 = 7

111 = RWX

110=RW-

100 =R--

001 = --X

011 = -WX

010 = -W-

 -rw-------: A file that is only accessible by its owner
 -rwxr-xr-x: A file that is executable by every user on the system. A "world-executable" file
 -rw-rw-rw-: A file that is open to modification by every user on the system. A "world-writable" file
 drwxr-xr-x: A directory that every user on the system can read and access
 drwxrwx---: A directory that is modifiable (including its contents) by its owner and group
 drwxr-x---: A directory that is accessible by its group

As mentioned in the start each user has 3 class types: owner,group,allusers so whenever using bit notation to change permission you have to specify user priveleges for all classes.

chmod 070 file

this will specify rwx permissions for group and no permissions for everyone else.

Comments

Popular Posts