Linux permissions are basically split into two areas.
• File ownership
• File access permissions
Every file has an owner. This is usually the user who created the file, although this can be changed.Users can also be classed into groups, so similar users can be grouped together.
The other element is the access permissions for the file. These are split into three areas:
• Who can read (view) the file ( r)
• Who can write to the file (w)
• Who can run the file (this only applies to files that can be run) (x)
Let’s look an example. Open a console and do a directory listing by typing:
at the command line.
This is simply a directory listing, but lets look at one line as an example:
-rw-r r 1 jono jono 1701 Jul 13 15:23 test.txt
A lot of information is given. Reading the information from left to right, this is what it means:
- File type indicator (- means normal file)
rw-r r File permissions
1701 File size
Jul 12 15:23 File creation time and date
Setting File Permissions
To change the permissions on a file we use the chmod command, which has the format:
The chmod command is a very versatile command and can change the permissions in a number of ways. Probably the easiest way to remember is by changing the permissions using the same letters to set them as they are displayed (r, w and x or octal digits 4 2 1). To do this you must first specify the section that you want to change (owner (u), group (g) or other (o)). You must then specify + or - to indicate whether you are giving (+) permissions or removing (-) them. Suppose that you would like to change the file test.txt so that all other users on the system can read and write to it. You would use:
chmod o+rw test.txt
This command basically says give every other user on the system (o) addition permissions (+) that are read (r) and write (w) on the file nickmail.txt.
Same can be written using octal form as
chmod 006 test.txt this is absolute assignment which will remove other permissions