7

This is a basic linux question I think, but I really want to know.

For example, currently I am in /usr/bin:

[x@localhost bin]$ pwd
/usr/bin
[x@localhost bin]$ cd /
[x@localhost /]$

Now I want to go back to previous path /usr/bin, how to do that quickly? I don't want to type cd /usr/bin again.

Freewind
  • 231
  • 3
  • 10

2 Answers2

26

The command cd - will allow you to quickly return to the last directory.

You may also be interested in the pushd and popd commands which allow even more control over your directory navigation.

jscott
  • 24,484
  • 8
  • 79
  • 100
3

Depending on the shell you use, there's usually a variable with the previous working directory. In bash, I believe it's $OLDPWD

Ben Thul
  • 3,024
  • 17
  • 24