pushd, dirs and popd - builtin commands in bash

[~]$ pushd /tmp
/tmp ~
[/tmp]$ pushd /etc
/etc /tmp ~
[/etc]$ pushd /home/
/home /etc /tmp ~
[/home]$ pushd /usr/local/
/usr/local /home /etc /tmp ~
[/usr/local]$ dirs -v
 0  /usr/local
 1  /home
 2  /etc
 3  /tmp
 4  ~
[/usr/local]$ cd ~3
[/tmp]$ pwd
/tmp
[/tmp]$ cd ~1
[/home]$ dirs -v
 0  /home
 1  /home
 2  /etc
 3  /tmp
 4  ~
[/home]$ popd
/home /etc /tmp ~
[/home]$ popd
/etc /tmp ~
[/etc]$ dirs -c
[/etc]$ popd
bash: popd: directory stack empty