/ factorpad.com / tech / linux-essentials / chmod-command.html
An ad-free and cookie-free website.
Beginner
Learn to change file and directory permissions at the Linux command line.
Videos can also be accessed from the YouTube Linux Essentials Playlist on YouTube.
Linux chmod Command Summary with Examples (4:10)
Our seventy-fifth word, or command to memorize is
chmod
from our category
Users.
chmod
allows you to change file
permissions.
-options | description |
---|---|
-h ,
--help |
Print help screen |
-R ,
--recursive |
Apply to files within directories recursively |
Recall from the file listing ls
command, we've seen permissions, and in this video on file mode, as in
change mode, chmod
we'll kick off a
set of videos on the topic covering users, then groups and then the
world.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The chmod
command has
only 9 options, the first argument is the mode to
change, followed by the file or list of files.
Like most commands, help is available with double-dash
--help
. The
-r
option applies changes of
directories recursively.
So why is chmod
an important command?
Well, in Linux, unlike other operations systems, file permissions are
given more importance, so you'll need to grasp how to make these
changes.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Let's start with a directory listing.
Thanks for sticking with it, if have been here from the start, we have been busy.
I've used a convention like ls -og
to keep the display here simple.
And video7*
just to show a set,
instead of all the files we've been working on.
So, let's dig a bit deeper here and at the left, you can see 10 dashes
or letters, the first indicates file type, dash
-
is for a regular file,
d
for directory,
l
for link. Then the permissions in
the next set of three for the owner, followed by three for the group,
and three for the rest of the world.
Next, let's create a new empty file using
touch video75.txt
and
ls -og video75.txt
.
For me the mode is read and write rw-
,
for the group and world it's read only
r--
so I'll
chmod
the group
g
and add
+w
for write.
And last, verify with an
lg -og video75.txt
.
The group can now write.
Okay now you know how to use chmod
.
And you know the syntax for commands, options and arguments.
One last tip about the chmod
command. So we're just kicking off here (with file permissions) and
I kept it very simple. We have a few more videos (tutorials) to come on
the topic of users and I put a table in the Description (also see the
Linux Cheat Sheet) on the modes
and two others called octals and binaries, which we'll cover in the next
few videos because this is all so very important.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the chmod
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Be on the lookout for new videos, subscribe, follow and join.
rsync
command,
hit Back.chown
, click
Next./ factorpad.com / tech / linux-essentials / chmod-command.html
A newly-updated free resource. Connect and refer a friend today.