DEV Community

Discussion on: change directory command

Collapse
 
moopet profile image
Ben Sinclair

We use ~ symbol to indicate that the path is relative.

That's not quite right. The path ~/foo/bar is an absolute one, your shell is expanding ~ to your home directory on the fly.

A relative path is one relative to your current working directory. So if you're in /home/user and you say cd /tmp you'll end up in /tmp (absolute) but if you say cd tmp without the root, you'll end up in home/user/tmp, assuming it exists.

You can tell that paths starting with '~' are absolute because it doesn't matter where you are when you use them.

Collapse
 
ashutoshpatole profile image
Ashutosh Patole

Got it ! Thanks for pointing out.