Skip to main content Skip to navigation

1.7 File permissions

File permissions in linux specify who can do what with a file (remember that directories are also files). For example, you mightn't want other users looking at a file that contains your bank details! In linux, users can set permissions on their files to control who can read (r) , write (w) and execute (x) their own files.

Every user will automatically be a member of at least one group . Your group is established when your account is first created. You can always check what groups you are in by typing groups at your shell.

File permissions can not only protect your files from other users, it also can protect you from making stupid mistakes ( e.g. deleting files that you really shouldn't).

There are three broad classifications of the type of person who can access a user's files:

  1. the user themselves
  2. a member of the user's group
  3. anyone! (referred to in linux as 'others')

There are many ways for you to check the permissions on your files. One way is to use a linux command to list all your files in a directory ls -lrt . When this command is issued to the shell (typed in to the prompt), a user will get a characterisitic output, as explained below with an example;


Let's say the user phillipa types ls -lrt in a directory. The file is called report.pdf , and it is the only file in her current working directory. Furthermore, phillipa is a member of a group called chemistry . The output of ls -lrt is as follows;
 total 1 
 -rwxrw-r--    1 phillipa    chemistry       18715 Sep 24  2004 report.pdf 
Going through each entry in the output; the first line tells you how many files are in your current working directory.
In the second line, the first entry is a 10-character string. The first character indicates the file type. Two common file types are:
  • - Ordinary file
  • d Directory
The next 3 groups of 3 characters indicate the file permissions for the user, any group member ( i.e. a member of the chemistry group), and anyone else (others). Each set of 3 characters can take any combination of rwx (read, write and execute). Dashes indicate that a particular permission in the rwx sequence has not been enabled.
So, this 10-character string tells us that phillipa can read, write and execute the file, members of the chemistry group can read and write to the file, and others can only read the file.
The next entry in lin 2 indicates how many links this file has - this really only applies to files tht are directories.
The next two entries indicate the user and the group who own this file .
The fifth entry gives the file size in characters, the next couple of entries give the date on which the file was last modified, and the final entry gives the file name itself.

Often when you have trouble accessing a file, the first thing you should check is the permissions. Also, as the owner of a file, you can change the permissions associated with this file (moe about this later)