Path Concepts (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
Video Transcription
00:00
>> Hey there Cybrarians and welcome back to
00:00
the Linux+ Course here at the Cybrary.
00:00
I'm your instructor Rob Goelz and in
00:00
today's lesson we're going to
00:00
be discussing path concepts.
00:00
Upon completion of today's lesson,
00:00
you'll be able to understand the concept of
00:00
an absolute path and differentiate between
00:00
an absolute path and a relative path and you'll be
00:00
able to determine when you might want
00:00
to use one over the other.
00:00
An absolute path is the direct
00:00
>> path to a file or command.
00:00
>> It's absolute because it's
00:00
the actual location of the file or
00:00
command and these paths always
00:00
start with root and go out to the very end.
00:00
A relative path is a path or file that
00:00
is relative to the directory that you're already in.
00:00
This is probably about as clear as mud.
00:00
Shall we see some examples?
00:00
I say we shall with some demo time.
00:00
We are over here in our CentOS environment once again,
00:00
now let's talk about absolute paths.
00:00
An absolute path could be,
00:00
let's say we're going to look at
00:00
our /etc/host file that we talked about.
00:00
If we want to look at etc host,
00:00
we could type less /etc/hosts as
00:00
an absolute path because it starts with the root.
00:00
We start with root, then etc,
00:00
then host, less /etc/host.
00:00
Now we can display the /etc/host file.
00:00
But a relative path would allow us to
00:00
see the contents of etc hosts.
00:00
But first we'd have to be in the etc directory.
00:00
Being able to see etc hosts by just typing
00:00
less hosts [NOISE] requires us
00:00
to be in the etc directory.
00:00
We're relatively able to do it
00:00
because we're in the etc directory.
00:00
Now we can just type less hosts
00:00
and we see the same thing.
00:00
Remember a relative path is
00:00
relative to the directory you're in.
00:00
An absolute path will always start at root,
00:00
and I mean the forward slash root,
00:00
this root, not the root directory [NOISE].
00:00
Less /etc/hosts, hosts versus just running less hosts.
00:00
This only works because we're in the host directory.
00:00
For instance, if we go back up to
00:00
just the root directory
00:00
and then we were to type less hosts,
00:00
we get a no such file or directory
00:00
because we're not in the relative path,
00:00
we're not inside of etc.
00:00
Relative path never begins with a root,
00:00
but it may begin with dot slash.
00:00
We can do cd etc.
00:00
Then we can do./hosts.
00:00
We can do a less on that, and that will work.
00:00
But we can't do this
00:00
because there is no such file or directory with hosts.
00:00
That is not the relative path,
00:00
that is an actual directory and there is
00:00
no host directory at the root.
00:00
That is a breakdown of absolute and relative paths.
00:00
At this point we've come to
00:00
>> the end of the lesson today.
00:00
>> In the lesson we covered absolute path,
00:00
relative path and when to use
00:00
a relative path over the absolute path.
00:00
Thank you so much for being here and I
00:00
look forward to seeing you in the next lesson.
Up Next