How to Use chmod Command to Change Linux File Permissions

Share this Article :

In this post, i will share with you the basic chmod command usage to change linux file permission. This was tested on CentOS 5.5.

Who – ugoa controls :

u = Owner
g = Users in the Group
o = Other users not in the group
a = All users/Everyone

Permission :

r = Read
w = Write
x = Execute

Opcode :

+ --> Add permission.
- --> Remove permission.
= --> Assign permission

Samples:

Allow execute permission to everyone:
chmod a+x samplesfiles.txt

Deny execute permission to everyone:
chmod a-x samplesfiles.txt

Allow read permission to everyone:
chmod a+r samplesfiles.txt

Deny read permission to everyone:
chmod a-r samplesfiles.txt

Allow write and execute permission to everyone:
chmod a+wx samplesfiles.txt

Deny write and execute permission to everyone:
chmod a-wx samplesfiles.txt

Make a file readable and writable by the group and others:
chmod go+rw samplesfiles.txt


Leave a Reply