Ubuntu: Ubuntu Terminal Command “cd -” makes a Loop!


Well I am fairly new in Ubuntu world. New to Terminal too. Asfaik I can use the command cd - to go back to the previous directory. Now lets say I am in a directory which is home/dir1/dir2/dir3/mydir. Well now if I write cd - terminal will send me to dir3 but if I want to go to dir2 and I write cd - terminal takes me to mydir again! And then if I write cd - again terminal takes me to dir3 as expected. It means I fall into a loop. Can anyone tell me how can....

  1. Directly go to dir2 from mydir?
  2. Browse mydir to dir3 and then dir3 to dir2 without falling into any loop?

Thanks for the answer.


If you want to go 1 level higher in directory tree, you do

cd ..  

So if you are at home/dir1/dir2/dir3/mydir this command will take you to home/dir1/dir2/dir3.

Same command another time to home/dir1/dir2.

If you want to go from home/dir1/dir2/dir3/mydir to home/dir1/dir2, you do

cd ../..  

The command you tried cd - takes you to previous directory.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »