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:
- your PC where ubuntu is installed (no internet connection)
- 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)
- usb flash drives (you'll use this to copy your downloaded packages)
- Ubuntu LiveCD (incase the PC connected to the internet has windows installed on it)
Upating your PCAssuming 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.txtBoot 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:
- ph.archive.ubuntu.com
- security.ubuntu.com
- 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 filesNow 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 installedAs 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 PackagesCopy 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 PackagesOn 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!