Step 1: Checking Existing Swap Space (Optional) # Before proceeding with creating a new swap file, it’s advisable to check if your VPS already has active swap space. Open a terminal and run the following command: sudo swapon --show If there is no output, your VPS likely doesn’t have active swap space, making it an ideal candidate for creating a new swap file. Step 2: Creating the Swap File # To create a 2GB swap file, follow these steps: Connect to your VPS via SSH. Execute the following command to create a 2GB swap file (you can adjust the size as needed): sudo fallocate -l 2G /swapfile Set appropriate permissions for the swap file: sudo chmod 600 /swapfile Prepare the swap file: sudo mkswap /swapfile Step 3: Enabling the Swap File # Once the swap file is created, enable it with the following command: sudo swapon /swapfile