Displaying Free and Used Memory with free

Although top includes some memory information, the free utility displays the amount of free and used memory in the system in kilobytes. (The -m switch displays in megabytes.) On one system, the output looks like this:

$ sudo free


total 516372 147736 433712

484972 368636



free 31400


buffers 19816

cached 317420

This output describes a machine with 512MB of RAM memory and a swap partition of 444MB. Note that some swap is being used although the machine is not heavily loaded. Linux is good at memory management and "grabs" all the memory it can in anticipation of future work.

A useful trick is to employ the watch command; it repeatedly reruns a command every 2 seconds by default. If you use

$ sudo watch free you will see the output of the free command updated every 2 seconds.

Another useful system-monitoring tool is vmstat (virtual memory statistics). This command reports on processes, memory, I/O, and CPU, typically providing an average since the last reboot; or you can make it report usage for a current period of time by telling it the time interval in seconds and the number of iterations you desire, as follows:

$ sudo vmstat 5 10

The preceding command runs vmstat every 5 seconds for 10 iterations.

Use the uptime command to see how long it has been since the last reboot and to get an idea of what the load average has been; higher numbers mean higher loads.

Disk quotas are a way to restrict the usage of disk space either by user or by groups. Although rarelyif everused on a local or standalone workstation, quotas are definitely a way of life at the enterprise level of computing. Usage limits on disk space not only conserve resources, but also provide a measure of operational safety by limiting the amount of disk space any user can consume.

Was this article helpful?

0 0

Post a comment