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

How to List All Files Ordered by Size in Linux?

In Linux, we can list all the files using the ls command. Here, we will share some commands which...

DOS AND DON'TS FOR Linux VPS

Dos and Don'ts for Linux Classic VPS, SSD VPS, and Linux Private Cloud VPS : Please allow...

How to disable anonymous ftp in cpnael?

Note : It is not recommended to use anonymous FTP. It allows any person to access FTP without...

How to sync time using NTP in Ubuntu server?

Linux server users might have noticed that after adjusting the system clock to the correct time,...

How to block an IP address using .htaccess?

You can block traffic coming from any specific IP addresses with .htaaccess file. Please refer to...

  • 0 Users Found This Useful

Was this answer helpful?