In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Find Which command for script files
The which command searches for the location of a system command in the path specified by the PATH variable and returns the first search result. In other words, using which command, you can see whether a system command exists and where the command is executed.
syntax: which [-a] command
-a: List all commands found in path directory
Examples:
which ifconfig
which which #Find out which file name
File search whereis
The whereis command can only be used to search for program names, and returns all information if parameters are omitted.
Syntax: whereis [-bmsu] file or directory name
-l : can list several main directories whereis will query
-b: only binary format files
-m: only find files under manual path of description file
-s: Find only source files
-u: Find other special files that are not in the above three projects
Examples:
whereis ifconfig #Find ifconfig file name
whereis -m passwd #only files in man are displayed
find command
find, used to find files in the file tree and process them accordingly
-name: Find files by file name
-perm: Find files by file permissions
-user: Find files by file owner
-size: Find files according to the specified file size [+n: greater than, -n: less than, n: equal]
-group: Find files by the group to which they belong
-mtime: Find files by file change time, -n means within n days,+n means n days ago
-newer file1 file2: Find files changed between file1 and file2
Examples:
find / -name xitai #Find system-wide file named xitai
find -mtime -2 #Find files modified in 48 hours
find /usr/local -size +100M #Find files larger than 100M
find -type d |sort #Find and sort all current target directories
find /usr/local/apache-tomcat-admin/ -perm 755 #Find files with permissions 755 in the specified directory
find /etc/ -newer /etc/passwd #Find files that are newer than/etc/passwd
locate command
The locate command is actually another way to write "find -name," but it is much faster because it does not search a specific directory, but a database (/var/lib/locatedb) that contains all the local file information. Linux automatically creates this database and updates it every day, so you can't find the latest files that have changed using the locate command. To avoid this, manually update the database using the updatedb command before using locate.
updatedb: Create the locate database before the first run
Parameters:
-i: ignore case
-c: Do not output file name, only count file number
-l : Output only a few lines
-r: followed by regular expressions
-S: Output database file related information
Examples:
locate -l 5 passwd
If it is wrong:
first install
yum -y install mlocate
Another error:
initialization
updatedb
locate -l 5 passwd
locate -S
type
The type command isn't really a lookup command; it's used to distinguish whether a command comes with the shell or is provided by a separate binary file external to the shell. If a command is external, using the-p argument displays the path to the command, equivalent to which command.
Examples:
type -p ifconfig
grep
Used to filter/search specified strings. Regular expressions can be used and can be used with a variety of commands.
Usage: grep [Options] Find content source file
-A: Display the line that matches and what follows
-B: Display the line that matches and what precedes it.
-C: Display the matching row and the content before and after
-c: Calculate the number of rows that match
-n: Display matching rows and row numbers
-i: ignore case
regular expression
^:'^grep' matches all lines starting with grep
'matches all rows ending in grep
.:'gr.p' means match 'gr' followed by any character followed by 'p'
:'grep' indicates a line matching one or more spaces followed by grep
[]:[Gg]rep means matching Grep and grep
[^]:[^A-FH-Z]rep indicates matching lines that do not begin with A-F, H-Z and follow rep
Examples:
grep -n 'cc' aa.txt
grep -in 'DD' aa.txt
grep -vn 'cc' aa.txt
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.