Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 14 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


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.