What is a swap file in Linux and how much should you use?
A swap file is a form of virtual memory, similar to random access memory (RAM) and cache on a processor in which a file swap can be used to store temporary data. It's the slowest form of memory, located on an HDD or SSD, and is reserved by the Linux system for use when the OS runs out of RAM. By configuring your Linux installation to use a swap file, you can technically use more RAM than your PC has physically installed.
This would allow the OS to have more apps running simultaneously and more data loaded for immediate retrieval than would otherwise be possible. Because the swap file (or page files) is not stored using physical components, such as one of the best RAM modules on the market, we only recommend using a swap file if you're unable to install more physical system memory. By default, an operating system such as Linux will manage the swap files automatically.