Permission Attribute

chmod Command

chmod command changes the permissions of each given file according to mode, which can be either a symbolic representation of changes to make, or an octal number representing the bit pattern for the new permissions.

The format of a symbolic mode is ‘[ugoa...][[+-=][rwxXs-tugo...]...][,...]’.

A combination of the letters ‘ugoa’ controls which users’ access to the file will be changed.

u

The user who owns it.

g

Other users in the file’s group.

o

Other users not in the file’s group.

a

All users.

+- =’ operators.

+

This operator causes the permissions selected to be added to the existing permissions of each file.

-

This operator causes them to be removed.

=

This operator causes them to be the only permissions that the file has.

The letters ‘rwxXstugo’ select the new permissions for the affected users.

r

Read.

w

Write (Delete / copy / move).

x

Execute (or access for directories).

X

Execute only if the file is a directory or already has execute permission for some user.

s

Set user or group ID on execution

t

Sticky.

u

The permissions granted to the user who owns the file.

g

The permissions granted to other users who are members of the file’s group.

o

The permissions granted to users that are in neither of the two preceding categories.

An octal number representing of file permission is a numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. Any omitted digits are assumed to be leading zeros.

Normal Permission Attribute of chmod

1st column is used for user (owner of the file) permission.

2nd column is used for group user’s permission.

3rd column is used for other users’ permission.








[root@localhost root]# ls

total 44

-rw-r--r-- 1 root root 1065 Apr 15 2005 anaconda-ks.cfg

-rw-r--r-- 1 root root 0 Jun 8 12:16 autoscan.log

-rw-r--r-- 1 root root 389 Jun 8 12:16 configure.scan

drwxr-xr-x 3 root root 4096 Nov 21 13:46 Desktop

-rw-r--r-- 1 root root 71 Nov 23 13:05 drive.txt

drwx------ 7 root root 4096 Jul 11 13:32 evolution

-rw-r--r-- 1 root root 3005 Apr 15 2005 install.log.syslog

-rw-r--r-- 1 root root 11038 Nov 25 15:21 isapnp.conf.new

-rw------- 1 root root 6003 Aug 16 19:34 mbox

[root@localhost root]# chmod u+x <>

ð To give the executing permission to file.

[root@localhost root]# chmod u+r <>

ð To give the read permission to user.

[root@localhost root]# chmod u+w <>

ð To give the write permission to user.

Again to remove the permission we will give the command as below,

[root@localhost root]# chmod u-x <>

[root@localhost root]# chmod u-r <>

[root@localhost root]# chmod u-w <>

Similarly administrator can give the permission to groups and others.

[root@localhost root]# chmod g+x <>

[root@localhost root]# chmod g+r <>

[root@localhost root]# chmod g+w <>

[root@localhost root]# chmod o+x <>

[root@localhost root]# chmod o+r <>

[root@localhost root]# chmod o+w <>

Similarly administrator can remove the permission from groups and others, such that

[root@localhost root]# chmod g-w <>

[root@localhost root]# chmod o-x <>

Again,

[root@localhost root]# chmod ugo+rwx <>

ð To give the all permission to the all user, group and others.

[root@localhost root]# chmod ugo-rwx <>

ð To remove the all permission to the all user, group and others.

[root@localhost root]# chmod u+rwx,g+w,o+x <>

ð To give the different types of permission to user, group, others.

[root@localhost root]# chmod u=r <>

ð To set only read permission for user and remove other permission.

[root@localhost root]# chmod g=x <>

[root@localhost root]# chmod o=r <>

Numerical Method of chmod

Uses a three digit mode number,

1. First digit specifies owner’s permissions.

2. Second digit specifies group’s permissions.

3. Third digit represent other’s permissions.

The value of read, write and execute are given below,

r = 4

w = 2

x = 1

[root@localhost root]# chmod 761 <>

ð That means,

u = r + w + x = 4 + 2 + 1 = 7

g = r + w = 4 + 2 = 6

o = x = 1

Example,

[root@ localhost root]# ll anaconda-ks.cfg

- rw- r-- r-- 1 root root 1042 Jun 25 12:59 anaconda-ks.cfg

[root@ localhost root]# chmod 761 anaconda-ks.cfg

[root@ localhost root]# ll anaconda-ks.cfg

- rwx rw- --x 1 root root 1042 Jun 25 12:59 anaconda-ks.cfg

[root@localhost root]# chmod 000 <>

ð To remove all type of file access permission from user, group and others.

Note: By default, always the numerical value is

644 For Ordinary File.

755 For Directory File.

Note: Universal permission:

666 For Ordinary File.

777 For Directory File.

[root@localhost root]# umask

0022

ð It will show the value of umask which are being used to set the file permission at when a file is created.

[root@localhost root]# umask 000

ð To set a new value of umask. Umask is one important command for giving and removing permission of the file.

Note: By default, for ordinary user the umask value is 002 and for super user it is 022.

The umask value is used at the file creation time by a formula which is given below,

universal value - umask value = file or directory's permission value.

Example,

666 - 022 = 644

777 - 022 = 755