Tuesday, February 10, 2009

Install Softwares on Ubuntu without Internet Connection

When installing ubuntu, it's a must that you have an internet connection when installing softwares since the software packages are downloaded from ubuntu's repositories.

But what if you installed ubuntu on a PC that is not directly connected to the internet?

there is hope.. this post is all about this.. Installing Softwares on Ubuntu without Internet Connection. (atleast without your PC directly connected to the internet).

you'll be needing a couple of things:
  1. your PC where ubuntu is installed (no internet connection)
  2. another PC which is connected to the internet (good if ubuntu is installed here as well, if not, you can always run ubuntu using liveCDs)
  3. usb flash drives (you'll use this to copy your downloaded packages)
  4. Ubuntu LiveCD (incase the PC connected to the internet has windows installed on it)

Upating your PC

Assuming your PC is newly installed with Ubuntu, you need to update it: meaning download all files needed by ubuntu for it to know all the location of softwares (and also the list of softwares)

on your terminal, do this: (in case you don't know where the terminal is, see this link)
sudo apt-get update -qq --print-uris |cut -d\' -f 2 > upgradelist.txt
That command will generate a file named "upgradelist.txt" which contains a list of files to be downloaded later on the PC with internet connection. On my pc upgradelist.txt looks like this:

Copy that file (upgradelist.txt) on your usb flash drive.


Downloading the Upgradelist.txt

Boot the PC with internet connection using a Ubuntu LiveCD (or using an ubuntu installed on usb flash drive). Then, copy the file "upgradelist.txt" on a folder on the desktop, and name it Upgrade.

on the terminal do this:
cd Desktop/Upgrade

wget -i upgradelist.txt -x
The last command will download all the files on directories. On my PC it downloaded files and put them on three directories:
  1. ph.archive.ubuntu.com
  2. security.ubuntu.com
  3. wine.budgetdedicated.com
Don't worry if we don't have the same directories.

Copy those directories on your usb flash drives, and bring them on your PC without internet connection.


Updating your PC with the downloaded files

Now that you've downloaded the files, we need to put them on your PC and let Ubuntu know where they are. Press ALT+F2 and type
gksu nautilus
That command will open a file manager with root (admin) privileges. Using this file manager, copy all the downloaded directories on the root directory under a directory named localrep.

This is equivalent to doing
sudo mkdir /localrep
in your terminal

The following figure shows my downloaded directories under localrep directory.

Next, we'll be editing the file where the original repositories are listed. Using the file manager with Root privileges, go to
/etc/apt/
and look for the file "sources.list"

Make a duplicate copy of that file and name it "sources.list.bak" (right-click on the file, copy, and then paste). It is important that you are using a file manager with Root privileges to be able to do this.

Incase something goes wrong, you'll be needing that file.

Next, right-click the file and select "Open with Text Editor..." (again it is also important that you are using a file manager with Root privileges to be able to do this)

(again you can open a file manager with root privileges by pressing alt+f2, then typing gksu nautilus)

Using the Replace button, replace all http:/ on that file with file:/localrep.

For instance, the line that says
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
should be renamed to
deb file:/localrep/localrep/security.ubuntu.com/ubuntu hardy-security main restricted
see the following figure for reference

Next, we tell ubuntu to use those lines, instead of the original ones. On your terminal do this
sudo apt-get update
Or
under System>Administration>Synaptic Package Manager, click on Reload.

Your PC is now ready to generate a download script file for any software you wish to install.


Selecting the Software Package to be installed

As an example we will be downloading vlc (a multimedia player).

On the Synaptic Package Manager, search for vlc, click on it, and on the pop-up that shows, select Mark for Installation. If it asks you to Mark Additional Required Changes, simply select Mark.

(don't click on Apply yet)

Under File, click on Generate package download script. This will generate a script that will be used to download all the files needed to install vlc on your machine. Save the script as downloadscript.sh.

But first, we need to edit that downloadscript.sh file, and replace some things.

Since that file was created with Root privileges, we also need a text editor with Root privileges in order to edit it. Press ALT+F2, and type
gksu gedit
A text editor will show up, open downloadscript.sh, and replace all instances of "file:/localrep" with "http:/".

Your file should look like this:


Save and Copy that file on your usb flash drive.


Downloading the Packages

Copy the downloadscript.sh on the PC with internet connection under a folder named VLC.

on your terminal, go to the director where the script is saved (in the folder named VLC), and do this
./downloadscript.sh
It will begin to download all the packages needed to install vlc.

After downloading, copy all the .deb files on a folder (or better, copy the entire folder VLC) into you usb flash drive.


Installing the Downloaded Packages

On your PC, fire up the Synaptics Package Manager, by going to System>Administration>Synaptics Package Manager.

Select again vlc, click, and then select Mark for Installation. If it asks you to Mark Additional Required Changes, simply select Mark.

Still under the Synaptics Package Manager, click on Add Downloaded Packages. Go to the directory where the downloaded packages are, click Open. And it will ask you to Apply the Following Changes? simply click on Apply.

vlc will now be installed.


Do the same process if you will need to install any other software.

enjoy!

10 comments:

  1. Really a master in linux system.
    Gonna be here always. :)

    ReplyDelete
  2. Thank you very much for the painstakingly detailed tutorial. I do not understand the Linux file system very well yet, but still swear by Ubuntu. I just wondered, what about the motherboard specific drivers, how does one install them if the PC with the Internet connection is different?

    ReplyDelete
  3. really really a nice and informative tutorial thanks dude

    ReplyDelete
  4. "On the Synaptic Package Manager, search for vlc, click on it, and on the pop-up that shows, select Mark for Installation. If it asks you to Mark Additional Required Changes, simply select Mark."

    When I have no internet on the machine, I can't see any of the files... It cannot download information (reload), therefore it cannot show me VLC or any other package for that matter.

    ReplyDelete
  5. over the years i`ve looking for manual like this )
    I`ve 2 machines with- & without internet connection, so i cant upgrade 1st one.
    It`ll help me, sure. Thanks, greetings to others !

    ReplyDelete
  6. Thank you for this great tutorial! I learned a lot of how to bypass the no Internet connection issue when doing a fresh install of Ubuntu.

    Thank you great tutorial.

    ReplyDelete
  7. thank you verymuch for giving tutorials about installing updates without internet connection i struggled to install by connecting to the internet thanks alot

    ReplyDelete
  8. nice...but u can do it in different way that i came up with..see my blog..

    http://kishor15389.blogspot.com/2010/11/install-vlc-player-and-other-packages.html

    i'm sure u'll like it..

    ReplyDelete
  9. Interesting way to build a blog! I think we need more blogger like this one who loves this kind of softwares and ways to be informative, by the way according with this topic, Ubuntu packages are based on packages from Debian's unstable branch: both distributions use Debian's deb package format and package management tools (APT and Synaptic). 23jj

    ReplyDelete