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.

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 stackoverflow.com Jul 13 '11 at 6:53

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

1 Answer 1

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

Your Answer

 
discard

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.