Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Go back to previous directory in shell
How can I change to the previous directory instead of going up?

is there a command line way to navigate back to the directory I was in?

I frequently do cd .. to go up a directory, but sometimes I accidentally just do cd which takes me to the user's home directory.

I want to go back to the directory I was just in, without navigating all the way through the nested folders or without typing the whole path out, which can be very long and prone to errors

I am specifically using OSX, but cd is pretty universal

share|improve this question

marked as duplicate by Oliver Salzburg, Indrek, Revolter, slhck, Diogo Jun 11 '12 at 16:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Try tipying a cd /? on your OSX. I did it on Windows but cd don't have such feature. –  Diogo Jun 11 '12 at 15:40
    
@Diogo That command does not work on OS X (or any Unix/Linux). –  slhck Jun 11 '12 at 16:17
    
@slhck I never used OSX so I really dont know.. My intent was to tell to type a cd -help or something like this to show cd manual. –  Diogo Jun 11 '12 at 16:26

2 Answers 2

up vote 8 down vote accepted

On *nix systems, you can type cd - to return to the previous directory. Doesn't work on Windows, though.

share|improve this answer

Try:

cd -

That works in Bash. It may work in your shell too.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.