8. ssh user@server bash < /path/ to/ local/script. sh 在远程机器上运行一段脚本。这条命令最大的好处就是不用把脚本拷到远程机器上。
9. screen -d -m -S some_ name ping my_ router 后台运行一段不终止的程序,并可以随时查看它的状态。- d -m 参数启动“ 分离” 模式,- S 指定了一个session 的标识。可以通过- R 命令来重新“ 挂载” 一个标识的session。更多细节请参考screen 用法man screen。
10. wget --random- wait -r -p -e robots= off -U mozilla http:// www. example. com 下载整个www. example. com 网站。11. curl ifconfig. me 当你的机器在内网的时候,可以通过这个命令查看外网的IP。
1 [cdh42@master httpTest]$ python -m SimpleHTTPServer
2 Serving HTTP on 0.0.0.0 port 8000 ...
3 192.168.153.128 - - [27/Dec/2014 19:10:46] "GET / HTTP/1.1" 200 -
4 192.168.153.128 - - [27/Dec/2014 19:10:46] code 404, message File not found
5 192.168.153.128 - - [27/Dec/2014 19:10:46] "GET /favicon.ico HTTP/1.1" 404 -
6 192.168.153.128 - - [27/Dec/2014 19:10:46] code 404, message File not found
7 192.168.153.128 - - [27/Dec/2014 19:10:46] "GET /favicon.ico HTTP/1.1" 404 -
8 192.168.153.128 - - [27/Dec/2014 19:12:22] "GET / HTTP/1.1" 200 -
9 192.168.153.128 - - [27/Dec/2014 19:13:03] "GET / HTTP/1.1" 200 -
10 [cdh42@master httpTest]$ netstat -lnpt
11 (Not all processes could be identified, non-owned process info
12 will not be shown, you would have to be root to see it all.)
13 Active Internet connections (only servers)
14 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
15 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
16 tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
17 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
18 tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 2574/python
19 tcp 0 0 :::22 :::* LISTEN -
20 tcp 0 0 ::1:631 :::* LISTEN -
21 tcp 0 0 ::1:25 :::* LISTEN -
View Code
在目录下写了一个index.html显示的结果如下,it's fun.
1 <html>
2 <head>
3 <title>test python web server</title>
4 </head>
5 <body>
6 This is a test python web server, <b>hello!</b>
7 </body>
8 </html>
View Code
14. history | awk '{CMD[$ 2]++; count++;} END { for (a in CMD )print CMD[ a] " " CMD[ a]/ count* 100 "% " a }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 这行脚本能输出你最常用的十条命令,由此甚至可以洞察你是一个什么类型的程序员。看不懂行代码?没关系,系统的学习一下* nix shell 脚本吧,力荐《Linux 命令行与Shell 脚本编程大全》。最后还是那句Shell 的至理名言:“Where there is a shell,there is a way!”