Ubuntu 12.04 – Failed to download package files

This tutorial is for Ubuntu 12.04 in which the following error appears when trying to install a package using the Ubuntu Software Center:

This might work for other Ubuntu versions, or other Linux distros based on Ubuntu, but no guarantee is made.

Assumes you know how to open a terminal. Instructions can be found here.

Possible Cause

The error message

Failed to download package files
Check your Internet connection.

when attempting to install software using the Ubuntu Software Center may occur if the package repository lists are out of date.

Updating the Repositories

1) Open a terminal:

2) Type the following command and then press the Enter key:

sudo apt-get update

3) Type your password and then press the Enter key:

Note: when you type your password, it will look like nothing is happening. This is normal. Linux gives no feedback when passwords are entered.

Ubuntu will spend several minutes updating the package repository lists:

When Ubuntu has updated the package repository lists, try installing the software package again – the problem should have gone away.

If the problem persists, it may be that you have a flaky Internet connection.