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.

2 Answers 2

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.

3

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

You must log in to answer this question.

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