Permissions - Intro
If you are just getting into linux and upto now have only been using MS Windows operating systems
you might find file permissions a bit of a nightmare. Hopefully this page will explain them for you.
Permissions apply to all users on a system apart from the "root" user (the superuser), this is
one of the main reasons why you should not log in as "root" apart from when doing system
maintenance.
UNIX file permissions are split into the three main following sections:
- User (owner of the file).
- Group (everyone with the same group name as the owner).
- Others (anyone else on the system).
When a new user is created they are given a user name (what they log in with) and a group name to belong to.
These groups are usually self-explantatory and aids system administration among other things.
Within these three sections you can specify the following options shown in the table below
(in "ls -l" display order).
| For the owner of the file: |
| Char | Value | Permission |
| r | 400 | Read |
| w | 200 | Write |
| x | 100 | Execute |
| |
| For the owner's group: |
| Char | Value | Permission |
| r | 40 | Read |
| w | 20 | Write |
| x | 10 | Execute |
| |
| For all others not in the owner's group: |
| Char | Value | Permission |
| r | 4 | Read |
| w | 2 | Write |
| x | 1 | Execute |
Here is a typical directory listing using the "ls -l" command, with a file's permissions indicated on
the left.
If we take one of the file's permissions and split it up into it's different sections as shown in the
diagram below:
As you can see, each section has the space for the three options show in the table above.
Where there are "-" characters show that the specific permission is not set.
So, the above set of permissions read:
- Read and write permissions for the user who owns the file ("mark" in this case).
- Read permissions for other users in the same group as the owner ("users" in this case).
- Read permissions for everyone else on the system.
File permissions also apply to directories in the same way, but the options have a
slightly different meaning.
- Read access allows users to view a directory's contents.
- Write access allows users to create files in the directory.
- Execute allows users to change into the directory.
|