[No audio]
Navigating to file system. Of course now you know a
lot about a file system. Now we need to know how
are we going to get into the file system? What are
those commands that we really need to learn to
actually go from one directory to another, get
their file contents and find out which directory
we are in. When navigating a Unix file system, there
are a few important commands. Again, the number one
command is cd which stands for change directory,
second one is pwd, which is print working
directory which tells you which directory you are
currently in, and the third one is ls, which
stands for listing which lists the contents of
your directory or folder. cd stands for change
directory, pwd stands for print working directory,
and ls stands for list. Now let's look at the real
example. I'm going to start with Windows because
the reason I compare Windows and Linux all the
time is because it will be a lot easier for every
one of you to really understand the concept behind
it. Because we actually work on Windows almost
every day and we scroll through everything and we
click through everything and we don't really
realize how experts we have become. So if you
really need to know Linux, there should be
some comparison with Windows that I will be
doing. So let's look at an example of Windows.
Okay, so I have the C drive, which in Linux is
what is the C drive for Linux is slash. When I
want it to go into this a C drive, I will just do
double click, and the folder comes up. And when I
want to go into Program Files, I'll to double click,
[No audio]
and the folders comes up, and so on. And if I want
to go into Windows directory, I'll just double click.
In Linux, let's go to the Linux
machine, I remember our Linux machine, the first
thing I want you to do of course is become root.
Meaning you are as yourself right now, how do you,
how do you know you are yourself, is because first
you see here on your prompt, you'll see your name.
If you just still want to know your name, you
could just type whoami, and you will see your
username. When you become root, you have to
type su, which means switch user, and just dash enter.
[No audio]
Put a new password
[No audio]
Okay, so you have this message that will tell you
the last time you became root was this date, this time, and so on.
Anyway, let's do clear, let's clear this, so
I'm going to clear the screen. So now when you are
in a directory, how do you know where you are. In
Windows you can tell right? You could tell you are
in computer local drive in Windows, it's up right here.
But in Linux you don't know so the command that
you're going to need is pwd. This is what, it's
going to tell you that you are in this directory.
[No audio]
If you want it to go into a different directory,
let's say you want to go to slash, which is slash,
slash is the primary or the parent directory of
all directories. So you type cd, which stands for
again change directory space slash, you hit enter.
Once you hit enter, how do you know you are in
that directory? Again you type pwd, and it will
tell you you are in slash directory. Now what's
inside of this directory, we need to see that. In
order to see that you have to type ls option l, and
it will tells you all the listings of the
directory and folders and files that are inside of
this directory. In Linux, in Windows, when you are in
My Computer you double clicking on a folder. Let's
say you're clicking on Program Files,
[No audio]
move this around, and you click on any other folder, let's say
Dell. So you notice you're just double clicking it,
and it is taking you to that directory. In Linux,
you don't have that. You don't have clicking.
So what you need to do is you need to do cd. So
you are already, what directory you are in, you are
in root, and let's say if you want to go to a
directory called let's say boot,
so cd boot, boot,
and there you are, you are in boot. Now let's say in
this example you want to come here, you already
see the listing of what's inside. How do I know
the listing in Linux? All you have do is run a
command, it's not that easy. There you go, it
tells you this is what you have inside. By the
way, some of the lines are chopped up a little, so
I'm just gonna make this a little more bigger.
[No audio]
Okay, so you're gonna see anything that starts
with dash, right here, it means it's a file,
anything that starts with d, it means it's a
directory or a folder. I want to go back to my
root directory, but before I go back, I wanted to
know where I am. The command is pwd, you we are
in boot, and I want to go to slash root again.
There are two ways you could do. You could do
either cd slash, it will take you to slash
directory or you could do cd.., which will
take you one step back, one directory back. In
Windows, how do you do that? In Windows, you could
simply just do, you could simply press
the back button, back button, and there you go. You
have all that. Also, in Windows, you notice you are,
when you double click once it is doing three
things for you. You double click once, that is
doing cd for you. Then automatically it's listing
all the directories inside it's doing ls for you
already. And now how do you know which directory
you are in, right here on top that's how it tells
you which directory you are in, and so it's in Windows you doing
three things in one shot. In Linux, you actually
have to use all three commands, one by one to see
the same thing as you want to see in in Windows.
So let's say if I want to go in etc, and I
want to go into another directory which is etc
sysconfig. So I am two directories in. How do I
know? pwd, print working directory. It tells you, you
are an /etc/sysconfig. Now if I wanted to go back
to etc directory, what I would do cd.., and
confirm if you are in etc directory, you do pwd,
and there you go. What if you want to go one step
back again cd.., and where you are, you
are in root, there you go. What happened if you
just type cd and hit enter? Okay, it did work
because we got a prompt back we didn't get any
error. But which directory are we again, we are in let's
check, we are in slash root. Why, because we are,
who we are, whoami. We are root, we are logged in
as root. And root directory is slash root. So
everyone, these three, first three commands that you
really need to learn in order to navigate the file
system. Without these three commands, you cannot do
anything in Linux. So what are the three commands
really quickly? First one is cd. Let's go to home.
that's it. What's inside the home. Let's type ls
-l. You forgot which directory you are in,
just type pwd, you are in home. If you want to go
to a different directory, let's say you want to go
to, I want to see what's inside of slash. So I will
type slash and what's inside of it, ls -l.
These are the directories. I want to go into
each of these directories and find out what's
inside of let's say, I want to go to var. I hit
enter, what's inside of the var.
These are the directories, different type of directories. I want to go to
file, a log directory right here. So I'll do cd
log. What's inside of log, I have to do ls -
l again. These are the files and directories
inside of log directory. Okay. All right, I forgot
where I am? where I am, pwd, /var/log, or if I want to
go back to slash directory, you could do dot dot,
then dot dot again, or you could just do simply cd
slash and now where you are, you are in slash.
Alright, so this concludes our lesson and I hope
you have pretty much a very good idea about cd, ls,
and pwd commands. As a homework, I would strongly
recommend you to log into your Linux machine, go
to cd slash, then ls -l, and I want you to go
into each of these directories one by one,
subdirectories, come back from a directory, find
out the listing of the directory, and then you will
find out exactly how to navigate the system.