Make apt-get assume yes as the answer to prompts during package installations

The way to avoid prompts when dealing with the APT package handling utility in Ubuntu Server.

When you install something with apt-get, it happens that you get prompted with questions like "Do you want to continue [Y/n]?". You can avoid these, which is nice if you are writing something that will run non-interactively as for example an installation script.

$ sudo apt-get install php5
After this operation, 29.4 MB of additional disk space will be used.
Do you want to continue [Y/n]?

The solution is to add the option -y.

$ sudo apt-get -y install php5

Isn't this dangerous? Not really. In most situations when you would abort, apt-get will too. You can read more about it in the manual.

This of course works on all Debian based distributions with APT, not just Ubuntu Server.