How to Use chmod Command to Change Linux File Permissions

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

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee