3 Access rights on Linux

3.1 Rights and executable files

Sample output of "ls -l" :

drwxr-xr-x    6 user users         200 2003-05-02 10:21 Documents 
drwx------    2 user users         112 2003-09-23 08:52 Mail
-rw-r--r--    1 root root            0 2003-06-16 15:25 TEST
lrwxrwxrwx    1 root root            5 2003-05-27 16:20 bin -> /bin/

All files / directories / other are associated with a user and a group.

Access rights are the first right caracters.

The first character indicates whether a link, directory, or other file.

dDirectory
lLink
-File
p? Pipe ?


The last 9 are separated as follows :

USerGroupEveryone
readwriteexecutereadwriteexecutereadwriteexecute


Number equivalent to the security bits:

01234567
-----x-w--wxr--r-xrw-rwx


Note: You can run a script or program that you have execute permission (x). To run a file in the current directory, type ". / <file>"

3.2 Using chmod

There are two ways to define the mask (access rights).

3.2.1 The exact mode

Specify the acces rights with number.

Syntax:

chmod <mode> <file>

eg "chmod 750 file" will produce the following permissions: "rwxr-x ---"

3.2.2 The relative mode

In relative mode we defines what we want to change

Syntax:

chmod <mode> <file>

The mode is defined as follows: <who><change><what>

Whoo"Other" nor group, nor user
gGroup
uUser
Change+Add
-Remove
WhatrRead
wWrite
xExecute