In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to use find and whereis commands in linux". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn how to use find and whereis commands in linux.
The linux find command is a very effective tool that traverses the current directory or even the entire file system to find certain files or directories.
The main options for the linux find command:
-name looks for files by file name
-perm finds files according to file permissions
-prune does not look in the currently specified directory
-user finds the file according to the owner of the file
-group looks for files according to the group to which they belong
-mtime-n + n finds the file according to the change time of the file.-n means that the file change time is less than n days from now, and + n means that the file change time is n days ago.
-nogroup looks for a file without a valid group, that is, the group to which the file belongs does not exist
-nouser finds files without valid owners
-newer file1! File2 finds files whose change time is newer than the file file1 but older than the file file2
-type looks for a certain type of file
[file type:
B block device file
D directory
C character device file
P pipe file
L symbolic link file
F ordinary documents]
-size n [c] finds files with n blocks of file length, with c indicating that the file length is in bytes
-when depth looks for files, it first looks for the files in the current directory, and then looks in its subdirectories
-mount does not cross the file system mount point when looking for files
-follow if the find command encounters a symbolic link file, it tracks to the file that the link points to
-cpio uses the cpio command on matching files to back up these files to a disk device
(for the rest of the options, please man find for further review)
Some examples of linux find command options:
$find / etc-type d # look for all directories under the / etc directory
$find / etc-user yaoyuan # find the file whose owner is yaoyuan in the / etc directory
$find. -size + 1000000c # looks for files with a length of more than 1m bytes in the current directory
The whereis command looks for files that match the criteria in the specified directory, and the attributes of the files should belong to the original code, binaries, or help files.
Options:
-b only look for binary files
-B only looks for binaries in the set directory
-f does not display the path name before the file name
-m only look for description files
-M only looks for description files in the set directory
-s only find the original code file
-S only looks for the original code file in the set directory
-u find files that do not contain the specified type
Whereis example
$whereis mysql
Mysql: / usr/bin/mysql / etc/mysql / usr/share/mysql / usr/share/man/man1/mysql.1.gz
The locate command is used to find files that meet the criteria. It will go to the database where files and directory names are saved to find files or directories that meet the criteria.
Options:
-u set up the database, starting from the root directory
-U set up the database, and you can specify the location to start
-e will be excluded from the scope of search
-f excludes specific file systems
-Q quiet mode, no error message is displayed
-n display at most n outputs
-r conditions for finding by using normal expressions
-o specify the name of the data inventory
-d specify the path to the database
-h display auxiliary message
-v displays more information
-V displays the version message of the program
(locate command can quickly find files when searching the database, the database is updated by updatedb program, and updatedb is established periodically by cron daemon. Locate command searches the database faster than the entire hard disk data to search for data, but the worse thing is that the files found by locate may not be found if they were recently created or renamed. In the default values, updatedb runs once a day, and you can update the settings by modifying crontab. (etc/crontab)
Locate is designated to be used to search for files that meet the criteria. It will store files and directory names in the database to find files or catalogs that meet the criteria of the template style, and can use special characters (such as "*" or "?"). If the template is specified as kcpa*ner, locate will find all files or directories that start with a string of kcpa and end with ner. If the name is kcpartner, if the directory name is kcpa_ner, it will list all files in the directory, including subdirectories. )
Locate example:
$locate inittab
/ usr/lib/upstart/migrate-inittab.pl
/ usr/share/terminfo/a/ansi+inittabs
The above is all the contents of the article "how to use find and whereis commands in 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.