In: Computer Science
File permissions let us control who can:
a.
change how files are executed only
b.
create files only
c.
delete files only
d.
read, write, and execute a file
Basic File Permissions
Permission Groups
Each file and directory has three user based permission groups:
Permission Types
Each file or directory has three basic permission types:
Viewing the Permissions
You can view the permissions by checking the file or directory permissions in your favorite GUI File Manager (which I will not cover here) or by reviewing 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
Modifying the Permissions
When in the command line, the permissions are edited by using the command chmod. You can assign the permissions explicitly or by using a binary reference as described below.
Explicitly Defining Permissions
To explicity define permissions you will need to reference the Permission Group and Permission Types.
The Permission Groups used are:
u – Owner
g – Group
o – Others
a – All users
The potential Assignment Operators are + (plus) and – (minus); these are used to tell the system whether to add or remove the specific permissions.
So for an example, lets say I have a file named file1 that currently has the permissions set to _rw_rw_rw, which means that the owner, group and all users have read and write permission. Now we want to remove the read and write permissions from the all users group.
To make this modification you would invoke the command:
chmod a-rw file1
To add the permissions above you would invoke the command:
chmod a+rw file1
As you can see, if you want to grant those permissions you would change the minus character to a plus to add those permissions.