Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes it is not comfortable to see meminfo in kilobytes while you have several gigs of RAM. In Linux it looks like that:

enter image description here

And here is how it looks in Mac OS X:

enter image description here

Is there a way to display meminfo in Linux top in terabytes, gigabytes and megabytes?

share|improve this question
Apparently, some posts say that in Redhat Linux you can do someting like top -M to display the usage in MB. If you only want to monitor the memory usage, you can use rather use htop. Not sure of any other option. – Barun Dec 19 '13 at 15:54
Right you are, but there is nothing about that in build-in help. I've just occasionally was able to find that in man page – Anthony Ananich Dec 19 '13 at 15:56
The man page is the builtin help. – casey Dec 19 '13 at 15:59
You could always use free -m, or better free -h instead. – terdon Dec 19 '13 at 16:48
Once you jump into top hit E until it shows the memory cumulative you're looking for, then hit W to write that configuration to disk. – Trev Norris Apr 13 '15 at 2:07

When in top, typing capital "E" cycles through different memory units (kb, mb, gb etc) in the total memory info:

The image shows tops general memory display with GiB as a unit.

While lower-case "e" does the same individual process lines:

The image shows processes in top where the memory is displayed in MiB

From the manpage:

2c. MEMORY Usage
    This  portion  consists of two lines which may express values in kibibytes
    (KiB) through exbibytes (EiB) depending on  the  scaling  factor  enforced
    with the 'E' interactive command.

Version Information: top -version: procps-ng version 3.3.9 System: CentOS 7

share|improve this answer
Does not work for me in RHEL – Anthony Ananich May 11 '14 at 11:49
Works in ubuntu 14.04 cheers. – tjjjohnson May 22 '14 at 4:22
works in fedora 20 – sivann Sep 19 '14 at 8:48
@AnthonyAnanich: Does work for me in RHEL 7. – krlmlr Dec 17 '14 at 11:14

There is a command-line option which does that:

-M : Detect memory units
            Show memory units (k/M/G) and display floating point values in the
            memory summary.

So it is sufficient to run top like that:

top -M

enter image description here

share|improve this answer
+1 , but checked in Ubuntu , its saying not working. Any way in Ubuntu ? – Raja Dec 19 '13 at 15:59
I have no clue, @richardparker – Anthony Ananich Dec 19 '13 at 16:32
Damn, you racked up a ton of karma with a simple (but good) self-answered Q&A. Nice work. – user1717828 Oct 29 '15 at 15:39

You can also use htop. It's much cooler than top.

If you are using Debian or one of its derivatives, then you can install it using sudo apt-get install htop.

htop screenshot

Edit: Here is a screenshot with a better color scheme:

htop screenshot with better colors

share|improve this answer
htop looks better with either a white or a black background. Your screenshot color scheme is less than optimal. – jlliagre Dec 19 '13 at 17:42
@jlliagre Eye of the beholder. – macmadness86 Aug 7 '15 at 7:07
@macmadness86 alternate screenshot added – jlliagre Aug 7 '15 at 7:20

top -M doesn't work on any of the Fedora, Debian or Ubuntu distros to my knowledge. I just tried it and it's not in the procps-ng package that provides top. There are many implementations of top so one needs to pay special attention to which they use.

In general it's best to use free with switching to get the amount of memory free on Linux.

procps vs. procps-ng

You might of noticed that on CentOS 5 & 6 as well as RHEL 5 & 6 that top -M appears to work. This is because those distros ship with the original version of procps. The project was forked and there is now another project procps-ng.

Some of the details as to why there was fork, from the Fedora Project's page.


Old (legacy) procps tools had no updates for several years and that led to a massive code split caused by a local-only application of distribution specific patches, which were not merged upstream. The project became hardly maintainable since some of the newly written patches were incompatible with sources maintained by other distributors. A similar incompatibility could be noticed in the applications behavior and their command line switches. This inevitable update can be understood as an effort to unify the procps tools across all Linux distributions.

So to be clear, the forked project, procps-ng is what Debian, Fedora, Ubuntu, and other distros are using, the legacy project, which does support top -M is still in use of several of the longer term releases that don't keep up with the latest and greatest.

NOTE: I downloaded the latest version of procps-ng, "procps-ng version" and it too was lacking the -M switch.

$ ./top/top -version
  procps-ng version
  lt-top -hv | -bcHiOSs -d secs -n max -u|U user -p pid(s) -o field -w [cols]


In running free with switches you can see the most likely reason as to why the lack of units feature is missing from procps-ng's implementation of top.

$ free -m
             total       used       free     shared    buffers     cached
Mem:          7782       6506       1276          0        504       1726
-/+ buffers/cache:       4274       3507
Swap:         7823       1429       6394
[saml@greeneggs ~]$ free -k
             total       used       free     shared    buffers     cached
Mem:       7969492    6663180    1306312          0     516948    1764780
-/+ buffers/cache:    4381452    3588040
Swap:      8011772    1463456    6548316

Rounding becomes problematic, so I believe, procps's implementation avoids the issue by not offering the ability.


Does an OK job of showing aggregate memory usage.

   ss of htop


In my opinion a better tool for looking at memory.

   ss of atop


Another useful tool is nmon for looking at system performance.

   ss of nmon

share|improve this answer
top -M works for me in RHEL6 – Anthony Ananich Dec 19 '13 at 21:58
@AnthonyAnanich - I researched this a bit more. CentOS 5.4's top version "procps version 3.2.8" has the -M switch, CentOS 5.8, also has this switch, "procps version 3.2.7". However Fedora 19 has "procps-ng version 3.3.8" which doesn't support the -M switch. – slm Dec 19 '13 at 22:07
@AnthonyAnanich - added details to my answer about procps vs. procps-ng. – slm Dec 19 '13 at 22:14
Great answer, thank you, @slm. I even do not know which of the three answers is the best. Will not award to anyone, I want let other people decide. – Anthony Ananich Jan 22 '14 at 11:11
@AnthonyAnanich - NP. You should consider picking one if you feel that it answers your Q 100%. Accepting an A is important since it signals to the rest of the community that passes by your Q that you as the OP felt this A answered or solved your particular issues. If other A's are outstanding they'll get UV'd as well. Not accepting one, is basically a signal that you as the OP still feel your Q hasn't bee sufficiently answered. The accepted A also gets positioned as the 1st A when ppl see your Q in the future. – slm Jan 22 '14 at 12:59

You can press the following keys:

  • e -- Change the scaling factor on the summary display
  • Shift+e -- Change the scaling factor on the task
  • Shift+w -- Save current settings
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.