首页>>科技 >>内容

linux运维常用命令汇总,Linux运维必备的13款实用工具

发布时间:2023-09-21 11:42:10编辑:温柔的背包来源:

很多朋友对linux运维常用命令汇总,Linux运维必备的13款实用工具不是很了解,每日小编刚好整理了这方面的知识,今天就来带大家一探究竟。

linux运维常用命令汇总,Linux运维必备的13款实用工具

本文介绍了Linux运维的几种实用工具,希望对Linux管理员有所帮助。

1、 查看进程占用的带宽——Nethogs Nethogs是终端下的网络流量监控工具,可以直观地显示每个进程占用的带宽。下载:http://sourceforge.net/projects/nethogs/files/nethogs/0.8/nethogs-0.8.0.tar.gz/download[root@localhost ~]#yum -y install libpcap-devel ncurses-devel[root@localhost ~] # tar zxvf nethogs-0.8.0.tar.gz[root@localhost ~]# cd nethogs[root@localhost nethogs]# make make install[root@localhost nethogs]# nethogs eth02、硬盘读取性能测试- IOZoneIOZone是一款Linux文件系统性能测试工具,可以测试不同操作系统下文件系统的读写性能。下载:http://www.iozone.org/src/current/[root@localhost current]# tar xvf iozone3_420.tar[root@localhost ~]# cd iozone3_420/src/current/[root@localhost current]# make linux[root@本地主机当前]# ./iozone -a -n 512m -g 16g -i 0 -i 1 -i 5 -f /mnt/iozone -Rb ./iozone.xls

-a 使用全自动模式-n 设置自动模式的最小文件大小(千字节)。 -g 设置可在自动模式下使用的最大文件大小(以千字节为单位)。 -i 用于指定要运行哪个测试。 -f 指定测试文件名,完成后自动删除-R 生成Excel到标准输出-b 指定输出到指定文件3、 实时监控磁盘IO-IOTop IOTop命令是一个命令专门用于显示硬盘IO。界面风格与top命令类似。 [root@localhost ~]# yum -y install iotop4、 网络流量监控-IPtrafIPtraf是一个运行在Linux下的简单网络状态分析工具。 [root@localhost ~]# yum -y install iptraf5、 网络流量监控-IFTopiftop是Linux下类似于top的实时流量监控工具。比iptraf 更直观。下载:http://www.ex-parrot.com/~pdw/iftop/[root@localhost ~]# tar zxvf iftop-0.17.tar.gz[root@localhost ~]# cd iftop-0.17 [root@localhost iftop-0.17] # ./configure[root@localhost iftop-0.17]# make make install[root@localhost iftop-0.17]# iftop [root@localhost iftop-0.17]# iftop -i eth0 #指定监控网卡接口

TX:发送流量RX:接收流量TOTAL:总流量Cumm:运行iftop 到当前时间的总流量峰值:峰值流量率:分别表示过去2 秒、10 秒、40 秒的平均流量: 6、 进程实时时间监控-HTopHTop是一个Linux下的交互式进程浏览器,可以用来代替Linux下的top命令。 rpm -ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm (安装第三方YUM 源) [root@localhost ~]# yum -y install htop : 7、 系统资源监控-NMONNMON是广泛应用于AIX及各种Linux操作系统上的监控和分析工具。下载:http://sourceforge.jp/projects/sfnet_nmon/releases/[root@localhost ~]# chmod +x nmon_x86_64_rhel6[ root@localhost ~]# mv nmon_x86_64_rhel6 /usr/sbin/nmon[root@localhost ~]# nmon8、监控多个日志-MultiTailMultiTail用于在控制台打开多个窗口,同时监控多个日志文档。功能与tail命令类似的软件。 rpm -ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm (安装第三方YUM源) [root@localhost ~]# yum -y install multitail[ root @localhost ~]# multitail -e 'fail' /var/log/secure #过滤监控关键字[root@localhost ~]# multitail -l 'ping baidu.com' #监控以下命令-l 要执行的命令执行[root@localhost ~]# multitail -i /var/log/messages -i /var/log/secure #-i 指定一个文件名9、SSH暴力破解保护-Fail2banFail2ban可以监控你的系统日志然后匹配日志Error信息正则表达式匹配执行相应的屏蔽动作。一般调用防火墙屏蔽来下载:http://www.fail2ban.org/wiki/index.php/Downloads[root@localhost ~]# cd failure2ban-0.8.11[root@localhost failure2ban -0.8.11]# python setup.py install[root@localhost failure2ban-0.8.11]# cd files/[root@localhost files]# cp ./redhat-initd /etc/init.d/fail2ban[root@localhost files]# service failure2ban start[root@localhost文件]# chkconfig --addfail2ban[root@localhost 文件]# chkconfigfail2ban on

