The free
command in Linux is used to show the amount of free memory in Linux. The example below shows the default usage of this command.
ubuntu@ip-172-31-0-140:~$ free total used free shared buffers cached Mem: 602736 294680 308056 16928 17632 146320 -/+ buffers/cache: 130728 472008 Swap: 0 0 0 |
The free -m
command will show the free memory in megabytes.
ubuntu@ip-172-31-0-140:~$ free -m total used free shared buffers cached Mem: 588 290 298 16 17 144 -/+ buffers/cache: 127 460 Swap: 0 0 0 |
This version: free -k
shows the output in kilobytes.
ubuntu@ip-172-31-0-140:~$ free -k total used free shared buffers cached Mem: 602736 297244 305492 16928 18248 147996 -/+ buffers/cache: 131000 471736 Swap: 0 0 0 |
The -t parameter will show an extra line that shows the totals for each column.
ubuntu@ip-172-31-0-140:~$ free -t total used free shared buffers cached Mem: 602736 298696 304040 16928 18384 148168 -/+ buffers/cache: 132144 470592 Swap: 0 0 0 Total: 602736 298696 304040 |
Combined with the -m parameter, you will get a good picture of your memory usage.
ubuntu@ip-172-31-0-140:~$ free -t -m total used free shared buffers cached Mem: 588 291 297 16 17 144 -/+ buffers/cache: 128 459 Swap: 0 0 0 Total: 588 291 297 |