chmod command in Linux / Ubuntu

Spread the love

chmod is mainly used to modify file permissions in Linux. chmod can be used to control who can access files, search directories. In this tutorial, we will learn about chmod command in Linux / Ubuntu.

Viewing The File Permissions

To view the file permission of files and directories you can use ls -l in the terminal.

ls -l

Above command will display file permission of all files and directories available in a directory. If you want to display file permission of specific file or directory available in a directory use ls -l filename in terminal.

ls is for list the file and -l is long format option.

  • The first character represents, is it file or directory? “-” is for files and letter “d”  is for the directory.
  • The next nine characters represent three sets of permissions.
  1. The first three characters represent the permissions for the owner of the file (user permissions).
  2. The middle three characters represent the permissions for members of the file (group permissions).
  3. The last three characters represent the permissions for anyone.
  • r ( Read Permission ). The file can be opened.
  • w ( Write permissions ). The file can be edited and deleted.
  • x ( Execute permissions ). The file can be run or executed, in the case of a directory, search it.
  • --- (No Permission ). No permissions have been granted.
  • rwx means full permissions have been granted.


  • u : User ( Owner of the file )
  • g : Group ( Who are members of the file’s group )
  • o : Other ( User who are neither owner of the file nor members of file’s group )
  • a : Anyone (All user, all of the above. ie. user, group, other)


  • + : Grants the permission.
  • – : Remove the permission.
  • = : Grant a permission and remove other permission.

Syntax: chmod [option] [permissions] [filename]

Syntax (digits/Numbers): chmod [option] [number_file]

** If you want to have this permission and only this permission set, use the = option

Setting And Modifying file/directory Permissions



Digits Permissions
000 No permission
001 Execute
010 Write
011 Write and Execute
100 Read
101 Read and Execute
110 Read and Write
111 Read, Write, and Execute
  • chmod +x filename   –
  • chmod +r filename  –
  • chmod +w filename  –
  • chmod +rwx filename  
  • chmod -wx filename   

** “r” is for read, “w” is for write, and “x” is for execute.



Disclosure: This website is supports by its reader. This means, if you buy any product / service through link on this website, we may earn a small commision withought costing you extra. Learn how you can support Us and why we need this?