注意:您需要配置iptables 才能实用。如果重启iptables,也必须重启fail2ban,因为fail2ban的原理是调用iptables实时拦截外部攻击。 [root@localhost ~]# grep -v'^#'/etc/fail2ban/jail.conf | grep -v'^$'[DEFAULT]ignoreip=127.0.0.1/8#忽略本地IP bantime=600#遵守规则封锁后时间findtime=600#遵守规则多久执行封锁。如果600秒达到3次,则执行maxretry=3#最大尝试次数backend=auto#记录修改检测日志gamin、polling 和autousedns=warn [ssh-iptables]enabled=true#默认禁用falsefilter=sshd 动作=iptables[name=SSH, port=ssh, protocol=tcp]# sendmail-whois[name=SSH,dest=收件人电子邮件, sender=发送发件人电子邮件, sendername='Fail2Ban'] logpath=/var/log/sshd. log #响应错误日志一般在/var/log/secure maxretry=5 #尝试次数和错误次数覆盖全局maxretry

注意:所有应用程序保护默认关闭,需要手动开启。 fail2ban.conf文件是日志信息,jail.conf文件是受保护的具体服务和动作配置信息。 [root@localhost ~]# touch /var/log/sshd.log[root@localhost ~]# service failure2ban restart[root@localhost ~]# failure2ban-client status #查看监控已启动Status |- 监狱数量: 1 `- Jail list: ssh-iptables[root@localhost ~]# iptables -L #iptables过滤表有一条规则fail2ban failure2ban-SSH tcp --anywhere Anywhere tcp dpt:ssh

10、 连接会话终端持久化-TmuxTmux是一款类似GNU Screen的优秀终端复用软件,比Screen更全面、灵活、高效。为了保证SSH连接时断开不影响任务运行。 rpm -ivhhttp://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm(安装第三方YUM源)11、页面显示磁盘空间使用情况-Agedu下载:http://www.chiark.greenend.org.uk/~sgtatham/agedu/[root@localhost ~]# tar zxvf Agedu-r9723.tar.gz[root@localhost ~]# cd Agedu-r9723[root@localhost ~]# ./configure[root@localhost ~]# make make install[root@localhost ~]# Agedu -s/#-s 扫描[root@localhost ~]# Agedu -w --address 192.168.0.10:80 #-w 输入Web 链接[root@localhost ~]# Agedu -w --address 192.168.0.108080 --auth none #--auth 关闭身份验证。如果不添加端口号,则会生成随机浏览器访问12、安全扫描。工具-NMapNMap是Linux下的网络连接扫描嗅探工具包,用于扫描互联网上计算机的开放网络连接。下载:http://nmap.org/download.html[root@localhost ~]# tar jxvf nmap-6.40.tar.bz2[root@localhost nmap-6.40]# ./configure[root@localhost nmap-6.40]# make make install[ root@localhost ~]# nmap 192.168.0.10 #获取基本信息[root@localhost ~]# nmap -O 192.168.0.10 #获取系统版本信息[root@localhost ~]# nmap -A 192.168.0.10 #获取系统综合信息[root@localhost ~]# nmap 192.168.0.0/24 #获取某个网段工作设备的基本信息

-sSTCP扫描-sV系统版本检测13、Web压力测试-HttperfHttperf比ab更强大。可以测试Web服务所能承载的最大服务量,发现潜在问题;比如:内存使用情况和稳定性。最大的优点:可以指定压力测试规则,模拟真实环境。下载:http://code.google.com/p/httperf/downloads/list[root@localhost ~]# tar zxvf httperf-0.9.0.tar.gz[root@localhost ~]# cd httperf-0.9.0[root@localhost httperf-0.9.0]# ./configure[root@localhost httperf-0.9.0]# make make install[root@localhost ~]# httperf --hog --server=192.168.0.202 --uri=/index.html --num-conns=10000 --wsess=10,10,0.1

参数说明: -hog:让httperf生成尽可能多的连接。 httperf会根据硬件配置定期生成访问连接; -num-conns:连接数,总共发起10000个请求; -wsess:模拟用户打开网页的时间模式,第一个10表示产生10个会话连接,第二个10表示每个会话连接发出10个请求,0.1表示每个会话连接请求之间的间隔/秒。审稿人:李茜

以上知识分享希望能够帮助到大家!