欢迎来到xieyy.cn这是谢YY的个人博客。主要提供服务器管理经验小结及在虚拟主机、邮局及DNS相关产品的维护信息。
Jun 24
昨天写了一篇linux下Apache严重漏洞攻击代码公开的文章。今天TTplay回复我,为什么当时查看httpd的时候,不使用watch命令。

关于watch命令,之前使用的都不多,今晚特别去了解一下linux下的watch命令。

Usage: watch [-dhntv] [--differences[=cumulative]] [--help] [--interval=] [--no-title] [--version]
  -d, --differences[=cumulative]        highlight changes between updates
                (cumulative means highlighting is cumulative)
  -h, --help                            print a summary of the options
  -n, --interval=              seconds to wait between updates
  -v, --version                         print the version number
  -t, --no-title                        turns off showing the header

watch -- 监测命令的运行结果

watch是一个非常实用的命令,基本所有的Linux发行版都带有这个小工具,如同名字一样,watch可以帮你监测一个命令的运行结果,省得你一遍遍的手动运行。

在Linux下,watch是周期性的执行下个程序,并全屏显示执行结果。

-d, --differences[=cumulative] 高亮显示变动
-n, --interval= 周期(秒)

如:watch -n 1 -d netstat -ant
其它操作:
切换终端: Ctrl+x
退出watch:Ctrl+g

watch -n 1 -d 'pstree|grep http' 每隔一秒高亮显示http链接数的变化情况。 后面接的命令若带有管道符,需要加''将命令区域归整。

在查看攻击时,经常使用的方式有如下:
实时查看模拟攻击客户机建立起来的连接数,使用
watch 'netstat -an | grep:21 | \ grep<模拟攻击客户机的IP>| wc -l'  

查看模拟攻击客户机被 DROP 的数据包数。

watch 'iptables -L -n -v | \grep<模拟攻击客户机的IP>'  

谢谢TTPLAY~
Tags: ,
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]