{Linux Tips} Paths Edition: Relative vs. Absolute Paths 09-09-2014, 03:10 AM
#1
Welcome to another Linux Tips!
In today's tip we're going to talk about Relative vs Absolute paths. We'll start with absolute paths.
Let's say you're in a directory in the following path:
let's also say you want to change to the /var/www/html/ directory. Well, that's easy, you can simply run the following:
and you will be moved to that directory. That is an example of an absolute path. Another example, let's use the same original directory (secret) and say you want to move to /home/bobby/, well you can do the same thing:
Basically, your location within the filesystem doesn't matter if you're utilizing absolute paths, because you're telling the system exactly where to move you to next.
Easy right? Absolute paths are not big deal. Now we'll look at relative paths, a little more tricky.
We'll say that we are in secret/ directory again (/home/bobby/Desktop/homework/secret/ in case you forgot). Now let's say you want to change to the Desktop directory using a relative path. That would look like
whaat??? you might think. Don't worry, I'll explain. If you issue a command that utilizes ../, that is referencing the directory above your current directory. So in our example of secret, a ../ references homework; another ../ references the directory about homework, in this case Desktop.
So let's say that there is another directory in Desktop we want to look at; let's call it movies. If we wanted to go from secret to movies, we could do this:
that would take us from secret to homework, then homework to Desktop, then Desktop to movies. (note, the system doesn't actually do it that way, that's just how you can think about it when learning more about paths.)
There you have it, examples of absolute vs. relative path navigation, enjoy!
In today's tip we're going to talk about Relative vs Absolute paths. We'll start with absolute paths.
Let's say you're in a directory in the following path:
Code:
/home/bobby/Desktop/homework/secret/Code:
cd /var/www/html/Code:
cd /home/bobby/Easy right? Absolute paths are not big deal. Now we'll look at relative paths, a little more tricky.
We'll say that we are in secret/ directory again (/home/bobby/Desktop/homework/secret/ in case you forgot). Now let's say you want to change to the Desktop directory using a relative path. That would look like
Code:
cd ../../So let's say that there is another directory in Desktop we want to look at; let's call it movies. If we wanted to go from secret to movies, we could do this:
Code:
cd ../../movies/There you have it, examples of absolute vs. relative path navigation, enjoy!
---
Click here to get started with Linux!
If I helped you, please +rep me, apparently we've started over on Rep and I'd like to break 100 again...
Click here to get started with Linux!
If I helped you, please +rep me, apparently we've started over on Rep and I'd like to break 100 again...
Inori Wrote: got clickbaited by roger











![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
























![[Image: 7ajmN5P.jpg]](https://i.imgur.com/7ajmN5P.jpg)