
linux查看ram大小
What are the ways to get ram size in Linux operating system?
在Linux操作系统中获得内存大小的方法有哪些?
Here is some methods to find ram size in Linux operating systems like Ubuntu, Debian, Fedora, CentOS, Red Hat.
这是一些在Linux操作系统(例如Ubuntu,Debian,Fedora,CentOS和Red Hat)中查找内存大小的方法。
使用meminfo获取Ram大小 (Getting Ram Size With meminfo)
Proc file system provides coonfiguration information about the current opoerating system. We can get information from direcly kernel provided /proc/meminfo . We can see a lot of information parameter with meminfo
Proc文件系统提供有关当前操作系统的配置信息。 我们可以从/ proc / meminfo提供的内核中直接获取信息。 我们可以通过meminfo看到很多信息参数
$cat /proc/meminfo
MemTotal: 1016756 kB
MemFree: 159240 kB
MemAvailable: 417356 kB
Buffers: 868 kB
Cached: 362436 kB
SwapCached: 0 kB
Active: 433572 kB
Inactive: 306476 kB
Active(anon): 377436 kB
Inactive(anon): 7756 kB
Active(file): 56136 kB
Inactive(file): 298720 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 376776 kB
Mapped: 101996 kB
Shmem: 8448 kB
Slab: 53196 kB
SReclaimable: 31768 kB
SUnreclaim: 21428 kB
KernelStack: 5104 kB
PageTables: 22476 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 508376 kB
Committed_AS: 2269324 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 143472 kB
VmallocChunk: 34359591920 kB
HardwareCorrupted: 0 kB
AnonHugePages: 145408 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 59236 kB
DirectMap2M: 989184 kB
DirectMap1G: 0 kB
- As we see there is a lot of details. Actually a lot of monitoring applications gets data from here. 我们看到有很多细节。 实际上,许多监视应用程序都从此处获取数据。
MemTotal is total ram size
MemTotal是总RAM大小
使用简单的免费命令获取Ram尺寸(Get Ram Size With Simple free Command)
We can get ram size with simple free command.
我们可以通过简单的免费命令获得内存大小。
$free
total used free shared buff/cache available
Mem: 1016756 441008 159324 8448 416424 417416
Swap: 0 0 0
But this will give information with kilobyte size. We want to get megabyte
但这将提供千字节大小的信息。 我们想获得兆字节
$free -m
total used free shared buff/cache available
Mem: 992 430 155 8 406 407
Swap: 0 0 0
Or I think gigabyte is better
或者我认为技嘉更好
$ free -g
total used free shared buff/cache available
Mem: 15 11 0 1 3 2
Swap: 0 0 0
使用vmstat获取内存大小 (Getting Ram Size With vmstat)
Another tool is vmstat as you see below
如下所示,另一个工具是vmstat
$vmstat -s | grep "total memory"
1016756 K total memory
如何在Linux中获得Ram大小? 信息移植 (How To Get Ram Size In Linux? Infografic)

linux查看ram大小