In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use the pushd and popd commands under Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
The most commonly used command to change directories on Linux systems is the cd command, while the pushd and popd commands can also switch between different directories.
How pushd and popd commands work in Linux system
The pushd and popd commands work according to the 'LIFO' (last in, first out) principle. Under this principle, only two operations are allowed: push a directory onto the stack and pop a directory off the stack.
The pushd command adds a directory to the top of the stack, while the popd command removes a directory from the top of the stack.
To display the directories in the directory stack (or history), we can use the dirs command shown below:
$dirs or $dirs-v
Dirs- displays directories located in the directory stack
Pushd command: add / put a directory path to the directory stack (history), after which you can browse any directory located in the directory stack (history). When you put a new directory on the stack, all the directories currently on the stack are printed.
The following commands show how this command works:
$pushd / var/www/html/$ pushd ~ / Documents/$ pushd ~ / Desktop/$ pushd / var/log/
Pushd- adds a new directory to the stack
According to the directory stack output above (catalog indexes are arranged in reverse order):
/ var/log is the fifth directory in the directory stack with an index of 0
~ / Desktop/ is the fourth with an index of 1
~ / Document/ is the third with an index of 2
/ var/www/html is the second with an index of 3
~ is the first one with an index of 4
In addition, we can also use the form of directory index pushd + # or pushd-# to add directory stacks. To enter the directory ~ / Documents, we can type:
$pushd + 2
Pushd- browses the directory digitally
Notice that after the previous step, the contents of the stack have changed. So, to enter the directory / var/www/html from the above example, we should use the following command:
$pushd + 1
Pushd- browses the directory digitally
Popd command-removes a directory from the top of the stack or history. To list all the directories in the directory stack, simply enter:
Popd to remove a directory from the directory stack, we can use the popd + # or popd-# command. At this point, we need to type the following command to remove the directory ~ / Documents:
$popd + 1
Popd- removes directories from the stack
The above is all the contents of this article entitled "how to use pushd and popd commands under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.