how to create swap file in ubuntu code example Example 1: create swapfile ubuntu sudo nano /etc/fstab Example 2: create swapfile ubuntu sudo chmod 600 /swapfile