You are not logged in.

#1 2019-12-26 20:58:11

linux_user
Member
Registered: 2016-11-04
Posts: 459

[SOLVED] Why do some Linux paths start with / while others don't?

Some commands like cd doesn't require / to be prefixed in the path while most others like rmdir does.

cd downloads/folder

rmdir /var/www/folder

Last edited by linux_user (2019-12-28 12:54:42)


"Blind faith to authority is the greatest enemy of truth."

Offline

#2 2019-12-26 21:27:16

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2015-09-29
Posts: 767

Re: [SOLVED] Why do some Linux paths start with / while others don't?

In this example:

cd downloads/folder

you will end up in the directory '/somedir/downloads/folder', provide you have issued the 'cd' command from the '/somedir' directory. (And if 'downloads/folder' dir exists.)

In that example:

cd /var/www/folder

you will end up in '/var/www/folder' (if it exists), no matter where you executed the 'cd' command; it may be from '/somedir', or '/some/other/dir', or '/var/www', or even '/var/www/folder'.

Same explanation goes for 'rmdir' ...

HTH

Last edited by iMBeCil (2019-12-26 21:28:56)


Postpone all your duties; if you die, you won't have to do them ..

Offline

#3 2019-12-26 22:19:20

damo
....moderator....
Registered: 2015-08-20
Posts: 5,967

Re: [SOLVED] Why do some Linux paths start with / while others don't?

Why do some Linux paths start with / while others don't?

All paths start from '/', but if you are already in '/somedir' then

cd otherdir/anotherdir

will change to '/somedir/otherdir/anotherdir', ie further down the directory tree from where you issued the command.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#4 2019-12-27 09:59:10

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,022
Website

Re: [SOLVED] Why do some Linux paths start with / while others don't?

Its called 'relative' vs 'absolute' path name (I think).

https://www.geeksforgeeks.org/absolute- … ames-unix/

pwd command should give you absolute path.

pwd
/home/ticho
cd ../../../var/www/html # lets relatively jump there
/var/www/html 

Last edited by brontosaurusrex (2019-12-27 10:06:44)

Offline

#5 2019-12-27 14:33:16

clusterF
Member
Registered: 2019-05-07
Posts: 539

Re: [SOLVED] Why do some Linux paths start with / while others don't?

Found this nice little blog write up explaining unix for the layman today on reddit /r/bsd.

https://neilkakkar.com/unix.html

Goes into some detail on paths and i like the way he wrote it from a why not a how perspective.

Unix is beautiful. Allow me to paint some happy little trees for you. I’m not going to explain a bunch of commands – that’s boring, and there’s a million tutorials on the web doing that already. I’m going to leave you with the ability to reason about the system.

Every fancy thing you want done is one google search away.
But understanding why the solution does what you want is not the same.
That’s what gives you real power, the power to not be afraid.

And since it rhymes, it must be true.

Last edited by clusterF (2019-12-27 14:36:16)

Offline

#6 2019-12-28 12:54:20

linux_user
Member
Registered: 2016-11-04
Posts: 459

Re: [SOLVED] Why do some Linux paths start with / while others don't?

Thank you all. smile


"Blind faith to authority is the greatest enemy of truth."

Offline

#7 2019-12-28 12:58:22

linux_user
Member
Registered: 2016-11-04
Posts: 459

Re: [SOLVED] Why do some Linux paths start with / while others don't?

clusterF wrote:

Found this nice little blog write up explaining unix for the layman today on reddit /r/bsd.

https://neilkakkar.com/unix.html

Goes into some detail on paths and i like the way he wrote it from a why not a how perspective.

Unix is beautiful. Allow me to paint some happy little trees for you. I’m not going to explain a bunch of commands – that’s boring, and there’s a million tutorials on the web doing that already. I’m going to leave you with the ability to reason about the system.

Every fancy thing you want done is one google search away.
But understanding why the solution does what you want is not the same.
That’s what gives you real power, the power to not be afraid.

And since it rhymes, it must be true.

That's a pretty good article. Thanks for sharing.


"Blind faith to authority is the greatest enemy of truth."

Offline

Board footer

Powered by FluxBB