sudo chmod 600 /swapfile

Category: VPS Management

sudo chmod 600 /swapfile

Restrict swap file permissions to root

Swap files contain memory pages, so they must not be world-readable — 600 grants read/write only to root. Both mkswap and swapon warn or refuse on a too-permissive swapfile. Run this immediately after creating the file and before formatting it.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.