Use sosreport command to generate diagnostic package

[RHEL] -7- common system state detection command

introduction

This article describes the most commonly used several RHEL system state detection command, including: network status, memory, host name and its architecture, system load, and user login status.

Article Directory

0 × 1. View network state

RHEL6 previous system most commonly used to view network status command is ifconfig, following are some basic usage of this command, for example:

01 [[email protected] ~]# ifconfig
02 #eno16777736为网卡的标识名称,inet后是这块网卡的IP地址,子网掩码,广播地址
03 eno16777736:  ..省略部分输出
04   inet 192.168.1.106  netmask 255.255.255.0  broadcast 192.168.1.255
05   ..省略部分输出
06   #ether后是这块网卡的MAC地址
07   ether 00:0c:29:78:31:59  txqueuelen 1000  (Ethernet)
08   #RX packets为这块网卡接收到的数据量
09   RX packets 13099  bytes 14064504 (13.4 MiB)
10   RX errors 0  dropped 0  overruns 0  frame 0
11   #TX packets为这块网卡发送的数据量
12   TX packets 1646  bytes 168262 (164.3 KiB)
13   TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
14  
15 #系统默认的环回接口
16 lo: flags=73 ..省略部分输出

In previous versions RHEL6, wired LAN card number is generally "eth" at the beginning, the wireless network card numbers usually begin with "wlan", and later versions RHEL7 in, "en" prefix stands for Ethernet, "wl" prefix stands for Wireless card, "vir" prefix stands for virtual interface.

ifconfig not only can be used to see if the card information can be used to disable or enable the network card, network card configuration to a temporary IP address (restart failure);
please refer to [ [Linux utility command] -12- Network Configuration Analysis ]

In RHEL7 later, the official recommended to use ip command to view and configure the network interface information, here are some common ip command, for example;

● Check the IP address and card information (with ifconfig):

01 #可以简写成ip a
02 [[email protected] ~]# ip addr
03 1: lo: <LOOPBACK,UP,LOWER_UP>
04     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
05     inet 127.0.0.1/8 scope host lo
06        valid_lft forever preferred_lft forever
07     inet6 ::1/128 scope host
08        valid_lft forever preferred_lft forever
09 2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP>
10    #MAC地址
11     link/ether 00:0c:29:78:31:59 brd ff:ff:ff:ff:ff:ff
12    #inet IP/子网掩码 brd 广播地址
13     inet 192.168.1.106/24 brd 192.168.1.255 scope global dynamic eno16777736
14        valid_lft 4333sec preferred_lft 4333sec
15     inet6 fe80::20c:29ff:fe78:3159/64 scope
16  
17 #单独查看一块网卡
18 [[email protected] ~]# ip addr show eno16777736
19 2: eno16777736:
20  ink/ether 00:0c:29:78:31:59 brd ff:ff:ff:ff:ff:ff
21  inet 192.168.1.106/24 brd 192.168.1.255 scope global dynamic eno16777736
22  valid_lft 6655sec preferred_lft 6655sec
23  inet6 fe80::20c:29ff:fe78:3159/64 scope link
24   valid_lft forever preferred_lft forever

● Check the interface card packet statistics (more detailed than ifconfig)

01 [[email protected] ~]# ip -s link
02 1: lo:
03  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
04  RX: bytes  packets  errors  dropped overrun mcast  
05  980        10       0       0       0       0     
06  X: bytes  packets  errors  dropped carrier collsns
07  980        10       0       0       0       0     
08 2: eno16777736:
09  link/ether 00:0c:29:78:31:59 brd ff:ff:ff:ff:ff:ff
10  #接收到的数据包统计
11  RX: bytes  packets  errors  dropped overrun mcast  
12  9393834    6644     0       0       0       0   
13  #发送出的数据包统计 
14  TX: bytes  packets  errors  dropped carrier collsns
15  87120      1123     0       0       0       0
16  
17 #单独查看一块网卡的数据统计信息
18 [[email protected] ~]# ip -s link show eno16777736

● display system routing tables, add and delete routing entries:

01 #显示当前路由表,第一条为默认路由,第二条为局域网路由
02 [[email protected] ~]# ip route show
03 default via 192.168.1.1 dev eno16777736  proto static  metric 1024
04 192.168.1.0/24 dev eno16777736  proto kernel  scope link  src 192.168.1.106
05  
06 ##删除路由条目
07 #删除默认路由
08 [[email protected] ~]# ip route del default via 192.168.1.1
09  
10 #删除普通路由
11 [[email protected] ~]# ip route del 192.168.1.0/24
12  
13 ##添加路由条目
14 #添加一条默认路由(未知网段的数据发往192.168.1.1,设备号为eno16777736)
15 [[email protected] ~]# ip route add default via 192.168.1.1 dev eno16777736
16  
17 #添加一条普通路由(发往192.168.2.0/24网段的数据发往192.168.1.1,设备号为eno16777736)
18 [[email protected] ~]# ip route add 192.168.2.0/24 via 192.168.1.1 dev eno16777736

● Check the ARP table, ARP binding and delete

