Login Register






{Linux Tips} Paths Edition: Relative vs. Absolute Paths filter_list
Author
Message
{Linux Tips} Paths Edition: Relative vs. Absolute Paths #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:

Code:
/home/bobby/Desktop/homework/secret/
let's also say you want to change to the /var/www/html/ directory. Well, that's easy, you can simply run the following:

Code:
cd /var/www/html/
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:

Code:
cd /home/bobby/
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

Code:
cd ../../
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:

Code:
cd ../../movies/
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!
---
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

[+] 1 user Likes roger_smith's post
Reply

RE: {Linux Tips} Paths Edition: Relative vs. Absolute Paths #2
Thank you for the awesome share! I was in need of this a while back when I was trying to make fa-nigga work in Firefox.

Reply

RE: {Linux Tips} Paths Edition: Relative vs. Absolute Paths #3
For anyone wondering "what does this have to do with hacking?" or "how can this help me hack?", look into file inclusion vulnerabilities. Roger's trying to educate everyone the proper way, and I commend him for that. However, a lot of this site's userbase are just going to skim this or disregard it if they're anything like I was when I was their age, unless they can immediately understand how it relates to their goal of being l33t h4x0rs.

Again, I'm not bashing your work Roger. I actually love it. I'm just trying to appeal to the lowest common denominator here Tongue

EDIT: Something that was not mentioned when dealing with paths is the special . path. It simply refers to the current directory.
If you're in /var/www already and you do this:
Code:
cd ./html
you'll end up in /var/www/html. You can also just do "cd html". I mentioned the . variant because it's useful in evading simplistic web-application firewalls. You can even do something like /var/www//////html or /var/www//././././././././../www//./../././././www///html and you'll still end up where you intended.
PGP
Sign: F202 79C9 76F7 40BB 54EC 494F 5DEF 1D70 14C1 C4CC
Encrypt: A5B3 1B21 55E1 80AF 4C6E DE83 467B 8EFC 3DEE 681C
Auth: CD55 E8A5 1A08 2933 8BA6 BC88 D81F 1943 739A 3C47

[+] 3 users Like Reiko's post
Reply

RE: {Linux Tips} Paths Edition: Relative vs. Absolute Paths #4
All very basic information, but I bet someone will find it useful. Thanks for teaching people!

(09-09-2014, 09:57 AM)Reiko Wrote: For anyone wondering "what does this have to do with hacking?" or "how can this help me hack?", look into file inclusion vulnerabilities. Roger's trying to educate everyone the proper way, and I commend him for that. However, a lot of this site's userbase are just going to skim this or disregard it if they're anything like I was when I was their age, unless they can immediately understand how it relates to their goal of being l33t h4x0rs.

Again, I'm not bashing your work Roger. I actually love it. I'm just trying to appeal to the lowest common denominator here Tongue

EDIT: Something that was not mentioned when dealing with paths is the special . path. It simply refers to the current directory.
If you're in /var/www already and you do this:
Code:
cd ./html
you'll end up in /var/www/html. You can also just do "cd html". I mentioned the . variant because it's useful in evading simplistic web-application firewalls. You can even do something like /var/www//////html or /var/www//././././././././../www//./../././././www///html and you'll still end up where you intended.

I don't know if they will skim through it. When I first started using Linux (years ago, now) I would have loved to have seen stuff like this. Instead, I picked up the information over time. That being said, I used Linux as my primary operating system for a good amount of time, so it wasn't necessarily about hacking. It was about understanding how to use an operating system.
[Image: 7ajmN5P.jpg]

Telegram: Oni_SL (Link)

Reply

RE: {Linux Tips} Paths Edition: Relative vs. Absolute Paths #5
thanks for all the feedback everyone. I'm going to try and do a couple of these things a week, of varying experience levels.
---
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

Reply