Instructor: File system paths.
Here we will talk about how we could navigate
the file system through the absolute path or relative path.
So basically, there are two paths to navigate a file system.
The first one is the absolute path
and the second one is the relative path.
An absolute path always begins with a slash.
This indicates that the path starts at the root directory.
An example of an absolute path is, if you are going to go
into the Samba directory, which is in /var/log/ directory,
it has two directories above it.
So you could start with cd /var/log/samba,
will take you directly to a Samba folder.
By the way, this is just an example that I picked up
to make you understand about the absolute path.
Then we have the relative path,
which does not begin with slash.
It identifies a location relative to your current position.
An example of relative path is you cd into /var.
Once you are already in var, you could just do cd logs.
Now, you notice we are not using /log,
because we are already in var directory,
and we could just simply go into cd log,
and then from there we could cd into Samba.
Again, here we are not using /log or /samba,
because they do not begin with slash,
they are within the /var directory.
So let's look at the example.
So first thing you have to do is become root user, su dash.
You put in a password.
Now, if you wanted to go directly to the Samba folder,
you could just go cd /var/log/samba.
Where are you?
You are in /var/log/samba.
Now, if you notice, if you go through the relative path,
which means let's go to slash,
we are in root directory /directory,
and if you wanna go to the var directory,
you could simply do var, or you could also do var.
Once you're in this directory, and if you try to do,
at this point, if you try to do cd /log,
it's not gonna find it, because you're trying to tell
the operating system that there is a log directory
within the slash directory, which is not the case.
So how are we going to get into the log
is by simply cd log.
And if you do pwd, you'll see you are in /var/log.
Now, if you wanted to go into one more directory,
which is Samba, what command would you run,
cd /samba or cd samba?
Well, you will run cd samba,
and it will take you to the Samba directory.
When you do pwd, it will tell you you are
in var/log/samba directory.
So this is the main difference between the absolute path
and the relative path, and the reason you use these
two different path is because if you already know
the directory where you wanna go in,
you don't have to go into one directory
then the second, third, or fourth,
you could directly go into the the path of the directory,
in our case, which is again /war/log/samba/,
and there you are.
And for example, if you wanna go to another directory,
let's say you're going cd /etc/sysconfig/network-scripts,
you could just do that and it will take you there.
By the way, if you hit tab, it will autocomplete
your directory if it exists in there.
Now you, which directory you are in?
You are in /etc/sysconfig/network-scripts.
If you wanna get out from one directory,
you do cd dot dot.
Where are you?
You are in /etc/sysconfig/.
You wanna go one step back, you do cd dot dot,
and you are in /etc/.
If you wanna go one more directory out, you do cd dot dot,
and you do, and you are into /directory.
Again, the root directory, the main parent directory.
So that's what this lecture is about, to tell you
the difference between the absolute path and relative path.