Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

free

Show the use of memory (RAM) and swap.

Niveau
Dagelijks Linux
Groep
Processen en jobs
Root nodig
Nee
Pakket
procps-ng

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

free -h prints total, used and free memory, the shared memory, the buffers and cache, and available: the memory programs can still get (free + cache the kernel can give back). Look at "available", not "free" — Linux uses spare RAM as cache on purpose.

Zo schrijf je het

free [OPTION]...

Opties 17

Meest gebruikt

-h, --human
Readable units (Mi, Gi).
-b, --bytes
In bytes.
-k, --kibi
In KiB (default).
-m, --mebi
In MiB.
-g, --gibi
In GiB.
--tebi, --pebi
In TiB or PiB.
--kilo, --mega, --giga, --tera, --peta
Powers of 1000 (implies --si).
--si
Use 1000 instead of 1024.
-w, --wide
Buffers and cache in their own columns.
-t, --total
Add a total line (RAM + swap).
-l, --lohi
Low and high memory details.
-L, --line
Everything on one line.
-v, --committed
Show committed memory.
-s, --seconds DELAY
Repeat every DELAY seconds.
-c, --count COUNT
Repeat COUNT times.
--help
Show help.
-V, --version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1Memory in readable units

    free -h
                   total        used        free      shared  buff/cache   available
    Mem:           3.6Gi       812Mi       2.1Gi        12Mi       891Mi       2.6Gi
    Swap:          4.0Gi          0B       4.0Gi

    available = what new programs can still use.

  2. 2Wide view

    free -hw

    Buffers and cache apart.

  3. 3Watch every 2 seconds

    free -h -s 2

    Ctrl+C to stop.

  4. 4With a total line

    free -ht

    RAM + swap together.

  5. 5Value for a script

    free -m | awk '/^Mem:/ {print $7}'
    2662

    Available MiB.

  6. 6One line

    free -hL

    Short for logs.

  7. 7Is swap used a lot?

    free -h | grep Swap; vmstat 1 5

    High si/so in vmstat = the system swaps actively (too little RAM).

  8. 8Drop the cache for a test (not in production)

    sync; echo 3 > /proc/sys/vm/drop_caches; free -h

    Shows that cache is given back.

  9. 9Who uses the memory?

    ps -eo pid,rss,cmd --sort=-rss | head

    free shows totals; ps shows the processes.

  10. 10Check OOM killer events (security/stability)

    journalctl -k | grep -i 'out of memory'

    The kernel killed a process because memory was full.

Bestanden

/proc/meminfo
The source of the numbers.

Exitcodes

0 :: Done. 1 :: Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man free