An initialized swap area is taken into use with swapon(8). This command tells the kernel that the swap area can be used. The path to the swap area is given as the argument, so to start swapping on a temporary swap file one might use the following command.
Swap areas can be used automatically by listing them in the /etc/fstab file.
The startup scripts will run the command swapon -a, which will start swapping on all the swap areas listed in /etc/fstab. Therefore, the swapon command is usually used only when extra swap is needed.
You can monitor the use of swap areas with free(1). It will tell the total amount of swap space used. The same information is available via top(1), or using the proc filesystem in file /proc/meminfo. It is currently difficult to get information on the use of a specific swap area.
A swap area can be removed from use with swapoff(8). It is usually not necessary to do it, except for temporary swap areas. Any pages in use in the swap area are swapped in first; if there is not sufficient physical memory to hold them, they will then be swapped out (to some other swap area). If there is not enough virtual memory to hold all of the pages Linux will start to trash; after a long while it should recover, but meanwhile the system is unusable. You should check (e.g., with free) that there is enough free memory before removing a swap space from use.
All the swap areas that are used automatically with swapon -a can be removed from use with swapoff -a; it looks at the file /etc/fstab to find what to remove. Any manually used swap areas will remain in use.
Sometimes a lot of swap space can be in use even though there is a lot of free physical memory. This can happen for instance if at one point there is need to swap, but later a big process that occupied much of the physical memory terminates and frees the memory. The swapped-out data is not automatically swapped in until it is needed, so the physical memory may remain free for a long time. There is no need to worry about this, but it can be comforting to know what is happening.