Hello, and welcome to this presentation from Pluralsight.
My name is Andrew Mallett,
and I'm going to be here as your instructor to help guide you through the
module where we take a look at understanding the file mode,
our file permissions.
Now as we work our way through this module,
we can be taking a look at listing,
setting and changing our standard file permissions.
We'll be taking a look at evaluating the permissions needed for certain
operations and being able to diagnose access issues,
work out why we can't access files when perhaps we think we should.
We're going to be taking a look at managing file ownership,
first a user owner and the group owner of a file and see how
that affects our user access.
Now most Linux file systems that are native to the Linux
operating system are going to support our file mode,
our file permissions.
However,
we also support file systems that are non native to Linux such as the FAT,
FAT16, and FAT32 file systems.
Now as these don't natively support permissions,
they're not suddenly going to support permissions with inside of Linux.
Standard file system permissions will support a single user and a single group.
To extend this, we also have access control lists,
but these are looked at in a later module.
With access control lists,
we can list permissions for multiple users and multiple groups much in the
same way as you can with other operating systems where you can list multiple
users and groups within an access control list.
Now, listing file permissions.
Now I'm sure you're able to do this, the ls ‑l, the long listing.
So we can then go through and see the metadata,
and the metadata is going to include the permissions.
But what exactly is this metadata?
Let's just take a look at another file. Here, we're looking
at a shadow file, and we might be put off by this at first
because suddenly we might think, hang on,
we don't have any permissions, but of course, we do.
We can have permissions, but just have permissions that are
not set to any user or group or others.
But let's take a look at the elements of this metadata.
Come on.
Let's go through and take a look. Now, with the definition shown underneath, we
can see the orange file type relates to the dash in the output that we see from
the long listing. A dash is just a regular file.
This is a regular file. We've got then the blue permissions, and
there are nine bits we can use for our permissions.
We've got our hard link count, which is essentially the number of
names pointing through to this file. In a directory, the minimum hard
link count would be two for a directory.
It's always going to have the directory name and the
directory dot within that directory.
We've got the user and group showing in green. 970
bytes is the size of this file.
Now if we don't like mathematics,
we can always use ls ‑lh to see our output of file
size in a human‑readable format.
So we can see then whether it's kilobytes,
megabytes, gigabytes without having to do the mathematics.
And then in most files. we have the modified time,
the time the file was last modified. But on some
special files such as block devices,
we would actually see driver information in this column.
Finally, we have our file name. Now as you can become used to the ls ‑l, we
can also go through and use the command stat. Stat is really good when we're
looking at the metadata as it kind of gives you a better layout to see the
metadata and a more clear description. As well as that, we're able to extract
just the information that we need.
This might be really useful in the script.
We might want to go through and check the permissions of a file or a directory.
So when we go through and use a stat ‑c, when we look at the
%a, we're looking at the numeric permissions, the octal
permissions. More on that later.
Don't get hung up on numbers at the moment.
We can use an uppercase A where we can see the symbolic permissions.
So it becomes a great way where we can extract just the information
that we want. When we're talking about the file type,
we're saying the single dash is a regular file, but
there are many different file types.
We've got our regular files. We've got directories that we
show with a d. We have symbolic links.
They would show with an l.
We have pipes. Pipes would then show with a p. We have block devices, we
have character devices, which would show as b and c.
And we have sockets used for communication, and they would show with an s.
So this just gives you a list of the final types you could expect
and the characters that denote that file type.
But enough of this. I think it's time we found a command line and looked at some of this for real.