linux 測試命令合集及舉例

來源:本站原創 Linux 超過744 views圍觀 0條評論

1 .uptime  查系統負載

[[email protected] ~]# 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 輸出時刷新的次數

[[email protected] ~]# 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狀態查看命令

[[email protected] ~]# yum install -y sysstat  —先安裝

[[email protected] ~]# 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  混合查看命令

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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

[[email protected] ~]# 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 查接口狀態 ,能查正常關閉還是防火墻擋掉

[[email protected] ~]# yum install -y nmap

[[email protected] ~]# nmap -p 80 www.qdxgqk.live

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.qdxgqk.live (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
[[email protected] ~]# nmap -p 443 www.qdxgqk.live

Starting Nmap 6.40 ( http://nmap.org ) at 2017-10-11 15:05 HKT
Nmap scan report for www.qdxgqk.live (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
[[email protected] ~]#

8.  iftop 查接口流量

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

[[email protected] ~]# yum install -y iftop   ———-安裝

[[email protected] ~]# 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 協議

[[email protected] ~]# 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

[[email protected] ~]# dig www.qdxgqk.live

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7 <<>> www.qdxgqk.live
;; 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.qdxgqk.live.            IN    A

;; ANSWER SECTION:
www.qdxgqk.live.        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.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3582轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
?
?
萌宠夺宝游戏