File and Directory Permissions

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, Cybrarians. Welcome back to
00:00
the Linux plus course here at Cybrary.
00:00
I'm your instructor Rob Goelz,
00:00
and in today's lesson, we're going to be talking
00:00
about file and directory permissions.
00:00
Upon completion of today's lesson,
00:00
you are going to be able to understand
00:00
how file and directory permissions work.
00:00
We're going to be able to explain
00:00
how file and directory permissions are
00:00
constructed and then explain
00:00
the components of that permission syntax.
00:00
File and directory permissions are called the primary
00:00
security characteristic in Linux. What does that mean?
00:00
Well, it means that all files and directories have
00:00
permissions applied and an owner set on them.
00:00
These permissions define how
00:00
the users can access the resources.
00:00
We're going to talk about the construction
00:00
of these permissions in this lesson.
00:00
The first thing we want to talk about are read, write,
00:00
and execute permissions which are
00:00
abbreviated R, W, and X,
00:00
because each object, which is a file or directory,
00:00
is going to have a permission made up of read,
00:00
write, or execute permissions.
00:00
We can see this on objects when we run ls -l
00:00
because it displays the type bit and
00:00
the three permission bits for the file.
00:00
We can see the directory object
00:00
is going to have a type bit: d,
00:00
which indicates it's directory.
00:00
In this case, it says dr-xr-xr-x
00:00
so that means read and execute,
00:00
and then we see the file object
00:00
has no type bit because it's a file,
00:00
it doesn't get a type bit and it
00:00
has -rw-rw-r which means
00:00
read and write, read and write, and then just read,
00:00
>> and then the link object has read, write,
00:00
>> read, write, read, write, read, write,
00:00
>> execute, execute, execute, execute.
00:00
>> Why are the permissions bits
00:00
repeated though? What is that about?
00:00
Why do we see those in some cases repeated three times?
00:00
Well, this brings us to the next component
00:00
of the permission structure,
00:00
and that is each object belongs to
00:00
a user owner and a group owner,
00:00
and additionally, you can set
00:00
an other permission which is O,
00:00
so U, G, O.
00:00
These are what are representing when we see
00:00
those repeating rwx permissions.
00:00
Using the previous example of that file object,
00:00
we can see rw for user,
00:00
rw for group, and r for other.
00:00
What that means is that the user,
00:00
the person who is the user that owns the file,
00:00
has read and write permissions.
00:00
The group, anybody in that group,
00:00
has read and write permissions to that file,
00:00
but anybody other than the user or a member of
00:00
the group only has read permissions to that file,
00:00
and together, these permissions make up what is
00:00
called the objects mode.
00:00
We'll see how you can change
00:00
the mode later in this module.
00:00
There's another concept we
00:00
should cover here at this point,
00:00
and that is the concept of octal notation.
00:00
Octal notation gives each permission a number.
00:00
Read or R has the number 4,
00:00
write has the number 2,
00:00
and execute has the number 1.
00:00
So to get the octal notation
00:00
for the permission on a file,
00:00
we add these numbers together,
00:00
we sum them up to give a numerical permission
00:00
for each one of the permission groups,
00:00
user, group, and other.
00:00
Using our file example again,
00:00
the best way to see this is just to see it in action,
00:00
the best way to explain it is just to see it in action.
00:00
Our user has read and write permissions.
00:00
That means that we add 4 because
00:00
read is 4 and write is 2 and we get 6.
00:00
So the permission octal notation for the user is 6.
00:00
Now if we look at group, group also has read and write.
00:00
Read is 4, write is 2, so we get 6.
00:00
But the other only has read permissions,
00:00
and since it only has read,
00:00
it just gets number 4.
00:00
Therefore, the octal notation for the permissions
00:00
on the file are 664.
00:00
With that, we've reached the end of this lesson.
00:00
In this lesson, we covered how
00:00
file and directory permissions work,
00:00
then we also talked about
00:00
the construction of file and directory permissions,
00:00
>> and finally, we talked about the components of
00:00
>> the permission syntax:
00:00
>> read, write, and execute,
00:00
>> user group, and owner,
00:00
>> and octal notation.
00:00
>> Thanks so much for being here,
00:00
>> and I look forward to seeing you in the next lesson.
Up Next