In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the order to search files or directories under CentOS". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "the command to search files or directories under CentOS".
To search for a file or directory:
The location where which views executable files
Whereis view the location of the file
Locate cooperates with database to view file location
Find actually searches the hard drive to query the file name
Which
Syntax:
[root @ test / root] # which [File name]
Parameter description:
Example:
[root @ test / root] # which passwd
/ usr/bin/passwd
Note: the basic function of which is to "find the executable file in the path through the contents of the environment variable PATH", so the basic function is to "find"
Executive file "!
Whereis
Syntax:
[root @ test / root] # whereis [- bmsu] [directory name]
Parameter description:
-b: only look for binary files
-m: only find the files under the manual path of the description file
-s: only look for source source files
-u: there is no file to describe the file!
Example:
[root @ test / root] # whereis passwd
Passwd: / usr/bin/passwd / etc/passwd / usr/share/man/man1/passwd.1.bz2
List the files or directories of passwd-related words!
[root @ test / root] # whereis-b passwd
Passwd: / usr/bin/passwd / etc/passwd
Only binary files are listed!
[root @ test / root] # whereis-m passwd
Passwd: / usr/share/man/man1/passwd.1.bz2
Search only the directory where man page is located!
Description:
If using find is too troublesome, and it takes a lot of time! Because if your hard drive is old, hey! There are waits! (at this time
Whereis is quite easy to use! In addition, whereis can add parameters to find relevant information, for example, if you are looking for an executable file (binary)
Then just add-b! For example, the above example for passwd this program to illustrate! If you don't add any parameters, then all the numbers
It's listed! So what exactly does whereis use? Why is the search so much faster than find? In fact, it's nothing! This is
Because the Linux system records all the files in the system in a database file, and when using whereis or locate, which is described below,
The contents of the database files will prevail, so sometimes you will find files that have been killed when you use these two execution files! That's it.
Because he is a "database" file! In addition, Linux basically does updatedb (that is, the database) for Linux hosts every day.
Files! ), you can find the relevant mechanism in / etc/cron.weekly/slocate.cron this file! Of course, you can also use the
/ usr/bin/updatedb to update database files!
Locate
Syntax:
[root @ test / root] # locate [directory name]
Parameter description:
Example:
[root @ test / root] # locate root
…… A lot of files about root words have come out @ _ @
[root @ test / root] # updatedb
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.