How to use chmod to change file permission?

In this article, we will describe how to use the chmod command to modify file permission in Linux systems.

What is chmod? 

The chmod (short for change mode) is a command which allows you to modify file permissions on Linux/Unix systems.

How to use it? 

There are three basic file permissions in Linux systems. 

  1. Read (r)
  2. Write (w)
  3. Execute (x)

And you can assign all three permissions by the below classes. 

  1. User (u)
  2. Group (g)
  3. Other (o)

The user is an account that owns the file. The group which owns the file may also have other accounts as members. The other are the rest of the accounts in the system. 

To view the current file permission on the file you can use the following command.

ls - la

Here is an example output of a file 1 which has read and write permission for the user and only read permission to everyone else on the system. 


File2 is has read, write, and execute permission for everyone whereas file3 has read, write, and execute permission for the only user. 

$ ls -la

-rw-r--r--  1 user       group     273 Mar 24 11:28 file1
-rwxrwxrwx  1 user       group    1449 Jan 29 14:01 file2
-rwx------  1 user       group    4119 Jan 26 13:22 file3

Following is a syntax to use the chmod command. 

chmod [references][operator][modes] filename

References : It is the short form the(u ,g, or o)  for each class.

Operator : It is to determine whether to add (+) remove (-) or set (=) the permission Modes : It is read(r), write(w), and execute(x). 

Following is an example to add the execute permission for the user to file1

chmod u+x file1

To remove the write permission for others for file2:

chmod o-w file2

For more information on changing file permissions please use the below command.

man chmod
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Install Minecraft Game Server in Linux VPS?

This article will assist you to install Minecraft Server in your Linux VPS. Checkout our VPS...

How To Install EPEL Repo on CentOS and RHEL 7?

EPEL stands for Extra Packages for Enterprise Linux. It is very easy to install additional...

Fix :: Linux SSH error "connection refused"

Problem Statement Can't connect to a Linux server(Debian Flavour) via SSH. Error Message...

How to Prevent File/Directory Modification, Deletion and Renaming in Linux?

If you are looking to prevent any file from being modified, delete or renaming, you will need to...

How Do I Point My Websites to VPS?

This article will guide you to point your websites to VPS. You can point your websites to VPS in...