02系统状态检测命令

系统状态检测命令

1. ifconfig 命令

ifconfig 命令用于获取网卡配置与网络状态等信息,格式为“ifconfig [网络设备][参数]"

日常使用中主要查看的就是网卡名称、inet参数后面的IP地址、ether参数后面的网卡物理地址(又称MAC地址)等。

[root@bogon /]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.206.131  netmask 255.255.255.0  broadcast 192.168.206.255
        inet6 fe80::4697:ba36:6eda:dd1a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:23:b8:65  txqueuelen 1000  (Ethernet)
        RX packets 1327  bytes 108782 (106.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 843  bytes 682198 (666.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

上例中,网卡名称是:ens33,IP地址是:192.168.206.131,MAC地址为:00:0c:29:23:b8:65。

2. uname 命令

uname 命令用于查看系统内核与系统版本等信息,格式为“uname [-a]”.
[root@bogon /]# uname -a
Linux bogon 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
补充:如果要查看当前系统版本的详细信息,则需要查看redhat-release文件,其命令如下:
[root@bogon /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

3. uptime 命令

uptime 命令用于查看系统的负载信息,格式为uptime。
[root@bogon /]# uptime
 15:40:40 up  1:09,  1 user,  load average: 0.00, 0.01, 0.05

该命令用于显示当前系统时间、系统已运行时间、启用终端数量以及平均负载等信息。

4. free 命令

free 命令用于显示当前系统中内存的使用量情况,格式为“free [-h]”。
[root@bogon /]# free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        134M        1.5G        8.5M        161M        1.5G
Swap:          2.0G          0B        2.0G

5. who 命令

who 命令用于查看当前登入主机的用户终端信息,格式为“who [参数]”。
[root@bogon /]# who
root     pts/0        2018-06-07 15:08 (192.168.206.1)

6. last 命令

last 命令用于查看所有系统的登录记录,格式为“last [参数]”。
[root@bogon /]# last
hk       tty1                          Thu Jun  7 15:52   still logged in
root     pts/0        192.168.206.1    Thu Jun  7 15:08   still logged in
hk       tty1                          Thu Jun  7 14:43 - 15:05  (00:22)
root     pts/0        192.168.206.1    Thu Jun  7 14:39 - 15:07  (00:28)
hk       pts/0        192.168.206.1    Thu Jun  7 14:34 - 14:37  (00:03)
root     pts/0        192.168.206.1    Thu Jun  7 14:32 - 14:33  (00:01)

7. history 命令

history命令用于显示历史执行过的命令,格式为“history [-c]”。
[root@bogon /]# history
    1  history
    2  ls
    3  pwd
    4  who
    5  history
[root@bogon /]# !4
who
hk       tty1         2018-06-07 15:52
root     pts/0        2018-06-07 15:08 (192.168.206.1)

使用该命令可以显示当前用户在本地计算机中执行过的最近1000条命令记录。

在使用 history 命令时,如果使用 -c 参数则会清空所有的命令历史记录。

还可以使用“!编码数字”的方式来重复执行某一次的命令。

补充:历史命令会被保存到用户目录的.bash_history文件中。可以使用cat命令查看其文件的内容。
[root@bogon /]# cat ~/.bash_history
yun inatall gcc
yum inatall gcc
yum inatall g++
gcc -v
ping www.baidu.com
ping 192.168.128.1
cd /etc/sysconfig/network-scripts/
ls

猜你喜欢

转载自www.cnblogs.com/rock-cc/p/9165795.html