Common commands of linux (file search command 3)

Command: find
Syntax: find [search range path] -name [file name] (search based on file name)
           find [search range path] -size [(+-) file size] (search based on file size, greater than + less than -)
           find [search scope path] -user (owner of file)
           find [time to find] [in days]
[in days] 1 ctime, atime, mtime 
[in minutes] 2 cmin, amin, mmin
           . . . . .

Description: Find any file or directory (all)

Example of find command: find [search scope path] -name


matches any character *


match the specified character?


find [search range path] -size [+-file size] (find based on file size, greater than + less than -)
Note that the size of the file is in data blocks. The size of the data block is 512bit
, such as: If you need to find a file of 100M, then you need to know how many blocks are 100M?
100M = ? block
1M = 1024K
100M = 102400K
1K = 2 blocks

100M = 2*102400 block


find [search scope path] -user (owner of the file)

Description: Find files belonging to a user




 find [time search] [in days]
 days: ctime, atime, mtime
 minutes: cmin, amin, mmin
c means: change means to change file attributes (such as owner, group, permission change).
a means: access means that it has been accessed (for example, it has been viewed, etc.).
m means: modify means to change the content.

Add before time: - for inside, + for outside

Description: View files that have changed within 120 minutes under the file




The connector used by find:
 -a (meaning of and, logical and)

 -o (or meaning, logical or)





find find: find by file type:
-type 

Among them: f means binary file, l means soft link file d means directory



Command: which
Syntax: which [command name]
Description: View the directory location where the command is located.
There are generally only two commands in linux. The first one is available to all users, the second one is only allowed to be used by administrators, and A command called whereis, which is similar to which

For example: rm command, in fact, we can use which rm to view its command content:


Alias ​​means an alias, which means that the rm command we use adds the -i option by default, which means that when deleting, it asks whether it needs to be deleted, then adding "\" uses the real rm command instead of the alias, You can delete it directly without prompting.
The connection execution symbol of find:
find ... -exec [execute command] {} \;  

Note: "{}" indicates the result of the find command, and "\" indicates the escape character

find ... -exec [execute command] {} \;  


find ... -ok [execute command] {} \;

The difference between ok and exec is that ok means to ask for confirmation.


Sometimes we see that the find command is very long, so you may be very dizzy. In fact, the reason is very simple. It is to use the commands we have learned before, and to clarify these, we can fully cope with the long commands written by others. operate.


find -inum [i node label] Find files according to the i node. In the Linux system, all files have a unique identifier, which is convenient for the Linux kernel to call. This is the i node.




Command: locate
Syntax: locate [file name]

Description: Find files, according to the index inside the Linux database (updatedb command, you can manually update the updatedb database, generally used in conjunction with locate)


Note: The search speed of locate is very fast, much faster than find. The reason is that locate is looking for the index value of the file database built by the Linux system, so the speed is very fast, but sometimes the newly created file cannot be found by using the locate command. , the reason is that the index of this file is not immediately updated to the Linux system file database



Command: man
Syntax: man [command or configuration file], 
Description: Help command, very useful, you can get the help document of the command, how to use it, etc.


Command: whatis 
Syntax: whatis [command]
Description: View the description of the command.


Command: --help
Syntax: [command] --help  
Description: View the command's option usage.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324490152&siteId=291194637