Find the command find, locate, whereis, which, type difference in linux
1. find
Java code
find is the most common and powerful search Command, you can use it to find any file you are looking for. Unlike the query database (/var/lib/locatedb) file, find finds disk space
find uses the following format:
$ find <specified directory> <specified condition> <Specify Action>
- <Specify Directory>: The directory to be searched and all its subdirectories. The default is the current directory.
- <Specify Condition>: The characteristics of the file to be searched.
- <Specify action>: Perform specific processing on 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*'
Search the current directory (including subdirectories, the same below), all file names are my The beginning of the file.
$ find . -name 'my*' -ls
Searches for files in the current directory with all file names starting with my and displays their details.
$ find . -type f -mmin -10
Searches for all the 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
Java code
The locate command is actually another way of writing "find -name", but it is much faster than the latter because Instead of searching for a specific directory, it searches 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
Java code
The whereis command can only be used for program name search, and only search binary files (parameter-b), man description file (parameters) -m) and source code file (parameter -s). If the parameter is omitted, all information is returned. As with locate, query the database (/var/lib/locatedb) file
use instance of the whereis command:
$ whereis grep
4. which
Java code
The purpose of which command is to search for the location of a system command in the path specified by the PATH variable 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
Java code
type command can't be found Command, which is used to distinguish whether a command is provided by the shell or by a separate binary file 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
After reinstalling Win7, I have never tried to install Linux again, occasionally playing, an
linux system - file sharing a file sharing premise 1 windows and linux ping pass test methods as fol
one, top command 1. Function The top command is used to display the program process in execution,
The arping command can be used to test the connectivity between hosts on the LAN and test wh
Debian Linux Network Configuration
Linux common directory detailed map
PCI device driver development under Linux
[Linux] software source installation - Tarball
Linux iptables ip, Linux iptables Shield ip
Ubuntu configuration apache2.4 speed limit function
Installation of Java, Maven, and Tomcat under Linux
How to install JDK graphic parsing in Ubuntu
Introduction to vim installation and basic configuration under Ubuntu
Win10 edge browser home page setup tutorial
Windows 2000 operating system CD Quest
Open Win8.1 build 9385 Bing lock screen wallpaper
LOL source plan series 5 skin packaging 75% off 24th sale
After Win7 reinstalls a black screen and prompts All boot options how to solve
How to make the taskbar not display the most recently opened project under Windows 8 system
How to open scanner in win7 system