Member-only story
Linux Basics — Buffer vs Cache
5 min readMar 13, 2025
Buffer and Cache Definitions
- Buffers are temporary storage for raw disk blocks, that is, cache data write to disks, usually not very large (about 20MB). In this way, the kernel can centralize scattered writes and optimize disk writes uniformly. For example, multiple small writes can be merged into a single large write, etc.
- Cache is a page cache for reading files from disk, which is used to cache data read from files. This way, the next time these file data is accessed, it can be quickly fetched directly from memory without having to access the slow disk again.
But do you kow since Buffer is just a cache for data that will be written to disk. In turn, will it also cache data read from disk? Or Cache is a cache for reading data from files, so does it also cache data for writing files?
free Command
To check system memory usage, the first command that comes in your mind is probably free
, for example:
$ free -h
total used free shared buff/cache available
Mem: 1.9G 1.0G 394M 2.6M 491M 728M
Swap: 0B 0B 0B
Obviously, this output contains the specific usage of physical memory Mem
and Swap
, such as total memory…