Hello, the beautiful people.
And in this video, you're going to begin to use the command line to move around your Linux file system.
Very, very exciting stuff.
Now, once you learn the techniques that you'll learn over the next few videos and begin to use them
for your everyday tasks, you'll begin to find that they are faster and more effective than the graphical
point and click methods that you are most likely using right now.
So in this video you're going to learn how to use the P and the less commands to know where you are
on your file system and what is around you.
And by the end of the video you'll know where you are on your file system and what's around you using
the command line, and you'll be ready to start moving around using some other commands that I'll show
you in the next video.
So I hope you're very, very excited.
Let's go ahead and jump right into it.
Okay.
So here we are in the terminal.
Now, the first thing we'd like to know when navigating the file system is where we currently are.
And the shell already tells us this.
Over here on the left, you'll see a bunch of text that is known as your shell prompt.
And the shell prompt.
Is everything up to this dollar sign?
Now let's break it down and show you what each bit means.
First of all, it tells you the user of who is logged in, which is Zeyad on this computer.
Then you've got an app symbol, then you've got the name of the computer, which is VB.
We called it this when we set up an install the virtual machine and VB is short for virtual box, then
you've got a colon, which is these two dots on top of one another, and then you have this squiggle
that's called Tilde.
Now in the bash shell, which is the shell that we're currently using, that tilde, that squiggle is
a short way of representing the current user's home directory.
So whenever you see that, Tilde, when you see that squiggle, it just means the path to the current
user's home directory.
So our shell prompt is basically telling us that we are in the home directory for the current user,
which we can tell is Ziad.
So we can actually confirm at any time what directory or what location our shell is currently operating
in by using the P command.
Now the P command stands for print working directory.
The command will just tell us the folder that our shell is currently operating in.
So if I type P and I hit Enter, we'll see the full path to my home directory appear, which is slash
home slash Ziad.
Now the path starts all the way from the root directory, the very base directory which is the slash
and works its way down until we get to the home directory for the user, Ziad, which is me.
Now we can actually see this if we click on our files and that opens up.
Now if you click on other locations, then click on computer.
This will open us up in the very base directory.
This is the this is the base directory for the system.
Now, if I click on home up here, then click on Ziad.
That is where we currently are in the shell at the moment.
Now, because the path starts all the way from the base directory, from the slash, it's known as an
absolute path.
So now that we know where we are and we know that our shell is operating inside of our home folder,
how can we take a look around and see what's in the home folder?
Well, first of all, we could do it using a graphical user interface.
We could click on our files here, and that's automatically going to open us up in our home folder.
And we can see this folders such as a desktop documents, downloads, pictures and so on and so on.
Now to see something similar on the command line, we need to use the L.
S command.
Now the LS is short for list and the LS command will list out our files in the directory.
So if we take a look at the main page for ls the manual page for ls will see that ls can take a path
to some folders.
It says here file says list information about the files, which is the current directory by default.
As a side note, LS does not accept standard input, so you can't pipe to it and instead you need to
give it everything as command line arguments.
That's just an aside.
Okay.
So now let's try and use the LS to the command to see what's going on in our home directory.
Now there's multiple ways to do this.
I could do with the long way and I could give it the full absolute file path.
I could type ls slash home slash Ziad.
That's the long way to do it.
Or because I know that the tilde represents my home folder.
I could give it a shortcut.
I could do ls then give it the tilde.
And that's exactly the same thing.
The tilde is just the home directory and for the current user it's just a shortcut.
Or even better because I know LS will by default list out the contents of the folder that I'm currently
in.
And because I'm in my home folder I can just type ls ls will by default list out the contents of the
directory that your shell is currently in.
And because we're in our home folder, I can just do ls without any command line arguments.
So let's go ahead and do that.
There we go.
So in there now what's come out, we can see several blue words now by default, blue text from the
LS command indicates folders.
But to make that clearer, we can we can give the LS command the uppercase F option.
So we put a dash on an uppercase F and F is meant to mean classify with emphasis on the F.
So now when I do that, if I do ls f now we can see that the items that have a slash at the end are
folders.
Now if I just make a file in our home directory by echoing the word hello into it, I'm going to call
it file txt.
So here we're using redirection to create the file.
There it is.
You can see there's been made.
If I knew and if I now do ls dash f we can see that the folders all have slashes after them and are
in blue, but the file itself doesn't.
Have a slash after it and it's text is in white.
So you can see that the LZ command allows us to see the difference between files and folders, files
and directories.
But something to bear in mind is if I take that LSB f output and put that into another file called list
txt, then I open up a list of txt.
You can see that there is no coloring, but you can see the difference between folders and folders and
files just by looking for the things that end in slashes.
Things that end in slashes are the folders and the things that don't are the files.
So, you know, this is really good if you want to save the information to a file and be able to tell
at a glance or have make a program tell at a glance, what's a folder and what's not.
So you can selectively operate on specific files or not.
So it's just a call it or shortcut.
Okay.
Now a much more useful option than the F than the F option for the LS command is the l option.
Now if I do ls dash l actually let me clear the screen first.
If I do ls dash l.
This puts everything in long form format and you can tell here that we get a lot more information about
our files and directories, including the file permissions over here on the left.
Anything that starts with a D is a directory and then there's file permissions.
So for the user read, write, execute for the group the user is in, the group being here is this column,
the user is this column.
So the user read, write, execute for the group, just read and execute.
No writing and for everyone else just reading and executing.
Then you've got the user that the the file belongs to the group.
The file belongs to how large the file is when it was last edited and what the file is actually called.
Okay.
So this is a this is the LZ dash command is a command that you'll use probably very, very often because
you can get a lot of information about your files, much more than just using the normal LS command.
The other thing I should mention is that this column here with all the numbers in the file sizes, this
shows the file size in bytes.
And to make that a bit clearer, you can give the LS command, not only the L option, but also the
Hatch option.
And the Hatch option stands for human readable.
It makes the file size a bit easier to read.
So if we do ls dash l hatch, we can now see that it's telling us that the desktop thing is about four
kilobytes.
This is about four kilobytes.
This one is just six bytes.
This is 93 bytes and these are four kilobytes.
If you had things that were megabytes in size, it would it would say an m If you had things that were
gigabytes in size, it would say a G.
And in general, it just makes this stuff a bit easier to read.
So that's the dash with the with the L option.
You've got the the permissions on the file.
So it begins with a D, it's a directory, it begins with a dash.
It's just a file.
The first three things are the permissions for the user.
Read, write, execute.
The the next one is for the group that the that the file is in the in this case it just has read and
execute but no.
Right.
And then this third column is for everyone else.
This is the so just read and execute in that sense.
This is the amount of hard links to the file.
But don't worry about those.
This is the user the file belongs to.
This is the group the file belongs to.
This is the file size in bytes.
This is the date the file was last edited and then this is the file itself.
So I'll make sure that that information is available on the cheat sheet at the end of the section.
But now you can start to see if I clear the screen the we can now use the p command to see where we
are and the RLS command to see what's around us.
All that's left to be able to understand is how to use the command to actually change where we are on
the file system so that we can move about.
But I think in the interests of time, we're going to save that until the next video.
So in the next video, we're going to be covering how to use the CD command to actually change where
you are on the file system and also be going through a few examples to see how these three commands
work together to help you navigate the file system much faster than would be possible using just pointing
and clicking.
So for all that goodness, I'll see you in the next video.