Linux-Noob Forums

Full Version: Changing directorys like a stack
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Heres a little trick on how to change directorys like a stack with push and pop :)

 

push == add directory to the stack

pop == remote the last directory form the stack

 

The first thing we are going to do is change to a directory with push this done by

entering pushd /path/ as shwon below.

 



Code:
[damian@localhost ~]$ pushd /home/damian/public_html
~/public_html ~
[damian@localhost public_html]$ pwd
/home/damian/public_html
[damian@localhost public_html]$




 

Now you can see that the directory has changed if we wanted to go back a directory we would

pop the directory like popd as shown below.

 



Code:
[damian@localhost public_html]$ pwd
/home/damian/public_html
[damian@localhost public_html]$ popd
~
[damian@localhost ~]$ pwd
/home/damian
[damian@localhost ~]$




 

Well enjoy poping and pushing your directorys :)