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 > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about the navigation skills of the Linux system, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Whether you are looking around the file system, looking for files, or trying to enter important directories, Linux can provide a lot of help. In this article, we will introduce some tips to make it easier for you to move around the file system, find and use the commands you need.
The cd command may be one of the top 10 commands learned by any Linux user, but it's not the only way to navigate through the Linux file system. Here are some other ways.
Whether you are looking around the file system, looking for files, or trying to enter important directories, Linux can provide a lot of help. In this article, we will introduce some tips to make it easier for you to move around the file system, find and use the commands you need.
Add to $PATH
One of the easiest and most useful ways to make sure you don't have to spend a lot of time looking for commands on Linux is to add the appropriate directory to the $PATH variable. However, the order of directories added to the $PATH variable is very important. They determine the order in which the system looks for the directory in which to run the command-stop when the first match is found.
For example, you might want to put the home directory first, so that if you create a script with the same name as other executables, just enter the name of the script and it will run.
To add a home directory to the $PATH variable, do the following:
$export PATH=~:$PATH
The ~ character represents the home directory.
If you save the script in the bin directory, the following is valid:
$export PATH=~/bin:$PATH
Then, you can run the script located in the home directory, as follows:
$myscriptGood morning, you just ran / home/myacct/bin/myscript
Important: the commands shown above will be added to your search path because $PATH (current path) is included. They won't cover it. Your search path should be configured in your .bashrc file, and any changes you intend to make permanent should be added there.
Use symbolic links
Symbolic links provide a simple and obvious way to record the location of directories that may need to be used frequently. For example, if you manage the content of your site, you may need to create the following link to make your account "remember" the location of the web page file:
Ln-s / var/www/html www
The order of the parameters is important. The first (/ var/www/html) is the target, and the second is the name of the link you created. If you are not currently in the home directory, the following command will do the same:
Ln-s / var/www/html ~ / www
Once set up, you can enter / var/www/html using cd www.
Use shopt
The shopt command also provides a way to make moving to another directory easier. When you use the autocd option of shopt, simply enter the name to go to the directory. For example:
$shopt-s autocd$ wwwcd-- www/home/myacct/www$ pwd-P/var/www/html $~ / bincd-/ home/myacct/bin$ pwd/home/myacct/bin
In the first set of commands above, the autocd option of the shopt command is enabled. Enter www and the cd www command will be invoked. Since this symbolic link was created in one of the examples of the ln command above, move us to / var/www/html. The pwd-P command displays the actual location.
In the second group, typing ~ / bin calls cd to enter the bin directory in the user's home directory.
Note that when you enter a command, the autocd behavior will not take effect, even if it is the name of the directory.
Shopt is a built-in command for bash, and it has many options. This just means that you don't have to type cd before entering the name of each directory.
To see the other options for shopt, simply type shopt.
Use $CDPATH
Perhaps one of the most useful tips for getting into a particular directory is to add the path you want to easily enter to $CDPATH. This creates a list of directories that can be entered by entering only part of the full pathname.
On the one hand, this can be a little tricky. Your $CDPATH needs to contain the parent directory of the directory you want to move to, not the directory itself.
For example, suppose you want to move to the / var/www/html directory just by typing cd html, and to a subdirectory in / var/log using only cd and a simple directory name. In this case, this $CDPATH can work:
$CDPATH=.:/var/log:/var/www
You will see:
$cd journal/var/log/journal$ cd html/var/www/html
When you enter an incomplete path, $CDPATH will take effect. It looks down at its directory list to see if the specified directory exists in one of the directories. When a match is found, it will take you there.
Keep it at the beginning of $CDPATH. It means that you can go to local directories without having to define them in $CDPATH.
$export CDPATH= ".: $CDPATH" $Videoscd-- Videos/home/myacct/Videos
It's not difficult to switch keys in the Linux file system, but if you use some convenient techniques to get to each location easily, you can save some brain cells.
After reading the above, do you have any further understanding of the navigation skills of the Linux system? If you want to know more knowledge or related content, 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.