21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
Download Linux Free E-Book's Click HERE! to Download
Home
Linux HowTo’s
Linux Basic Tool’s
Linux News
Basic Linux Quiz 1
Free eBooks
Subscribe
About Us
LINUX BASIC COMMANDS / LINUX BASIC TOOL'S 0 FOLLOW:
PREVIOUS STORY
BEST LINUX CHMOD COMMAND WITH HOW TO INSTALL RIOT IM DESKTOP
MATRIX CLIENT IN UBUNTU 16.04 – A BEST
EXAMPLES CHAT CLIENT FOR LINUX
BY BALAMUKUNDA SAHU · PUBLISHED FEBRUARY 20, 2018 · UPDATED FEBRUARY 21, 2018
SHARE
Custom Search
Search
0
0
BEST LINUX CHMOD COMMAND WITH EXAMPLES
h s j 3 f b 1 q
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 1/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
Introduction
I
n this article we are going to learn what is Linux chmod
command and how to use it. chmod command is used in
Linux related operating system to Change file mode bits. In
simple language you can change the permissions of files and
directories in Linux using chmod command. There are two methods
by which we can change the permission’s :
Download Free Linux eBook HERE! "Learn Linux in 5 Days" -
A Free Linux eBooks for Beginners
1. Alphabetical
2. Numerical
To change permission using Linux chmod command we have to
follow some syntax and rules. As we discussed above we can
change permission using Numerical and Alphabetical way, Here I
have explained both method’s with all tricks.
Alphabetical Way :
To use this method you have to remember below rules and
alphabets for proper use.
To change permission of user you have to use the alphabet “u“. Like
that for Group “g” and for others it’s “o“.
Newsletter
Like User, Group and Others we have to remember some alphabets
Signup for Updated Linux Tutorials,
to give Read, Write and Execute permission Like for Read Guides and News.
permission you have to use the alphabet “r“, for Write “w” and for
Execute it’s “x“. Email*
So the formula for assigning permissions using chmod command is Name
shown below :
Subscribe
u – User
g – Group
o – Others
r – Read
w – Write
x – Execute
For Example if you want to give Read & Write permission to
User/Owner and Read permission to Group & Others using
Alphabetical way then the command would be : chmod NXP i.MX6 SoM - From $24
u+rw,g+r,o+r Filename WiFi/BT, Single/Dual/Quad Core up
to 1.2GHz, CAN, USB, UART, SPI,
Display, Linux/Android
Numerical Way :
CATEGORIES
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 2/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
To use this method you have to remember below Rules and Linux Basic Commands (26)
Numbers for proper use.
Linux Basic Tool's (29)
4 – To give Read Permission
2 – To give Write Permission Linux HowTo's (222)
1 – To give Execute Permission
Linux News (7)
For Example if you want to give Read & Write permission to
Monitoring Tools (2)
User/Owner and Read permission to Group & Others using Numeric
way then the command calculation would be : Programming Languages (1)
4+2 = 6 : This will add Read & Write permission to User/Owner. RHEL 7 (14)
4 : This will add Read permission to Group. ubuntu (175)
4 : This will add Read permission to Other. Webmin Guides (2)
So the command would be like : chmod 644 filename
You can check permission of any file using below command :
elinuxbook@ubuntu:~$ ls -l file.txt
-rw-rw-r-- 1 elinuxbook elinuxbook 0 Feb 20 06:16 file.t
And use the below command to check permission of a directory :
elinuxbook@ubuntu:~$ ls -ld data/
drwxrwxr-x 2 elinuxbook elinuxbook 4096 Feb 20 06:18 dat
Now here the question is How to Identify what permissions been
assigned to a file or a directory. It’s quiet simple.
Above I have given two examples. Now let’s identify the permission
of file.txt. If you notice the properties of the file starts with “-rw-rw-
r–“. Here we can identify what permission assigned to file.txt.
The permission section is divided in to 10 bits out of which
“–” : First bit is responsible to identify whether it’s an file, directory
or a Symbolic Link. Refer the symbols below :
Important symbols :
– : Permission assigned to a File
d : Permission assigned to a Directory
l : Permission assigned to a Symbolic Link
2nd, 3rd, 4th bit’s are for permission of Owner.
5th, 6th, 7th bit’s are for permission of Group.
8th, 9th, 10th bit’s are for permission of Others.
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 3/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
To Give permission to any file/directory you have to use “+”
Symbol. Balamukunda Sahu
To remove permission from any file/directory you have to use Seguir
“–” Symbol. 121 seguidores
Now let’s have a look at some most
important Linux chmod command with
examples :
Assign permission to a File
Here I have a file named file.txt. Let’s give Read and Write
permission to User/Owner using chmod command.
elinuxbook@ubuntu:~$ chmod u+rw file.txt
elinuxbook@ubuntu:~$ ls -l file.txt
-rw------- 1 elinuxbook elinuxbook 0 Feb 20 06:16 file.t
By Numerical Way use the below command :
elinuxbook@ubuntu:~$ chmod 600 file.txt
Also Read :
EXPLAINING SPECIAL LINUX PERMISSIONS ( SUID | SGID |
STICKY BIT )
COMPLETE UNIX COMMANDS AND BASIC LINUX COMMANDS
WITH EXAMPLES FOR BEGINNERS
Assign Permission to a Directory
The below command can be used to give permission to a directory.
Here I have a directory named data. So let’s give Full Permission
(Read, Write, Execute) to User/Owner. Refer the command below.
elinuxbook@ubuntu:~$ chmod u+rwx data/
elinuxbook@ubuntu:~$ ls -ld data/
drwx------ 2 elinuxbook elinuxbook 4096 Feb 20 06:18 dat
Numerical Way :
elinuxbook@ubuntu:~$ chmod 700 data/
Remove permission from a file/directory
Remove permission from a file/directory using below Linux chmod
command. Here I am removing Read and Write permission from
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 4/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
User/Owner.
elinuxbook@ubuntu:~$ chmod u-rw file.txt
elinuxbook@ubuntu:~$ ls -l file.txt
----rw-r-- 1 elinuxbook elinuxbook 0 Feb 20 07:18 file.t
Give permission to Everyone
You can use the below command to give permission to everyone.
Here I am assigning Full Permission to everyone to access file.txt.
There are two methods to do the same.
Method : 1
elinuxbook@ubuntu:~$ chmod a+rwx file.txt
elinuxbook@ubuntu:~$ ls -l file.txt
-rwxrwxrwx 1 elinuxbook elinuxbook 0 Feb 20 06:44 file.t
Method : 2
You can also use the below Linux chmod command to do the same.
elinuxbook@ubuntu:~$ chmod ugo+rwx file.txt
elinuxbook@ubuntu:~$ ls -l file.txt
-rwxrwxrwx 1 elinuxbook elinuxbook 0 Feb 20 06:44 file.t
Numerical Way :
elinuxbook@ubuntu:~$ chmod 777 file.txt
Assign di erent permissions to User, Group & Others by using
Single Linux chmod Command
Here I am Removing Execute permission from User/Owner and
Adding Execute permission to Group & Others by using single
command.
elinuxbook@ubuntu:~$ chmod u-x,g+x,o+x file.txt
elinuxbook@ubuntu:~$ ls -l file.txt
-rw-rwxrwx 1 elinuxbook elinuxbook 0 Feb 20 09:40 file.t
Assign permission to a file by taking reference of any other file
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 5/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
You can copy permission from one file to another. Here I have a file
named a1.txt whose permission is something like “-rw-r–r–“.
elinuxbook@ubuntu:~$ ls -l a1.txt
-rw-r--r-- 1 elinuxbook elinuxbook 0 Feb 20 07:21 a1.txt
Now I want to assign the same permission to my another file
named a2.txt. You can do so using Linux chmod command with
argument –reference. Refer the command below.
elinuxbook@ubuntu:~$ chmod --reference=a1.txt a2.txt
elinuxbook@ubuntu:~$ ls -l a2.txt
-rw-r--r-- 1 elinuxbook elinuxbook 0 Feb 20 07:22 a2.txt
Assign Permission Recursively
I have a directory named data, in which I have so many files and I
want to give permission to all of them at once instead of manually
one by one. To so you can use the Linux chmod command with
argument -R. This will help you to give permission Recursively.
elinuxbook@ubuntu:~$ chmod -R ugo+rwx data/
Numerical Way :
elinuxbook@ubuntu:~$ chmod -R 777 data/
Assign permission with Verbose output
You can get output a er assigning permission to any
files/directories by using Linux chmod command with argument -v.
Refer the command below.
elinuxbook@ubuntu:~$ chmod -v 777 file.txt
mode of 'file.txt' changed from 0664 (rw-rw-r--) to 0777
Assign permission with output (This command will give output
only if there is any changes)
chmod command with argument -c also do’s the same thing as
Verbose output (i.e. -v). But it will show the output only if there is
any changes in permission. If you are assigning same permission
then it won’t show any output.
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 6/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
elinuxbook@ubuntu:~$ chmod -c 755 file.txt
mode of 'file.txt' changed from 0777 (rwxrwxrwx) to 0755
Assigning Permission by ignoring/solving errors
To avoid any erroes or to rectify any errors during assigning
permission you can use Linux chmod command with argument -f.
Refer the command below.
elinuxbook@ubuntu:~$ chmod -f 755 file.txt
For chmod command Help
For chmod command more options and arguments you can use the
below command.
elinuxbook@ubuntu:~$ chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
or: chmod [OPTION]... OCTAL-MODE FILE...
or: chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that o
-c, --changes like verbose but report only wh
-f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every f
--no-preserve-root do not treat '/' specially (th
--preserve-root fail to operate recursively on
--reference=RFILE use RFILE's mode instead of MOD
-R, --recursive change files and directories re
--help display this help and exit
--version output version information and exit
Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo])
GNU coreutils online help: <http://www.gnu.org/software/
Full documentation at: <http://www.gnu.org/software/core
or available locally via: info '(coreutils) chmod invoca
Check chmod command version
You can use the Linux chmod command with argument –version to
check the version of installed chmod command version.
elinuxbook@ubuntu:~$ chmod --version
chmod (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.o
This is free software: you are free to change and redist
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie and Jim Meyering.
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 7/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
We have tried our best to include all possible Linux chmod
command with examples. If something missed out you can
comment below and we will include that on our article.
If you found this article useful then Like us, Share this post on your
preferred Social media, Subscribe our Newsletter OR if you have
something to say then feel free to comment on the comment box
below.
h s j 3 f b 1 q 1 o 5
SHARES
Ads by Google
Download Linux Ubuntu 1 Linux File Linux
In Linux Linux Run Linux With
Balamukunda Sahu
This is Balamukunda Sahu the Founder and Editor of ELinuxBook have 5+
years of Industrial Experience. I thankful to all our website viewers who
encourage me to write quality posts and articals, Keep visit to our site and I will
bring all latest Linux Tutorials, Updates and News for you.
YOU MAY ALSO LIKE...
4 0 0
EXPLAINING SPECIAL USEFUL LINUX FDISK MOST USEFUL LINUX
LINUX PERMISSIONS ( COMMAND WITH PING COMMAND (PING
SUID | SGID | STICKY BIT ) EXAMPLES – A LINUX UTILITY) WITH EXAMPLES
DISK PARTITION TOOL
APRIL 10, 2017 MAY 12, 2017
MAY 7, 2017
LEAVE A REPLY
Comment
Name * Email *
Website
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 8/9
21/2/2018 BEST LINUX CHMOD COMMAND WITH EXAMPLES
Post Comment
RECENT COMMENTS RECENT POSTS CATEGORIES
Balamukunda Sahu on HOW TO INSTALL BEST LINUX CHMOD COMMAND WITH Linux Basic Commands
ULTRACOPIER ADVANCE COPY SOFTWARE IN EXAMPLES
UBUNTU 16.04 – A TERACOPY ALTERNATIVE FOR Linux Basic Tool's
LINUX HOW TO INSTALL RIOT IM DESKTOP MATRIX
CLIENT IN UBUNTU 16.04 – A BEST CHAT Linux HowTo's
Balamukunda Sahu on HOW TO INSTALL CLIENT FOR LINUX
LAMP STACK ON UBUNTU 16.04 Linux News
HOW TO INSTALL SPEK AUDIO SPECTRUM
Balamukunda Sahu on HOW TO INSTALL ANALYZER (SOUND ANALYZER) IN UBUNTU Monitoring Tools
LAMP STACK ON UBUNTU 16.04 16.04 – A BEST FREQUENCY ANALYZER FOR
LINUX Programming Languages
Balamukunda Sahu on HOW TO INSTALL
LAMP STACK ON UBUNTU 16.04 HOW TO INSTALL TRAVERSO DAW BEST RHEL 7
AUDIO RECORDING SOFTWARE IN UBUNTU
Balamukunda Sahu on HOW TO INSTALL ubuntu
16.04
LAMP STACK ON UBUNTU 16.04
Webmin Guides
HOW TO INSTALL HIPCHAT CLIENT
(ATLASSIAN HIPCHAT) IN UBUNTU 16.04 – A
BEST INSTANT MESSENGER APP FOR LINUX
Copyright Policy
Contact Us
Sitemap
Elinuxbook: Linux Tutorials, Guides, Howtos, Tips and Tricks © 2018. All
Rights Reserved.
This work is licensed under a :
Without our permission Content/Work of this site cannot be Republished
either Online or O line, .
http://www.elinuxbook.com/best-linux-chmod-command-with-examples/ 9/9