点我

系统状态检测命令

ifconfig

ifconfig 命令用于获取网卡配置与网络状态等信息,格式为“ifconfig [网络设备] [参数]”。使用 ifconfig 命令来查看本机当前的网卡配置与网络状态等信息时,其实主要查看的就是网卡名称、inet 参数后面的 IP 地址、ether 参数后面的网卡物理地址(又称为 MAC 地址),以及 RX、TX 的接收数据包与发送数据包的个数及累计流量。

[test@bogon ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.168.130  netmask 255.255.255.0  broadcast 192.168.168.255
        inet6 fe80::687d:c04:25bb:980d  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:2f:1c:3e  txqueuelen 1000  (Ethernet)
        RX packets 884  bytes 840623 (820.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 397  bytes 32027 (31.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 1000  (Local Loopback)
        RX packets 84  bytes 9492 (9.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 9492 (9.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:ce:27:5f  txqueuelen 1000  (Ethernet)
        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

[test@bogon ~]$ 

uname

uname 命令用于查看系统内核与系统版本等信息,格式为“uname [-a]”。

在使用 uname 命令时,一般会固定搭配上-a 参数来完整地查看当前系统的内核名称、主机名、内核发行版本、节点名、系统时间、硬件名称、硬件平台、处理器类型以及操作系统名称等信息。

[test@bogon ~]$ uname -a
Linux bogon 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[test@bogon ~]$ 

uptime

uptime 用于查看系统的负载信息,格式为 uptime。

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

平均负载值指的是系统在最近 1 分钟、5 分钟、15 分钟内的压力情况(下面加粗的信息部分);负载值越低越好,尽量不要长期超过 1,在生产环境中不要超过 5。

[test@bogon ~]$ uptime
 22:30:11 up 7 min,  3 users,  load average: 0.00, 0.10, 0.10
[test@bogon ~]$ 

free

free 用于显示当前系统中内存的使用量信息,格式为“free [-h]”。

为了保证 Linux 系统不会因资源耗尽而突然宕机,运维人员需要时刻关注内存的使用量。在使用 free 命令时,可以结合使用-h 参数以更人性化的方式输出当前内存的实时使用量信息。

[test@bogon ~]$ free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        886M        373M         13M        561M        715M
Swap:          2.0G          0B        2.0G
[test@bogon ~]$ 

其中:

  • total:内存总量
  • used:已使用的内存量
  • free:可用的内存量
  • shared:进程共享的内存量
  • buff/cache:磁盘缓存的内存量
  • available:缓存的内存量

who

who 用于查看当前登入主机的用户终端信息,格式为“who [参数]”。

可以快速显示出所有正在登录本机的用户的名称以及他们正在开启的终端信息。

[test@bogon ~]$ who
test     :0           2024-12-28 22:22 (:0)
test     pts/0        2024-12-28 22:23 (:0)
test     pts/1        2024-12-28 22:24 (192.168.168.1)
[test@bogon ~]$ 

last

last 命令用于查看所有系统的登录记录,格式为“last [参数]”。

使用 last 命令可以查看本机的登录记录。但是,由于这些信息都是以日志文件的形式保存在系统中,因此黑客可以很容易地对内容进行篡改。千万不要单纯以该命令的输出信息而判断系统有无被恶意入侵!

[test@bogon ~]$ last
test     pts/1        192.168.168.1    Sat Dec 28 22:24   still logged in   
test     pts/0        :0               Sat Dec 28 22:23   still logged in   
test     :0           :0               Sat Dec 28 22:22   still logged in   
reboot   system boot  3.10.0-862.el7.x Sat Dec 28 22:22 - 22:36  (00:13)  
test     pts/1        :0               Fri Dec 27 23:17 - 23:38  (00:20)  
test     pts/0        :0               Fri Dec 27 22:49 - 23:38  (00:48)  
test     :0           :0               Fri Dec 27 22:48 - down   (00:49)  
reboot   system boot  3.10.0-862.el7.x Fri Dec 27 22:43 - 23:38  (00:55)  

wtmp begins Fri Dec 27 22:43:25 2024
[test@bogon ~]$ 

history

history 命令用于显示历史执行过的命令,格式为“history [-c]”。

history 命令应该是作者最喜欢的命令。执行 history 命令能显示出当前用户在本地计算机中执行过的最近 1000 条命令记录。如果觉得 1000 不够用,还可以自定义/etc/profile 文件中的HISTSIZE 变量值。

在使用 history 命令时,如果使用-c 参数则会清空所有的命令历史记录。还可以使用“!编码数字”的方式来重复执行某一次的命令。

[test@bogon ~]$ history
    1  man man
    2  echo xbxaq.com
    3  date
    4  date "+%Y-%d-%m"
    5  date "+%H-%S"
    6  date "+%H-%S-%M"
    7  date -h
    8  date --help
    9  clea
   10  clear
   11  wget https://xbxaq.com/doc/67/ -P /tmp/xbxaq.com
   12  wget https://xbxaq.com/doc/67/ -P /tmp/xbxaq.com --no-check-certificate
   13  ll /
   14  ll /tmp
   15  clear
   16  ll /tmp
   17  ll /tmp/xbxaq.com/
   18  ps -aux
   19  top
   20  pidof ssh
   21  pidof sshd
   22  pidof 1184
   23  pidof sshd
   24  kill 1184
   25  su root
   26  ifconfig
   27  uname -a
   28  ll /etc/

注意:历史命令会被保存到用户家目录中的.bash_history 文件中。Linux 系统中以点(.)开头的文件均代表隐藏文件,这些文件大多数为系统服务文件,可以用 cat 命令查看其文件内容。

[test@bogon ~]$ cat .bash_history 
man man
echo xbxaq.com
date
date "+%Y-%d-%m"
date "+%H-%S"
date "+%H-%S-%M"
date -h
date --help
clea
clear
wget https://xbxaq.com/doc/67/ -P /tmp/xbxaq.com
wget https://xbxaq.com/doc/67/ -P /tmp/xbxaq.com --no-check-certificate
ll /
ll /tmp
clear
ll /tmp
ll /tmp/xbxaq.com/
ps -aux
top
pidof ssh
pidof sshd
pidof 1184

分类: Linux

评论

-- 评论已关闭 --

目录