From /proc/meminfo to free

How to calculate each field of the free command from proc/meminfo:

free /proc/meminfo
Mem total MemTotal
Mem free MemFree
Mem available MemAvailable
Mem used MemTotal - Buffers - (Cached + SReclaimable) - MemFree
Mem shared Shmem
Mem buffers Buffers
Mem cache Cached + SReclaimable
Mem buffer/cache Buffers + (Cached + SReclaimable)
Swap total SwapTotal
Swap free SwapFree
Swap used SwapTotal - SwapFree
  • Note: For some distributions, like busybox, SReclaimable is not counted in Mem cache.