Linux 系统管理——系统资源查看

1、vmstat 命令监控系统资源

[root@localhost ~]# vmstat 【刷新延时  刷新次数】

例如:

[root@localhost ~]# vmstat 1  3

[root@localhost ~]# vmstat 1 3
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0      0 991384  30628 521036    0    0   113    63   51   59  1  2 97  1  0	
 0  0      0 991328  30628 521064    0    0     0     0   25   33  0  0 100  0  0	
 0  0      0 991328  30628 521064    0    0     0     0   18   20  0  0 100  0  0	

最主要的是看内存memory 和CPU

该命令实际和 top差不多

2、dmesg 开机时内核检测信息

[root@localhost ~]# dmesg

[root@localhost ~]# dmesg | grep CPU

特别注意:Linux如何使用命令查看系统的硬件信息?

       dmesg  就是一个非常有用的命令

3、free  命令查看内存使用状态

[root@localhost ~]# free  [-b|-k|-m|-g]

选项:

  -b   :以字节为单位显示

   -k  : 以KB为单位显示,默认就是以KB为单位显示

   -m  :以MB为单位显示

   -g   : 以GB为单位显示

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:       1906188     913664     992524       3692      30628     521064
-/+ buffers/cache:     361972    1544216
Swap:      2097148          0    2097148
[root@localhost ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1861        892        969          3         29        508
-/+ buffers/cache:        353       1508
Swap:         2047          0       2047
[root@localhost ~]# 

buffer 缓冲   cached 缓存

3.1、缓存和还重的区别:

简单来说

缓存(cache)是用来加速数据从硬盘中“读取”到内存的,

而缓冲(buffer)是用来加速数据从内存“写入”硬盘的。

4、查看CPU信息

[root@localhost ~]# cat /proc/cpuinfo

注意:一旦断电,/proc/cpuinfo 中的信息就会丢失,每次开机都会检查该文件,并写入内容

5、uptime 命令

[root@localhost ~]# uptime

#显示系统的启动时间和平均负载,也就是top命令的第一行。w命令也可以看到这个数据。

6、查看系统与内核相关信息

[root@localhost ~]# uname 【选项】

选项:

-a  :查看系统所有相关信息

-r   :查看内核版本

-s   :查看内核名称

7、判断当前系统的位数,如何做?

不能直接查看,但可以通过系统内核shell外的命令文件间接查看,比如:

[root@localhost ~]# file  /bin/ls

[root@localhost ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
[root@localhost ~]# 

8、如何查询当前Linux 系统的发行版本

[root@localhost ~]# lsb_release -a

[root@localhost ~]# lsb_release -a
LSB Version:	:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:	CentOS
Description:	CentOS release 6.10 (Final)
Release:	6.10
Codename:	Final

9、列出进程打开或使用的文件信息

[root@localhost ~]# lsof 【选项】

#列出进程调用或打开的文件的信息

选项:

-c  字符串:只列出以字符串开头的进程打开的文件

-u  用户名; 只列处某个用户的进程打开的文件

-p  pid   :列出某个PID进程打开的文件

[root@localhost ~]# lsof -c init
COMMAND PID USER   FD   TYPE             DEVICE SIZE/OFF   NODE NAME
init      1 root  cwd    DIR              253,0     4096      2 /
init      1 root  rtd    DIR              253,0     4096      2 /
init      1 root  txt    REG              253,0   150352 781891 /sbin/init
init      1 root  mem    REG              253,0    66432 130338 /lib64/libnss_files-2.12.so
init      1 root  mem    REG              253,0  1930416 130848 /lib64/libc-2.12.so
init      1 root  mem    REG              253,0    93352 130876 /lib64/libgcc_s-4.4.7-20120601.so.1
init      1 root  mem    REG              253,0    47760 130853 /lib64/librt-2.12.so
init      1 root  mem    REG              253,0   146592 130852 /lib64/libpthread-2.12.so
init      1 root  mem    REG              253,0   268240 130854 /lib64/libdbus-1.so.3.4.0
init      1 root  mem    REG              253,0    39896 130496 /lib64/libnih-dbus.so.1.0.0
init      1 root  mem    REG              253,0   106016 130498 /lib64/libnih.so.1.0.0
init      1 root  mem    REG              253,0   161776 130847 /lib64/ld-2.12.so
init      1 root    0u   CHR                1,3      0t0   4601 /dev/null
init      1 root    1u   CHR                1,3      0t0   4601 /dev/null
init      1 root    2u   CHR                1,3      0t0   4601 /dev/null
init      1 root    3r  FIFO                0,8      0t0   9948 pipe
init      1 root    4w  FIFO                0,8      0t0   9948 pipe
init      1 root    5r   DIR               0,10        0      1 inotify
init      1 root    6r   DIR               0,10        0      1 inotify
init      1 root    7u  unix 0xffff8800377d83c0      0t0   9949 @/com/ubuntu/upstart
init      1 root    9u  unix 0xffff88007cdfb100      0t0  13719 socket

最常用的uname  lsb_release  free  dmesg

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值