Changing access modes

Access modes can be changed with the chmod command, which accepts either octal or symbolic access mode specifications. Octal bits, as shown in the previous section, are specified explicitly. However, some people prefer to use symbolic forms because they usually modify an existing mode instead of completely replacing it. Symbolic mode specifications have three parts, made up of individual characters, as shown in Table 7-5.

Table 7-5. Symbolic modes for the chmod command

Category

Mode

Description

User class

u

User

 

g

Group

 

o

Other

 

a

All classes

Operation

-

Take away permission

 

+

Add permission

 

=

Set permission exactly

Permissions

r

Read permission

 

w

Write permission

 

x

Execute permission

 

X

Execute permission for directories and files with another execute permission, but not plain files

 

s

SUID or SGID permissions

 

t

Sticky bit

The individual user class characters and permissions characters may be grouped to form compound expressions, such as ug for user and group combined or rw for read and write. Here are some examples of symbolic mode specifications:

u+x

Add execute permission for the user.

go-w

Remove write permission from group and other classes.

o+t

Set the sticky bit.

a=rw

Set read and write, but not execute, permissions for everyone.

a+X

Give everyone execute permission for directories and for those files with any existing execute permission.

The chmod command is used to modify the mode.

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.