- In this video, we are going to explore the ls utility.
So what is the ls utility?
Well, you should start by using pwd to
to find the name of the current directory
and then you want to investigate what's inside.
And that is what ls is doing.
ls is used to list files and directories
and ls has a couple of useful options like ls-a
which will show hidden files as well, or ls-L
which provides a long listing
providing many details about your files.
Now you will notice, and I will demonstrate
that if you use ls -l on a directory
now you see the contents of that directory.
If that's not what you wanna see, use ls -ld
that will show you the properties
and not the contents of the directory.
And there is ls -lrt
which shows a time sorted list of files.
That's a lot of options together
but I'm putting them here on the slide together
because this is how normally you would use a command.
Ls -lrt is showing the last modified file
last in the list.
And that's the awesome solution.
If you are trying to find out what exactly has changed
while you were doing a certain manipulation.
If you know which directory use ls -lrt
and you will find the last modified file last.
Let me show you.
All right.
We have already seen ls -l.
Here is ls -l again showing a list
of directories in this case, including their properties.
Let me use CD without arguments to get to my home directory.
And in the home directory I'm using ls.
This is what we see, just a couple of directories mainly.
If you use ls -a
then we can see the hidden files as well.
These are mostly configuration files that are stored to
determine how our environment is shaped.
We'll explore these configuration files later.
I would like to show you ls -lrt.
And I would like to show you in the var log directory.
Why? Because the var log directory is a directory
where different processes are writing logs too.
And if I wanna see which log is the most used,
well use ls -lrt, and you can see the last modified file is
mentioned last, which is messages 1405.
Notice that this is something for sent to us.
If you do the same on Ubuntu, shall we do it on Ubuntu?
On Ubuntu, we go to var log and I use ls -lrt.
And what do we see?
We see that on the Ubuntu system, the name is syslog.
It is also one of the biggest files,
that also says something.
One more thing that I want to show you
and that is ls /etc or
ls -l /etc.
What is that doing?
This is showing me contents of the etc directory.
Now, what if I don't want
to see contents of the etc directory
but just the properties of the directory.
While in that case, I'm adding a d, ls -ld /etc
and now we can see the properties of the directory
and this ls -ld is going to be very important,
once you are going to manage permissions
because permissions are set often on directories.
And if you want to see the current settings,
ls -ld on the directory will help you.