Ubuntu / Linux news and application reviews.

Some people do not have a permanent access to the Internet or the connection is limited; as an example, a friend can't download files larger than 10 mb. So how to install applications offline, in Ubuntu? Obviously, the packages have to be downloaded from another computer but this should include all the dependencies or else it would be useless.

The answer is a simple command:

sudo apt-get --print-uris --yes install PACKAGE_NAME | grep ^\' | cut -d\' -f2 >mydownload.txt

Where PACKAGE_NAME is the application you want to install and "mydownload.txt" is the output text file.

Basically, this command does not install the application, but creates a text file with the download URL for the application you want to install AND all its dependencies.

You can then download all the files from another computer, by using a download manager which supports downloading a list of urls from a file, or if you have access to another Linux machine, simply run this command to download all the packages:
wget --input-file mydownload.txt

The last (and worst) solution would be to enter each URL in a web browser and download them manually.

In case you did not understand how the command works, here is an example. To get a file with all the urls for the packages needed to install OpenOffice.org, you would run this in a terminal:
sudo apt-get --print-uris --yes install openoffice.org | grep ^\' | cut -d\' -f2 >mydownload.txt

The following URLs will then be written inside the mydownload.txt file:

Once you have the packages and dependencies on the computer with no, or limited internet access, simply copy all of them in a new folder and run this command:
sudo dpkg -i *.deb

This will install all the .deb files.

Please note: the computer on which you need to install the files needs to have an internet connection from time to time, to be able to update the package list (sudo apt-get update) so you'll be able to download the latest files.

Important: the mydownload.txt file will be empty if you run this command for an application which is already installed and up to date! Also, you have to create the list on the machine where you want the packages to be installed, otherwise some dependencies will not be displayed if they are already installed on that machine but not on yours.