Add a directory to the top of the directory stack.
pushd [-n] [+N | -N | dir]
Adds a directory to the top of the directory stack and switches the current working directory to that directory.
Rotates the directory stack so that the new top of the stack becomes the current working directory.
Without arguments, exchanges the top two directories on the stack.
-n Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated.
+N (optional): Rotates the stack so that the N-th directory from the left (as shown by the dirs command) becomes the top. (Counting from 0)
-N (optional): Rotates the stack so that the N-th directory from the right (as shown by the dirs command) becomes the top. (Counting from 0)
dir (optional): The directory to push onto the stack.
Returns success unless an invalid option is provided or an execution error occurs.
# Add a directory to the stack and change the current working directory.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd ~/Desktop
~/Desktop ~
[user2@pc Desktop]$
# Add a directory to the stack without changing the current working directory.
[user2@pc ~]$ dirs
~
[user2@pc ~]$ pushd -n ~/Desktop
~ ~/Desktop
[user2@pc ~]$ pushd -n ~/Pictures
~ ~/Pictures ~/Desktop
# Adjust the order of the stack.
[user2@pc ~]$ pushd +1
~/Pictures ~/Desktop ~
[user2@pc ~]$ pushd -1
~/Desktop ~ ~/Pictures
[user2@pc ~]$ pushd
~ ~/Desktop ~/Pictures
dirs, popd, and pushd.help command for related help information.