查看Linux系统下CPU、内存、硬盘等信息
阅读原文时间:2023年08月09日阅读:6

做个记录,方便日后查看使用。


1. 查看CPU

1.1 查看CPU个数

[root@qy-ggyf-zyl-31 ~]# cat /proc/cpuinfo | grep "physical id" | uniq | wc -l 8

1.2 查看CPU详情

[root@qy-ggyf-zyl-31 ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 94
model name : Intel Core Processor (Skylake)
stepping : 3
microcode : 0x1
cpu MHz : 2194.842
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f rdseed adx smap clflushopt avx512cd xsaveopt xsavec xgetbv1 arat
bogomips : 4389.68
clflush size : 64
cache_alignment : 64
address sizes : 46 bits physical, 48 bits virtual
power management:

1.3 查看CPU型号

[root@qy-ggyf-zyl-31 ~]# cat /proc/cpuinfo | grep 'model name' |uniq
model name : Intel Core Processor (Skylake)

2. 查看内存

2.1 查看内存总数

[root@qy-ggyf-zyl-31 ~]# cat /proc/meminfo | grep MemTotal
MemTotal: 32775916 kB

2.2 查看内存详情

[root@qy-ggyf-zyl-31 ~]# cat /proc/meminfo
MemTotal: 32775916 kB
MemFree: 24031996 kB
MemAvailable: 29836020 kB
Buffers: 157888 kB
Cached: 7458304 kB
SwapCached: 0 kB
Active: 3515628 kB
Inactive: 4711068 kB
Active(anon): 1625168 kB
Inactive(anon): 575904 kB
Active(file): 1890460 kB
Inactive(file): 4135164 kB

3. 查看硬盘

3.1 查看硬盘大小

[root@cwcsb-gxcwy832-xnce-2 upload]# fdisk -l | grep Disk
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Disk label type: dos
Disk identifier: 0x000ba968
Disk /dev/vdb: 536.9 GB, 536870912000 bytes, 1048576000 sectors

3.2 查看硬盘使用情况

[root@cwcsb-gxcwy832-xnce-2 upload]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda2 100G 49G 52G 49% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 17M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda1 485M 130M 356M 27% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/1001

4. 查看文件夹

4.1 查看当前目录下文件和文件夹数

[root@cwcsb-gxcwy832-xnce-2 upload]# ls |wc -l 11

4.2 查看当前目录总大小

[root@cwcsb-gxcwy832-xnce-2 upload]# du -sh 3.1G .

4.3 查看当前目录下各文件和文件夹大小

  注:此举可以快速定位大文件所存在的位置。

[root@cwcsb-gxcwy832-xnce-2 upload]# du -sh *
1.2G BOOT-INF
144K exp_cwy_GX1009_1104.log
3.4M HDTool
3.0M HDTool.zip
144K imp_cwy_GX1009_1028.log
84K nohup.out
1.8G olk
101M promtail
4.0K sendstartup.sh
36M telegraf-1.21.4-1.x86_64.rpm
8.0K update_aun.sh
[root@cwcsb-gxcwy832-xnce-2 upload]# ls
BOOT-INF HDTool imp_cwy_GX1009_1028.log olk sendstartup.sh update_aun.sh
exp_cwy_GX1009_1104.log HDTool.zip nohup.out promtail telegraf-1.21.4-1.x86_64.rpm

4.4 查看当前目录下各文件和文件夹(含下一级目录)大小

[root@cwcsb-gxcwy832-xnce-2 upload]# du -h --max-depth=1 *
1.2G BOOT-INF/classes
19M BOOT-INF/lib
1.2G BOOT-INF
144K exp_cwy_GX1009_1104.log
3.4M HDTool
3.0M HDTool.zip
144K imp_cwy_GX1009_1028.log
84K nohup.out
12K olk/META-INF
420K olk/org
1.2G olk/BOOT-INF
1.8G olk
101M promtail
4.0K sendstartup.sh
36M telegraf-1.21.4-1.x86_64.rpm
8.0K update_aun.sh

4.5 指定显示文件或文件夹大小

[root@cwcsb-gxcwy832-xnce-2 upload]# du -h --max-depth=0 /opt/cwy8.32
5.8G /opt/cwy8.32
[root@cwcsb-gxcwy832-xnce-2 upload]# du -h --max-depth=1 /opt/cwy8.32
8.0K /opt/cwy8.32/config
1.6G /opt/cwy8.32/middleware
4.2G /opt/cwy8.32/product
5.8G /opt/cwy8.32
[root@cwcsb-gxcwy832-xnce-2 upload]# du -h --max-depth=1 BOOT-INF/
1.2G BOOT-INF/classes
19M BOOT-INF/lib
1.2G BOOT-INF/
[root@cwcsb-gxcwy832-xnce-2 upload]# du -h --max-depth=1 exp_cwy_GX1009_1104.log
144K exp_cwy_GX1009_1104.log

5. 查看Linux系统

5.1 查看Linux内核版本信息

[root@cwcsb-gxcwy832-xnce-2 upload]# uname -a
Linux cwcsb-gxcwy832-xnce-2 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@cwcsb-gxcwy832-xnce-2 upload]# cat /proc/
version

Linux version 3.10.0-957.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Thu Nov 8 23:39:32 UTC 2018

5.2 查看Linux系统版本信息

[root@cwcsb-gxcwy832-xnce-2 upload]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@cwcsb-gxcwy832-xnce-2 upload]# cat /etc/centos-
release

CentOS Linux release 7.6.1810 (Core)