This tutorial explains Linux “free” command, options and its usage with examples.
DESCRIPTION
free displays the total amount of free and used physical memory and swap space in the system, as well as the buffers and cache consumed by the kernel.
SYNOPSIS
free [-b|-k|-m|-g] [-l] [-o] [-t] [-s delay ] [-c count ]
OPTIONS
Normal invocation of free does not require any options. The output, however, can be fine-tuned by specifying one or more of the following flags:
-b, –bytes
Display output in bytes.
-k, –kb
Display output in kilobytes (KB). This is the default.
-m, –mb
Display output in megabytes (MB).
-g, –gb
Display output in gigabytes (GB).
-l, –lowhigh
Display detailed information about low vs. high memory usage.
-o, –old
Use old format. Specifically, do not display -/+ buffers/cache.
-t, –total
Display total summary for physical memory + swap space.
-c n, –count=n
Display statistics n times, then exit. Used in conjunction with the -s flag. Default is to display only once, unless -s was specified, in which case default is to repeat until interrupted.
-s n, –repeat=n
Repeat, pausing every n seconds in-between.
EXAMPLES
1. Simple Example to display information about free and used memory on the system
$ free total used free shared buffers cached Mem: 1011876 896904 114972 0 43564 342528 -/+ buffers/cache: 510812 501064 Swap: 1046524 12756 1033768
2. To display memory usage in kilobytes
$ free -k total used free shared buffers cached Mem: 1011876 896904 114972 0 43580 342560 -/+ buffers/cache: 510764 501112 Swap: 1046524 12756 1033768
3. To display memory usage in megabytes
$ free -m total used free shared buffers cached Mem: 988 875 112 0 42 334 -/+ buffers/cache: 498 489 Swap: 1021 12 1009
4. Display memory information twice after delay of 1 second
$ free -s 1 -c 2 total used free shared buffers cached Mem: 1011876 897400 114476 0 43836 342668 -/+ buffers/cache: 510896 500980 Swap: 1046524 12756 1033768 total used free shared buffers cached Mem: 1011876 897540 114336 0 43836 342648 -/+ buffers/cache: 511056 500820 Swap: 1046524 12756 1033768
5. Display total values too
$ free -t total used free shared buffers cached Mem: 1011876 897368 114508 0 43880 342648 -/+ buffers/cache: 510840 501036 Swap: 1046524 12756 1033768 Total: 2058400 910124 1148276
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Check Linux Books
- Apply for Programming Internship
- Practice Programming MCQs
- Check Information Technology Books