read only(r) - Users can read the file but cannot modify or execute it.
write(w) - Users can read and modify the file.
execute(x) - Users can run the file.
user(u) - The owner of the file(For eg: The managing director of the company)
group(g) - File access to users in its group(For eg: All employees working for the Human Resource Department in a company)
others(o) - File access to every other user in the network(For eg: Every other employee in the company)
Displaying file permissions:
You can display the file permissions in the current directory by typing,
For a specific file or directory type,
$ls -l (directory/file name)
Your output would be something like,
The first character is usually a '-' or a 'd'. '-' indicates a file, 'd' indicates a directory.
The next three characters define the file permissions for the user,
the next three for the group and
the final three for others on the network.
Lets take picture.gif. The first '-' indicates that it is a file and the file permissions for the three user categories are as follows
Changing file permissions - chmod
chmod is used to change file permissions.
If you would like to see what is really happening to the file, use verbose mode
To apply changes to all files and directories under the current directory, use -R,
The various user options for chmod is given below:
For example, if you would like to change the file permissions of lab from -rw------- to -rw-r-xr-x, you need to type,
i.e., you are giving read and execute access to the group as well as others
Other examples are,
#chmod ugo+rwx (file/directory name)
which gives read, write and execute access to all users.
#chmod go-w (file/directory name)
which removes the write privileges of group and others from modifying the file.
Changing the owner - chown
The owner of a file could be changed by using the chown command.
#chown (username/new owner) (file/directory name)
Changing the group - chgrp
The group to which the file belong can be changed using the chgrp command
#chgrp (groupname) (file/directory name)