In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the use of navigation skills in the Linux file system, the article is very detailed, has a certain reference value, interested friends must read it!
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 up commands on Linux is to add the appropriate directory to the $PATH variable. However, the order of directories added to the $PATH variable is important. They determine the order in which the system looks in directories to run commands-stopping 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 any other executable file, you can simply enter the name of the script and it will run.
To add a home directory to the $PATH variable, you can do the following:
$ export PATH=~:$PATH
The ~ character represents the home directory.
If you save the script in the bin directory, the following works:
$ export PATH=~/bin:$PATH
You can then run scripts located in the home directory, as follows:
$ myscript Good morning, you just ran /home/myacct/bin/myscript
Important: The commands shown above are added to your search path because $PATH(current path) is included. They don't cover it. Your search path should be configured in your.bashrc file, and any changes you intend to make permanent should also be added there.
Use symbolic links
Symbolic links provide a simple and obvious way to document the location of directories that may be used frequently. For example, if you manage the content of a website, you may want to make your account "remember" the location of web files by creating links like this:
ln -s /var/www/html www
The order of 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 your home directory, the following command will do the same:
ln -s /var/www/html ~/www
Once set up, you can use cd www to go to/var/www/html.
Use of Shopt
The shopt command also provides a way to make moving to other directories easier. When you use the autocd option of shopt, just enter the name to go to the directory. For example:
$ shopt -s autocd $ www cd -- www /home/myacct/www $ pwd -P /var/www/html $ ~/bin cd -- /home/myacct/bin $ pwd /home/myacct/bin
In the first set of commands above, the autocd option of the shopt command is enabled. Entering www will invoke the cd www command. Since this symbolic link was created in one of the ln command examples above, move us to/var/www/html. The pwd -P command displays the actual position.
In the second group, typing ~/bin calls cd into the bin directory in the user's home directory.
Note that the autocd behavior will not take effect when you type the command, even if it is also the name of the directory.
Shopt is a bash built-in command that has many options. This simply means that you don't have to type cd before you want to enter the name of each directory.
To see other options for shopt, simply type shopt.
Use $CDPATH
Probably one of the most useful tips for getting into a particular directory is to add the path you want to be able to easily access to $CDPATH. This creates a directory list that can be accessed by typing only part of the full pathname.
On the one hand, it can be 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 simply by typing cd html, and move to a subdirectory in/var/log simply by using cd and a simple directory name. In this case,$CDPATH works:
$ CDPATH=.:/ var/log:/var/www
You will see:
$ cd journal /var/log/journal $ cd html /var/www/html
$CDPATH takes effect when you enter a path other than the full path. It looks down its directory list to see if the specified directory exists in one of them. When it finds a match, it will take you there.
Keep at the beginning of $CDPATH. This means you can enter local directories without having to define them in $CDPATH.
$ export CDPATH=".:$ CDPATH" $ Videos cd -- Videos /home/myacct/Videos
Key switching isn't hard on Linux file systems, but if you use a few handy tricks to get to each location easily, you can save some brain cells.
That's all for "What are the tips for navigating the Linux file system?" Thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.