In the Linux system, there are a total of 5 commands for finding files, but generally only two to three of them are used. You can use the find command to quickly find any files you want to find. Let's go.
1. find
find is the most common and most powerful Find command, you can use it to find any file you are looking for.
The format of find is as follows:
$ find "specified directory" "specified condition" "specified action"
- "specified directory": the directory to be searched and All subdirectories. The default is the current directory.
- "Specified Conditions": The characteristics of the file to be searched.
- "Specified Action": Specific processing of search results.
If nothing is added, find defaults to the current directory and its subdirectories, and does not filter any results (that is, returns all files), displaying them all on the screen.
Use examples of find:
$ find . -name ‘my*’
Searches for the current directory (including subdirectories, the same below), all files whose names begin with my.
$ find . -name ‘my*’ -ls
Searches for files in the current directory with all filenames starting with my and displays their details.
$ find . -type f -mmin -10
Searches for all regular files that have been updated in the past 10 minutes in the current directory. If the -type f parameter is not added, the normal file + special file + directory is searched.
2. locate
The locate command is actually another way of writing "find -name", but it is much faster than the latter because it does not search for specific directories, but instead Search for a database (/var/lib/locatedb) that contains all local file information. The Linux system automatically creates this database and automatically updates it once a day, so you can't find the latest changed files using the locate command. To avoid this, you can manually update the database using the updatedb command before using locate.
Use examples of the locate command:
$ locate /etc/sh
Search for all files starting with sh in the etc directory.
$ locate ~/m
Search all files starting with m in the user's home directory.
$ locate -i ~/m
Searches for all files starting with m in the user's home directory, and ignores case.
3. whereis
The whereis command can only be used for program name searches, and only searches for binary files (parameter -b), man documentation (parameter -m), and source code files ( Parameter -s). If the parameter is omitted, all information is returned.
Use examples of the whereis command:
$ whereis grep
4. which
The role of which command is, in the path specified by the PATH variable, Search for the location of a system command and return the first search result. In other words, using the which command, you can see if a system command exists and which command is executed.
Use example of which command:
$ which grep
5. type
The type command can't be used as a find command, it is used to distinguish a certain Whether the commands are provided by the shell or by independent binary files outside the shell. If a command is an external command, then using the -p parameter will display the path to the command, which is equivalent to the which command.
Use example of type command:
$ type cd
The system will prompt, cd is the shell's own command (build-in).
$ type grep
The system prompts that grep is an external command and shows the path to the command.
$ type -p grep
After adding the -p parameter, it is equivalent to the which command.
The above is the introduction of the Linux lookup command. The main search commands are all these. Remember that it is completely sufficient. If you are still worried about finding files, these commands will solve your problem.
To master the partition of Linux hard disk, we must know the concept of MBR, extended partition and
The order of the connector ld link in Linux system is very important. If the order is not correct, i
We all know that yum is a package manager in the CentOS system for downloading and
Some Red Flag Linux 6.0 system users find that their computer cant mount NTFS parti
How to install zoneminder software in Linux
Linux installation of the appropriate kernel header file method
Linux which command to find files using
How Linux System Supervisor manages processes
How to identify Linux system rpm and yum tools
How to solve the omitting directory error when copying files in Linux?
CentOS closes Ctrl+Alt+Del to restart shortcuts
Linux system view wwn number trick
Ubuntu replaces the Firefox version of the method
How Linux can modify the TCP port range
Operating system security precautions: Win2003 articles
Xp timing shutdown and restart trick
Microsoft Windows Crisis Covered After Windows 7 Hot Sale
How to recover the win10 recycle bin?
Can I use old DOS programs under 64-bit systems?
Win7 set the method of mouse double click speed and moving speed
How to burn the system CD: Burning the operating system CD method tutorial
Don't wait to push. Teach you how to upgrade win10 immediately?