File Permissions and the chmod/chgrp/chown commands
The chmod/chgrp/chown commands are used to change the permissions/ownership
of files and/or directories. Linux is often used as a multi-user system and
it is not desirable that all users have access to all files and directories.
For eg. : On a multi-user environment in a corporate office using a central
server running linux , it might be required the accounts documents be shared
between employees of the acccounts department . At the same time, it might
be undesirable and indeed dangerous if anyone having access to the server
is able to read/edit them.
It is for such situations that Linux has a 3X3 permission system.
There are 3 levels of security for a file :
Read Permission : Permission to read a file (r)
Write Permission : Permission to edit a file (w)
Execute Permission : Permission to execute a file if it is executable
(x)
and 3 different levels for a directory :
Enter Permission : Permission to Enter into the Directory
Show Entry : Permission to see the contents of the Directory
Write Entry : Permission to make a new file or subdirectory in
the Directory
For granting the above permissions, users are divided into 3 different
sets
User : The owner of the file/directory - mostly the person
who created the file/directory
Group : Linux users can be divided in groups and one user can
be a member of more than one group.
A Group denotes all users who are members of group(s)
to which the owner of a file/directory belongs
Others : All users not in the group(s) of the owner.
For eg :
A user level r/w/x permission means only the owner can read, write and
execute the file
A group level r/w/x permission means only the members of group(s) to which
the owner belongs can read, write and execute the file
An other level r/w/x permission means Everyone can read/write/execute
the file.
The chmod Command
The chmod command is used to change the permissions of files/directories
in linux. It\\\\\\\'s syntax is as follows :
chmod -R/c/f/v [u / g / o / a] [+ / - / =] [rwxXstugo..]
for eg. if u want to give all users in the group of the owner just read
permission to a file called foo.txt, the command is
chmod g+r /home/aarjav/foo.txt