I want to understand why and what the below command does. People seem to just pluck the nvidia-[number] out of thin air, and I can't find any reference or documentation on where they seem to have magically got the number from. Could someone spare the time to explain what the number is, and how to find/use the command that I need to use for a graphics card in the future?
sudo apt-get install nvidia-331
Nvidia-331
is the name of a package, containing Nvidia drivers version 331.xx.You can see which Nvidia driver versions exist at Nvidia site.
You can also see which versions are at xorg-edgers HERE.
If you start Ubuntu Synaptic application and search for "nvidia", you will see which Nvidia drivers are present in official repositories and what are package names.