Linux swap directories quickly

If you’re hopping back and forth between say /etc/apache2 and /var/log/apache2. From /etc/apache2 type:

> pushd /var/log/apache2

 

This pushes /etc/apache2 on the directory stack and then cd’s to /var/log/apache2. Now to go back, just type:

> pushd

 

This swaps the current directory and the directory on the top of the stack. pushd again and you’re back to /var/log/apache2.