Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go up several directories in linux

Tags:

linux

cd

When I want to go one directory up I use

cd ..

But when I want to go 7 directories up is there any way to do this other than just typing seven (7) times cd .. ?

like image 743
user15683854875644328975643872 Avatar asked Aug 30 '12 13:08

user15683854875644328975643872


People also ask

How do I navigate multiple directories in Linux?

If you have specific directories you want to move you can supply multiple directories to the mv command, the last one is taken as the dest - so mv /path/to/a /path/to/b /newpath will move "a" and" b"and all their subdirectories into be into /newpath.

How do you jump between directories in Linux?

The cd (change directory) command moves you into a different directory. To move out of that directory, use cd along with the path to some other location, or use double dots to backtrack, or return home to navigate from there. Navigating a Linux computer is like navigating the internet.

How do I go back more than one directory in Linux?

To navigate into the root directory, use "cd /" To navigate to your home directory, use "cd" or "cd ~" To navigate up one directory level, use "cd .." To navigate to the previous directory (or back), use "cd -"

How do I go back 3 folders in command prompt?

Type cd \ into the prompt to go back to the directory. If you need to navigate from a location back to the main command prompt, this command takes you back immediately.


1 Answers

cd ../../../../../../../ 

Also another useful navigation tip is if for example lets say you keep switching from a directory (call it A) to another (call it B) that's 7 directories up, in your case.

So if you're in directory A:

A> cd ../../../../../../../ B> // Now you're in directory B and want to go back to A B> cd - 

That will move right back to directory A. - expands to the previous directory you were in.

like image 51
Florin Stingaciu Avatar answered Sep 22 '22 02:09

Florin Stingaciu