Enable and inspect swap files or partitions quickly with a single command. 09.05.2026 | reading time: 3 min Swap extends physical memory by using disk space; `swapon` is the command that activates swap spaces and reports what is in use, so a sysadmin can add or check swap without rebooting. Create a swapfile in minutes Do this on a machine with root access: allocate a file, secure it, format it for swap, enable it, then verify with `swapon`; for example run `sudo fallocate -l 1G /swapfile` then `sudo chmod 600 /swapfile` then `sudo mkswap /swapfile` then `sudo swapon /swapfile` then `swapon --show` which will list the active swap like `NAME TYPE SIZE USED PRIO /swapfile file 1G 0B -2`. Options that matter in practice Use `swapon --show` to list active swap with human-readable sizes, `swapon --summary` or the legacy `swapon -s` for a compact view, `swapon -p` to set priority when enabling multiple swap devices, and `swapon --all` to enable entries from `/etc/fstab`; remember to run `mkswap` before enabling a raw partition or file and use `swapoff` to deactivate swap before resizing or removing it. When and why to touch swap Enable a swapfile to provide emergency memory, add swap to avoid OOM kills during heavy batch jobs, or test behavior with different priorities; for persistent swap add a line like `echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab` and then `sudo swapon --all` so the system will activate it automatically on boot. Other commands you'll use Before `swapon` you create swap with `mkswap`, take swap offline with `swapoff`, and inspect memory pressure with `free -h`; combine them in scripts to automate provisioning or maintenance. Final note and next step Mastering `swapon` gives a quick, reproducible way to manage swap during setup and troubleshooting; experiment safely on a test host, then deepen your Linux skills and consider formal certification such as CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy to turn practice into proof. Join Bits & Bytes Academy First class LINUX exam preparation. storage setup utilities