How to search for files in linux

Source: Internet
Author: User
In linux, how to search for files-general Linux technology-Linux technology and application information is as follows. 1. whereis file name
Features: fast and accurate search.

2. find/-name file name
I found a lot of things and found many "Permission Denied ".
# Find/-name php. ini

3. locate file name
The fastest way is to perform fuzzy search.

Note: If you use this command for the first time, you may need to update the database. Just execute the command as prompted.

The locate command can be used to quickly find files when searching for databases. The database is updated by the updatedb program, and the updatedb is periodically created by the cron daemon, the locate command is faster than searching for data from the entire hard disk, but worse is that the files found by the locate are created recently or renamed, it may not be found. In the specified value, updatedb runs once a day. You can modify crontab to update the set value. (Etc/crontab)

Locate is used to search for qualified files. It stores the files and directories in the database to find files or directories that meet the template style conditions, special characters (such as "*" or "?" ) To specify the template style. For example, if you specify the template as the kcpa * ner, locate will find all the files or directories whose start string is kcpa and end with the ner, for example, if the directory name is kcpartner and the directory name is kcpa_ner, all files including subdirectories in the directory are listed.

The locate command is similar to the find file query function. However, the locate program uses the update program to create an index database for all files and directories on the hard disk. When executing the loacte command, it directly finds the index, the query speed is faster. The index database is generally managed by the operating system, but you can also directly issue an update command to force the system to immediately modify the index database.

However, the first time you run update, you will often fail to use locate to search for files. At this time, you need to execute the slocate u command (you can also execute the updatedb command, with the same effect) to update the slocate database, this command will generate a slocate execution file under/usr/sbin, and then the locate will go to this database to find the information you want.

Locate: This Command requires the database indexed in the background to support running. In Ubuntu, the database file is located in/var/cache/locate/locatedb. Generally, this database file is automatically updated through cron every day. If the update is unfortunately not obtained, You can execute sudo updatedb to manually update the update.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.