In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. perform a file name lookup
Which (find 'execution file') / / path query based on PATH environment variable
Which [- a] command / / where the argument-a lists all found commands, not just the first one found
For example: which ifconfig
II. Search for file names
1. Whereis (looking for specific files)
Whereis [- bmsu] filename/directoryname
-b: only look for binary files
-m: only look for files under the manual path of the description file
-s: only look for source source files
-u: find special files that are not under the above three regulations
For example: whereis ifconfig
2 、 locate
Depends on the pre-built index library, the search speed is fast.
Usage: locate [- ir] keyword
-I: ignore case differences
-r: the display defense method followed by regular expressions
For example: locate ifconfig
Note: lcoate is based on the data recorded in / var/lib/mlocate, while the data source updates the data from the hard disk to / var/lib/mlocate according to the configuration of / etc/updatedb.config by updating the database updatedb.
Note: the whereis and locate commands may search for deleted files because the database is not updated in a timely manner (usually once a day), but updatedb updates can be performed manually.
Install locate:
Yum-y install mlocate
View the package:
Yum search mlocate
The command will not take effect until the update database is installed:
Just execute updatedb directly.
3 、 find
Real-time lookup tool to complete file lookup by traversing the file system hierarchy under the specified directory
Working characteristics:
The speed of searching is a little slower.
Precise search
Real-time search
Usage:
Find [option] [PATH] [search criteria] [action]
Search criteria: specify search criteria, which can be based on file name, size, type, dependency, permissions, etc.
Action: take actions on files that meet the search criteria, such as delete operations
Search criteria:
1) query based on time
In terms of 'days':
-atime,-ctime,-mtime
Take mtime as column
-mtime n: n is a number that was modified within one day n days ago.
-mtime-n: modified files within n days (including day n)
-mtime + n: modified file days ago (excluding the nth day)
In terms of 'points':
-amin,-mmin,-cmin
Note: the time is calculated on a 24-hour basis from now on, as shown in the following figure:
2) query according to users and user groups
-uid n: where n is the UID of the specified owner, which can be viewed in / etc/passwd
-gid n: where n is the GID of the specified group, which can be viewed in / etc/group
-user name: find files whose owner is name
-group name: find files with group name
-nouser: find files in / etc/passwd that do not have ownership
-nogroup: find files in / etc/group that do not belong to a group
For example: find / home-user legayu
3) search based on file name and file permissions
-name 'pattern': lookup file
-iname 'pattern': is the same as-name, but ignore the case of the file you are looking for
Supports the glob wildcard character *,? , [], [^]
-type TYPE: find files of file type TYPE. Common file types include regular file (f), device file (b, c), directory (d), connection file (l), socket (s), and FIFO file (p).
-size [+ -] SIZE: find files larger (+) or smaller (-) than SIZE. Size specification: C: for byte,k: for 1024byte. M and G can also be used for: MB and GB. For example, find files larger than 50kB:-size + 50k.
-perm mode: find files with file permissions "exactly equal" to mode
-perm-mode: find files whose file permissions "must contain all" mode
-perm / mode: find files with file permissions that "contain any" mode
For example: find /-name passwd
4) combinational logic
And:-a
Or:-o
Non:-not.not!
Description: logical relationship split and merge
! a-a! B =! (a-o B)
! a-o! B =! (a-a-B)
For example:
Find files for non-root users in / tmp
There are two ways:
Find / tmp-not-user root-ls
Find / tmp-not-uid 0-ls
Find files whose / tmp directory is mainly non-root and whose filename does not contain a fstab string.
5) Special functions of find
Operate on the results of the query
-print: output to standard output; default action
-ls: similar to executing the "ls-l" command on the found file to output the details of the file. You cannot use the 'll' alias here.
-delete: delete the found file
-fls / PATH/TO/SOMEFILE: saves the long format information of all found files to the specified file
-ok COMMAND {}\;: execute the command indicated by COMMAND for each file found; each operation is confirmed by the user
-exec COMMAND {}\;: execute the command indicated by COMMAND for each file found
Note: when find passes the found file path to the following command, it first finds out all the qualified file paths and passes them to the following command at one time
However, some commands cannot accept excessively long parameters, and command execution will fail.
There is another way to get around this problem:
That is find | xargs COMMAND
For example, find / root-perm + 644-exec ls-l {}\
Note: {} refers to the content found by find, and'\; 'indicates that the Terminator'\'is an escape character.
For example:
Find files in the / etc directory that all users do not have write permission to
~] # find / etc-not-perm / 222-type f-ls
Description: all users have at least one write permission, and the opposite is that they do not have the right to write
Look for files in the / etc directory that have at least one class of users that do not have execute permissions
~] # find / etc-not-perm-111111-type f-ls
Description: at least one category of users do not have the right to execute, that is, they all have the right to reverse it.
The above is the editor introduced to you the Linux command and file search and interpretation of the integration, I hope to help you, if you have any questions, please leave me a message, the editor will reply to you in time. Thank you very much for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.