Commands commonly used in shell scripts: wget, Curl, SS, Lsof, Nmap, NC, netstat, telnet
Lab Environment Description:
(1) The port used by the remote Nginx Server Ip:192.169.5.136,nginx service is 80;
(2) ip:192.169.5.121 of local Ceshiji
Common commands on server local monitoring service ports: Netstat, SS, Lsof (for short, three ' S ')
Examples of options for common commands:
(1) [[email protected] ~]# NETSTAT-LNP |grep nginx
TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1292/nginx
(2) [[email protected] ~]# Ss-lnp|grep Nginx
LISTEN 0 *:80 *:*
-T (TCP) displays only TCP-related options
-U (UDP) displays only UDP-related options
-N refuses to display aliases, showing all numbers converted to numbers.
-l lists only the service states that are in Listen (listening)
-P Displays the program name that establishes the associated link
(3) [[email protected] ~]# lsof-i: 80|grep nginx
Nginx 1292 root 6u IPv4 8868 0t0 TCP *:http (LISTEN)
Nginx 1293 www 6u IPv4 8868 0t0 TCP *:http (LISTEN)
Nginx 1294 www 6u IPv4 8868 0t0 TCP *:http (LISTEN)
Description:lsof-i: 80 knows which process is consuming the 80 port
commands from remote monitoring Server local port: Telnet, Nmap, NC (for short, three ' n ')
Description: Used primarily to verify that the remote port is turned on
(1) [[email protected] ~]# nc-v-z-w2 192.169.5.136 80
Connection to 192.169.5.136 Port [Tcp/http] succeeded!
[[email protected] ~]# echo $?
0
-V Displays the instruction execution process.
-w< Timeout seconds > Set the time to wait for the connection.
-Z uses 0 in/out mode and is only used when scanning communication ports. Therefore, the above can also be written as follows:
[Email protected] ~]# nc-v-w2 192.169.5.136 80
Connection to 192.169.5.136 Port [Tcp/http] succeeded!
[[email protected] ~]# echo $?
0
(2) [[email protected] ~]# Nmap 192.169.5.136-p 80
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9B/CD/wKioL1lnOLbACpsIAAAvEfXSLfM911.png "title=" 11. PNG "alt=" Wkiol1lnolbacpsiaaavefxslfm911.png "/>
(3) [[email protected] ~]# telnet 192.169.5.136 80|grep Connected
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9B/CD/wKioL1lnOYjQQlUgAAAMh83YkYs641.png "title=" 11. PNG "alt=" Wkiol1lnoyjqqlugaaamh83ykys641.png "/>
Examples of shell scripts are used:
[Email protected] ~]# echo-e ' \ n ' |telnet 192.169.5.136 2>/dev/null|grep Connected |wc-l
1
Server Common test commands: wget, curl
(1) [[email protected] ~]# wget-t 5 baidu.com
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9B/D2/wKiom1lnZl-Cq-B_AABBFxusn0M204.png "title=" 11. PNG "alt=" Wkiom1lnzl-cq-b_aabbfxusn0m204.png "/>
Description:-T indicates a time-out or can be expressed in--timeout.
[Email protected] ~]# wget--timeout=5 baidu.com
(2) [[email protected] ~]# Wget-q-T 5 baidu.com
[[email protected] ~]# echo $?
0
Description:-Q indicates quiet mode (no information output), equivalent to:
[Email protected] ~]# wget-t 5 baidu.com &>/dev/null
[[email protected] ~]# echo $?
0
(3) [[email protected] ~]# wget-t 5--spider baidu.com
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9B/D2/wKiom1lnaNmBpNLwAABCpz_4B2E202.png "title=" 11. PNG "alt=" Wkiom1lnanmbpnlwaabcpz_4b2e202.png "/>
Description:--spider indicates that no download information is detected.
(4) [[email protected] ~]# Wget-o/root/test1 http://baidu.com
[email protected] ~]# cat Test1
<meta http-equiv= "Refresh" content= "0;url=http://www.baidu.com/" >
Description:-O (uppercase letters) is followed by the path where HTTP content is downloaded, meaning that you can customize the file download path with-O.
(5) [[email protected] ~]# Curl baidu.com # #获取指定网页
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9B/D4/wKioL1lnhNyTY8jaAAAVbAYWFuo328.png "title=" 11. PNG "alt=" Wkiol1lnhnyty8jaaaavbaywfuo328.png "/>
(6) [[email protected] ~]# curl-i baidu.com
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9B/D4/wKioL1lnhYGTX9kmAAA6eSiUOlw440.png "title=" 11. PNG "alt=" Wkiol1lnhygtx9kmaaa6esiuolw440.png "/>
Description:-i/--head only returns header information, using head request
(7) [[email protected] ~]# curl-s-I baidu.com|wc-l
12
[Email protected] ~]# curl-i baidu.com|wc-l
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9B/D5/wKiom1lnhwjxRFx-AAAW0NcSEQw080.png "title=" 11. PNG "alt=" Wkiom1lnhwjxrfx-aaaw0ncseqw080.png "/>
Description:-s/--silent indicates quiet mode
(8) [[email protected] ~]# curl-s-o/dev/null baidu.com
[Email protected] ~]# curl-s-o/root/shiyan baidu.com
[email protected] ~]# cat Shiyan
<meta http-equiv= "Refresh" content= "0;url=http://www.baidu.com/" >
Description:-o/--output <file> Indicates the output of the baidu.com download to the/root/shiyan file.
This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1947343
Commands commonly used in shell scripts: wget, Curl, SS, Lsof, Nmap, NC, netstat, telnet