Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Using system directory stack with pushd & popd

Answer:

When you need to changes a lot of directory frequently, pushd & popd can be very useful

E.g.

john@localhost:/tmp $ pushd /home/jack/
# change to /home/jack/ and push to the stack
/home/jack /tmp

john@localhost:/home/jack $ pushd /home/mark/
# change to /home/mark/ and push to the stack
/home/mark /home/jack /tmp

john@localhost:/home/mark $ popd
# pop current directory and change to /home/jack
/home/jack /tmp

john@localhost:/home/jack $ popd
# pop current directory and change to /tmp
john@localhost:/tmp/ $
  1. Change to the home directory in Linux
  2. Change to previous directory using cd command
  3. How to mirror a directory to a remote server over SSH?
  4. How to count the number of files in a directory?
  5. How to print the current stack backtrace in Perl?

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>