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

Related Articles


Nextcloud is an open-source and secure PHP-based content collaboration platform. It is used for...

How to install/add Softaculous in Plesk?

Softaculous is software that auto-install web applications with one click. There is a wide range...

How to install Nagios 4.4.5 on Centos7?

Nagios is an Open-source monitoring tool. With Nagios, you can monitor your servers and networks...

How To Install PIP in Linux?

PIP called a Package management system for Python. It allows your system to install and manage...

How to Protect GRUB with Password in Linux ?

GRUB called as Grand Unified Bootloader is a default Boot loader on Unix OS. In a Linux system,...

  • 0 Users Found This Useful

Was this answer helpful?