SEARCH

How-To Geek

How to Change to the Previous Working Directory

If you’ve switched into another folder with the cd command, and then want to get back to the previous one, you don’t have to remember the whole path. Just use the following command:

cd -

This will switch back to the previous directory. For instance, if you were in /var/www/vhosts/default and then switched to /etc, you could simply use the cd – command to switch back.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 07/30/10

Comments (2)

  1. licheca

    Doesn´t work in windows. Do you know a similar command?

  2. sakti dc

    thanks

Enter Your Email Here to Get Access for Free:

Go check your email!