Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I was wondering if there was a way to navigate back to the previous folder after a 'cd'.


~/ cd /home/
~/ cd /usr/local/
~/ want should I write here to return to the home dir (not 'cd /home' ^^)

Any suggestions?

share|improve this question
Any particular shell? – Ignacio Vazquez-Abrams Sep 10 '11 at 8:19
I am using the standard gnome-terminal that comes with ubuntu 11.04 (not Unity) – bliof Sep 10 '11 at 8:24
gnome-terminal is not a shell. – Ignacio Vazquez-Abrams Sep 10 '11 at 8:24
I didn't say that – bliof Sep 10 '11 at 8:25
up vote 2 down vote accepted

If you're using bash or some similar shell you can use cd - to return to the previous working directory.

[ignacio@localhost ~]$ cd bin/
[ignacio@localhost bin]$ cd -
[ignacio@localhost ~]$ 
share|improve this answer

The pushd/popd utilities keep a stack of the directories that you have visited.

[arcege]:~/Documents> pushd /usr/local
/usr/local ~/Documents
[arcege]:/usr/local> pushd /tmp
/tmp /usr/local ~/Documents
[arcege]:/tmp> dirs
/tmp /usr/local ~/Documents
[arcege]:/tmp> popd
/usr/local ~/Documents
[arcege]:/usr/local> popd

The downside is that you need to remember to use pushd instead of cd.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .