Original blog, reproduced please indicate the source
Http://blog.csdn.net/hello_hwc?viewmode=contents
which command
First look at the description of man which
Which-shows the full path of (shell) commands.
Find the absolute path to the command under the $path directory, the path configuration is different, and the results are different.
View the path of the system
[Email protected] testforcsdn]# echo $PATH/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/ Sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/bin:/root/bin
Examples of Use
[email protected] testforcsdn]# which lsalias ls= ' ls--color=tty ' /bin/ls
Filter out the information in alias
[email protected] testforcsdn]# which--skip-alias ls/bin/ls
whereis Command
Man Whereis whereis - Locate the binary, source, and manual page files for a command
Find system-specific binaries, source files, and manual page files from db
Note: DB is a snapshot of the system file information, stored in the local database, the search speed will be fast, the DB is updated every time, if you want to update manually, use the command
UpdateDB
Options
-B: Only binary files are found
-M: Only files found under the manual path of the description file
-S: Find source files only
-u: File without document description
Example
1. list files related to init
[Email protected] testforcsdn]# Whereis initinit:/sbin/init/etc/init.d/usr/share/man/man8/init.8.gz
2. Find binary files only
[Email protected] testforcsdn]# whereis-b initinit:/SBIN/INIT/ETC/INIT.D
Locate
From the DB, here the DB and the Whereis in the DB, find the system with the specified name of all the relevant files
Common options
-B matches base name only
-C Number of statistics
-R Regular Match
-W matches the full path name
-d specifies dbpath without the default/var/lib/mlocate/mlocate.db
Example
[Email protected] ~]# locate-c init601[[email protected] ~]# LOCATE-BC init486
<pre name= "code" class= "plain" >[[email protected] ~]# Locate init | Mroe
Find
Find a file from disk, you can specify a path when you find it
1.-name Search by name
[Email protected] ~]# Find/etc-name init/etc/sysconfig/init
2.-size Search by size
[Email protected] ~]# Find testforcsdn/-size-2048testforcsdn/testforcsdn/file.txttestforcsdn/ File.softlinktestforcsdn/file.hardlink
3,-user through the owner find
[Email protected] ~]# Find testforcsdn/-user roottestforcsdn/testforcsdn/file.txttestforcsdn/ File.softlinktestforcsdn/file.hardlink
4,-ctime/mtime/atime-cmin/mmin/amin
C Change as permission changes
A access
M Modify Modify
Time is per day
Min per minute
Find files that have been accessed within one hour
[Email protected] ~]# Find testforcsdn/-amin-60testforcsdn/testforcsdn/file.txttestforcsdn/ File.softlinktestforcsdn/file.hardlink
5,-type by type to find
Common types
F-Binary
L Soft Connection
Catalog D
[Email protected] ~]# Find testforcsdn/-type ltestforcsdn/file.softlink
6,-inum
Find files for specified inode
Finds the specified inode and then outputs
Finds the specified inode and then deletes the file
Find/-inum 15–exec rm–rf {} \;
7,-a-r
A and
R or
Multiple criteria to find simultaneously
Find files with size less than 2M and types are soft connected
[Email protected] ~]# find testforcsdn/-size-2048-a-type ltestforcsdn/file.softlink
8, exec to find the results of processing
Look for files that are less than 2M in size and are soft-connected, and then show more information
[[email protected] ~]# find testforcsdn/-size-2048-a-type l-exec ls-l {} \;lrwxrwxrwx 1 root root 8 Oct 20:32 tes Tforcsdn/file.softlink-File.txt
Explanation: here {} is the result of a lookup, a semicolon; to escape with \
Grep
Attach a link previously written
GREP's 9 Classic usage scenarios
http://blog.csdn.net/hello_hwc/article/details/40017833
Linux file Find command-which Whereis find locate