In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Linux command and file query
1 query of script file name
Which (looking for "execution file")
Parameter-a: lists all commands that can be found in the path directory, not just the name of the first directory found
Take ifconfig as an example
The correct file execution name can be found
Take which itself as an example
Alias--- > command alias, enter which will be equal to the following string of commands
Take the commonly used cd instruction as an example
Why can't you find it?
The reason lies in the lookup mechanism of which. Which looks up the directory specified in PATH by default. Cd is the built-in command of bash. Of course, you can't find it. Here we use the type instruction.
You can see that cd is a shell builtin, that is, a built-in command
2 lookup of file name
Generally speaking, we do not often use the find instruction, because the find instruction needs to be looked up in memory, which will be very slow, so we will first use whereis and locate to check. If we can't find it, we will use the database to find both find,whereis and locate, so the speed is very fast.
Whereis (looking for specific files)
Parameter:-b: find only files in binary format
-m: only look for files under the manual path of the description file
-s: only look for source source files
-u: find other files that are no longer in the above three options
Take the ifconfig instruction as an example
Only find out that what is related to passwd is the "description document"
Locate
The locate instruction is very easy to use, just enter the "file part name" directly after it.
Parameter:-I ignores case differences
-r is followed by the display of regular expressions
Take passwd as an example
As long as it contains passwd in it, it will be displayed.
Usage restrictions: since the locate lookup data is found by the created database library / var/lib/mlocata/, the database information needs to be updated, so when we create a new folder, we look for this file
Since the database has not been updated, it will not be found, so we can update the database manually. -> enter updatesb directly
Find instruction
This is a very important instruction to look up directly in memory.
Time parameter: take-mtime as an example
-mtime n: n is a number, meaning a file that has been changed "within one day" before n days
-mtime + n: lists the file names that were changed before n days (excluding the n days themselves)
-mtime-n: lists the file names that have been changed within n days (including the n days themselves)
-newer file: file is an existing file that lists filenames newer than file
The figure is as follows:
Take find / var-mtime4 as an example, the timeline is:
Parameters related to users or user groups
-uid n: this number is the user's account ID, and the number corresponding to the account name is recorded in / etc/passwd.
-gid NRU n is the ID of user group name
-username: name is the user's account name such as root
-groupname:name is the user group name
-nouser: looking for someone whose file owner does not exist / etc/passwd
-nogroup: find files whose user groups do not exist in etc/group
Find the files under / home that belong to dz:
Find files in the root directory that do not belong to anyone
-name filename looks for a file with the file name 1
-name [+ -] size finds files larger than size size specifications: C: for byte,k, for 1024bytes
Take finding files smaller than 50kb as an example
-type type: find files of type type
Take finding regular documents as an example (f)
File permission parameter
-pern mode: find files whose file type is exactly equal to mode
-pern-mode: find files whose permissions must all contain mode permissions
-pern + mode finds files with file permissions that contain arbitrary mode permissions
For example, when we look for-rwx rmurx rmurx, that is,-pern+755, we will also include a-rw- file exists because it contains the-rw attribute
Find files with permissions of 777
Permissions are files that contain any permissions less than 777
Permissions are files that must contain all permissions of 777
Other actions:
-exec command:commad is another command, and-exec can be followed by other commands to process the search results.
For example, files with permissions containing one of 7000 are listed using ls-l
Take the find / perm + 7000-exec ls-l {}\; instruction as an example
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.