I have been asked several times about reducing the “swapiness” on a Linux machine to make the machine more responsive. So here is a post on how to do that. Remember just because you can does not make it a good thing to do.
If the machine has 8GB or more RAM turn down the swapiness. That is, if you do not want the system using swap until only 10-15% of RAM is left unused. Then this is the post for you.
To see the current swapiness value, which is probably 60 as that is the Ubuntu default.
To set a new value that is remembered over a reboot edit sysctl.conf
sudo nano /etc/sysctl.conf
Add or amend the line the following line
vm.swappiness = 10
and to change the value once the machine is running with out rebooting. This does not survive a reboot.
sudo sysctl vm.swappiness=10
Personally I just leave this alone, if your machine is constantly swapping to disk give it some more RAM. if that is not possible run less apps concurrently.