- ping host — 测试目标主机是否连通
效果如下:
➜ anyang ping www.baidu.com
PING www.a.shifen.com (119.75.217.109) 56(84) bytes of data.
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=1 ttl=52 time=32.1 ms
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=2 ttl=52 time=31.1 ms
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=3 ttl=52 time=64.4 ms
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=4 ttl=52 time=45.0 ms
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=5 ttl=52 time=63.9 ms
64 bytes from 119.75.217.109 (119.75.217.109): icmp_seq=6 ttl=52 time=25.4 ms
^C
--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5001ms
rtt min/avg/max/mdev = 25.419/43.695/64.408/15.620 ms
- whois domain — 查看域名的详细信息
效果如下:
➜ anyang whois jianshu.com
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: JIANSHU.COM
Registrar: NAME.COM, INC.
Sponsoring Registrar IANA ID: 625
Whois Server: whois.name.com
Referral URL: http://www.name.com
Name Server: F1G1NS1.DNSPOD.NET
Name Server: F1G1NS2.DNSPOD.NET
Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Updated Date: 06-apr-2016
Creation Date: 20-mar-2008
Expiration Date: 20-mar-2020
- dig domain — 域名解析(将域名映射到地址)
- dig -x host — 逆向查询(将地址映射到域名)
效果如下:
➜ anyang dig jianshu.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> jianshu.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64332
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;jianshu.com. IN A
;; ANSWER SECTION:
jianshu.com. 600 IN A 106.75.2.241
;; Query time: 144 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Wed Dec 07 17:50:26 CST 2016
;; MSG SIZE rcvd: 56
➜ anyang dig -x 202.200.112.200
; <<>> DiG 9.10.3-P4-Ubuntu <<>> -x 202.200.112.200
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2080
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;200.112.200.202.in-addr.arpa. IN PTR
;; ANSWER SECTION:
200.112.200.202.in-addr.arpa. 3600 IN PTR xfz.xaut.cn.
200.112.200.202.in-addr.arpa. 3600 IN PTR xfz.xaut.edu.cn.
;; Query time: 115 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Wed Dec 07 17:55:59 CST 2016
;; MSG SIZE rcvd: 109
- wget file — 下载文件
- wget -c file — 断点续传
- wget -r url — 递归下载文件
效果如下:
➜ anyang wget http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
--2016-12-07 18:11:35-- http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
Resolving cn.wordpress.org (cn.wordpress.org)... 66.155.40.250, 66.155.40.249
Connecting to cn.wordpress.org (cn.wordpress.org)|66.155.40.250|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://cn.wordpress.org/wordpress-3.1-zh_CN.zip [following]
--2016-12-07 18:11:37-- https://cn.wordpress.org/wordpress-3.1-zh_CN.zip
Connecting to cn.wordpress.org (cn.wordpress.org)|66.155.40.250|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3448957 (3.3M) [application/zip]
Saving to: ‘wordpress-3.1-zh_CN.zip’
wordpress-3.1-zh_CN 7%[> ] 244.22K 31.1KB/s eta 1m 45s ^C
➜ anyang wget -c http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
--2016-12-07 18:11:59-- http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
Resolving cn.wordpress.org (cn.wordpress.org)... 66.155.40.250, 66.155.40.249
Connecting to cn.wordpress.org (cn.wordpress.org)|66.155.40.250|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://cn.wordpress.org/wordpress-3.1-zh_CN.zip [following]
--2016-12-07 18:12:01-- https://cn.wordpress.org/wordpress-3.1-zh_CN.zip
Connecting to cn.wordpress.org (cn.wordpress.org)|66.155.40.250|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 3448957 (3.3M), 3194644 (3.0M) remaining [application/zip]
Saving to: ‘wordpress-3.1-zh_CN.zip’
wordpress-3.1-zh_CN 100%[+==================>] 3.29M 198KB/s in 12s
2016-12-07 18:12:16 (268 KB/s) - ‘wordpress-3.1-zh_CN.zip’ saved [3448957/3448957]
➜ anyang ls
file1 learngit test wordpress-3.1-zh_CN.zip
- telnet host — 远程登录
- curl url — 通过 url 语法在命令行下上传或下载文件
- netstat — 显示各种网络相关的信息
- netstat -a — 显示所有端口
- netstat -at — 显示所有 tcp 端口
- netstat -au — 显示所有 udp 端口
效果如下:
➜ anyang netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:hostmon 0.0.0.0:* LISTEN
tcp 0 0 anyang:domain 0.0.0.0:* LISTEN
tcp 0 0 localhost:domain 0.0.0.0:* LISTEN
tcp 0 0 localhost:ipp 0.0.0.0:* LISTEN
tcp 0 0 anyang:50716 140.205.172.5:https TIME_WAIT
tcp 0 0 anyang:38262 119.167.151.130:http TIME_WAIT
tcp 0 0 anyang:59446 113.200.101.240:https TIME_WAIT
tcp 0 0 anyang:48646 106.75.2.241:http ESTABLISHED
tcp 0 0 anyang:56038 123.138.46.49:https TIME_WAIT
tcp 0 0 anyang:53002 linux.cn:https TIME_WAIT
tcp 0 0 anyang:35568 123.138.46.32:https TIME_WAIT
tcp 0 0 anyang:37560 ec2-54-222-216-13:https ESTABLISHED
tcp 0 0 anyang:57712 hn.kd.ny.adsl:https TIME_WAIT
tcp 0 0 anyang:34666 123.138.46.33:https TIME_WAIT
tcp6 0 0 [::]:hostmon [::]:* LISTEN
tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN
➜ anyang netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:51767 0.0.0.0:*
udp 0 0 0.0.0.0:ipp 0.0.0.0:*
udp 0 0 0.0.0.0:mdns 0.0.0.0:*
udp 0 0 0.0.0.0:hostmon 0.0.0.0:*
udp 0 0 anyang:domain 0.0.0.0:*
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 0.0.0.0:59548 0.0.0.0:*
udp6 0 0 [::]:mdns [::]:*
udp6 0 0 [::]:hostmon [::]:*
udp6 0 0 [::]:40747 [::]:*
相关资料:
- 29个你必须知道的Linux命令: http://www.imooc.com/article/1285
- 常用命令行介绍: https://github.com/iamcoach/console/blob/master/COMMANDS.md
- 常用命令行cheet sheet: https://bbs.excellence-girls.org/topic/167
- 书籍《鸟哥的Linux私房菜》: https://book.douban.com/subject/4889838/
- Ubuntu各种技巧:http://wiki.ubuntu.org.cn/UbuntuSkills