整理linux 查看操作系统、CPU、内存、磁盘等信息
一、查看 cpu 信息
1 、 所 有 信 息 lscpu [root@localhost ~]# lscpu
Architecture: x86_64 ##cpu 架构
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2 ##总共有 8 核
On-line CPU(s) list: 0,1
Thread(s) per core: 1 ##每个 CPU 支持的线程数Core(s) per socket: 1 ##每个 CPU 的核数Socket(s): 2 ##共有几个 cpu
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 140
Model name: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz Stepping: 1
CPU MHz: 2803.203
BogoMIPS: 5606.40
Hypervisor vendor: VMware Virtualization type: full
L1d cache: 48K
L1i cache: 32K
L2 cache: 1280K
L3 cache: 12288K NUMA node0 CPU(s): 0,1
[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
2 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
[root@localhost ~]# cat /proc/cpuinfo |grep "processor"|sort -u|wc -l 2
4…查看物理 cpu:
[root@localhost ~]# grep "physical id" /proc/cpuinfo|sort -u|wc -l 2
5…查看每个物理 cpu 的内核数:
[root@localhost ~]# grep "cpu cores" /proc/cpuinfo|uniq cpu cores 1
[root@localhost ~]# grep "siblings" /proc/cpuinfo|uniq siblings 1
如果多个逻辑CPU 的"physical id"和"core id"均相同,说明开启了超线程或者换句话说
逻辑CPU 个数 > 物理 CPU 个数 * CPU 内核数 开启了超线程逻辑CPU 个数 = 物理 CPU 个数 * CPU 内核数 没有开启超线程
二、查看内存:
total used free shared buff/cache available Mem: 1819 936 110 27 772
705
Swap: 2048 0 2048
[root@localhost ~]# free -h
total used free shared buff/cache available Mem: 1.8G 936M 110M 27M 772M 705M
Swap: 2.0G 0B 2.0G
[root@localhost ~]# cat /proc/meminfo MemTotal: 1863028 kB
MemFree: 98728 kB
MemAvailable: 707964 kB
Buffers: 88 kB
Cached: 746408 kB
SwapCached: 0 kB
Active: 1046584 kB
Inactive: 406632 kB
Active(anon): 676952 kB
Inactive(anon): 58260 kB
Active(file): 369632 kB
Inactive(file): 348372 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 2098172 kB
SwapFree: 2098172 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 706804 kB
Mapped: 161072 kB
Shmem: 28492 kB
Slab: 108196 kB
SReclaimable: 44636 kB
SUnreclaim: 63560 kB
KernelStack: 9856 kB
PageTables: 38000 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 3029684 kB
Committed_AS: 4204640 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 213128 kB
VmallocChunk: 34359277564 kB
Percpu: 55296 kB
HardwareCorrupted: 0 kB
AnonHugePages: 208896 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 114560 kB
DirectMap2M: 1982464 kB
DirectMap1G: 0 kB
三、查看磁盘:
[root@localhost ~]# df -h
Filesystem Size Used Avail Use Mounted on
devtmpfs |
895M |
0 |
895M |
0 /dev |
tmpfs |
910M |
0 |
910M |
0 /dev/shm |
tmpfs |
910M |
11M |
900M |
2 /run |
tmpfs |
910M |
0 |
910M |
0 /sys/fs/cgroup |
/dev/sda3 |
28G |
4.4G |
24G 16 / |
|
/dev/sda1 |
297M |
163M |
134M 55 /boot |
tmpfs |
182M 8.0K |
182M |
1 |
/run/user/42 |
tmpfs |
182M 0 |
182M |
0 |
/run/user/0 |
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 xfs b03273da-ba2a-4871-8ae2-29a43a986a71 /boot
├─sda2 swap 5da90dd7-6cdf-406b-bd24-3c7b4a54269a [SWAP]
└─sda3 xfs 4e25f65e-d974-49a1-a07e-cdd5c53b3be6 / sr0
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 300M 0 part /boot
├─sda2 8:2 0 2G 0 part [SWAP]
└─sda3 8:3 0 27.7G 0 part /
sr0 11:0 1 1024M 0 rom
--查看 dm8 目录下各个文件使用情况
[root@DM dm8]# du -h /dm8/
---查看 dm8 文件的总大小[root@DM dm8]# du -s /dm8/ 13900328 /dm8/
四、磁盘调度:
[root@localhost ~]# cat /sys/block/sda/queue/scheduler noop [deadline] cfq
例如:想更改到 noop 电梯调度算法:
--首先查看需要更改的磁盘是在哪[root@localhost ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos
Disk identifier: 0x000a03f6
Device Boot Start End Blocks Id System
/dev/sda1 |
* |
2048 |
616447 |
307200 |
83 |
Linux |
/dev/sda2 |
616448 |
4812799 |
2098176 |
82 |
Linux swap / Solaris |
|
/dev/sda3 |
4812800 |
62914559 |
29050880 |
83 |
Linux |
[root@localhost ~]# echo noop > /sys/block/sda/queue/scheduler [root@localhost ~]# cat /sys/block/sda/queue/scheduler
[noop] deadline cfq
[root@localhost ~]# grubby --update-kernel=ALL --args="elevator=deadline"
重启之后,查看调度方法:
[root@localhost ~]# cat /sys/block/sda/queue/scheduler noop [deadline] cfq
五、查看操作系统版本:
[root@localhost ~]# cat /proc/version
Linux version 3.10.0-1160.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Mon Oct 19 16:18:59 UTC 2020
查看当前操作系统内核信息:
[root@localhost ~]# uname -a
Linux localhost 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
查看操作系统发行信息:
[root@localhost ~]# cat /etc/centos-release CentOS Linux release 7.9.2009 (Core)
社区地址:https://eco.dameng.com