Preface
Blogger github
Blogger's personal blog http://blog.healerjean.com
1. Help instruction
1.1 – - help: display command help information inside the shell
--The help command is used to display help information inside the shell. The help command can only display command help information inside the shell. The help information of external command can only be viewed by man or info command.
grep --help
root@healerjean:~# grep --help Usage: grep [OPTION]... PATTERN [FILE]... Search for PATTERN in each FILE or standard input. PATTERN is, by default, a basic regular expression (BRE). Example: grep -i 'hello world' menu.h main.c Regexp selection and interpretation: -E, --extended-regexp PATTERN is an extended regular expression (ERE) -F, --fixed-strings PATTERN is a set of newline-separated strings -G, --basic-regexp PATTERN is a basic regular expression (BRE) -P, --perl-regexp PATTERN is a Perl regular expression -e, --regexp=PATTERN use PATTERN for matching -f, --file=FILE obtain PATTERN from FILE -i, --ignore-case ignore case distinctions -w, --word-regexp force PATTERN to match only whole words -x, --line-regexp force PATTERN to match only whole lines -z, --null-data a data line ends in 0 byte, not newline Miscellaneous: -s, --no-messages suppress error messages -v, --invert-match select non-matching lines -V, --version display version information and exit --help display this help text and exit Output control: -m, --max-count=NUM stop after NUM matches -b, --byte-offset print the byte offset with output lines -n, --line-number print line number with output lines --line-buffered flush output on every line -H, --with-filename print the file name for each match -h, --no-filename suppress the file name prefix on output --label=LABEL use LABEL as the standard input file name prefix -o, --only-matching show only the part of a line matching PATTERN -q, --quiet, --silent suppress all normal output --binary-files=TYPE assume that binary files are TYPE; TYPE is 'binary', 'text', or 'without-match' -a, --text equivalent to --binary-files=text -I equivalent to --binary-files=without-match -d, --directories=ACTION how to handle directories; ACTION is 'read', 'recurse', or 'skip' -D, --devices=ACTION how to handle devices, FIFOs and sockets; ACTION is 'read' or 'skip' -r, --recursive like --directories=recurse -R, --dereference-recursive likewise, but follow all symlinks --include=FILE_PATTERN search only files that match FILE_PATTERN --exclude=FILE_PATTERN skip files and directories matching FILE_PATTERN --exclude-from=FILE skip files matching any file pattern from FILE --exclude-dir=PATTERN directories that match PATTERN will be skipped. -L, --files-without-match print only names of FILEs containing no match -l, --files-with-matches print only names of FILEs containing matches -c, --count print only a count of matching lines per FILE -T, --initial-tab make tabs line up (if needed) -Z, --null print 0 byte after FILE name Context control: -B, --before-context=NUM print NUM lines of leading context -A, --after-context=NUM print NUM lines of trailing context -C, --context=NUM print NUM lines of output context -NUM same as --context=NUM --color[=WHEN], --colour[=WHEN] use markers to highlight the matching strings; WHEN is 'always', 'never', or 'auto' -U, --binary do not strip CR characters at EOL (MSDOS/Windows) -u, --unix-byte-offsets report offsets as if CRs were not there (MSDOS/Windows) 'egrep' means 'grep -E'. 'fgrep' means 'grep -F'. Direct invocation as either 'egrep' or 'fgrep' is deprecated. When FILE is -, read standard input. With no FILE, read . if a command-line -r is given, - otherwise. If fewer than two FILEs are given, assume -h. Exit status is 0 if any line is selected, 1 otherwise; if any error occurs and -q is not given, the exit status is 2. Report bugs to: bug-grep@gnu.org GNU grep home page: <http://www.gnu.org/software/grep/> General help using GNU software: <http://www.gnu.org/gethelp/> root@healerjean:~#
1.2 man: View command help (rich man pages)
man command, short for manual, to view instruction help, configuration file help, programming help and other information in Linux. man is a help document for installing a program
You can find it in the system directory. If the software has a matching page, you can use man to find it. If a man page file is deleted, man cannot be displayed. The help information displayed by man command is more abundant. It has more command usage examples, command descriptions and other contents than the help option of command
man grep
1.2.1 browsing skills
1.2.1.1. Scroll one line: Enter
1.2.1.2 turn page: space bar
1.2.1.3. Query a content: for example, query the position of a
1.2.1.4 exit: q
GREP(1) General Commands Manual GREP(1) NAME grep, egrep, fgrep, rgrep - print lines matching a pattern SYNOPSIS grep [OPTIONS] PATTERN [FILE...] grep [OPTIONS] [-e PATTERN]... [-f FILE]... [FILE...] DESCRIPTION grep searches the named input FILEs for lines containing a match to the given PATTERN. If no files are specified, or if the file "-" is given, grep searches standard input. By default, grep prints the matching lines. In addition, the variant programs egrep, fgrep and rgrep are the same as grep -E, grep -F, and grep -r, respectively. These variants are deprecated, but are provided for backward compatibility. OPTIONS Generic Program Information --help Output a usage message and exit. -V, --version Output the version number of grep and exit. Matcher Selection -E, --extended-regexp Interpret PATTERN as an extended regular expression (ERE, see below). -F, --fixed-strings Interpret PATTERN as a list of fixed strings (instead of regular expressions), separated by newlines, any of which is to be matched. -G, --basic-regexp Interpret PATTERN as a basic regular expression (BRE, see below). This is the default. -P, --perl-regexp Interpret the pattern as a Perl-compatible regular expression (PCRE). This is highly experimental and grep -P may warn of unimplemented features. Matching Control -e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. If this option is used multiple times or is combined with the -f (--file) option, search for all patterns given. This option can be used to protect a pattern beginning with "-". -f FILE, --file=FILE Obtain patterns from FILE, one per line. If this option is used multiple times or is combined with the -e (--regexp) option, search for all patterns given. The empty file contains zero patterns, and therefore matches nothing. -i, --ignore-case Ignore case distinctions in both the PATTERN and the input files. -v, --invert-match Invert the sense of matching, to select non-matching lines. -w, --word-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore. -x, --line-regexp Select only those matches that exactly match the whole line. For a regular expression pattern, this is like parenthesizing the pattern and then surrounding it with ^ and $. -y Obsolete synonym for -i. General Output Control -c, --count Suppress normal output; instead print a count of matching lines for each input file. With the -v, --invert-match option (see below), count non-matching lines. --color[=WHEN], --colour[=WHEN] Surround the matched (non-empty) strings, matching lines, context lines, file names, line numbers, byte offsets, and separators (for fields and groups of context lines) with escape sequences to display them in color on the terminal. The colors are defined by the environment variable GREP_COLORS. The deprecated environment variable GREP_COLOR is still supported, but its setting does not have priority. WHEN is never, always, or auto. -L, --files-without-match Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match. -l, --files-with-matches Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. -m NUM, --max-count=NUM Stop reading a file after NUM matching lines. If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless of the presence of trailing context lines. This enables a calling process to resume a search. When grep stops after NUM matching lines, it outputs any trailing context lines. When the -c or --count option is also used, grep does not output a count greater than NUM. When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines. -o, --only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line. -q, --quiet, --silent Quiet; do not write anything to standard output. Exit immediately with zero status if any match is found, even if an error was detected. Also see the -s or --no-messages option. -s, --no-messages Suppress error messages about nonexistent or unreadable files. Output Line Prefix Control -b, --byte-offset Print the 0-based byte offset within the input file before each line of output. If -o (--only-matching) is specified, print the offset of the matching part itself. -H, --with-filename Print the file name for each match. This is the default when there is more than one file to search. -h, --no-filename Suppress the prefixing of file names on output. This is the default when there is only one file (or only standard input) to search. --label=LABEL Display input actually coming from standard input as input coming from file LABEL. This is especially useful when implementing tools like zgrep, e.g., gzip -cd foo.gz | grep --label=foo -H something. See also the -H option. -n, --line-number Prefix each line of output with the 1-based line number within its input file. -T, --initial-tab Make sure that the first character of actual line content lies on a tab stop, so that the alignment of tabs looks normal. This is useful with options that prefix their output to the actual content: -H,-n, and -b. In order to improve the probability that lines from a single file will all start at the same column, this also causes the line number and byte offset (if present) to be printed in a minimum size field width. -u, --unix-byte-offsets Report Unix-style byte offsets. This switch causes grep to report byte offsets as if the file were a Unix-style text file, i.e., with CR characters stripped off. This will produce results identical to running grep on a Unix machine. This option has no effect unless -b option is also used; it has no effect on platforms other than MS-DOS and MS-Windows. -Z, --null Output a zero byte (the ASCII NUL character) instead of the character that normally follows a file name. For example, grep -lZ outputs a zero byte after each file name instead of the usual newline. This option makes the output unambiguous, even in the presence of file names containing unusual characters like newlines. This option can be used with commands like find -print0, perl -0, sort -z, and xargs -0 to process arbitrary file names, even those that contain newline characters. Context Line Control -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -B NUM, --before-context=NUM Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -C NUM, -NUM, --context=NUM Print NUM lines of output context. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. File and Directory Selection -a, --text Process a binary file as if it were text; this is equivalent to the --binary-files=text option. --binary-files=TYPE If the first few bytes of a file indicate that the file contains binary data, assume that the file is of type TYPE. By default, TYPE is binary, and grep normally outputs either a one-line message saying that a binary file matches, or no message if there is no match. If TYPE is without-match, grep assumes that a binary file does not match; this is equivalent to the -I option. If TYPE is text, grep processes a binary file as if it were text; this is equivalent to the -a option. When processing binary data, grep may treat non-text bytes as line terminators; for example, the pattern '.' (period) might not match a null byte, as the null byte might be treated as a line terminator. Warning: grep --binary-files=text might output binary garbage, which can have nasty side effects if the output is a terminal and if the terminal driver interprets some of it as commands. -D ACTION, --devices=ACTION If an input file is a device, FIFO or socket, use ACTION to process it. By default, ACTION is read, which means that devices are read just as if they were ordinary files. If ACTION is skip, devices are silently skipped. -d ACTION, --directories=ACTION If an input file is a directory, use ACTION to process it. By default, ACTION is read, i.e., read directories just as if they were ordinary files. If ACTION is skip, silently skip directories. If ACTION is recurse, read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -r option. --exclude=GLOB Skip files whose base name matches GLOB (using wildcard matching). A file-name glob can use *, ?, and [...] as wildcards, and \ to quote a wildcard or backslash character literally. --exclude-from=FILE
1.3. info: more details than man instruction
The info instruction is more about man. But man is much more convenient to use. There is only one page for a man. Generally, if the summary of information contained in a man is in info, there will be a prompt: "please refer to the info page for more details"
2. passwd: used to change password
Used to change the password, first enter the old password, then enter the new password
3. who: view the user information of the current user logging in to the system
View the user information of the current user logging in to the system
root@healerjean:~# who root pts/0 2020-01-15 12:26 (106.37.187.184)
3. uname: display the system information of Linux currently in use
Display the system information of Linux currently in use
command | Explain |
---|---|
uname -a | All: display all information |
uname -s | sysname: display operating system name (Linux) |
uname -n | nodename: the host name displayed on the network (healerjean) |
uname -r | Release: release number of the operating system (4.4.0-117-generic) |
uname -m | machine: displays the computer type (x86 ʄ) |
3.1 uname-a: display all information
root@healerjean:~# uname -a Linux healerjean 4.4.0-117-generic #141-Ubuntu SMP Tue Mar 13 11:58:07 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
3.2 other orders
root@healerjean:~# uname -s Linux root@healerjean:~# uname -n healerjean root@healerjean:~# uname -r 4.4.0-117-generic root@healerjean:~# uname -m x86_64 root@healerjean:~#
4. date: display or set system time
display or set the system time
root@healerjean:~# date
Wed Jan 15 14:04:18 CST 2020
5. cal: output calendar information
Output calendar information
root@healerjean:~# cal
January 2020
Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 .15. 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Month | English |
---|---|
January | january |
February | february |
March | march |
April | april |
May | may |
June | june |
July | july |
August | august |
September | september |
October | october |
November | november |
December | december |
5. su: switch login user
You need to know the user name and password to switch the system used by the user.
Return to use command: exit
6. netstat: view port status
The netstat command can let you know the network situation of the whole Linux system.
command | Explain |
---|---|
netstat -a | List all connections |
netstat -t | List connections for TCP protocol: |
netstat -u | List connections for UDP protocol |
netstat -n | It is forbidden to use reverse domain name resolution to speed up the query. For details, see the following |
netstat -l | List only connections in listening |
netstat -p | Get process name, process number and user ID |
6.1 instructions
6.1.1,Status
Status | Explain |
---|---|
LISTEN | Listen for connection requests from remote TCP ports |
SYN-SENT | Wait for the matching connection request after sending the connection request (if there are a large number of such status packets, check whether they are recruited) |
SYN-RECEIVED | After receiving and sending a connection request, wait for the other party to confirm the connection request (if there is a large number of this state, it is estimated that it is attacked by flood) |
ESTABLISHED | Represents an open connection |
FIN-WAIT-1 | Wait for confirmation of a remote TCP connection interrupt request or a previous connection interrupt request |
FIN-WAIT-2 | Waiting for connection interrupt request from remote TCP |
CLOSE-WAIT | Waiting for connection interruption request from local user |
CLOSING | Wait for remote TCP to confirm connection interruption |
LAST-ACK | Wait for the confirmation of the original connection interruption request to the remote TCP (not a good thing, this item appears, check whether it is attacked) |
TIME-WAIT | Wait enough time to ensure that the remote TCP receives confirmation of a connection interruption request |
CLOSED | No connection status |
6.2.2 common combined commands
6.2.2.1. Only query the tcp protocol and display the process number, prohibit reverse domain name resolution, and display the port with the status of LISTEN
netstat -ntpl | grep 8080
6.2.2.2 query tcp and udp protocols, display process number, and disable domain name reverse resolution
netstat -anput | grep 8888
6.1. netstat -a: list all connections
List all connections
netstat -a
root@healerjean:~# netstat -a Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:https *:* LISTEN tcp 0 0 *:7777 *:* LISTEN tcp 0 0 localhost:9000 *:* LISTEN tcp 0 0 *:6666 *:* LISTEN tcp 0 0 localhost:6379 *:* LISTEN tcp 0 0 *:9999 *:* LISTEN tcp 0 0 *:http *:* LISTEN tcp 0 0 *:tproxy *:* LISTEN tcp 0 0 *:8082 *:* LISTEN tcp 0 0 healerjean:45088 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45080 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45102 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45016 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:42858 100.100.30.25:http ESTABLISHED tcp 0 0 healerjean:44990 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45074 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45066 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45032 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45082 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45056 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45036 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45062 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:44998 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45026 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:44996 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45046 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45084 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45052 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45000 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45068 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45072 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45044 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45086 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45028 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45020 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45034 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45064 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45030 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45008 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45076 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45058 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45098 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45024 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45022 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45014 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:44994 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45096 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45012 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45054 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45078 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45004 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45070 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45100 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:ssh 106.37.187.184:4775 ESTABLISHED tcp 0 0 healerjean:45090 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:44992 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45048 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45094 100.100.100.200:http TIME_WAIT tcp 0 8400 healerjean:ssh 106.37.187.184:18710 ESTABLISHED tcp 0 0 healerjean:45006 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45002 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45018 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45050 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:45042 100.100.100.200:http TIME_WAIT tcp6 0 0 [::]:mysql [::]:* LISTEN udp 0 0 *:bootpc *:* udp 0 0 healerjean:ntp *:* udp 0 0 localhost:ntp *:* udp 0 0 *:ntp *:* udp6 0 0 [::]:ntp [::]:* Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ] DGRAM 2328429 /run/user/0/systemd/notify unix 2 [ ACC ] STREAM LISTENING 2328430 /run/user/0/systemd/private unix 2 [ ACC ] SEQPACKET LISTENING 9292 /run/udev/control unix 2 [ ACC ] STREAM LISTENING 11260 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 10224 /run/uuidd/request unix 3 [ ] DGRAM 9051 /run/systemd/notify unix 2 [ ACC ] STREAM LISTENING 685879 /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 9289 /run/systemd/fsck.progress unix 2 [ ] DGRAM 9290 /run/systemd/journal/syslog unix 10 [ ] DGRAM 9291 /run/systemd/journal/dev-log unix 2 [ ACC ] STREAM LISTENING 9297 /run/systemd/journal/stdout unix 6 [ ] DGRAM 9298 /run/systemd/journal/socket unix 2 [ ACC ] STREAM LISTENING 230958689 /var/run/mysqld/mysqld.sock unix 2 [ ACC ] STREAM LISTENING 400046466 /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> unix 2 [ ACC ] STREAM LISTENING 400046465 /tmp/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> unix 2 [ ] DGRAM 2330332 unix 3 [ ] STREAM CONNECTED 735406 unix 3 [ ] STREAM CONNECTED 2330326 unix 3 [ ] STREAM CONNECTED 3046640 unix 3 [ ] STREAM CONNECTED 2328411 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 538788633 unix 3 [ ] STREAM CONNECTED 735407 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 3046639 unix 3 [ ] STREAM CONNECTED 11837 unix 3 [ ] STREAM CONNECTED 12567 /run/systemd/journal/stdout unix 2 [ ] DGRAM 410089914 unix 2 [ ] DGRAM 2328419 unix 2 [ ] DGRAM 735409 unix 3 [ ] STREAM CONNECTED 11838 /var/run/dbus/system_bus_socket unix 2 [ ] STREAM CONNECTED 537159779 unix 3 [ ] STREAM CONNECTED 11364 unix 3 [ ] DGRAM 735419 unix 3 [ ] STREAM CONNECTED 11363 unix 2 [ ] DGRAM 11360 unix 3 [ ] DGRAM 735420 unix 3 [ ] STREAM CONNECTED 538788636 unix 3 [ ] STREAM CONNECTED 749487 unix 3 [ ] STREAM CONNECTED 538788634 unix 3 [ ] STREAM CONNECTED 749488 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 12622 /run/systemd/journal/stdout unix 2 [ ] DGRAM 539128832 unix 3 [ ] STREAM CONNECTED 12566 unix 3 [ ] STREAM CONNECTED 11421 unix 3 [ ] STREAM CONNECTED 12701 unix 3 [ ] STREAM CONNECTED 11523 unix 3 [ ] STREAM CONNECTED 12702 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 534823795 unix 2 [ ] DGRAM 11431 unix 3 [ ] STREAM CONNECTED 559897 /run/systemd/journal/stdout unix 2 [ ] DGRAM 9316 unix 3 [ ] STREAM CONNECTED 11326 /run/systemd/journal/stdout unix 2 [ ] STREAM CONNECTED 538789484 unix 3 [ ] STREAM CONNECTED 560057 /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 559038 unix 3 [ ] STREAM CONNECTED 560056 unix 3 [ ] STREAM CONNECTED 12648 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 685878 unix 2 [ ] DGRAM 538974267 unix 3 [ ] STREAM CONNECTED 538788635 unix 2 [ ] STREAM CONNECTED 537177061 unix 3 [ ] STREAM CONNECTED 11324 unix 2 [ ] DGRAM 2866759 unix 3 [ ] STREAM CONNECTED 686129 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 750451 unix 3 [ ] STREAM CONNECTED 2865786 unix 3 [ ] STREAM CONNECTED 400046463 unix 3 [ ] STREAM CONNECTED 400046464 unix 2 [ ] DGRAM 11976 unix 3 [ ] STREAM CONNECTED 2866737 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 752695 unix 3 [ ] STREAM CONNECTED 400046461 unix 3 [ ] STREAM CONNECTED 752698 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 400046462
6.2. netstat -t: list the connections of TCP protocol
List connections for TCP protocol
6.2.1,netstat -t
netstat -t
root@healerjean:~# netstat -t Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 healerjean:49414 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49504 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49458 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:42858 100.100.30.25:http ESTABLISHED tcp 0 0 healerjean:49478 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49468 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49500 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:6666 li2091-37.members:51004 TIME_WAIT tcp 0 0 healerjean:49430 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49428 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49442 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49518 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49490 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49470 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49426 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49436 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49476 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49510 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49508 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49516 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49494 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49484 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49498 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49460 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49448 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49416 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49464 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49486 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49488 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49452 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49462 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49446 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49512 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49420 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:ssh 106.37.187.184:4775 ESTABLISHED tcp 0 0 healerjean:49438 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49466 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49502 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49474 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49444 100.100.100.200:http TIME_WAIT tcp 0 2352 healerjean:ssh 106.37.187.184:18710 ESTABLISHED tcp 0 0 healerjean:49432 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49456 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49454 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49492 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49506 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49520 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49514 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49440 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49434 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49472 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49424 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49422 100.100.100.200:http TIME_WAIT
6.2.2,netstat -at
netstat -at
root@healerjean:~# netstat -at Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:https *:* LISTEN tcp 0 0 *:7777 *:* LISTEN tcp 0 0 localhost:9000 *:* LISTEN tcp 0 0 *:6666 *:* LISTEN tcp 0 0 localhost:6379 *:* LISTEN tcp 0 0 *:9999 *:* LISTEN tcp 0 0 *:http *:* LISTEN tcp 0 0 *:tproxy *:* LISTEN tcp 0 0 *:8082 *:* LISTEN tcp 0 0 healerjean:47344 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47326 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47382 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47414 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47440 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47416 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:42858 100.100.30.25:http ESTABLISHED tcp 0 0 healerjean:47404 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47370 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47332 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47448 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47444 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47428 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47368 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47386 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47418 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47430 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47400 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47336 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47422 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47384 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47446 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47396 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47374 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47432 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47408 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47390 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47398 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47352 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47372 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47338 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47420 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47438 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47442 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47358 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47388 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47378 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47364 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47348 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47410 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47366 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47450 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47452 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47454 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47406 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47362 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47376 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47394 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47412 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47354 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47350 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47356 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:ssh 106.37.187.184:4775 ESTABLISHED tcp 0 0 healerjean:47380 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47426 100.100.100.200:http TIME_WAIT tcp 0 7824 healerjean:ssh 106.37.187.184:18710 ESTABLISHED tcp 0 0 healerjean:47402 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47334 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47330 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47346 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47436 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49250 100.100.27.15:3128 ESTABLISHED tcp 0 0 healerjean:47340 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:47342 100.100.100.200:http TIME_WAIT tcp6 0 0 [::]:mysql [::]:* LISTEN root@healerjean:~#
6.3. netstat -u: list the connections of UDP protocol
6.3.1,netstat -u
netstat -au
root@healerjean:~# netstat -u Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State
6.3.2,netstat -au
netstat -au
root@healerjean:~# netstat -au Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 *:bootpc *:* udp 0 0 healerjean:ntp *:* udp 0 0 localhost:ntp *:* udp 0 0 *:ntp *:* udp6 0 0 [::]:ntp [::]:* root@healerjean:~#
6.4. Netstat-n disables reverse domain name resolution to speed up query
By default, netstat uses reverse domain name resolution technology to find the host name corresponding to each IP address. This slows down the search. If you think the IP address is enough and you don't need to know the host name, use the - n option to disable domain name resolution. In this way, reverse domain name resolution is disabled and query speed is accelerated
6.4.1,netstat -n
netstat -n
root@healerjean:~# netstat -n Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 172.17.39.235:49748 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49804 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49794 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49722 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49726 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49716 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49788 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49802 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49750 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49714 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49774 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49738 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49820 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49740 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49790 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:42858 100.100.30.25:80 ESTABLISHED tcp 0 0 172.17.39.235:49818 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49696 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49700 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49796 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49768 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49732 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49808 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49780 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49760 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49742 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49728 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49754 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49702 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49800 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49746 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49730 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49806 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49708 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49786 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49792 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49718 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49724 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49704 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49782 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49762 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49758 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49710 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49776 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49744 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49798 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49736 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:22 106.37.187.184:4775 ESTABLISHED tcp 0 0 172.17.39.235:49770 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49812 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49822 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49778 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49810 100.100.100.200:80 TIME_WAIT tcp 0 5376 172.17.39.235:22 106.37.187.184:18710 ESTABLISHED tcp 0 0 172.17.39.235:49734 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49772 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49706 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49712 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49764 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49766 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49698 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49814 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49756 100.100.100.200:80 TIME_WAIT Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node Path unix 2 [ ] DGRAM 2328429 /run/user/0/systemd/notify unix 3 [ ] DGRAM 9051 /run/systemd/notify unix 2 [ ] DGRAM 9290 /run/systemd/journal/syslog unix 10 [ ] DGRAM 9291 /run/systemd/journal/dev-log unix 6 [ ] DGRAM 9298 /run/systemd/journal/socket unix 2 [ ] DGRAM 2330332 unix 3 [ ] STREAM CONNECTED 735406 unix 3 [ ] STREAM CONNECTED 2330326 unix 3 [ ] STREAM CONNECTED 3046640 unix 3 [ ] STREAM CONNECTED 2328411 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 538788633 unix 3 [ ] STREAM CONNECTED 735407 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 3046639 unix 3 [ ] STREAM CONNECTED 11837 unix 3 [ ] STREAM CONNECTED 12567 /run/systemd/journal/stdout unix 2 [ ] DGRAM 410089914 unix 2 [ ] DGRAM 2328419 unix 2 [ ] DGRAM 735409 unix 3 [ ] STREAM CONNECTED 11838 /var/run/dbus/system_bus_socket unix 2 [ ] STREAM CONNECTED 537159779 unix 3 [ ] STREAM CONNECTED 11364 unix 3 [ ] DGRAM 735419 unix 3 [ ] STREAM CONNECTED 11363 unix 2 [ ] DGRAM 11360 unix 3 [ ] DGRAM 735420 unix 3 [ ] STREAM CONNECTED 538788636 unix 3 [ ] STREAM CONNECTED 749487 unix 3 [ ] STREAM CONNECTED 538788634 unix 3 [ ] STREAM CONNECTED 749488 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 12622 /run/systemd/journal/stdout unix 2 [ ] DGRAM 539128832 unix 3 [ ] STREAM CONNECTED 12566 unix 3 [ ] STREAM CONNECTED 11421 unix 3 [ ] STREAM CONNECTED 12701 unix 3 [ ] STREAM CONNECTED 11523 unix 3 [ ] STREAM CONNECTED 12702 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 534823795 unix 2 [ ] DGRAM 11431 unix 3 [ ] STREAM CONNECTED 559897 /run/systemd/journal/stdout unix 2 [ ] DGRAM 9316 unix 3 [ ] STREAM CONNECTED 11326 /run/systemd/journal/stdout unix 2 [ ] STREAM CONNECTED 538789484 unix 3 [ ] STREAM CONNECTED 560057 /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 559038 unix 3 [ ] STREAM CONNECTED 560056 unix 3 [ ] STREAM CONNECTED 12648 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 685878 unix 2 [ ] DGRAM 538974267 unix 3 [ ] STREAM CONNECTED 538788635 unix 2 [ ] STREAM CONNECTED 537177061 unix 3 [ ] STREAM CONNECTED 11324 unix 2 [ ] DGRAM 2866759 unix 3 [ ] STREAM CONNECTED 686129 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 750451 unix 3 [ ] STREAM CONNECTED 2865786 unix 3 [ ] STREAM CONNECTED 400046463 unix 3 [ ] STREAM CONNECTED 400046464 unix 2 [ ] DGRAM 11976 unix 3 [ ] STREAM CONNECTED 2866737 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 752695 unix 3 [ ] STREAM CONNECTED 400046461 unix 3 [ ] STREAM CONNECTED 752698 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 400046462 root@healerjean:~#
6.4.2,netstat -atn
netstat -atn
root@healerjean:~# netstat -atn Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:7777 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6666 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN tcp 0 0 172.17.39.235:47784 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47800 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47768 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47786 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47758 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47816 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:42858 100.100.30.25:80 ESTABLISHED tcp 0 0 172.17.39.235:47848 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47752 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47834 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47840 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47738 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47820 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47802 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47790 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47764 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47814 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47774 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47828 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47748 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47772 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47838 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47798 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47792 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47760 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47734 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47824 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47812 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47766 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47732 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47794 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47756 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47846 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47830 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47826 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47782 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47770 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47746 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47796 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:49626 100.100.27.15:3128 ESTABLISHED tcp 0 0 172.17.39.235:47844 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47780 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47730 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:22 106.37.187.184:4775 ESTABLISHED tcp 0 0 172.17.39.235:47818 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47842 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47778 100.100.100.200:80 TIME_WAIT tcp 0 8032 172.17.39.235:22 106.37.187.184:18710 ESTABLISHED tcp 0 0 172.17.39.235:47804 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47822 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:80 86.107.226.174:38561 TIME_WAIT tcp 0 0 172.17.39.235:47836 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47740 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47750 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47742 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47736 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47754 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47762 100.100.100.200:80 TIME_WAIT tcp 0 0 172.17.39.235:47788 100.100.100.200:80 TIME_WAIT tcp6 0 0 :::3306 :::* LISTEN root@healerjean:~#
6.5. netstat -l: list only the connections in listening
The background process of any network service will open a port to listen for access requests. These listening sockets can be listed by netstat just like the connected sockets. Use the - l option to list the sockets you are listening on.
6.5.1,netstat -l
netstat -l
root@healerjean:~# netstat -l Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:https *:* LISTEN tcp 0 0 *:7777 *:* LISTEN tcp 0 0 localhost:9000 *:* LISTEN tcp 0 0 *:6666 *:* LISTEN tcp 0 0 localhost:6379 *:* LISTEN tcp 0 0 *:9999 *:* LISTEN tcp 0 0 *:http *:* LISTEN tcp 0 0 *:tproxy *:* LISTEN tcp 0 0 *:8082 *:* LISTEN tcp6 0 0 [::]:mysql [::]:* LISTEN udp 0 0 *:bootpc *:* udp 0 0 healerjean:ntp *:* udp 0 0 localhost:ntp *:* udp 0 0 *:ntp *:* udp6 0 0 [::]:ntp [::]:* Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 2328430 /run/user/0/systemd/private unix 2 [ ACC ] SEQPACKET LISTENING 9292 /run/udev/control unix 2 [ ACC ] STREAM LISTENING 11260 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 10224 /run/uuidd/request unix 2 [ ACC ] STREAM LISTENING 685879 /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 9289 /run/systemd/fsck.progress unix 2 [ ACC ] STREAM LISTENING 9297 /run/systemd/journal/stdout unix 2 [ ACC ] STREAM LISTENING 230958689 /var/run/mysqld/mysqld.sock unix 2 [ ACC ] STREAM LISTENING 400046466 /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> unix 2 [ ACC ] STREAM LISTENING 400046465 /tmp/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
6.5.2 netstat-a l: the result here is a little unscientific, so use - l instead of - a command
root@healerjean:~# netstat -al Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:https *:* LISTEN tcp 0 0 *:7777 *:* LISTEN tcp 0 0 localhost:9000 *:* LISTEN tcp 0 0 *:6666 *:* LISTEN tcp 0 0 localhost:6379 *:* LISTEN tcp 0 0 *:9999 *:* LISTEN tcp 0 0 *:http *:* LISTEN tcp 0 0 *:tproxy *:* LISTEN tcp 0 0 *:8082 *:* LISTEN tcp 0 0 healerjean:50050 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49956 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50012 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50060 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49970 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50014 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50072 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49958 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50022 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50048 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49972 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50054 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:42858 100.100.30.25:http ESTABLISHED tcp 0 0 healerjean:49994 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50002 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50026 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50018 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49990 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50068 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50062 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50064 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50078 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49964 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50016 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49986 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:51836 100.100.27.15:3128 ESTABLISHED tcp 0 0 healerjean:49988 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49968 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49952 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50044 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50066 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50004 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50010 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50024 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50076 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50038 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49996 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50056 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49962 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50058 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50000 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49998 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49980 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50040 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49960 100.100.100.200:http TIME_WAIT tcp 0 0 localhost:9999 localhost:48164 TIME_WAIT tcp 0 0 healerjean:50032 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50036 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49978 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:ssh 106.37.187.184:4775 ESTABLISHED tcp 0 0 healerjean:50028 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50070 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49984 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50046 100.100.100.200:http TIME_WAIT tcp 0 6784 healerjean:ssh 106.37.187.184:18710 ESTABLISHED tcp 0 0 healerjean:50006 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49954 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50080 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50052 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49976 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49966 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:50030 100.100.100.200:http TIME_WAIT tcp 0 0 healerjean:49992 100.100.100.200:http TIME_WAIT tcp6 0 0 [::]:mysql [::]:* LISTEN udp 0 0 *:bootpc *:* udp 0 0 healerjean:ntp *:* udp 0 0 localhost:ntp *:* udp 0 0 *:ntp *:* udp6 0 0 [::]:ntp [::]:* Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ] DGRAM 2328429 /run/user/0/systemd/notify unix 2 [ ACC ] STREAM LISTENING 2328430 /run/user/0/systemd/private unix 2 [ ACC ] SEQPACKET LISTENING 9292 /run/udev/control unix 2 [ ACC ] STREAM LISTENING 11260 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 10224 /run/uuidd/request unix 3 [ ] DGRAM 9051 /run/systemd/notify unix 2 [ ACC ] STREAM LISTENING 685879 /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 9289 /run/systemd/fsck.progress unix 2 [ ] DGRAM 9290 /run/systemd/journal/syslog unix 10 [ ] DGRAM 9291 /run/systemd/journal/dev-log unix 2 [ ACC ] STREAM LISTENING 9297 /run/systemd/journal/stdout unix 6 [ ] DGRAM 9298 /run/systemd/journal/socket unix 2 [ ACC ] STREAM LISTENING 230958689 /var/run/mysqld/mysqld.sock unix 2 [ ACC ] STREAM LISTENING 400046466 /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> unix 2 [ ACC ] STREAM LISTENING 400046465 /tmp/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> unix 2 [ ] DGRAM 2330332 unix 3 [ ] STREAM CONNECTED 735406 unix 3 [ ] STREAM CONNECTED 2330326 unix 3 [ ] STREAM CONNECTED 3046640 unix 3 [ ] STREAM CONNECTED 2328411 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 538788633 unix 3 [ ] STREAM CONNECTED 735407 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 3046639 unix 3 [ ] STREAM CONNECTED 11837 unix 3 [ ] STREAM CONNECTED 12567 /run/systemd/journal/stdout unix 2 [ ] DGRAM 410089914 unix 2 [ ] DGRAM 2328419 unix 2 [ ] DGRAM 735409 unix 3 [ ] STREAM CONNECTED 11838 /var/run/dbus/system_bus_socket unix 2 [ ] STREAM CONNECTED 537159779 unix 3 [ ] STREAM CONNECTED 11364 unix 3 [ ] DGRAM 735419 unix 3 [ ] STREAM CONNECTED 11363 unix 2 [ ] DGRAM 11360 unix 3 [ ] DGRAM 735420 unix 3 [ ] STREAM CONNECTED 538788636 unix 3 [ ] STREAM CONNECTED 749487 unix 3 [ ] STREAM CONNECTED 538788634 unix 3 [ ] STREAM CONNECTED 749488 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 12622 /run/systemd/journal/stdout unix 2 [ ] DGRAM 539128832 unix 3 [ ] STREAM CONNECTED 12566 unix 3 [ ] STREAM CONNECTED 11421 unix 3 [ ] STREAM CONNECTED 12701 unix 3 [ ] STREAM CONNECTED 11523 unix 3 [ ] STREAM CONNECTED 12702 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 534823795 unix 2 [ ] DGRAM 11431 unix 3 [ ] STREAM CONNECTED 559897 /run/systemd/journal/stdout unix 2 [ ] DGRAM 9316 unix 3 [ ] STREAM CONNECTED 11326 /run/systemd/journal/stdout unix 2 [ ] STREAM CONNECTED 538789484 unix 3 [ ] STREAM CONNECTED 560057 /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 559038 unix 3 [ ] STREAM CONNECTED 560056 unix 3 [ ] STREAM CONNECTED 12648 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 685878 unix 2 [ ] DGRAM 538974267 unix 3 [ ] STREAM CONNECTED 538788635 unix 2 [ ] STREAM CONNECTED 537177061 unix 3 [ ] STREAM CONNECTED 11324 unix 2 [ ] DGRAM 2866759 unix 3 [ ] STREAM CONNECTED 686129 /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 750451 unix 3 [ ] STREAM CONNECTED 2865786 unix 3 [ ] STREAM CONNECTED 400046463 unix 3 [ ] STREAM CONNECTED 400046464 unix 2 [ ] DGRAM 11976 unix 3 [ ] STREAM CONNECTED 2866737 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 752695 unix 3 [ ] STREAM CONNECTED 400046461 unix 3 [ ] STREAM CONNECTED 752698 /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 400046462 root@healerjean:~#
6.5.3,netstat -tnl
netstat -tnl
root@healerjean:~# netstat -tnl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:7777 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:6666 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN tcp6 0 0 :::3306 :::* LISTEN
6.6. netstat -p: get the process name, process number and user ID
6.6.1. netstat -p: get the process name, process number and user ID
netstat -p
root@healerjean:~# netstat -p Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 healerjean:52226 100.100.27.15:3128 ESTABLISHED 31604/CmsGoAgent-Wo tcp 0 0 healerjean:50366 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50284 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50312 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50406 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50372 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50294 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:7777 scan-145.security:45342 TIME_WAIT - tcp 0 0 healerjean:50364 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50382 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50282 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50350 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:42858 100.100.30.25:http ESTABLISHED 12165/AliYunDun tcp 0 0 healerjean:50362 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50308 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50386 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50346 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50388 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50314 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50360 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50408 100.100.100.200:http ESTABLISHED 595/aliyun-service tcp 0 0 healerjean:50392 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50324 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50338 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50358 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50302 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50320 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50292 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50380 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50342 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50310 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50304 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50356 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50394 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50384 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50396 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50340 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50398 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50280 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50290 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50300 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50318 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50370 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50378 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50402 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50376 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50390 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50316 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50322 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50286 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50344 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50404 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50296 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50352 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50306 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50288 100.100.100.200:http TIME_WAIT - tcp 0 2048 healerjean:ssh 106.37.187.184:18710 ESTABLISHED 29062/2 tcp 0 0 healerjean:50348 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50374 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50354 100.100.100.200:http TIME_WAIT - tcp 0 0 healerjean:50334 100.100.100.200:http TIME_WAIT - Active UNIX domain sockets (w/o servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ] DGRAM 2328429 30717/systemd /run/user/0/systemd/notify unix 3 [ ] DGRAM 9051 1/systemd /run/systemd/notify unix 2 [ ] DGRAM 9290 1/systemd /run/systemd/journal/syslog unix 9 [ ] DGRAM 9291 1/systemd /run/systemd/journal/dev-log unix 6 [ ] DGRAM 9298 1/systemd /run/systemd/journal/socket unix 2 [ ] DGRAM 2330332 30718/(sd-pam) unix 3 [ ] STREAM CONNECTED 735406 26511/systemd-udevd unix 3 [ ] STREAM CONNECTED 2330326 30717/systemd unix 3 [ ] STREAM CONNECTED 3046640 28619/php-fpm.conf) unix 3 [ ] STREAM CONNECTED 2328411 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 538788633 28170/nginx.conf unix 3 [ ] STREAM CONNECTED 735407 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 3046639 28619/php-fpm.conf) unix 3 [ ] STREAM CONNECTED 11837 492/accounts-daemon unix 3 [ ] STREAM CONNECTED 12567 1/systemd /run/systemd/journal/stdout unix 2 [ ] DGRAM 410089914 29170/mysqld unix 2 [ ] DGRAM 2328419 30717/systemd unix 2 [ ] DGRAM 735409 26511/systemd-udevd unix 3 [ ] STREAM CONNECTED 11838 469/dbus-daemon /var/run/dbus/system_bus_socket unix 2 [ ] STREAM CONNECTED 537159779 25044/java unix 3 [ ] STREAM CONNECTED 11364 469/dbus-daemon unix 3 [ ] DGRAM 735419 26511/systemd-udevd unix 3 [ ] STREAM CONNECTED 11363 469/dbus-daemon unix 2 [ ] DGRAM 11360 469/dbus-daemon unix 3 [ ] DGRAM 735420 26511/systemd-udevd unix 3 [ ] STREAM CONNECTED 538788636 28170/nginx.conf unix 3 [ ] STREAM CONNECTED 749487 28341/uuidd unix 3 [ ] STREAM CONNECTED 538788634 28170/nginx.conf unix 3 [ ] STREAM CONNECTED 749488 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 12622 1/systemd /run/systemd/journal/stdout unix 2 [ ] DGRAM 539128832 29062/2 unix 3 [ ] STREAM CONNECTED 12566 490/systemd-logind unix 3 [ ] STREAM CONNECTED 11421 492/accounts-daemon unix 3 [ ] STREAM CONNECTED 12701 490/systemd-logind unix 3 [ ] STREAM CONNECTED 11523 510/cron unix 3 [ ] STREAM CONNECTED 12702 469/dbus-daemon /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 534823795 1/systemd unix 2 [ ] DGRAM 11431 490/systemd-logind unix 3 [ ] STREAM CONNECTED 559897 1/systemd /run/systemd/journal/stdout unix 2 [ ] DGRAM 9316 190/systemd-journal unix 3 [ ] STREAM CONNECTED 11326 1/systemd /run/systemd/journal/stdout unix 2 [ ] STREAM CONNECTED 538789484 28178/java unix 3 [ ] STREAM CONNECTED 560057 469/dbus-daemon /var/run/dbus/system_bus_socket unix 3 [ ] STREAM CONNECTED 559038 21061/python3 unix 3 [ ] STREAM CONNECTED 560056 21061/python3 unix 3 [ ] STREAM CONNECTED 12648 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 685878 1/systemd unix 3 [ ] STREAM CONNECTED 538788635 28170/nginx.conf unix 2 [ ] STREAM CONNECTED 539222767 28178/java unix 2 [ ] STREAM CONNECTED 537177061 25044/java unix 3 [ ] STREAM CONNECTED 11324 469/dbus-daemon unix 2 [ ] DGRAM 2866759 31595/CmsGoAgent.li unix 3 [ ] STREAM CONNECTED 686129 469/dbus-daemon /var/run/dbus/system_bus_socket unix 2 [ ] DGRAM 750451 28432/ntpd unix 3 [ ] STREAM CONNECTED 2865786 31595/CmsGoAgent.li unix 3 [ ] STREAM CONNECTED 400046463 12165/AliYunDun unix 3 [ ] STREAM CONNECTED 400046464 12165/AliYunDun unix 2 [ ] DGRAM 11976 641/dhclient unix 3 [ ] STREAM CONNECTED 2866737 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 752695 28575/sshd unix 3 [ ] STREAM CONNECTED 400046461 12165/AliYunDun unix 3 [ ] STREAM CONNECTED 752698 1/systemd /run/systemd/journal/stdout unix 3 [ ] STREAM CONNECTED 400046462 12165/AliYunDun root@healerjean:~#
6.6.2,netstat -tnpl
netstat -tnpl
root@healerjean:~# netstat -tnpl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 28575/sshd tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 28170/nginx.conf tcp 0 0 0.0.0.0:7777 0.0.0.0:* LISTEN 28178/java tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 28619/php-fpm.conf) tcp 0 0 0.0.0.0:6666 0.0.0.0:* LISTEN 28170/nginx.conf tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 21426/redis-server tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN 25044/java tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 28170/nginx.conf tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 28170/nginx.conf tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 28170/nginx.conf tcp6 0 0 :::3306 :::* LISTEN 29170/mysqld
7. ls: display file
command | Explain |
---|---|
ls -a | Query all files and folders, including hidden files |
ls -l | Detailed list, not including hidden files, or ls -l abbreviated to ll |
ls -al | Detailed list of all files (including hidden files) |
ls -h | Friendly file display (the size will show K), or ls - lh, ll -h |
7.1. Ls-a: query all files and folders, including hidden files
Query all files and folders, including hidden files
7.2. Ls-l: detailed list, excluding hidden files, or ls-l can be abbreviated to ll
Detailed list, not including hidden files, or ls -l abbreviated to ll
7.3 LS al: detailed list of all files (including hidden files)
7.4. ls -l: - h friendly display or ls - lh ll -h
7.5. ls -l /etc: view the detailed list under other directories
8. View files
8.1 cat: display file command
8.1.1 cat filename: display file content
Show file contents
cat iku-client.stdout.log
root@healerjean:/usr/local/service/logs/iku/iku-client# cat iku-client.stdout.log . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.5.RELEASE) 2020-01-15 10:37:29 INFO -[ ]- Starting IkuClientApplication v1.0.0-SNAPSHOT on healerjean with PID 28178 (/usr/local/service/app/iku/iku-client/iku-client.jar started by root in /usr/local/service/app/iku/iku-client) com.healerjean.proj.IkuClientApplication.logStarting[50] 2020-01-15 10:37:29 INFO -[ ]- The following profiles are active: prod com.healerjean.proj.IkuClientApplication.logStartupProfileInfo[679] 2020-01-15 10:37:30 INFO -[ ]- Multiple Spring Data modules found, entering strict repository configuration mode! org.springframework.data.repository.config.RepositoryConfigurationDelegate.multipleStoresDetected[244] 2020-01-15 10:37:30 INFO -[ ]- Bootstrapping Spring Data repositories in DEFAULT mode. org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn[126] 2020-01-15 10:37:31 INFO -[ ]- Finished Spring Data repository scanning in 278ms. Found 10 repository interfaces. org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn[182] 2020-01-15 10:37:31 WARN -[ ]- No MyBatis mapper was found in '[com.healerjean.proj]' package. Please check your configuration. org.mybatis.spring.mapper.ClassPathMapperScanner.doScan[166] 2020-01-15 10:37:31 INFO -[ ]- Multiple Spring Data modules found, entering strict repository configuration mode! org.springframework.data.repository.config.RepositoryConfigurationDelegate.multipleStoresDetected[244] 2020-01-15 10:37:31 INFO -[ ]- Bootstrapping Spring Data repositories in DEFAULT mode. org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn[126] 2020-01-15 10:37:31 INFO -[ ]- Spring Data Redis - Could not safely identify store assignment for repository candidate "com.healerjean.proj.data.repository.item.ItemAdzoneRefRepository". org.sprin
8.1.2 cat -n filename: display the file content and add the line number
Display the contents of the file with line number
root@healerjean:/usr/local/service/logs/iku/iku-client# cat -n iku-client.stdout.log 1 2 . ____ _ __ _ _ 3 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ 4 ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 5 \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 6 ' |____| .__|_| |_|_| |_\__, | / / / / 7 =========|_|==============|___/=/_/_/_/ 8 :: Spring Boot :: (v2.1.5.RELEASE) 9 10 2020-01-15 10:37:29 INFO -[ ]- Starting IkuClientApplication v1.0.0-SNAPSHOT on healerjean with PID 28178 (/usr/local/service/app/iku/iku-client/iku-client.jar started by root in /usr/local/service/app/iku/iku-client) com.healerjean.proj.IkuClientApplication.logStarting[50] 11 2020-01-15 10:37:29 INFO -[ ]- The following profiles are active: prod com.healerjean.proj.IkuClientApplication.logStartupProfileInfo[679] 12 2020-01-15 10:37:30 INFO -[ ]- Multiple Spring Data modules found, entering strict repository configuration mode! org.springframework.data.repository.config.RepositoryConfigurationDelegate.multipleStoresDetected[244] 13 2020-01-15 10:37:30 INFO -[ ]- Bootstrapping Spring Data repositories in DEFAULT mode. org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn[126] 14 2020-01-15 10:37:31 INFO -[ ]- Finished Spring Data repository scanning in 278ms. Found 10 repository interfaces. org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn[182] 15 2020-01-15 10:37:3
8.2 tail: see from the end
It is often used in the shell to display the progress in the screen, and generally used to browse the logs in real time
tail -f filename tail -500f filename How many lines are displayed
9. cp: Copy command
When - R or - R is not added, only the files and folders will be copied; when - R or - R is added, the folders will be copied - including the subfolders at the next level, and the subfolders in the subfolders, etc
9.1. cp originFileNmae newFileName: copy file
cp test.txt cp.txt
root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 48 drwxrwxrwx 2 root root 4096 Jan 15 15:20 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log -rw-r--r-- 1 root root 6 Jan 15 15:20 test.txt root@healerjean:/usr/local/service/logs/iku/iku-client# cp test.txt cp.txt root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 52 drwxrwxrwx 2 root root 4096 Jan 15 15:20 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ -rw-r--r-- 1 root root 6 Jan 15 15:20 cp.txt -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log -rw-r--r-- 1 root root 6 Jan 15 15:20 test.txt root@healerjean:/usr/local/service/logs/iku/iku-client#
9.2. cp conf -r /use/local: copy directory
10. rm: delete command
10.1 rm filename: delete file
rm test.txt
root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 44 drwxrwxrwx 2 root root 4096 Jan 15 15:13 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log -rw-r--r-- 1 root root 0 Jan 15 15:14 test.txt root@healerjean:/usr/local/service/logs/iku/iku-client# rm test.txt root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 44 drwxrwxrwx 2 root root 4096 Jan 15 15:19 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log
10.2 Rm-rf directory name: delete directory
-r: It's a downward recursion. No matter how many levels of directories there are, delete them at the same time
-f: It means to delete directly without any hint
rm -rf conf
root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 56 drwxrwxrwx 3 root root 4096 Jan 15 15:22 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ drwxr-xr-x 2 root root 4096 Jan 15 15:22 conf/ -rw-r--r-- 1 root root 6 Jan 15 15:20 cp.txt -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log -rw-r--r-- 1 root root 6 Jan 15 15:20 test.txt root@healerjean:/usr/local/service/logs/iku/iku-client# rm -rf conf root@healerjean:/usr/local/service/logs/iku/iku-client# ll total 52 drwxrwxrwx 2 root root 4096 Jan 15 15:22 ./ drwxrwxrwx 4 root root 4096 Jan 14 18:45 ../ -rw-r--r-- 1 root root 6 Jan 15 15:20 cp.txt -rw-r--r-- 1 root root 0 Jan 15 10:37 iku-client.error -rw-r--r-- 1 root root 35435 Jan 15 14:59 iku-client.stdout.log -rw-r--r-- 1 root root 6 Jan 15 15:20 test.txt root@healerjean:/usr/local/service/logs/iku/iku-client#
11. Decompression
11.1. Tar, extract tar file
command | Explain |
---|---|
z | Indicates that the tar package is compressed by gzip, so you need to unzip it with gunzip |
x | Extract files from tar package |
v | Show details |
f xxx.tar.gz | Specifies that the file to be processed is xxx.tar.gz |
C | Compress to specified directory |
11.1.1 decompress the current directory
tar -zxvf jdk.tar.gz
11.1.2 extract to the specified directory
tar -zxvf jdk.tar.gz -C /usr/local
11.2. unzip, zip: zip file
11... 2.1 unzip filename.zip unzip
unzip filename.zip
11.2.2. zip new.zip filename: compression
zip scf-m.zip scf-m
12. chmod: permission change
12.1 who: users, groups, other users, all users, and file permissions
u user, g group, o others, a all users (default)
12.2,opcode
+Add permission, - delete permission, = reassign permission
12.3,permission
r read, w write, x execute, s set user (or group) ID number t set sticky bit to prevent file or directory from being deleted by non owner
12.4 figures
As an option, most of us use the form of three octal digits to express permissions
The first specifies the permissions of the owner, the second specifies the permissions of the group, and the third specifies the permissions of other users. Each user determines the permissions by the sum of 4 (read), 2 (write), and 1 (execute). For example, 6 (4 + 2) represents the right to read and write, and 7 (4 + 2 + 1) has the right to read, write and execute.
You can also set the fourth digit, which is in front of the three digit permission sequence. The fourth digit value is 4, 2, 1, which means as follows:
4. Set the user ID during execution, which is used to authorize the process based on the file owner, rather than the user who created the process.
2. Set the user group ID during execution, which is used to authorize the process based on the group of the file, rather than the user who created the process.
1. Set the adhesive position.
12.5 examples
12.5.1 multiple cases
chmod u+x file add execution permission to the owner of file chmod 751 file assigns read, write and execute (7) permissions to the owner of file, read and execute (5) permissions to the group of file, and execute (1) permissions to other users chmod u=rwx,g=rx,o=x file another form of the example above chmod =r file assign read permissions to all users chmod 444 file as above Chmod a-wx, a + R file is the same as the above example chmod -R u+r directory recursively assigns read permission to the owner of all files and subdirectories under the directory chmod u+x *.sh grants execution permission to all sh in bin
12.5.2 self test
1. Create a new file, txt.txt
2,chmod u=rwx txt.txt
3. At this time, you can see that the root user has read / write permission, but other groups and users only have read permission, that is to say, the healerjean group can't delete this user, only assigning a value to the group can delete this txt.txt file
4. Grant permission to the group healerjean (the highest one here, you can see that the lock of txt.txt disappears)
13. sudo: let ordinary users execute some or all root commands
13.1. Add users to sudo configuration file
13.1.1. The following prompt is given because the user is not added to sudo's configuration file
13.1.2 add user to enter sudo configuration file
2.1. Switch to root
2.2. Add the write permission of sudo file. The command is:
chmod u+w /etc/sudoers
2.3 edit sudoers file, find root ALL=(ALL) ALL in this line, and add xxx ALL=(ALL) ALL under it (xxx here is your user name)
vi /etc/sudoers
Here you can add any of the following four lines to sudoers youuser ALL=(ALL) ALL %youuser ALL=(ALL) ALL youuser ALL=(ALL) NOPASSWD: ALL %youuser ALL=(ALL) NOPASSWD: ALL Line 1: allow user youuser to execute sudo command (password required) Second line: allow users in user group youuser to execute sudo command (password required) Line 3: allow user youuser to execute sudo command without entering password Line 4: allow users in user group youuser to execute sudo command without entering password
13.1.3. In this way, ordinary users can use sudo
14. mv: move files and directories
command | Explain |
---|---|
mv filename filename | Change the source file name to the destination file name |
mv filename directory name | Move files to destination directory |
mv directory name directory name | The target directory already exists. Change the source directory Move to destination directory; destination Change the name if the directory does not exist |
15. cd: switch the current working path
15.1 command use
command | Explain |
---|---|
cd.. / and cd, | Previous directory |
cd ~ | Current user directory |
cd - | Last accessed directory |
cd / | Follow up directory |
16. mkdir: create directory
16.1 cascade creation directory
16.1.1. Create t1 first, then t2
mkdir t1/t2
16.1.2 create directory directly and dynamically
mkdir -p t1/t2
17. vi/vim: editing files
17.1. Exit
1. q! Force exit without saving 2. wq save and exit 3. q do not save, exit 4. w save, do not exit 5. All have! All are compulsory. 5.1. wq! Save to force exit 5.2, w! Force save, do not exit 5.3, q! Do not save, force exit
17.2. Select Delete, vi cannot be used, vim can
gg move the cursor to the first line, V is to enter the visual mode. You can move up and down. After selecting the content, you can do other operations G cursor moves to the last line d delete selection
18. ps: view process
18.1 ps-ef: query process
18.1.1 return format description
format | Explain |
---|---|
UID | Which user opened the process root can kill almost all processes |
PID | Process ID, linux can only kill a process if it knows this ID |
cmd | Indicates the program corresponding to the process, or the location of the program |
18.1.2 test
18.1.2.1 querying the process of an application
ps -ef | grep scf-client
[work@vm10-123-3-2 ~]$ ps -ef | grep scf-client work 12523 1 0 Jan02 ? 00:53:18 /usr/local/service/app/scf/scf-client/jdk1.8.0_202/bin/java -Xmn128M -Xmx512M -Xms256M -XX:MaxPermSize=128M -XX:PermSize=128M -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -XX:CMSFullGCsBeforeCompaction=50 -XX:+UseCMSCompactAtFullCollection -XX:MaxTenuringThreshold=10 -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintFlagsFinal -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8383 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Xloggc:/usr/local/service/log/scf/scf-client/gc.log -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=19136 -Dlog4j2.isThreadContextMapInheritable=true -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.endorsed.dirs=/usr/local/service/app/scf/scf-client/jdk1.8.0_202/jre/lib/endorsed:/usr/local/service/app/scf/scf-client/resin-pro-4.0.58/endorsed -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/usr/local/service/app/s
19. Kill: kill the process
Kill-9 PID is the process number
20, shutdown
20.1 reboot: Reboot command
20.2 halt: direct shutdown command
21. Linux software installation
21.1. yum: centos install software command
21.1.1. yum list: view the list of installable software of remote server
yum list
Filename (package name) the name of the version container
21.1.2. yum search keyword: search all software packages related to the keyword of the server vendor
yum search java
21.1.3. yum -y install package name: installation software
Install software, command-y: auto answer yes
Test: install a gcc c compiler. I don't know why I have already installed it
21.1.4. yum -y update package name: update software
Remember to input the package name. If you don't input it, you will update everything. This will change the linux kernel and cause unnecessary losses
21.1.5. yum -y remove package name: uninstall software
21.1.6 precautions
Update and uninstall of yum are generally not used. What to use. Don't use it easily
21.2 rpm: centos installation software command
command | Explain |
---|---|
rpm–i | Installation mode |
rpm–q | Query mode |
rpm–V | Validation mode |
rpm–e | Deletion mode |
rpm -U | Upgrade mode |
21.2.1 other combined commands
command | Explain |
---|---|
-a | Query all suites. |
–nodeps | Do not verify suite file correlation |
-i | Query installation information |
-l | Installation location, view installation location |
-f | View which package the system file belongs to |
-h | (hash) display progress (used during installation) |
-v | Display information about the installation process (what the console prints) |
21.2.2 rpm -q: query mode
21.2.1.1 rpm -qa: check whether the machine has java software
rpm -qa | grep java
[work@vm10-123-3-2 ~]$ rpm -qa | grep java tzdata-java-2016g-2.el7.noarch javapackages-tools-3.4.1-11.el7.noarch nuxwdog-client-java-1.0.3-5.el7.x86_64 python-javapackages-3.4.1-11.el7.noarch
21.2.1.2 rpm -qi: view the details of the software
rpm -qi gcc
[work@vm10-123-3-2 ~]$ rpm -qi gcc Name : gcc Version : 4.8.5 Release : 11.el7 Architecture: x86_64 Install Date: Fri 30 Jun 2017 08:47:54 AM CST Group : Development/Languages Size : 39227971 License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD Signature : RSA/SHA256, Mon 21 Nov 2016 01:46:14 AM CST, Key ID 24c6a8a7f4a80eb5 Source RPM : gcc-4.8.5-11.el7.src.rpm Build Date : Sat 05 Nov 2016 12:01:22 AM CST Build Host : worker1.bsys.centos.org Relocations : (not relocatable) Packager : CentOS BuildSystem <http://bugs.centos.org> Vendor : CentOS URL : http://gcc.gnu.org Summary : Various compilers (C, C++, Objective-C, Java, ...) Description : The gcc package contains the GNU Compiler Collection version 4.8. You'll need this package in order to compile C code.
21.2.1.3 rpm -ql: check the installation location of the software
rpm -ql gcc
[work@vm10-123-3-2 ~]$ rpm -ql gcc /usr/bin/c89 /usr/bin/c99 /usr/bin/cc /usr/bin/gcc /usr/bin/gcc-ar /usr/bin/gcc-nm /usr/bin/gcc-ranlib /usr/bin/gcov /usr/bin/x86_64-redhat-linux-gcc /usr/lib/gcc /usr/lib/gcc/x86_64-redhat-linux /usr/lib/gcc/x86_64-redhat-linux/4.8.2 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32 /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtbegin.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtbeginS.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtbeginT.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtend.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtendS.o /usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/crtfastmath.o
21.2.1.4 rpm -qf: check which package the software belongs to
[work@vm10-123-3-2 ~]$ rpm -qf /usr/bin/gcc-ranlib gcc-4.8.5-11.el7.x86_64
21.2.3 rpm-i: installation mode
If there is no dependency, an error will be reported. In this way, you can install whichever is missing, so it is not as convenient as the yum command and apt get command
rpm -ivh http-
21.2.4 rpm -e: delete mode
rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
21.3 difference between yum and rpm commands
1. rpm is a software package management method developed by red hat company. With rpm, we can easily install, query, uninstall and upgrade the software. However, the dependency between rpm packages is often complicated, especially when the software is composed of multiple rpm packages.
2. Yum (full name: Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, red hat and SUSE. Based on RPM package management, it can automatically download and install RPM packages from specified servers, automatically handle dependency relationships, and install all dependent packages at one time without tedious downloading and installation
21.4 apt get: Ubuntu installation software
21.4.1 apt get update: update
21.4.2 apt get install nginx: install nginx
21.4.3 apt get remove openjdk: uninstall openjdk
22. wget: download files
wget http://sw.bos.baidu.com/sw-search-sp/software/991c736e7065f/BaiduNetdisk_5.6.2.1.exe
23,ping,nslookup,telent
23.1 nslookup and ping
ping is the IP address of a server. (if there are multiple servers, IP address will appear randomly. nslookup is to check which servers provide services for the domain name. Many companies use load balancing technology to randomly assign users' access to a certain server, so you may ping differently sometimes. nslookup can see all servers providing services
23.2,telnet
23.2.1. telnet ip port check whether a port is open
telnet 39.97.176.134 6666
24. Adding users and groups
24.1. groupadd: Add User Group
groupadd mysql
24.2 useradd: add user to user group
Add user mysql (first user) to user group mysql useradd -g mysql mysql
24.3 chown-r changes the owner of the current directory to other users
Modify the current directory mysql owner as mysql user, mysql group chown -R mysql:mysql ./ Modify the directory / usr/weblogic owner to weblogic user, weblogic group, and the following path represents the directory (refer to MySQL installation) chown -R weblogic:weblogic /usr/weblogic Change the user of test.xml to weblogic chown weblogic test.xml
25. Configuration of environment variables
25.1,java
export MYSQL_HOME="/usr/local/mysql" export PATH="$PATH:$MYSQL_HOME/bin" JAVA_HOME=/usr/local/java1.7.0_80 JRE_HOME=/usr/local/java1.7.0_80/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME PATH
25.2,mysql
#mysql export MYSQL_HOME="/usr/local/mysql-5.7.21-macos10.13-x86_64" export PATH="$PATH:$MYSQL_HOME/bin" #maven java installation automation already has export M2_HOME="/Library/apache-maven-3.3.9" export PATH="$M2_HOME/bin:$PATH"
26. Execute sh file
26.1 relative path
26.1.1 directly. / add the file name. Sh (hello.sh must have x permission)
26.1.2. Add the file name. Sh directly to sh (hello.sh may not have x permission)
./hello.sh sh hello.sh
26.2 absolute path
./home/test/shell/hello.sh /home/test/shell/hello.sh sh /home/test/shell/hello.sh //Environment variables can be written directly to hello.sh
27. ssh: connect to the server
Remember to enter yes, and then you will be asked for the password
ssh root@192.168.1.1 -p 27505
28. sed: replace string
28.1 sed-i: direct operation of text files
sed -i 's/Original string/New string/' /home/1.txt //Only for the first one in each line sed -i 's/Original string/New string/g' /home/1.txt //Replace all
The difference between these two commands is, take a look at the example
#cat 1.txt d ddd #ff
sed -i 's/d/7523/' /home/1.txt //results of enforcement 7523 7523dd #ff
sed -i 's/d/7523/g' /home/1.txt //results of enforcement 7523 752375237523 #ff
28.2 delete string
sed -i '/Character string/d' file
29. Upload and download
29.1 scp: Command upload and download
29.1.1 downloading files
scp username@servername:/path/filename /var/www/local_dir(Local directory)
29.1.2 download directory
SCP - R username @ servername: / var / www / remote? Dir / (remote directory) / var / www / local? Dir (local directory)
29.1.3 uploading files
scp -r filename username@servername:remote_dir
29.1.3 upload directory
scp -r local_dir username@servername:remote_dir
29.2. sz, rz software and command upload and download
When you connect to Linux server remotely, you always need to upload and download files. To achieve this, you can use either FTP or scp command at the local terminal.
But if you are using tools such as Xshell to operate the server, the easiest way is to use its own sz and rz commands.
29.2.1 sz: Download
sz –be filename
-a Transfer as text( ascii).
-b Binary transmission( binary).
29.2.2 rz: Upload
rz –be
30. Soft link, hard link
30.1. Ln-S soft link (equivalent to the original file)
A shortcut is just like our common shortcut.
Ln-S absolute path absolute path / relative path
30.1.1 when soft connection is a document
30.1.1.1 deletion
1. Delete soft link file, source file has no effect
2. Delete the source file, the soft link file is not available (the linux file viewing color will change from normal color to red), as follows
root@healerjean:/usr/local/service/logs# ll total 20 drwxrwxrwx 4 root root 4096 Jan 15 17:52 ./ drwxrwxrwx 5 root root 4096 Jan 14 18:52 ../ drwxrwxrwx 4 root root 4096 Jan 14 18:45 iku/ drwxrwxrwx 2 root root 4096 Jan 14 19:19 nginx/ lrwxrwxrwx 1 root root 32 Jan 15 17:52 test2.txt -> /usr/local/service/logs/test.txt -rw-r--r-- 1 root root 103 Jan 15 17:50 test.txt root@healerjean:/usr/local/service/logs# rm test.txt root@healerjean:/usr/local/service/logs# ll total 16 drwxrwxrwx 4 root root 4096 Jan 15 17:52 ./ drwxrwxrwx 5 root root 4096 Jan 14 18:52 ../ drwxrwxrwx 4 root root 4096 Jan 14 18:45 iku/ drwxrwxrwx 2 root root 4096 Jan 14 19:19 nginx/ lrwxrwxrwx 1 root root 32 Jan 15 17:52 test2.txt -> /usr/local/service/logs/test.txt root@healerjean:/usr/local/service/logs# cat test2.txt cat: test2.txt: No such file or directory root@healerjean:/usr/local/service/logs#
30.1.1.2 modification
Content: no matter which file content is modified, both files will change, because they are similar to shortcuts
File name: modify the file name, the two files will not change
30.1.2 contents
30.1.2.1 deletion
1. Delete the soft link directory. The source directory has no effect
2. Delete the source directory, the soft link directory is not available (the linux file viewing color will change from normal color to red), as follows
30.1.2.2 modification
Content: no matter which file content is modified, both files will change, because they are similar to shortcuts
File name: modify the file name, the two files will not change
30.2. ln: hard link (creates the same file, occupying memory)
So copying a file can only be a file copy, not a directory,
Function: modify the contents of one file, and the other will change, but delete means delete the file separately, without interfering with each other
ln absolute path / relative path absolute path / relative path
31. iptables: Firewall
By default, this firewall is not used in the higher version, but firewalld. When using the iptables command, the following error will be prompted
Error: "Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory."
31.1 orders
31.1.1 stop and disable firewalld
systemctl stop firewalld systemctl mask firewalld
31.1.2 installation of iptables
yum –y install iptables-services
31.1.3 start iptables
systemctl enable iptables
31.1.4 viewing firewall status
service iptables status
31.1.5 start firewall
service iptables start
31.1.6 turn off the firewall (it will also start after power on)
service iptables stop
31.1.7 disable firewall (permanent)
chkconfig iptables off
31.1.8 enable firewall
chkconfig iptables on
31.2 modify the configuration of Internet access to Linux
If you use tomcat to access linux, you need to first configure / etc/selinux/config, find SELINUX=enforcing, and change it to SELINUX=disabled
31.2.1 check selinux status
/usr/sbin/sestatus -v
31.3. Configure firewall / etc/sysconfig/iptables
1. I'm a second-class product. I put the code behind the commit. It's been a long time since I found it,
2. Moreover, Firewall is used in the configuration file, which is even more stupid. If the configuration file is wrong, the Firewall command start cannot be used at all.
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
32,curl
32.1 curl: single file viewing
curl http://www.centos.org
32.2 curl-i: view the return information of the request, and verify whether you have permission to access
curl -I https://www.baidu.com/ curl -I http://127.0.0.1:9999
root@healerjean:/usr/local/service/logs# curl -I https://www.baidu.com/ HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform Connection: keep-alive Content-Length: 277 Content-Type: text/html Date: Wed, 15 Jan 2020 11:35:52 GMT Etag: "575e1f60-115" Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT Pragma: no-cache Server: bfe/1.0.8.18 root@healerjean:/usr/local/service/logs# curl -I http://127.0.0.1:9999 HTTP/1.1 404 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Wed, 15 Jan 2020 11:37:19 GMT root@healerjean:/usr/local/service/logs# curl -I http://127.0.0.1:6666 HTTP/1.1 403 Forbidden Server: nginx/1.10.3 (Ubuntu) Date: Wed, 15 Jan 2020 11:37:31 GMT Content-Type: text/html Content-Length: 178 Connection: keep-alive
32.2. Curl-o, curl-o: File Download
32.2.1, - o: save the file as a file with the file name specified in the command line
curl -o down.html http://www.gnu.org/software/gettext/manual/gettext.html
root@healerjean:/usr/local/service/logs# curl -o down.html http://www.gnu.org/software/gettext/manual/gettext.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1487k 100 1487k 0 0 433k 0 0:00:03 0:00:03 --:--:-- 433k root@healerjean:/usr/local/service/logs# ll total 2992 drwxrwxrwx 4 root root 4096 Jan 15 19:23 ./ drwxrwxrwx 5 root root 4096 Jan 14 18:52 ../ -rw-r--r-- 1 root root 1523198 Jan 15 19:22 down.html drwxrwxrwx 4 root root 4096 Jan 14 18:45 iku/ drwxrwxrwx 2 root root 4096 Jan 14 19:19 nginx/
32.2.2, - O: save the file locally using the default file name in the URL
curl -O http://www.gnu.org/software/gettext/manual/gettext.html
root@healerjean:/usr/local/service/logs# curl -O http://www.gnu.org/software/gettext/manual/gettext.html % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1487k 100 1487k 0 0 677k 0 0:00:02 0:00:02 --:--:-- 677k root@healerjean:/usr/local/service/logs# ll total 2992 drwxrwxrwx 4 root root 4096 Jan 15 19:23 ./ drwxrwxrwx 5 root root 4096 Jan 14 18:52 ../ -rw-r--r-- 1 root root 1523198 Jan 15 19:22 down.html -rw-r--r-- 1 root root 1523198 Jan 15 19:23 gettext.html drwxrwxrwx 4 root root 4096 Jan 14 18:45 iku/ drwxrwxrwx 2 root root 4096 Jan 14 19:19 nginx/
32.3, - u: download files from FTP server
32.3.1, - u -o: list all folders and files in the directory
curl -u ftpuser:ftppass -O ftp://ftp_server/public/
32.3.2, - U-O: Download File
curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/file.txt
32.4, - T upload file to FTP server
32.4.1 upload files, multiple files
curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com
33. which: find whether the command exists and where the command is stored
Find out if the command exists and where it is stored
root@healerjean:/usr/local/service/logs# which nginx /usr/sbin/nginx
34. Where is: used to search program name
Used to search for program name
command | Explain |
---|---|
whereis -b | Search Binary |
whereis -m | man documentation |
whereis -s | Source code file |
root@healerjean:/usr/local/service/logs# whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
35. df: disk space view
35.1. df -k/-m/-h: display the disk usage and occupancy, which is KB by default
command | Explain |
---|---|
df -k, df | Display disk usage and occupancy in kilobytes, the default is kilobytes |
df -m | Display disk usage and usage in M |
df -h | Friendly display in GB, MB, KB and other formats that are easy to read |
35.1.1 display format description
format | Explain |
---|---|
Filesystem | file system |
1K-blocks | capacity |
Used | Already used |
Available | available |
Use% | Used% |
Mounted on | Mount point |
35.1.2 command operation
35.1.2.1, df, df -k: display disk usage and occupancy in kilobytes, default is kilobytes
root@healerjean:~# df Filesystem 1K-blocks Used Available Use% Mounted on udev 2004712 0 2004712 0% /dev tmpfs 404632 3088 401544 1% /run /dev/vda1 41151808 5122896 33915484 14% / tmpfs 2023156 0 2023156 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 2023156 0 2023156 0% /sys/fs/cgroup tmpfs 404632 0 404632 0% /run/user/0 root@healerjean:/usr# df -k Filesystem 1K-blocks Used Available Use% Mounted on udev 2004712 0 2004712 0% /dev tmpfs 404632 3088 401544 1% /run /dev/vda1 41151808 5122964 33915416 14% / tmpfs 2023156 0 2023156 0% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 2023156 0 2023156 0% /sys/fs/cgroup tmpfs 404632 0 404632 0% /run/user/0
35.1.2.2 df -m: display disk usage and occupancy in M
root@healerjean:~# df -m Filesystem 1M-blocks Used Available Use% Mounted on udev 1958 0 1958 0% /dev tmpfs 396 4 393 1% /run /dev/vda1 40188 5003 33121 14% / tmpfs 1976 0 1976 0% /dev/shm tmpfs 5 0 5 0% /run/lock tmpfs 1976 0 1976 0% /sys/fs/cgroup tmpfs 396 0 396 0% /run/user/0
35.1.2.3 df-h: friendly display, in GB, MB, KB and other formats that are easy for people to read
root@healerjean:/usr# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 396M 3.1M 393M 1% /run
/dev/vda1 40G 4.9G 33G 14% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 396M 0 396M 0% /run/user/0
35.1.3 result description
1. The file system / dev/vdal is our real disk. You can also see that its mount point is the root directory /, and other folders under the root directory. In fact, we can see from the percentage used, except that it is a little larger, others are basically 0
2. File system temfs: it is a temporary file system. You can see that it is all hung in the corresponding disk directory. In general, we only care about / dev/vdal
3. So you can see that the space of the whole disk is 40G, which has been used for 14%, 4.9G, and 33G is available
36. du: Directory space view
command | Explain |
---|---|
du -k,du | Current directory: view the usage of all directories and multi-level directories in the current directory list in kilobytes. The default is kilobytes |
du -m | Current directory: view the usage of all directories and multi-level directories in the current directory list by M |
du -h | Current directory: friendly display of all directories and multi-level directory usage in the current directory list, Display in GB, MB, KB and other formats that are easy for people to read |
du -a | The current directory contains the usage of all directories, multi-level directories and all files |
du -sh | View usage of current directory |
du -sh /usr/ | View usage of a directory |
du /usr/ | View all files and directory usage in a directory list |
36.1 view the usage of all files and directories in the directory list
36.1.1. du/ du -k: current directory: view the usage of all directories and multi-level directories in the current directory list in kilobytes. The default is kilobytes
root@healerjean:/usr/local/service# du 63036 ./app/iku/iku-client-webh5 64700 ./app/iku/iku-client 127740 ./app/iku 127744 ./app 2136 ./logs/nginx 324 ./logs/iku/iku-client-webh5 48 ./logs/iku/iku-client 376 ./logs/iku 5492 ./logs 1440 ./image/iku/iku-client-webh5 4 ./image/iku/iku-client 1448 ./image/iku 1452 ./image root@healerjean:/usr/local/service# du -k 63036 ./app/iku/iku-client-webh5 64700 ./app/iku/iku-client 127740 ./app/iku 127744 ./app 2136 ./logs/nginx 324 ./logs/iku/iku-client-webh5 48 ./logs/iku/iku-client 376 ./logs/iku 5492 ./logs 1440 ./image/iku/iku-client-webh5 4 ./image/iku/iku-client 1448 ./image/iku 1452 ./image 134692 .
36.1.2 du -m: current directory: view the usage of all directories and multi-level directories in the current directory list by M
du -m
root@healerjean:/usr/local/service# du -m 62 ./app/iku/iku-client-webh5 64 ./app/iku/iku-client 125 ./app/iku 125 ./app 3 ./logs/nginx 1 ./logs/iku/iku-client-webh5 1 ./logs/iku/iku-client 1 ./logs/iku 6 ./logs 2 ./image/iku/iku-client-webh5 1 ./image/iku/iku-client 2 ./image/iku 2 ./image 132 .
36.1.3 du-h: current directory: friendly display of all directories and multi-level directory usage in the current directory list, and display in the format of GB, MB, KB, etc., which is easy for people to read
du -h
root@healerjean:/usr/local/service# du -h 62M ./app/iku/iku-client-webh5 64M ./app/iku/iku-client 125M ./app/iku 125M ./app 2.1M ./logs/nginx 324K ./logs/iku/iku-client-webh5 48K ./logs/iku/iku-client 376K ./logs/iku 5.4M ./logs 1.5M ./image/iku/iku-client-webh5 4.0K ./image/iku/iku-client 1.5M ./image/iku 1.5M ./image 132M .
36.1.4 du -h /usr/local/service /: specify the usage of all directories and multi-level directories in the specified directory list to be displayed friendly,
Display in GB, MB, KB and other formats that are easy for people to read
du -k /usr/local/service/ du -m /usr/local/service/ du -h /usr/local/service/
root@healerjean:/usr/local/service# du -k /usr/local/service/ 63036 /usr/local/service/app/iku/iku-client-webh5 64700 /usr/local/service/app/iku/iku-client 127740 /usr/local/service/app/iku 127744 /usr/local/service/app 2136 /usr/local/service/logs/nginx 324 /usr/local/service/logs/iku/iku-client-webh5 48 /usr/local/service/logs/iku/iku-client 376 /usr/local/service/logs/iku 5492 /usr/local/service/logs 1440 /usr/local/service/image/iku/iku-client-webh5 4 /usr/local/service/image/iku/iku-client 1448 /usr/local/service/image/iku 1452 /usr/local/service/image 134692 /usr/local/service/ root@healerjean:/usr/local/service# du -m /usr/local/service/ 62 /usr/local/service/app/iku/iku-client-webh5 64 /usr/local/service/app/iku/iku-client 125 /usr/local/service/app/iku 125 /usr/local/service/app 3 /usr/local/service/logs/nginx 1 /usr/local/service/logs/iku/iku-client-webh5 1 /usr/local/service/logs/iku/iku-client 1 /usr/local/service/logs/iku 6 /usr/local/service/logs 2 /usr/local/service/image/iku/iku-client-webh5 1 /usr/local/service/image/iku/iku-client 2 /usr/local/service/image/iku 2 /usr/local/service/image 132 /usr/local/service/ root@healerjean:/usr/local/service# du -h /usr/local/service/ 62M /usr/local/service/app/iku/iku-client-webh5 64M /usr/local/service/app/iku/iku-client 125M /usr/local/service/app/iku 125M /usr/local/service/app 2.1M /usr/local/service/logs/nginx 324K /usr/local/service/logs/iku/iku-client-webh5 48K /usr/local/service/logs/iku/iku-client 376K /usr/local/service/logs/iku 5.4M /usr/local/service/logs 1.5M /usr/local/service/image/iku/iku-client-webh5 4.0K /usr/local/service/image/iku/iku-client 1.5M /usr/local/service/image/iku 1.5M /usr/local/service/image 132M /usr/local/service/
36.1.5 du-a: the current directory contains all directories, multi-level directories, and the usage of all files
du -ah
root@healerjean:/usr/local/service# du -ah 62M ./app/iku/iku-client-webh5/iku-client-webh5.jar 4.0K ./app/iku/iku-client-webh5/stop.sh 4.0K ./app/iku/iku-client-webh5/restart.sh 4.0K ./app/iku/iku-client-webh5/start.sh 62M ./app/iku/iku-client-webh5 4.0K ./app/iku/iku-client/stop.sh 4.0K ./app/iku/iku-client/restart.sh 4.0K ./app/iku/iku-client/start.sh 64M ./app/iku/iku-client/iku-client.jar 64M ./app/iku/iku-client 125M ./app/iku 125M ./app 2.1M ./logs/nginx/access.log 16K ./logs/nginx/error.log 2.1M ./logs/nginx 1.5M ./logs/down.html 160K ./logs/iku/iku-client-webh5/iku-client-webh5.stdout.log 0 ./logs/iku/iku-client-webh5/iku-client-webh5.stdout.error 160K ./logs/iku/iku-client-webh5/iku-client-webh5.log 324K ./logs/iku/iku-client-webh5 4.0K ./logs/iku/iku-client/cp.txt 0 ./logs/iku/iku-client/iku-client.error 36K ./logs/iku/iku-client/iku-client.stdout.log 4.0K ./logs/iku/iku-client/test.txt 48K ./logs/iku/iku-client 376K ./logs/iku 1.5M ./logs/gettext.html 5.4M ./logs 96K ./image/iku/iku-client-webh5/ikuisme.jpg 1.4M ./image/iku/iku-client-webh5/ikuhelpcenter.jpg 1.5M ./image/iku/iku-client-webh5 4.0K ./image/iku/iku-client 1.5M ./image/iku 1.5M ./image 132M .
36.2. du -sh: view the usage of a directory
du -sh current directory du -sh /usr / specify Directory: usr directory
root@healerjean:/usr/local/service# du -sh 132M root@healerjean:/usr# du -sh /usr/ 2.8G /usr/
37. top: cpu usage
top - 21:09:44 up 219 days, 7:37, 2 users, load average: 0.04, 0.03, 0.00 Tasks: 118 total, 1 running, 117 sleeping, 0 stopped, 0 zombie %Cpu(s): 1.0 us, 0.7 sy, 0.0 ni, 98.0 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 4046316 total, 430480 free, 1464136 used, 2151700 buff/cache KiB Swap: 0 total, 0 free, 0 used. 2258136 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 12165 root 10 -10 136508 17196 14520 S 2.0 0.4 1810:00 AliYunDun 25044 root 20 0 3532516 620744 17324 S 0.7 15.3 10:18.50 java 28178 root 20 0 3516784 588380 17000 S 0.7 14.5 4:15.60 java 7 root 20 0 0 0 0 S 0.3 0.0 92:27.21 rcu_sched 1 root 20 0 37772 5652 3844 S 0.0 0.1 11:05.70 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.55 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 3:40.50 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh 9 root rt 0 0 0 0 S 0.0 0.0 0:01.91 migration/0 10 root rt 0 0 0 0 S 0.0 0.0 1:12.97 watchdog/0 11 root rt 0 0 0 0 S 0.0 0.0 1:03.37 watchdog/1 12 root rt 0 0 0 0 S 0.0 0.0 0:01.92 migration/1 13 root 20 0 0 0 0 S 0.0 0.0 4:44.08 ksoftirqd/1 15 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H 16 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs 17 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns 18 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 perf 19 root 20 0 0 0 0 S 0.0 0.0 0:08.80 khungtaskd 20 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback 21 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd 22 root 39 19 0 0 0 S 0.0 0.0 1:24.81 khugepaged 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd 25 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd 27 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff 28 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md 29 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 devfreq_wq 34 root 20 0 0 0 0 S 0.0 0.0 0:00.62 kswapd0 35 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 vmstat
37.1 output log analysis
First line, task queue information
top - 21:09:35 up 219 days, 7:37, 2 users, load average: 0.04, 0.03, 0.00
format | Explain |
---|---|
21:10:23 | System current time |
up 219 days | The host has been running for 219 days |
2 users | Number of user connections (not number of users, who command) |
load average: 0.07, 0.03, 0.00 | System average load, count the system average load in the last 1,5,15 minutes |
@: 1. load average: system average load
load average in the top command shows the average system load in the last 1, 5, and 15 minutes. System average load representation
The system average load is defined as the average number of processes in the queue (* * how many processes are running on the CPU or waiting to run) * * within a specific time interval. A process is in the run queue if it:
1. It is not waiting for the result of the I/O operation
2. It does not actively enter the wait state (that is, it does not call 'wait')
3. Not stopped (e.g. waiting for termination)
Many people will understand the average load: three numbers represent the average load of the system in different time periods (one minute, five minutes, and fifteen minutes). The smaller the number, the better. The higher the number, the greater the load on the server, which may also be a signal of a problem with the server.
But it's not so. What factors make up the average load, and how to distinguish whether their current situation is "good" or "bad"? When should we pay attention to what abnormal values?
Before answering these questions, we need to understand some knowledge behind these values. Let's use the simplest example to illustrate that a server is equipped with only one single core processor.
Single core processor
Driving across the bridge: a single core processor can be likened to a single lane.
Imagine that you now need to charge for the bridge on this road, busy with the vehicles that are going to cross the bridge. First of all, you need to know some information, such as the load of the vehicle and how many vehicles are waiting to cross the bridge. If there is no vehicle waiting in front, you can tell the driver in the back to pass. If there are many vehicles, they need to be informed that they may need to wait for a while.
0.00 means there is no traffic on the bridge deck at present, and passing vehicles can pass without waiting at all.
1.00 means it is within the bearing range of this bridge. This is not a bad situation, but the traffic will be a little blocked, but this situation may cause the traffic to get slower and slower.
More than 1.00 indicates that the bridge has been overloaded and the traffic is seriously congested. How bad is the situation? For example, the situation of 2.00 shows that the traffic flow has exceeded twice the capacity of the bridge, so there will be more vehicles crossing the bridge twice are waiting anxiously. At 3.00, the situation is even worse, which means that the bridge is almost unbearable, and there are more than twice the load of vehicles waiting.
The above situation is very similar to the load situation of the processor. The bridge time of a car is like the actual time that a processor processes a thread. Unix system defined process run time is the processing time of all processor cores plus the waiting time of threads in the queue.
**In practice, experienced system administrators will mark this line at 0.70: so the ideal load you say is 1.00? ". load 1.00 means that the system has no remaining resources. * *
"Need to investigate": if your system load is around 0.70 for a long time, then you need to take some time to understand the reason before things get worse.
"Fix the law now": 1.00. If your server system load is hovering at 1.00 for a long time, you should solve this problem immediately. Otherwise, you will get a call from your boss in the middle of the night, which is not a pleasant thing.
"Exercise at 3:30 am": 5.00. If your server load exceeds the figure of 5.00, you will lose your sleep, and you have to explain the reason for this in the meeting. In short, do not let it happen.
Multiple processors
What about multiple processors? My average is 3.00, but the system is running normally! Do you have a host with four processors? So it's normal that its load average is 3.00
In a multiprocessor system, 1.00 indicates a single processor, while 2.00 indicates two dual processors, and 4.00 indicates that the host has four processors.
Multicore and multiprocessor (see 42 for Linux calculation method)
Let's discuss the difference between multi-core processor and multi processor. From the perspective of performance, one host with multi-core processors has the same number of processing performance as another. Of course, the actual situation will be much more complex, but even though the actual performance caused by these factors is slightly different, in fact, the system still calculates the load average based on the number of processor cores. This gives us two new rules:
It's not important that the core is distributed in several single physical processes. In fact, two four core processors are equal to four dual core processors and eight single processors. So, it should have eight processor cores. In multi-core processing, your system average should not be higher than the total number of processor cores.
Finally, the "load average" returns three average values: 1 minute system load, 5 minutes system load and 15 minutes system load. Which value should I refer to?
If only one minute of system load is greater than 1.0 and the other two time periods are less than 1.0, this indicates that it is only a temporary phenomenon and the problem is not serious.
If the average system load is greater than 1 within 15 minutes (after adjusting the number of CPU cores), it indicates that the problem persists, not temporarily. Therefore, you should mainly observe the "15 minute system load" as an indicator of the normal operation of the computer.
Line 2: process information: process number correlation
Tasks: 215 total, 2 running, 213 sleeping, 0 stopped, 0 zombie
format | Explain |
---|---|
Tasks: 215 total | Total process |
2 running | Number of running processes |
213 sleeping | Number of sleeping processes, sleeping processes, waiting for the event to complete, but can be woken up |
0 stopped | Number of processes stopped |
0 zombie | The number of zombie processes. The process has been terminated but cannot be deleted out of memory |
@: 1. Number of zombie processes (let's talk about it when we meet, let's take a look at the concept)
When a process dies and exits, but the parent process does not get its return code, the process will become a zombie process, and the zombie process will remain in the process table with the termination state and will wait for the parent process to get its exit state. So as long as the child process exits, the parent process is still running, but the parent process does not read the process state of the child process, and the child process enters the Z state. What if the parent process exits? It will become an orphan process and be recycled by the init process
Line 3: CPU information: display the percentage occupied
In general, we can focus on us, sy and id
%Cpu(s): 6.4 us, 0.1 sy, 0.0 ni, 93.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
format | Explain |
---|---|
6.4 us | CPU time to run (UN prioritized) user processes |
0.1 sy | Percentage of CPU occupied by kernel space |
0.0 ni | CPU time to run prioritized user processes |
93.5 id | Idle CPU percentage |
0.0 wa | Percentage of CPU time waiting for I / O |
0.0 hi | Hardware CPU interrupt percentage |
0.0 si | Soft interrupt percentage |
0.0 st | Virtual machine percentage |
@What does% cpu mean
The total utilization rate of all CPUs shown here indicates that your CPU is multi-core. After you run top, press the keyboard 1 to see the utilization rate of each CPU. The top shows the utilization rate of all CPUs
@User space and kernel space
User space applications often need to call hardware (QQ calls camera to take photos) or run content related to the system core (360 cleaning process), which inevitably involves dealing with the kernel. What is the calling relationship between them?
The open() file open function as an example
When the upper application executes the open() function in the user space, it will trigger the system soft interrupt. The system calls the system to call the system function sys_open() to execute the open code in the kernel space, so that the internal code of the open function in the user space can get the permission to run in the kernel space, and can do some things that compare the core better.
@3. Concerns
**There is also an important note about CPU. Let's see the army**
Line 4: run memory information in kilobytes
The memory included in the kernel management is not always in use, but also includes the memory that has been used in the past and can be reused now. The kernel does not return the memory that can be reused to free, so the free memory on linux will be less and less, but there is no need to worry about it.
4046316 total, 430480 free, 1464136 used, 2151700 buff/cache
format | Explain |
---|---|
32780396 total | Total physical memory |
430480 free | Total free+used=total |
1464136 used | Used memory |
2151700 buff/cache | Amount of memory used as kernel cache |
Line 5: swap information virtual memory usage (swap space)
**< font color = "red" > for memory monitoring, we need to monitor the used of swap partition in the fifth line at all times in top. If this value is changing constantly, it means that the kernel is constantly exchanging data between memory and swap, which is the real memory shortage. </font>**
KiB Swap: 0 total, 0 free, 0 used. 2258136 avail Mem
format | Explain |
---|---|
0 total | Total exchange area |
0 free | k free |
0 used | Total number of swap partitions used |
16426028 avail Mem | Total amount of available exchanges, |
Line 6: big army (I'll focus on the following memory, what is this thing in the end)
format | Explain |
---|---|
PID | Process id |
USER | User name of the process owner |
PR | Priority, dynamic priority |
NI | Static priority, nice value |
VIRT | The total amount of virtual memory used by the process, in kilobytes. |
RES | Size of physical memory used by the process |
SHR | Shared internal memory used by the process |
S | Process status (D = non interruptible sleep status, R = running, S = sleep, T = tracking / stopping, Z = zombie process) |
%CPU | CPU time percentage from last update to now |
%MEM | Percentage of physical and total memory used by the process |
TIME | Total CPU time used by the process, in 1 / 100 second |
COMMAND | Name and parameters of the command that started the process |
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30030 work 20 0 10.338g 1.034g 5180 S 100.0 3.3 33568:33 java 16587 work 20 0 10.335g 1.248g 23332 S 6.7 4.0 120:49.18 java 423411 root 20 0 43472 2596 1252 S 0.0 0.0 6:43.18 systemd 412342 root 20 0 0 0 0 S 0.0 0.0 0:00.08 kthreadd
@1. Parameter interpretation:
1.1 PR: priority (dynamic priority)
We also define the concept of priority as the meaning of priority value. Linux actually implements 140 priority ranges, ranging from 0-139. The smaller the value, the higher the priority.
The nice value is - 20 to 19, which maps to its actual priority range of 100-139.
instructions:
1. Java program default execution priority is 20, nice is 0
1.2 NI: static priority, nice value
Negative value means high priority, positive value means low priority - 20 to 19, 40 in total
1. The smaller the value, the higher the priority of the process, and the higher the value, the lower the priority. The nicer the person is, the worse the ability to seize resources, and the less nice the person is, the stronger the ability to seize resources. That's what nice value size means
2. Priority adjusted by nice and renice commands;
instructions:
1. Java program default execution priority is 20, nice is 0
1.3 VIRT: the total amount of virtual memory used by the process, in kb.
1. The "required" virtual memory size of the process, including the library, code, data used by the process, as well as the heap space and stack space allocated by malloc and new;
2. If the process newly requests 10MB of memory, but only 1MB is used, it will increase 10MB instead of 1MB
3,VIRT=SWAP+RES
instructions:
1. It doesn't seem to matter at the moment
1.4 RES: the size of the physical memory used by the process (important)
1,The amount of memory currently used by the process, including
malloc
,new Allocated heap space and allocated stack space, excluding swap out Quantity;2,Include sharing of other processes;
3,If applied
10MB
's memory, actual use1MB
,It only grows.1MB
,AndVIRT
Contrary;4,
RES
=CODE
+DATA
DATA
1,Memory occupied by data. If top No display, press f Key can be displayed.2,The real data space required by this program is the one to be used in real operation. Personal understanding: it is necessary for code execution.
instructions:
1. If JAVA program, RES = code location actual physical memory + (heap memory + stack memory + meta space)
1.5 SHR: shared internal memory used by the process
1. In addition to the shared memory of its own process, it also includes the shared memory of other processes;
2. Although the process uses only a few shared library functions, it contains the size of the entire shared library
3. The formula for calculating the amount of physical memory occupied by a process: RES – SHR;
4. After swap out, it will come down
1.6. S: process status
D = non interruptible sleep state
R= operation
S= sleep
T = track / stop
Z = zombie process
1.7,% CPU: percentage of CPU time used since the last update
It shows the percentage of a core occupied by a process, rather than the percentage of the whole CPU. Sometimes if it is greater than 100, it is because the process uses multiple threads to occupy multiple cores. In the era of multi-core CPU, sometimes it is normal if the system is relatively large.
The default in the header is the total cpu. After pressing the 1 command, if there are multiple core CPUs, all logical CPUs will be displayed (see content 42 for logical CPUs). After the top command, press 1 to see the other CPUs, and the% CPUs in the following table
In terms of system load, the effect of multi-core CPU is similar to that of multi-core CPU. Therefore, when considering the system load, it is necessary to consider that this computer has several CPU and each CPU has several cores. As long as the average load of each core is not more than 1, it indicates that the computer operates normally. If the system pressure is really tight, this situation is normal. The logical CPU calculated by the average system load is one thing.
1.8,% MEM: percentage of physical memory and total memory used by the process
Percentage of physical space memory actually occupied by the project
@Order interpretation
@@: 2.1, 1 display the execution of multiple CPUs
What is the meaning of the total cpu displayed by default for the cpu displayed directly after top?
That is to say, if there is a multi-core cpu, all the logical cpu usage will be displayed (see content 42 for logical cpu). Press 1 after the top command to see other cpu situations. The% cpu in the following table shows the percentage of one core occupied by the process, not the percentage of the whole cpu. Sometimes if it is greater than 100, it is because the process uses multiple threads to occupy the cpu, multiple cores
Tasks: 222 total, 2 running, 220 sleeping, 0 stopped, 0 zombie %Cpu0 : 0.0 us, 1.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu1 : 1.0 us, 0.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu2 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu3 :100.0 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu4 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu5 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu6 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu7 : 0.0 us, 1.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu8 : 1.0 us, 0.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu9 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu10 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu11 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu12 : 0.0 us, 1.0 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu13 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu14 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st %Cpu15 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 32780396 total, 3229812 free, 14268924 used, 15281660 buff/cache KiB Swap: 0 total, 0 free, 0 used. 16398644 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30030 work 20 0 10.338g 1.034g 5180 S 100.0 3.3 33573:45 java 3166 work 20 0 10.120g 805828 4456 S 1.0 2.5 612:42.83 java 12523 work 20 0 10.307g 1.015g 7364 S 1.0 3.2 57:11.89 java 27862 work 20 0 162056 2412 1588 S 1.0 0.0 0:02.02 top 28921 work 20 0 162056 2396 1568 R 1.0 0.0 0:00.44 top
@@: 2.2, P: sort according to the percentage of CPU usage
top - 19:57:34 up 209 days, 23:28, 7 users, load average: 1.00, 1.02, 1.05 Tasks: 220 total, 1 running, 219 sleeping, 0 stopped, 0 zombie %Cpu(s): 6.4 us, 0.1 sy, 0.0 ni, 93.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 32780396 total, 3191436 free, 14263632 used, 15325328 buff/cache KiB Swap: 0 total, 0 free, 0 used. 16403992 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 30030 work 20 0 10.338g 1.034g 5180 S 100.3 3.3 33715:06 java 8744 work 20 0 10.265g 0.984g 5448 S 0.7 3.1 223:51.40 java 12523 work 20 0 10.307g 1.015g 7364 S 0.7 3.2 57:35.84 java 12566 work 20 0 11.015g 1.441g 7812 S 0.7 4.6 100:58.45 java 3166 work 20 0 10.120g 805828 4456 S 0.3 2.5 613:03.48 java 4989 work 20 0 10.180g 919996 6252 S 0.3 2.8 133:03.37 java
@@: 2.3, M: sort by resident memory size
38,xargs
38.1 text content
healerjean$ cat -n text.txt 1 a b c d e f g 2 h i j k l m n 3 o p q 4 r s t
38.1.1. | xargs: output all contents of text in a single line
healerjean$ cat text.txt | xargs a b c d e f g h i j k l m n o p q r s t
38.1.2, | xargs -n4: select how many to print per line (group by space and line feed)
-n multi line output: directly followed by numbers
healerjean$ cat text.txt | xargs -n4 a b c d e f g h i j k l m n o p q r s t
38.1.3. | xargs -dX: separate a string according to the character X
-The d option allows you to customize a delimiter:
healerjean$ echo "nameXnameXnameXname" | xargs -dX name name name name
38.1.4 combined use of - D-N
echo "nameXnameXnameXname" | xargs -dX -n2 name name name name
38.2 combining multiple commands
38.2.1. (query - > delete)
Delete key beginning with vedio keys vedio* | xargs redis-cli del Query the file named. svn and delete find . -name ".svn"| xargs rm -Rf delete mirror docker images | grep registry.cn-qingdao.aliyuncs.com/duodianyouhui/dev-server | xargs docker rmi
39,grep
command | Explain |
---|---|
grep a text.txt | To view the contents of a line containing a string |
grep -n keyword filename | View the contents of the line of a string and display the line number |
grep -i keyword filename | List the matching rows of the searched content, case insensitive during the search |
grep -A 5 keyword filename | Display the last 5 lines matched |
grep -B 5 keywordf filename | Show the first 5 lines that match |
grep -C 5 keyword filename | Display the first and last 5 lines matched, the same as below |
grep -5 *keyword filename | Display the front and back 5 lines matched, fuzzy matching |
grep -c keyword filename | Returns the number of strings in a file |
grep -c keyword filename 1 filename 2 | Returns the number of strings in multiple files |
39.1 general query
39.1.1 display the line number, partial case, query the front and back 5 lines of abc
grep -ni -5 abc scf-client.stdout.log
2.2. Associated result query
healerjean$ find . -name '*.txt' |grep test ./study/cant-breathe/13,redis/7/1,spring redis/spring-redis-test.txt ./study/HealerJean.github.io/_posts/DDKJ/3,AngularJS_Vue/Vue/Template/element-starter/node_modules/hoek/test/modules/ignore.txt
40,find
40.1, - Name: query by name, - iname is not case sensitive
find . -name '*.txt' |grep test
healerjean$ find . -name '*.txt' |grep test ./study/cant-breathe/13,redis/7/1,spring redis/spring-redis-test.txt ./study/HealerJean.github.io/_posts/DDKJ/3,AngularJS_Vue/Vue/Template/element-starter/node_modules/hoek/test/modules/ignore.txt
40.2, - type: search according to the file type (f file, d directory, l soft link file
find . -type f -name "text.txt"
healerjean$ find . -type f -name "text.txt" ./text.txt ./workspace/duodianyouhui/youhui-admin/node_modules/vue-resource/test/data/text.txt
40.3 -print -print0
-print adds a carriage return line feed (default) after each output,
-print0 will not be linked directly into a single line.
root@AaronWong shell_test]# find /ABC/ -type l -print /home/AaronWong/ABC/libcvaux.so /home/AaronWong/ABC/libgomp.so.1 /home/AaronWong/ABC/libcvaux.so.4 [root@AaronWong shell_test]# find /ABC/ -type l -print0 /home/AaronWong/ABC/libcvaux.so/home/AaronWong/ABC/libgomp.so.1/home/AaronWong/ABC/libcvaux.so.4/hom
41. w c: count the number of - c bytes, - w words, - l lines in the file
cat text.txt a b c d e f g h i j k l m n o p q r s t
41.1. Wc-l statistics lines
healerjean$ wc -l text.txt 4 text.txt healerjean$ cat text.txt| wc -l 4
41.2. Wc-w: count the number of words (excluding spaces, line breaks, etc.)
healerjean$ wc -w text.txt 20 text.txt
41.3. Wc-c: count the number of characters (only the number of Bytes is displayed)
healerjean$ wc -c text.txt 40 text.txt
41.3. wc direct printing, printing line number, word book, character number respectively
$ wc testfile # Statistics for testfile files 3 92 598 testfile # testfile file has 3 lines, 92 words and 598 bytes $ wc testfile testfile_1 testfile_2 #Statistics of three files 3 92 598 testfile #The first file has 3 lines, 92 words and 598 bytes 9 18 78 testfile_1 #The second file has 9 lines, 18 words and 78 bytes 3 6 32 testfile_2 #The third file has 3 lines, 6 words and 32 bytes 15 116 708 Total consumption #The total number of lines, words and bytes of the three files is 15, 116 and 708
42. Linux view the number of physical CPUs, cores and logical CPUs
Number of physical CPUs: the number of CPUs actually inserted on the main board (physical id `)
Number of cpu cores: the number of chipsets on a single CPU that can process data, such as dual core, quad core, etc
Number of logical CPUs: Generally speaking, the number of logical CPUs = the number of physical CPUs × the number of each core. If it is not equal, it means that the cpu of the server supports hyper threading technology (HT: simply speaking, it can make one core of the processor play a role in the operating system like two cores. In this way, the available execution resources of the operating system are doubled and the overall performance of the system is greatly improved. At this time, the logical cpu = the number of physical CPUs × the number of cores x 2) this is the reference value of the average load of our top command system
42.1. cat /proc/cpuinfo to view information in cpu
variable | Explain |
---|---|
processor | The id of the logical processor. |
physical id | id of the physical processor |
core id | The id of each core. |
cpu cores | How many cores does a physical CPU have |
siblings | How many logical CPUs does a physical CPU have |
Is it a hyper thread?
If siblings and cpu cores are the same, hyper threading is not supported or not open.
If siblings are twice as many as cpu cores, and two logical CPUs have the same core id, then hyper threading is supported and enabled.
Number of physical CPU s: cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
Check the CPU core: cat /proc/cpuinfo | grep "cores" | uniq
Number of logical CPU s: cat /proc/cpuinfo | grep "processor" | wc -l
42.1.1 my meter test server
Number of physical CPU s: 16
[work@vm10-123-3-2 ~]$ cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l 16
Number of logical cores in a single CPU: 1 (if the number of logical cores in a physical CPU is different, multiple lines will be displayed)
[work@vm10-123-3-2 ~]$ cat /proc/cpuinfo | fgrep "cores" | uniq cpu cores : 1
Number of logical CPU s: 16
[work@vm10-123-3-2 ~]$ cat /proc/cpuinfo | grep "processor" | wc -l 16
**Summary: This machine has 16 and physical CPUs, each CPU has a logic core, and the system has a total of 16 logic CPUs. Obviously, multithreading is not enabled, and it is observed that siblings are not twice as many as cpu cores. The reason is true**
[work@vm10-123-3-2 ~]$ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 0 siblings : 1 core id : 0 cpu cores : 1 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 1 siblings : 1 core id : 0 cpu cores : 1 apicid : 1 initial apicid : 1 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 2 siblings : 1 core id : 0 cpu cores : 1 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 3 siblings : 1 core id : 0 cpu cores : 1 apicid : 3 initial apicid : 3 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 4 siblings : 1 core id : 0 cpu cores : 1 apicid : 4 initial apicid : 4 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 5 siblings : 1 core id : 0 cpu cores : 1 apicid : 5 initial apicid : 5 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 6 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 6 siblings : 1 core id : 0 cpu cores : 1 apicid : 6 initial apicid : 6 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 7 siblings : 1 core id : 0 cpu cores : 1 apicid : 7 initial apicid : 7 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 8 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 8 siblings : 1 core id : 0 cpu cores : 1 apicid : 8 initial apicid : 8 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 9 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 9 siblings : 1 core id : 0 cpu cores : 1 apicid : 9 initial apicid : 9 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 10 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 10 siblings : 1 core id : 0 cpu cores : 1 apicid : 10 initial apicid : 10 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 11 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 11 siblings : 1 core id : 0 cpu cores : 1 apicid : 11 initial apicid : 11 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 12 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 12 siblings : 1 core id : 0 cpu cores : 1 apicid : 12 initial apicid : 12 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 13 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 13 siblings : 1 core id : 0 cpu cores : 1 apicid : 13 initial apicid : 13 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 14 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 14 siblings : 1 core id : 0 cpu cores : 1 apicid : 14 initial apicid : 14 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: processor : 15 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel Core Processor (Skylake) stepping : 3 microcode : 0x1 cpu MHz : 2599.998 cache size : 19712 KB physical id : 15 siblings : 1 core id : 0 cpu cores : 1 apicid : 15 initial apicid : 15 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 bogomips : 5199.99 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management:
42.1.2 other case tests
processor | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
physical id | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
core id | 0 | 2 | 1 | 3 | 0 | 2 | 1 | 3 |
siblings | 4 | 4 | 4 | 4 | 4 | 4 | 4 | 4 |
cpu cores | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
1. Logical processors 0 and 4 reside on the core 0 of physical package 0, and the number of siblings is twice that of cpu cores. This means that logical processors 0 and 4 support hyper threading (HT) technology, as do logical processors 1 and 5, 2 and 6, 3 and 7. This configuration is configured to support two 2 cores and CPUs of hyper threading technology
This means that hyper threading technology is supported, because two logical processors share a kernel. And the server above
Interested, welcome to add blogger wechatHa, bloggers are happy to communicate with friends from all walks of life. If you are satisfied, please give the blogger any amount. If you are interested in wechat transfer, please note your wechat or other contact information. Add blogger wechat.
Please leave a message below. Free discussion with bloggers
WeChat public address | Alipay | |
---|---|---|