Which command shows the amount of free and used memory in the system, including swap?
Trap 1: top
While `top` displays real-time process activity and includes a memory summary line showing total, used, free, and swap figures, it fails to meet the question’s requirement because it does not provide a dedicated, static snapshot of memory and swap usage on demand; instead, it continuously refreshes a dynamic process list. It is tempting because its header does show memory and swap statistics, making it seem sufficient, and it would be the correct choice if the task were to monitor live memory consumption alongside CPU usage over time.
Trap 2: df -h
df shows disk usage, not memory.
Trap 3: vmstat
vmstat shows virtual memory statistics but not in a simple free/used summary.
- A
top
Why wrong: While `top` displays real-time process activity and includes a memory summary line showing total, used, free, and swap figures, it fails to meet the question’s requirement because it does not provide a dedicated, static snapshot of memory and swap usage on demand; instead, it continuously refreshes a dynamic process list. It is tempting because its header does show memory and swap statistics, making it seem sufficient, and it would be the correct choice if the task were to monitor live memory consumption alongside CPU usage over time.
- B
free -h
free -h specifically shows memory usage with swap.
- C
df -h
Why wrong: df shows disk usage, not memory.
- D
vmstat
Why wrong: vmstat shows virtual memory statistics but not in a simple free/used summary.