Knowing File Permissions in Linux

  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/dhuha/public_html/includes/file.inc on line 646.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.
  • : Function split() is deprecated in /home/dhuha/public_html/modules/filter/filter.module on line 1206.

Not understanding about file permissions in Linux ? I'll give a simple explanation about that and hopefully it will be usefull.

Permissions
in Linux can be read=r, write=w and execute=x. There
are 3 categories of ownership for each file and directory:

u:
a valid user with an entry in /etc/passwd

g:
a valid group with an entry in /etc/group

o:
other

For example :

jafar@tebetreply:~$ ls -l

-rw-r--r-- 1 root  root     351 2007-09-27 12:39 symlink     
drwxr-xr-x 2 jafar jafar     48 2008-04-30 18:33 tes          
 
-rw-r--r-- 1 jafar jafar   7365 2007-10-29 13:13 tes.pl         

-rw-r--r--

The first character indicates the type of file, and the next three
indicate read, write, and execute permission for each of the three user
types, user, group and other. Since there are three types of permission
for three users, there are a total of nine permission bits. The table
below shows the syntax:

1 2 3 4 5 6 7 8 9 10
File User Permissions Group Permissions Other Permissions
Type Read Write Execute Read Write Execute Read Write Execute
d r w e r w e r w e
  • Character 1 is the type of file: - is ordinary, d is directory, l is link.
  • Characters 2-4 show owner permissions. Character 2 indicates
    read permission, character 3 indicates write permission, and character
    4 indicates execute permission.
  • Characters 5-7 show group permissions. Character 5=read, 6=write, 7=execute
  • Characters 8-10 show permissions for all other users. Character 8=read, 9=write, 10=execute

So if we have something like this -rw-r--r--, we can say this file : for user (read+write), for group (read only) and for other (read only).

Octal
and symbolic permissions
.

We can also use octal notation to give permission in a file or directory.



Symbolic

octal

binary

read

4

'
100'

write

2

'
010'

execute

1

'
001'

Permissions
apply to the user, the group and to others. An item has a set of  3
grouped permissions for each of these categories.

How
to translate
-rw-r--r-- in octal notation



user

group

other

rw

4+2=6

r__

4=4

r__

4=4

-rw-r--r-- = 644 in octal notation

-rwxrwxrw- = 775 in octal notation

The
standard permission

UNIX
system create files and directories with standard permissions as
follows:

Standard
permission for:

Files 666 -rw-rw-rw-

Directories 777 -rwxrwxrwx


Not difficult isnt it.