Linux System Lookup Command parsing

Source: Internet
Author: User

1.find Command parsing

If you put this file in a single folder, as long as the common "ls" command can be easily found out, then use the "find" command to find it can not impress you, after all, "find" command the powerful function of more than this. If you know the file name of a file, you do not know which folder to put the file into, or even a nested folder in layers.

1) Search by file name

Find/-name file

 
  
2) Normal user find the method that the administrator user forbidden to access the file does not display the error prompt

Find/-name Access_log 2>/dev/null

This method is to transfer the lookup error prompt to a specific directory. After the command executes, the error message is sent to Stderrstream 2,/dev/null is a special file that indicates empty or incorrect information.

3) Find files in a specific directory

Find/etc-name file

4) based on partial file name lookup method

Find/etc-name ' *srm* '

 
5) Search According to the characteristics of the file

Find/-size 1500c (Linux file size is 1,500 bytes)

Find/-size +10000000c (finds files larger than 10000000 bytes in the root directory and displays them)

Find/-size-10000000c (finds files that are less than 10000000 bytes in the root directory and displays them)

Find/-amin N (finds files accessed in the last N minutes of the system)

Find/-atime N (finds files accessed last n*24 hours in the system)

Find/-cmin N (finds files in the system for the last n minutes of the changed state)

Find/-ctime N (finds files in the system for the last n*24 hour changed state)

Find/-empty (finds files or folders that are empty in the system)

Find/-false (finds files that are always wrong in the system)

Find/-fstype type (finds files in the system that exist on the specified file system, for example: ext2)

Find/-group Cat (finds files belonging to Groupcat in the system)

Find/-group gname (Locate the file in the system that belongs to the GNAM filegroup and specify the group and ID of the file)

Find/-gid N (finds files with file number group ID n in the system)

Find/-mmin-5 (finds files that have been modified in the last 5 minutes of the system)

Find/-mtime-1 (finds files that have been modified in the last 24 hours of the system)

Find/-nouser (finds files belonging to obsolete users in the system)

Find/-user Fred (finds files belonging to Fred This user in the system)

6) Description of control options for the Find command

-daystart test system starting from today 24 hours of files, usage similar to-amin

-depth uses a depth-level lookup process to prioritize file content in a specified level of directory

-follow follow the linked connection method to find; In addition, you can ignore the linked connection mode query

-help Display Command Summary

-maxdepth levels finds find by descending method in a hierarchy of directories. -maxdepth 2-name Fred

-mount is not located in the file system directory and is used similar to-xdev.

-noleaf prohibit optimal lookups in non-unux file systems, MS-DOS systems, CD-ROM file systems

-version Print Version number

7) Find a file using a hybrid lookup method
The find command can use a hybrid lookup method, for example, if we want to find a file that is larger than 100000000 bytes in the/tmp directory and modified within 48 hours, we can use-and to combine the two find-and-select items together into a mixed lookup.

Find/tmp-size +10000000c-and-mtime +2

If we want to find all files not belonging to Panda in the/tmp directory, Find/tmp! -user Panda.

8) How to find and display files
Finding a file is our goal, we would like to know the details and properties of the found file, if we take the present find file, in using the LS command to view the file information is quite cumbersome, now we can also combine these two commands to use.

Find/-name "httpd.conf"-ls

The httpd.conf file information is displayed on the screen immediately after the system finds the httpd.conf file.
12063 34-rw-r--r--1 root root 33545 Dec 15:36/etc/httpd/conf/httpd.conf

The following table is a list of commonly used find files and displays the parameters and usage of file information
Options
Description of Use
-exec command;
Find and Execute commands
-fprint file
Print file full filename
-fprint0 file
Print files full file name including empty files
-fprintf file format
Print file format
-OK command;
Perform actions on user commands, according to the user's Y acknowledgment input
-printf format
Print file format
-ls
Print files of the same file format.

2.locate Command parsing

3.whereis Command parsing

4.which Command parsing

5.type Command parsing

Linux System Lookup Command parsing

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.