In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Linux how to switch paths, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
As long as you play the linux command line, change the directory that is a piece of cake, the direct cd command is done, but in addition to the simple cd command, there are many other commands that can make your operation more convenient and fast.
Suppose a situation, a file A stored in the tenth directory ten, after a lot of hard work to enter the ten, the result accidentally typed into a cd command, watching the cursor flicker in the root directory, is not very helpless? Do you have to hit a lot of paths to re-enter the ten directory?
Don't bother, type "cd -" to see if you are going back to the path you just took.
Note: "cd -" can switch between the current directory and the previous directory.
Another convenient command for path switching is pushd, which can switch between different paths.
If I want to switch between / usr and / etc/ssh and / etc/rc.d and the current path, I can enter at the command line:
Pushd / usr
/ usr ~
Pushd / etc/ssh
/ etc/ssh / usr ~
Pushd / etc/rc.d
/ etc/rc.d / etc/ssh / usr ~
Pushd automatically adds the current path to the switchable path. Execute dirs, and you can see that four paths are displayed:
Dirs
/ etc/rc.d / etc/ssh / usr ~
Enter pushd to switch between the first two paths.
Pushd + 2 is fine if you want to switch to the last (bottom of the stack) path.
Pushd
/ etc/ssh / etc/rc.d / usr ~
Pushd
/ etc/rc.d / etc/ssh / usr ~
Pushd + 2
/ usr ~ / etc/rc.d / etc/ssh
If you want to clear these paths, execute dirs-c.
Dirs-c
Dirs
/ usr
If you need to delete a directory from the stack, type popd, followed by the directory name, and press enter
Working in Linux's multi-directory command prompt is painful, but the following tips for switching directories using cd and pushd can help you save time and effort.
At the Linux command prompt, use the cd command to change the current directory. These are some basic uses of the cd command:
To change your root path, type cd and press enter.
Enter a subdirectory, type cd, a space, then the subpath name (for example: cd Documents), and press enter.
Enter the directory one level above the current directory, type cd, space, two dots, and then press enter.
Enter a specific directory, type cd, a space, a path name (such as cd / usr/local/lib), and then press enter.
To determine your directory, type pwd, press enter, and you will see the name of the current directory you are in.
Use pushd to switch between different directories.
In command-line mode, when you work in different directories, you will find that you have a lot of time to waste on repeated typing. If these directories are not in the same root directory, you have to enter the full pathname during the conversion, which is inevitably a bit unbearable. But you can use one or two of the following steps to avoid all redundant input: use the history in the command-line interpreter, or use the command-line function pushd.
The advantage of using history in the command line interpreter is that you only need to press a few keys. Use the up arrow on the command line to find the command you used until you find it, and then press enter. If the two directories you switch are close to each other in the subdirectory structure of the entire drive, using the history in the interpreter may be your best choice.
However, if you switch between two distinct paths, you may want to take advantage of the pushd function, which you can use to create a directory stack (a list in memory).
Note: by default, the pushd function may not be included in your Linux; however, it is included in Red Hat and Red Hat-driven systems. If you do not have pushd functions in your system, you can download the relevant function tools on the ibiblio.org website.
Here's how to use pushd. Suppose you are now working in the / usr/share/fonts directory. You need to make some changes to / usr/share/fonts, and you will frequently switch between the two directories. To start in one directory, use the pushd function to change to another directory. In our example, to start under / usr/share/fonts, you type pushd/opt/wonderword/fonts and then press enter. Now you will see the contents of the stack on the next line:
/ opt/wonderword/fonts / usr/share/fonts
As you can see, when you type pushd and a pathname, a stack is automatically generated with the directory name you typed and the directory name you are currently working on. In our example, the path you typed (/ opt/wonderword/fonts) is at the top of the stack.
Quickly return to the previous directory, you can type pushd directly, if you do not follow the pathname, you will return to the previous directory in the stack.
If you need to delete a directory from the stack, type popd, followed by the directory name, and press enter. To see a list of directories in the stack, type dirs, and then press enter. The popd and dirs commands are also some of the common functions.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.