Use CD-(middle bar) to switch to the previous directory
The CD command will change the directory stack
1, dirs
1) function
Displays all records in the current directory stack (the dirs command with no parameters displays the records in the current directory stack)
2) syntax
(1) Format: dirs [-CLPV] [+n] [-n]
(2) Options
-C Delete all records in the directory stack
-l display in full format
-p a directory row of the way display
-V each row is a directory to display the contents of the directory stack, plus the number in front of each directory
+N Displays the nth directory from left to right, with numbers starting from 0
-N Displays the nth Daily record from right to left, with numbers starting from 0
Note: dirs always displays the directory of course, and then the contents of the stack, even if the directory stack is empty, the dirs command still displays only the course directory
2, pushd
1) function
The pushd command is often used to add directories to the stack, add records to the top of the directory stack, and switch to the directory, and if the pushd command does not add any parameters, the 2 directories on the top of the record stack will be swapped for location
2) syntax
(1) Format: pushd [Directory |-n | +n] [-n]
(2) Options
The directory joins the directory to the top of the stack and executes the "CD directory" to switch to that directory
+n move the nth directory to the top of the stack (number starting from the left, number starting from 0, adjusting the stack will change the current directory at the same time)
-N Moves the nth directory to the top of the stack (starting from the right, the number starts at 0, and the adjustment stack changes the current directory at the same time)
-N does not switch directories when the directory is in the stack
3, POPD
1) function
POPD is used to delete records from the directory stack, and if the popd command does not add any parameters, the topmost record of the directory stack is deleted and then the topmost directory in the deleted directory stack is switched to
2) syntax
(1) Format: popd [-n | +n] [-n]
(2) Options
+n Delete the nth directory (from the left, the number starts at 0, and the adjustment stack changes the current directory at the same time)
-N Deletes the nth directory (from the right, the number starts at 0, and the adjustment stack changes the current directory at the same time)
-N does not switch directories when the directory is out of the stack
Linux directory stack and directory switching