Assisgning appropriate file permissions is critical for security potocols
and accessibility. It is important to understand the variouos protocols when
assigning permissions under various data groups. For example, directories stored under
web directories have different file permissions and group allocations than data
stored under data directories.
To view file permissions use the ls -al command. The left column
contains the file type, and permisions assigned to file uses. To change file permissions,
use the chmod command. The chmod command can be used to change the read, write
and execute permissions for the user, group or others.
in general file users can be assigned as:
- u (user) you, the owner of the account
- g (group) assigned by the system administrator
- o (other) everyone else not you, and not in your group
and permissions can assigned as:
- r (read) allows your files to be seen and copied
- w (write) allows the files to be changed
- x (execute) allows an executable program to be run.
Permisisons are assigned consecutively for the user,
group and others (ugo) in the read write and execute (rwx) order
Let's dissect the following example with 1 file and 1 directory:
drwx------ 2 user1 group1 512 Jul 17 15:45 tdirectory/
-rw-rw-r-- 1 user1 group1 5 Jul 18 16:03 tfile
Both the file and directory are owned by user1 and are a member
of group group1. The left column of the directory, tdirectory,
(drwx------) specifies that it is a directory by the "d" in the
first position and it has read, write and executable (rwx) access for
for the user only. The left column of the file, tfile, (-rw-rw-r--)
specifies that has read and write acess for the user and group and only read
access for others.
Permissions can be changed using the following syntax:
chmod [ugo][+|-|=][rwx] file ...
For example, to add read and write privaleges for the group, type
chmod g+rw file ...
To remove read and write privaleges for the group and others, type
chmod o-rw file ...
An easier way to apply permissions is by using binary codes.
To apply read (4) and write(2) {4+2=6} privaleges to the user, use
chmod 600 tfile
-rw------- 1 user1 group1 5 Jul 18 16:03 tfile
To apply read (4) and write(2) {4+2=6} privaleges to the user and group, use
chmod 660 tfile
-rw-rw---- 1 user1 group1 5 Jul 18 16:03 tfile
To apply read (4) and write(2) {4+2=6} privaleges to the user and group, and read only permission
to others (4) use
chmod 664 tfile
-rw-rw-r-- 1 user1 group1 5 Jul 18 16:03 tfile
For more information on chmod, type man chmod at the command prompt.
In general at ERD, file permssions should not have read or write acces at the other
level to maintain security, especially for web-based files and directories.
To change group allocations, use the chgrp command. For example:
chgrp group2 tfile
returns
-rw-rw---- 1 user1 group2 5 Jul 18 16:03 tfile
For more information on chgrp, type man chgrp at the command prompt.