在平常工作中会碰到各类各样的系统问题linux查看服务状态,作为一个合格的开发或运维人员,须要具备一定的快速查看系统运行状态的能力。
本文分享一下常见且超实用的查看系统状态的测量命令。
ifconfig命令用于获取网卡配置信息和查看网路状态等信息的命令。
命令格式为ifconfig[网路设备][参数]
通常使用该命令用于的就是网卡名称、ip配置是否正确、网卡化学地址以及RX、TX的接收数据包与发送数据包的个数及累计流量等信息。
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C
inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
Interrupt:185 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2022 errors:0 dropped:0 overruns:0 frame:0
TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
uname
uname(中文全称unixname)命令用于查看系统内核与系统版本等信息。
格式为uname[-amnrsv][--help][--version]
使用该命令常用命令为uname-a来查看当前系统的内核名称、主机名、内核发行版本、节点名、处理器、硬件平台以及操作系统等信息。
# uname -a
Linux localhost.localdomain 4.11.0-14-generic #20~16.04.1-Ubuntu SMP Wed Aug 9 09:06:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
另外倘若查看当前系统版本的详尽信息,可以通过查看redhat-release文件获取。
# cat /etc/redhat-release
Centos Linux release 7.3.1611 (Core)
uptime
uptime用于查看系统的负载信息。它显示了当前系统时间、系统早已运行的时间、启用终端数目以及平均负载情况。
# uptime
10:10:42 up 5 days, 19:23, 2 users, load average: 2.16, 2.45, 3.15
free
free指令会显示显存的使用情况,包括实体显存,虚拟的交换文件显存,共享显存区段,以及系统核心使用的缓冲区等。
格式为free[-bkmotV][-s]
有时侯系统会由于资源用尽造成宕机linux是什么系统,为此系统管理员要时刻关注系统显存的使用量。
# free
total used free shared buff/cached available
Mem: 254772 184568 70204 9244 5692 25045
Swap: 4063228 0 4063228
history
history命令用于显示历史记录和执行过的命令。
格式为history[参数]
该命令很常用,例如当系统出现了问题,想要查看该系统没出现问题之前用户都做了什么操作,这个时侯就可以通过该命令查看记录信息。
# history
1 service network restart
2 exit
3 id
4 cat /etc/redhat-release
...
who
who命令用于查看当前登录主机的用户终端信息,显示的资料包含了使用者ID、使用的终端机、用户ip、上线时间等等。
命令格式为who-[husfV][user]
# who
root pts/1 2021-10-14 18:51 (192.168.1.157)
root pts/2 2021-10-14 19:48 (192.168.1.23)
last
last命令用于显示用户近来登陆信息。
格式为last[参数]
# last
root pts/1 192.168.1.23 Mon Oct 25 18:51 still logged in
root pts/0 192.168.1.23 Mon Oct 25 07:23 still logged in
sosreport
在linux中,我们可以使用sosreport命令来搜集系统配置及构架信息并输出到确诊文档linux 常用命令,这样当Linux系统出现故障须要联系技术支持人员时,我们可以使用这个命令来简单搜集系统的运行状态和服务配置信息linux查看服务状态,便于后续技术人员便捷定位。
# sosreport
sosreport (version 3.0)
This command will collect diagnostic and configuration information from
this Red Hat Enterprise Linux system and installed applications.
An archive containing the collected information will be generated in
/var/tmp and may be provided to a Red Hat support representative.
Any information provided to Red Hat will be treated in accordance with
the published support policies at:
https://access.redhat.com/support/
The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.
No changes will be made to system configuration.
Press ENTER to continue, or CTRL-C to quit. 此处敲击回车来确认收集信息
Please enter your first initial and last name [ywnz.com]:此处敲击回车,来确认主机名称
Please enter the case number that you are generating this report for:此处敲击回车来确认主机编号
Running plugins. Please wait ...
...
文章评论