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

Suppose I have entered following sequence of command:

[root@user ~] cd /
[root@user /] cd /usr
[root@user usr] cd /local
[root@user local] cd /myFolder
[root@user myFolder] cd /
[root@user /] <!-- do some opration -->
[root@user /] <!-- what can I write to go back to myFolder -->

Is there any command in cent os to go back to previous location? That I'm in myFolder then I come back to /. Do some operation and then want to go back to myFolder. I'm not talking about writing cd /usr/local/myFolder. May be there is something like back or backto_previous_location. I want functionality something like we get by clicking on Back button in window explorer.

share|improve this question

migrated from Jul 13 '11 at 6:53

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

Two solutions:

  • The most powerful one: Use the Bash directory stack

  • Somewhat what you are looking for: cd - which goes to the PWD before the last cd. In fact, the cd - command is equivalent to cd "$OLDPWD" - I think that you can guess what $OLDPWD is. More information here and here.

share|improve this answer
cd - works fine. Thnx. – Harry Joy Jul 12 '11 at 10:20

to go previous dirctory you just type

cd Desktop

Desktop # cd test Desktop/test#cd love Desktop/test/love# cd ../ test Desktop#

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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