01 #查看本地ARP缓存,命令可简写成ip nei
02 [[email protected] ~]# ip neighbor
03 192.168.1.1 dev eno16777736 lladdr ec:26:ca:01:e3:c2 DELAY
04  
05 #添加静态ARP绑定
06 [[email protected] ~]# ip nei add 192.168.1.23 lladdr 11:11:11:11:11:11 dev eno16777736 nud perm
07  
08 [[email protected] ~]# ip nei
09 192.168.1.23 dev eno16777736 lladdr 11:11:11:11:11:11 PERMANENT
10 192.168.1.1 dev eno16777736 lladdr ec:26:ca:01:e3:c2 REACHABLE
11  
12 #删除ARP条目(必须指定IP与对应的网卡地址)
13 [[email protected] ~]# ip nei del 192.168.1.23 dev eno16777736

0 × 2. Display system version using the uname

When we need to download and install some software, it may need to first understand the framework and core information system, such as their own, this time you can use the uname command, for example:

1 #这条命令只需要看下面注释的三个部分即可
2 [[email protected] ~]# uname -a
3 Linux qingsword.com(机器名称) 3.10.0-123.el7(内核版本) .x86_64 #1 SMP Mon May 5 11:16:57 EDT 2014 x86_64 x86_64 x86_64(64位系统) GNU/Linux
4  
5 #除此之外,如果想查看RHEL的版本信息,可以查看下面这个文件中的内容
6 [[email protected] ~]# more /etc/redhat-release
7 Red Hat Enterprise Linux Server release 7.0 (Maipo)

0 × 3. Uptime command to view the system load using

In addition to using the system load command to view top outer, uptime command can be output in the first line of the top order to print out separately:

1 [[email protected] ~]# uptime
2 00:51:25 up 9 min,  2 users,  load average: 0.02, 0.52, 0.49

0 × 4. See using the memory free command

possible to separate free command is displayed in the top command output lines 4 and 5:

01 #默认以K为单位
02 [[email protected] ~]# free
03              total       used       free     shared    buffers     cached
04 Mem:       1870784    1069868     800916       9836        924     279848
05 -/+ buffers/cache:     789096    1081688
06 Swap:            0          0          0
07  
08 #以M为单位
09 [[email protected] ~]# free -m
10              total       used       free     shared    buffers     cached
11 Mem:          1826       1044        782          9          0        273
12 -/+ buffers/cache:        770       1056
13 Swap:            0          0          0
14  
15 #人性化输出
16 [[email protected] ~]# free -h
17              total       used       free     shared    buffers     cached
18 Mem:          1.8G       1.0G       781M       9.6M       924K       273M
19 -/+ buffers/cache:       771M       1.0G
20 Swap:           0B         0B         0B

0 × 5. See terminal records log

who command to view the currently logged in user, last login can view the history:

1 #本例中:0为root登录的图形界面,pts/0为图形界面中打开的一个shell窗口
2 [[email protected] ~]# who
3 root  :0  2016-11-14 00:43 (:0)
4 root  pts/0  2016-11-14 00:45 (:0)
5  
6 #使用last命令可以查看所有系统的登入记录,这些记录是保存在文件中的,命令只是查看了文件中的内容,文件内容是可以被篡改的,所以用这条命令来判断系统有没有被非法登录过并不可取
7 [[email protected] ~]# last
8 root  pts/0 :0  Mon Nov 14 00:45 still logged in

0 × 6. View the current user command history

history command can be used to view a list of the current user input through the command history, and can execute a command directly removed from the history list:

01 #查看历史命令列表中的最后三条记录
02 [[email protected] ~]# history | tail -n 3
03   154  history
04   155  who
05   156  history tail -n 3
06  
07 #重新执行第155条命令
08 [[email protected] ~]# !155
09 who
10 root     :0       2016-11-14 00:43 (:0)
11 root     pts/0    2016-11-14 00:45 (:0)
12  
13 #历史命令记录最多可以保存的条目数量是/etc/profile文件中的HISTSIZE变量决定的,我的系统中最多为1000条
14 [[email protected] ~]# more /etc/profile | grep HISTSIZE=
15 HISTSIZE=1000
16  
17 #暂时清空历史命令记录(重启后失效)
18 [[email protected] ~]# history -c
19  
20 #要想真正清空当前用户的命令历史记录,需要清空当前用户家目录中的.bash_history文件中的所有数据
21 [[email protected] ~]# vim ~/.bash_history
22 1000dd
23 :wq

0 × 7. Sosreport command generation diagnostic kits using

When we encounter not solve the problem, Red Hat provides a command sosreport used to collect and generate diagnostic messages, the collected diagnostic information (a compressed packet) sent to Red Hat, they will provide the basis of this compressed package to determine the root cause of the problem is the content, the solution will be sent to you (paid service):

1 #直接在终端中输入命令,默认三个回车后,开始收集系统信息
2 [[email protected] ~]# sosreport
3 Your sosreport has been generated and saved in:
4 #最后会生成一个tar归档,将这个压缩包发送给红帽技术支持即可
5  /var/tmp/sosreport-qingsword.com-20161114012652.tar.xz

* Reproduced please specify from: Mostly edge (QingSword.COM)

* Original connection: http://www.qingsword.com/qing/rhel-7.html

Guess you like

Origin www.cnblogs.com/xuanbjut/p/11605523.html