Make the "free" command a little more human friendly

Solution Verified - Updated -

Issue

  • RFE for a human readable option for free command
  • Any chance of adding a -h for a human readable display to the /usr/bin/free utility? Reasons are:
    • a) not obvious at first what units are displayed in, e.g.
# free
             total       used       free     shared    buffers     cached
Mem:       3924552     386908    3537644          0      68736     167080
-/+ buffers/cache:     151092    3773460
Swap:      6029304          0    6029304
 * b) free doesn't say what the default units are:
# free -h
free: invalid option -- 'h'
usage: free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay] [-c count] [-V]
  -b,-k,-m,-g show output in bytes, KB, MB, or GB
  -l show detailed low and high memory statistics
  -o use old format (no -/+buffers/cache line)
  -t display total for RAM + swap
  -s update every [delay] seconds
  -c update [count] times
  -V display version information and exit
  • Only the man page says what the default unit is, i.e. "The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes."
    • c) Makes it easier to read - I'm not interested in the exact figure, just a rough figure that's more manageable. So example output would be like this (sorry if columns are all over the place):
# free
             total       used       free     shared    buffers     cached
Mem:       3.9GB     3.8GB    3.5GB          0      67MB     167MB
-/+ buffers/cache:     147MB    3.6GB
Swap:      5.8GB          0    5.8GB
  • No changes to the columns/format or the default unit option (keep it as KB for compatibility). Would be nice if available in RHEL 5+.
  • Also update the "options" page as shown in b) so show the default KB is indicated.
  • The customer requests that we consider adding some human friendly detail to /usr/bin/free. Specifically a -h option to match other gnu utilities and a note in the help text to indicate that the default unit of measurement is in bytes.
  • Customer is looking for a a more human friendly output that is easier to read at a glance.
  • addition of a -h option to produce results in the highest order of magnitude possible (like other utilities)
  • addition of a note in the help text, to make clear that calling the command without options reports in bytes.
  • Arguably this detail is available in the man page, but the customer asks we consider it anyway.

Environment

  • Red Hat Enterprise Linux 6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content