linux 测试命令合集及举例

来源:本站原创 Linux 超过34 views围观 0条评论

1 .uptime  查系统负载

[root@centos64 ~]# uptime
13:13:38 up 18:15,  1 user,  load average: 0.00, 0.02, 0.05
                                              1     5    15 平均负载
                                             
                                              单CPU负载为1 时为满负载 为1倍数时为超负载
                                              X个CPU负载为X 时为满负载
                                             
2  top  -b 批处理
        -n 输出时刷新的次数

[root@centos64 ~]# top -b -n 1
top – 13:20:22 up 18:22,  1 user,  load average: 0.01, 0.02, 0.05
Tasks:  93 total,   1 running,  92 sleeping,   0 stopped,   0 zombie
%Cpu(s): 
5.3 us,   用户时间
10.5 sy,  系统时间
0.0 ni,   NICE时间
78.9 id,  空闭时间
0.0 wa,   I/O等待
0.0 hi,   处理硬件中断占的时间百分比
5.3 si,   处理软件中断占的时间百分比
0.0 st    流逝的时间   如果有虚拟机,就表示VM中执行其他任务所占的CPU时间比
KiB Mem :   999696 total,   592712 free,   139164 used,   267820 buff/cache

可利用的mem为 free+buff/cache才对
可以按M 进行MEM 排序

KiB Swap:  2097148 total,  2097148 free,        0 used.   678356 avail Mem

   PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
     1 root      20   0  128164   6828   4060 S  0.0  0.7   0:02.72 systemd
     2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd
     3 root      20   0       0      0      0 S  0.0  0.0   0:00.99 ksoftirqd/0
    
    
在top命令下 按K 输入PID 直接终止进程

3.iostat  I/O状态查看命令

[root@centos64 ~]# yum install -y sysstat  —先安装

[root@centos64 ~]# iostat
Linux 3.10.0-693.2.2.el7.x86_64 (centos64)     10/11/2017     _x86_64_    (1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.37    0.00    0.30    0.08    0.00   99.24

Device:      tps每秒传输量    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
sda               0.14         3.46         0.51     238914      35255
dm-0              0.14         3.31         0.48     228567      33187
dm-1              0.00         0.03         0.00       2228          0

4. iotop  混合查看命令

[root@centos64 ~]# iotop |tee /tmp/1.log

Total DISK READ :       0.00 B/s | Total DISK WRITE :       2.36 M/s
Actual DISK READ:       0.00 B/s | Actual DISK WRITE:      18.86 M/s
Total DISK READ :       0.00 B/s | Total DISK WRITE :       2.36 M/s                                                            
18.86 Mual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
   TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                             
11118 be/4 root        0.00 B/s    2.36 M/s  0.00 %  0.00 % sftp-server

5. 链接检测  yum install -y ethtool

[root@centos64 ~]# ethtool ens33
Settings for ens33:
    Supported ports: [ TP ]
    Speed: 1000Mb/s——-
    Duplex: Full——-
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: off (auto)
    Supports Wake-on: d
    Wake-on: d
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes————
   
6. nslookup

[root@centos64 ~]# yum provides */nslookup   ———-查看哪个包包含nslookup
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
32:bind-utils-9.9.4-50.el7.x86_64 : Utilities for querying DNS name servers——-安装包
Repo        : base
Matched from:
Filename    : /usr/bin/nslookup

[root@centos64 ~]# yum install -y bind-utils——–安装
Installed:
  bind-utils.x86_64 32:9.9.4-51.el7                                                                                                 

Dependency Installed:
  bind-libs.x86_64 32:9.9.4-51.el7                                                                                                  

Complete!
   
 
7.  nmap 查接口状态 ,能查正常关闭还是防火墙挡掉

[root@centos64 ~]# yum install -y nmap

[root@centos64 ~]# nmap -p 80 www.jdccie.com

Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-11 15:05 HKT
Stats: 0:00:17 elapsed; 0 hosts completed (0 up), 1 undergoing Ping Scan
Ping Scan Timing: About 100.00% done; ETC: 15:05 (0:00:00 remaining)
Nmap scan report for www.jdccie.com (118.123.7.68)
Host is up (0.0061s latency).
PORT   STATE SERVICE
80/tcp open  http   ———状态

Nmap done: 1 IP address (1 host up) scanned in 17.49 seconds
[root@centos64 ~]# nmap -p 443 www.jdccie.com

Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-11 15:05 HKT
Nmap scan report for www.jdccie.com (118.123.7.68)
Host is up (0.00092s latency).
PORT    STATE    SERVICE
443/tcp filtered https    ———-防火墙过滤

Nmap done: 1 IP address (1 host up) scanned in 0.61 seconds
[root@centos64 ~]#

8.  iftop 查接口流量

[root@centos64 ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm   —加源

[root@centos64 ~]# yum install -y iftop   ———-安装

[root@centos64 ~]# yum provides */iftop
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
perl-SNMP_Session-1.13-5.el7.noarch : SNMP support for Perl 5
Repo        : base
Matched from:
Filename    : /usr/share/doc/perl-SNMP_Session-1.13/test/iftop

9.  tcpdump 抓包

tcpdump -i ens33 -nn tcp     -i接口 -nn 协议

[root@centos64 ~]# tcpdump  -n host 192.168.142.129 -i ens33    -n 不解析 host  -i 接口
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
15:46:58.638357 ARP, Request who-has 192.168.142.1 tell 192.168.142.129, length 46
15:46:58.638920 ARP, Reply 192.168.142.1 is-at 00:50:56:c0:00:08, length 46
^C
2 packets captured

10.   dig &nslookup    dig – DNS lookup utility

[root@centos64 ~]# dig www.jdccie.com

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7 <<>> www.jdccie.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38229
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.jdccie.com.            IN    A

;; ANSWER SECTION:
www.jdccie.com.        899    IN    A    118.123.7.68

;; Query time: 2162 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Wed Oct 11 16:00:20 HKT 2017
;; MSG SIZE  rcvd: 59

文章出自:CCIE那点事 http://www.jdccie.com/ 版权所有。本站文章除注明出处外,皆为作者原创文章,可自由引用,但请注明来源。 禁止全文转载。
本文链接:http://www.jdccie.com/?p=3582转载请注明转自CCIE那点事
如果喜欢:点此订阅本站
  • 相关文章
  • 为您推荐
  • 各种观点