Linux: Kako prikazati trenutnu potrosnju RAM memorije?
Prikaz preko pseudo datoteke /proc/meminfo
Jedan od nacina je koristiti grep alat za filter kljucnih rijeci MemFree
iz sistemskog fajla /proc/meminfo
grep Mem /proc/meminfo
ispis
MemTotal: 131917312 kB
MemFree: 3970444 kB
MemCommitted: 354429952 kB
Za prikaz ukupe RAM memorije
grep MemTotal /proc/meminfo
Za prikaz slobodne memorije
grep MemFree /proc/meminfo
FREE KOMANDA
Komanda cesto koristena za prikazivanje trenutne potrosnje RAM memorije je komanda free.
Primjeri upotrebe:
- Prikaz potrosnje u Gigabajtima
free -g
ispis komande iznad
total used free shared buffers cached
Mem: 125 122 3 0 5 63
-/+ buffers/cache: 53 72
Swap: 20 11 9
- Prikazm potrosnje u formatu lakse citljivom za covjeka tzv human
free -g -h
ispis
total used free shared buffers cached
Mem: 125G 122G 3.7G 0B 5.6G 63G
-/+ buffers/cache: 53G 72G
Swap: 20G 11G 9.1G
- Total odnosno zbirni prikaz kolicine RAM memorije i velcine swap particije
free -g -h -t
ispis
total used free shared buffers cached
Mem: 125G 122G 3.6G 0B 5.6G 63G
-/+ buffers/cache: 53G 72G
Swap: 20G 11G 9.1G
Total: 146G 133G 12G
- Opcija -o izbacuje prikaz linije “buffer adjusted”
free -g -h -o
total used free shared buffers cached
Mem: 125G 122G 3.6G 0B 5.6G 63G
Swap: 20G 11G 9.1G
- Zbog lakseg koristenja format pisanja se moze pojednostaviti u sljedeci
free -ghto
ispis
total used free shared buffers cached
Mem: 125G 122G 3.6G 0B 5.6G 63G
Swap: 20G 11G 9.1G
Total: 146G 133G 12G
Help stranice za free komandu.
free --help
ispis
Usage:
free [options]
Options:
-b, --bytes show output in bytes
-k, --kilo show output in kilobytes
-m, --mega show output in megabytes
-g, --giga show output in gigabytes
--tera show output in terabytes
-h, --human show human readable output
--si use powers of 1000 not 1024
-l, --lohi show detailed low and high memory statistics
-o, --old use old format (no -/+buffers/cache line)
-t, --total show total for RAM + swap
-s N, --seconds N repeat printing every N seconds
-c N, --count N repeat printing N times
--help display this help text
-V, --version output version information and exit
For more details see free(1).