I noticed there is a difference between outputs of free command:
On debian:
$ free -h
total used free shared buffers cached
Mem: 4.0G 3.4G 629M 0B 96K 1.3G
-/+ buffers/cache: 2.1G 2.0G
Swap: 4.0G 1.1G 2.9G
On gentoo:
$ free -h
total used free shared buff/cache available
Mem: 15G 3.7G 9.6G 485M 2.2G 11G
Swap: 8.8G 2.6G 6.2G
Redhat (at least 7.x) seems to have same output as gentoo. Why is that? Is it possible to display debian style output on gentoo / redhat systems as well? Are both distros using different gnu coreutils?
Best Answer
free
is provided byprocps-ng
; Debian 8 has version 3.3.9, which uses the old style with a separate line forbuffers/cache
, while Gentoo and presumably RHEL 7.x have version 3.3.10 or later which uses the new style. You can see the reasoning behind the change in the corresponding commit message.If you really want the old-style output you can run an older version of
procps
, but you'll find that distributions will migrate to the newer style by default. The newer style also gives the amount of available memory which is a really useful piece of information (see How can I get the amount of available memory portably across distributions? for details).Somewhat confusingly, version 3.3.9 refers to the format without the
buffers/cache
line as "old format", and you can see it in that version withfree -o
. So all told:versions 3.3.9 and earlier show by default
versions 3.3.9 and earlier, with
-o
, showversions 3.3.10 and later only show
versions 3.3.10 and later also have a wide output mode,
-w
, which shows(This is all on the same system; note how the accounting is more accurate with the later versions.)