Is there any difference between the outputs of two commands, "free -m" and "cat /proc/sys/vm/swappiness," specifically in terms of swap.
Asked
Active
Viewed 16 times
1 Answers
1
They’re rather different:
$ free -m
total used free shared buff/cache available
Mem: 31838 20657 595 5277 10585 5285
Swap: 8191 8191 0
$ cat /proc/sys/vm/swappiness
60
free -m
shows how memory (and swap, if any) are currently used. cat /proc/sys/vm/swappiness
shows the current value of the swappiness setting, which determines how the kernel balances page cache usage (part of the “buff/cache” output of free -m
) and swap usage.
Changing swappiness will eventually affect the output of free -m
: smaller values should result in lower swap usage (but won’t reduce existing swap usage) and lower cache usage, whereas higher values should result in higher swap usage and higher cache usage.
See Why does swappiness not work? and How does the kernel decide between disk-cache vs swap? for details of swappiness.

Stephen Kitt
- 434,908