vi编辑器简单查日志命令

来源:互联网 发布:男士包品牌 知乎 编辑:程序博客网 时间:2024/04/28 14:30

VI标准 linux编辑器http://www.newsmth.net/pc/pccon.php?id=5721&nid=220783

VI编辑器基本操作

i :切换到输入模式

删除:backspace delete 键

退出 插入模式 是 esc 键

在 查看模式下 双击d 键 是 删除一行

查看模式下 按 o 在当前行下面新增 一行 并且 进入 插入模式

回到 行头 home 键      行尾 end 键

向上翻页 Ctrl + u    向下翻页 Ctrl + d    翻页的操作 都是在 查看模式下

 访问日志vi /etc/httpd/logs/access_log

防火墙规则 /etc/sysconfig/iptables

tail -f /etc/httpd/logs/access_log

访问的就是 access

错误的就是error
错误的是 vi /etc/httpd/logs/error_log

 Ctrl + D 下翻页

Ctrl + U 上翻页

退出时 esc + :q! 【强制不保存退出】

退出时 esc+     :wq!【强制并且保存退出】

tail -f /etc/httpd/logs/access_log |grep

---------------------------------------------------------

实时监控访问日志命令tail -f access_log   tail -n 50 -f example.txt

-------------------

日志筛选命令 tail -f ~/access_log |grep XX        (参数=特征)   筛选有特征的命令

-----------------

输出有访问特征mumber的IP tail -f ~/access_log |grep member|awk '{print $1}'        

--------------------

例子:打印出来包含此特征的所有第一列IP保存到CC1文件里

tail -f access_log|grep "311 '-' '-'"|awk '{print $1}' > cc1

第一列是 IP 所以 用 print $1

------------------

 

log-no-refer-agent-ip > c  cc-ip-paser c       service iptables restart    blockthis 116.253.107.86


原创粉丝点击