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

 

 

DigitsPermissions
000No permission
001Execute
010Write
011Write and Execute
100Read
101Read and Execute
110Read and Write
111Read, 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.

 

A
adduser | addgroup | alias | anacron | apt | aptitude | arp | at | atq | atrm | awk
B
basename | banner | batch | bc | bg | bzip
C
cat | cal | cd | chgrp | chown | cksum | chmod | clear | cmp | comm | cp
D
date | dd | df | diff | dir | dmidecode | du
E
echo | eject | env | exit | expr
F
factor | find | free
G
grep | groups | gunzip | gzip
H
head | history | hostname | hostnamectl | htop | hwclock | hwinfo
I
id | ifconfig | ionice | iostat | ip | iptables | iw | iwlist
J
K
kill | kmod
L
last | less | ln | locate | login | lp | ls | lshw | lscpu | lsof | lsusb
M
man | mdsum | mkdir | more| mv
N
nano | nc | neofetch | netcat | netstat | nice | nmap | nproc
O
openssl
P
passwd | pidof | ping | pr | ps | pwd | pstree
Q
R
rdiff-backup | reboot | rename | rm | rmdir | rnmod
S
scp | shred | shutdown | sleep | sort | split | ssh | stat | su | sudo | sum
T
tac | tail | talk | tar | tee | time | tree | top | touch | tr
U
unalias | uname | uniq | unzip | uptime | users
V
vim | vi
W
w | wall | watch | wc | wget | whatis | whereis | which | who | whoami
X
xargs
Y
yes | youtube-dl
Z
zcmp | zdiff | zip | zz

Sharing is Caring
Scroll to Top