Ubuntu: How can I install software or packages without Internet (offline)?



Question:

I have a friend who has got a computer that is not connected to the Internet. Is there any way to install software offline easily?


Solution:1

Check out Keryx; it's an offline repository manager.

How does it work? It lets you download updates and new programs (with dependencies) to your flash drive.

Its interface is similar to synaptic, but it works from a pendrive (it doesn't need installation). Unfortunately, the GUI needs wxwidgets, which don't come preinstalled on Ubuntu (they're cross-platform and installable from here and Ubuntu repository here). It can only install software in a Ubuntu system, but you can download the updates or new packages in any Linux, Windows or OS X.

Here you can find a tutorial.

Another detailed step-by-step tutorial is in this answer.

Launchpad also hosts downloadable files.

A screenshot:

Screenshoot


Solution:2

A quick hack

A quick hack is to copy all the packages you downloaded for your install to his machine (detailed instructions here). The .deb files are stored in /var/cache/apt/archives, then in the other computer launch Synaptic and select File -> Add Package Downloaded and search the folder were you put the files and open it, accept all (or install from terminal using the command sudo dpkg -i DEB_PACKAGE_NAME).

NOTE:
This assumes that your package manager is not setup to delete the packages straight after install. It also assumes that you are running the same version of Ubuntu (10.10, 12.04, etc) and architecture version (32b or 64b).


A DVD repository

If you want the latest bug fixes and security patches available then have a look at this tutorial, which covers creating your own DVD repository.


Solution:3

A USB repository

If you have a decent sized USB stick - assuming around 4-8Gb (or external hard drive) you can set up a custom copy of the Ubuntu repository and configure that as a local repository as covered in AptGet/Offline/Repository on help.ubuntu.com.

To get the actual package files (the .deb files), I suggest using apt-mirror.

The apt-mirror package will help you create a custom mirror which should be smaller than the 30Gb of the full repository. Install the package:

sudo apt-get install apt-mirror  

and edit its configuration file

gksudo gedit /etc/apt-mirror/mirror.list  

or since Ubuntu 14.04

gksudo gedit /etc/apt/mirror.list  

Only include the repository sections you want. Here is a simple example that copies the binary .deb files from all 4 sections (main, restricted, universe and multiverse) as well as the latest bug fixes.

# apt-mirror configuration file  ##  ## The default configuration options (uncomment and change to override)  ##  #  set base_path    /tmp/ubuntumirror  #    ## Repositories to copy from -     ## use a mirror so you don't overload the main server!!!    # Lucid binaries - no source files  deb http://archive.ubuntu.com/ubuntu lucid main restricted universe multiverse  deb http://archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse      ## Clean up older .deb files no longer in the archive  clean http://archive.ubuntu.com/ubuntu  

It is guesstimated that you will need around 15Gb of space for all 4 sections, without the source.

I have put the path for all the .deb files to be /tmp, make sure you have enough space so your hard drive does not fill up (if your hard drive does fill up and your computer freezes, /tmp should be cleared with a reboot).

If you just want the main files, remove the restricted, universe and multiverse names from the configuration file.

If you are using a different architecture (you have 64bit, but your friend has 32 bit) then add the following at the start of the mirror.list configuration file:

set defaultarch i386  

Once you have the apt-mirror configuration you want, run apt-mirror and go do something fun or life changing as it will take hours or days to get the repository (depending on your connection and the Ubuntu mirror you are using).

Once you have the .deb files, copy the files to your USB memory stick (or external hard drive) and set up the local repository as per the article mentioned previously.

Test it works before taking it to your friend!


Solution:4

You need to get a PC with Internet connection first, where you can download required .deb files. Once you have downloaded all the files, You can now create a CD/DVD rom or ISO file which can you use to install the software you have downloaded in your offline PC.

Start with a clean install or VM.
sudo apt-get install aptoncd

Install the packages you want on one PC
sudo apt-get install gbrainy

Run aptoncd
enter image description here
Click Create
enter image description here
Click Burn and set options then Apply
enter image description here
Burn it or save it
enter image description here

Note that aptoncd only backs up things in the current apt-cache.
This is why we started with a clean VM/new install and did all of this in one run.


Solution:5

I use apt-get with the "--print-uris" option to do it. I also add "-qq" so it would be quiet.

Use sed to remove extra characters added to some filenames (something like 3%2a) and to get the url, filename and md5sum of files. Use wget to download the files. Use md5sum to check if the files are downloaded properly.

You may use this to create a shell script for Linux or Mac OS (replace ".cmd" in the commands to .sh and do "chmod a+x (filename) to add permission to execute the script) or a Windows Command batch file, and an MD5Sum file to make sure the files are downloaded correctly.

Commands

Create script:

sudo apt-get <<<apt-get command and options>>> --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > script.cmd  

Examples:

sudo apt-get install anjuta --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > install-anjuta.cmd  sudo apt-get upgrade --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > upgrade.cmd  sudo apt-get dist-upgrade --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > dist-upgrade.cmd  

Create md5sum file:

sudo apt-get <<<apt-get command and options>>> --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt  

Examples:

sudo apt-get install anjuta --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt  sudo apt-get upgrade --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt  sudo apt-get dist-upgrade --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt  

You need md5sum for Windows if you're using that operating system to download files.


Create script to download repository listings:

sudo apt-get update --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) :/wget -c \1 -O \2.bz2/p" > update.cmd  

Checking MD5 Sums

You may add these to the ends of scripts to check md5sum:

Linux:

md5sum --quiet -c md5sum.txt  

Windows (uses older md5sum, does not support --quiet):

md5sum -c md5sum.txt  

To add automatically to script:

echo -e "md5sum -c md5sum.txt\npause" >> script.cmd  

Installing List Files (Update Command)

Run these commands to the target computer.

You need to use bunzip2 to extract the repository list files:

bunzip2 *.bz2  

Then copy to listing folder (current folder only contains list files):

sudo cp * /var/lib/apt/lists/  

Above combined (current folder may contain other files):

for listfile in `ls *.bz2`; do bunzip2 $listfile; sudo cp ${listfile%.bz2} /var/lib/apt/lists/; done  

Faster Downloads

If you want to make downloading the files faster, try using Axel.

Replace wget -c ... -O ... with axel ... -o ....

Folder Hierarchy (Downloading files using Windows)

I usually create a folder like this:

  • apt-get/
    • bin/
      • msys-1.0.dll
      • msys-intl-8.dll
      • wget.exe
      • msys-iconv-2.dll
      • md5sum.exe
      • libeay32.dll
      • libintl3.dll
      • libssl32.dll
      • libiconv2.dll
    • update/
      • update.cmd
      • md5sum.txt
    • install/
      • install-foo.cmd
      • install-bar.cmd
      • upgrade.cmd
      • md5sum.txt

Then change wget in the lines above to ..\\bin\\wget.exe, md5sum to ..\\bin\\md5sum.exe, etc.

This will separate the *.deb files and list files into different folders.

Updating your system

  1. Boot to target computer that uses Ubuntu
  2. Create a script for update
  3. Boot to a computer with an internet connection
  4. Run update.sh (for Linux or Mac OS) or update.cmd (Windows)
  5. Go back to target computer
  6. Install list files
  7. Create a script for upgrade/dist-upgrade (add md5sum commands to end)
  8. Go back to computer with internet connection
  9. Run upgrade.sh/dist-upgrade.sh (Linux or Mac OS) or upgrade.cmd/dist-upgrade.cmd (Windows)
  10. Go back to target computer
  11. Copy *.deb files to cache: sudo cp *.deb /var/cache/apt/archives/
  12. Run: sudo apt-get upgrade or sudo apt-get dist-upgrade

Download Executables for Windows

Wget for Windows: http://gnuwin32.sourceforge.net/packages/wget.htm

md5sum for Windows: http://gnuwin32.sourceforge.net/packages/coreutils.htm or http://www.etree.org/cgi-bin/counter.cgi/software/md5sum.exe

You may also use the ones from MinGW, which are what I use. You only need wget.exe, md5sum.exe and the necessary shared libraries. Check the section "Folder Hierarchy".

Notes

  • I'm not entirely sure if everything above commands will work, since I haven't used them for a month now. Especially the update command, which I haven't tested today some parts of it.
  • To easily see the results of the commands, add a "pause" line in the end of the scripts, if using Windows.
  • I recommend to create shell scripts to update, upgrade and install packages if you're using these commands often.


Solution:6

Offline Repository

How to create an offline repository is described here: You just have to download the appropriate files from archive.ubuntu.com. Alternatively, you could use apt-medium.

EDIT: Another approach based on a local rchive of *.deb files is described in different blog entries (see here and here). Sarath Chandra summarizes as follows:

  1. Make a dir accessible (atleast by root)

    sudo mkdir /var/my-local-repo  
  2. Copy all the deb files to this directory.

  3. Make the directory as a

    sudo bash -c 'dpkg-scanpackages /var/my-local-repo /dev/null | gzip -c9 > /var/my-local-repo/Packages.gz'  

    or

    sudo dpkg-scanpackages /var/my-local-repo /dev/null | gzip -c9 > /var/my-local-repo/Packages.gz  
  4. Add the local repo to sources

    echo "deb file:/var/my-local-repo ./" > /tmp/my-local.list  sudo mv /tmp/my-local.list /etc/apt/sources.list.d/my-local.list  sudo apt-get update  


Solution:7

In synaptic you can select the packages you want to install and under the first menu there is an option to generate a script which you can take to another machine and run there. This script will "wget" (i.e. "download") all the packages you specified that you wanted (and their dependencies) which you run on a computer that does have internet access.

Once run you'll have all the package files needed by the disconnected computer. Carry them on a CD/USB stick and install them by sudo dpkg -i *.deb.


Solution:8

You can use Cube. It is a portable package manager which is compatible with Ubuntu, Linux Mint and other distributions that use apt-get.

Cube Running on Windows Cube Server

Cube Running on Linux Cube Server

Downloading Repositories Cube Server

Downloading Apps Cube ServerCube Server

Installing Apps on Linux Cube Server

You can install Camicri Cube Server via apt-get by entering the following commands in your terminal:

sudo add-apt-repository ppa:camicrisystems/daily  sudo apt-get update && sudo apt-get install cube-server  

Or download the offline installers (Windows and Linux) in our Launchpad Page.

Here is a complete tutorial on how to download, install and use Cube Server on Linux and Windows.


Solution:9

Step 1: Get the download URLs in a file :

Execute the following command replacing package-names with required ones, separating by a space.

apt-get -y install --print-uris package-name | cut -d\' -f2 | grep http:// > apturls  

Step 2: Copy this file (apturls) to a machine which has high-speed Internet access, and execute the following command to download the packages:

wget -i path-to-apturls-file   

Step 3: Now get those downloaded packages to your machine, and install them using :

cd path-to-the-downloaded-packages-directory    sudo dpkg -i *.deb  

Done!


Solution:10

You can use apt-offline or apt-offline-gui.
Pre-requistes: A friend's system with Internet connection. apt-offline installed in both your systems.

The Offline installation is achieved in 3 simple steps.

Step 1:
Generate a signature file on the Disconnected Debian box at home
apt-offline set /tmp/apt-offline.sig
The above command will generate all information required from apt about updating its database.

Step 2:
Download data based on the signature file generated earlier
apt-offline get C:\apt-offline.sig --threads 5
The above command will download data as mentioned in the signature file. To speed up downloads (that can be from multiple apt repositories), in this example we spawn 5 download threads.
Once completed, you could just copy the data (an archive file, if you used the --bundle option) back to the removable medium and copy it back onto your offline host.

Step 3:
Once you're back upon the home Debian machine, you feed the data from the removable medium to apt-offline:
apt-offline install /media/USB/apt-offline.zip
This will update the APT database on your disconnected machine seamlessly.

Apt-offline can be even used in Windows systems. In my opinion, apt-offline is the best option for Offline installation.

Source


Solution:11

There are several good, effective answers listed above. However, this is the mechanism I personally use -- apt-ftparchive. I'm documenting it here, in case I need it again in the future. Perhaps it might be useful to you.

Creating the Archive Snapshot

  • Create an instance of Ubuntu that closely mimics the target environment
    • For example, an Ubuntu 12.04 64-bit instance in Amazon
  • Start with a clean package environment
    • sudo apt-get clean
  • Update the package lists
    • sudo apt-get update
  • Download all package updates available
    • sudo apt-get dist-upgrade --download-only
  • Download all relevant packages and dependencies
    • sudo apt-get install --download-only byobu run-one bikeshed dotdee powernap
  • Install the apt-ftparchive utility
    • sudo apt-get install apt-utils
  • Create the package manifest
    • (cd /var/cache/apt/archives/ && sudo apt-ftparchive packages . ) | sudo tee /var/cache/apt/archives/Packages
  • Create an archive of the packages
    • sudo tar cvf snapshot.tar -C /var/cache/apt archives/

Using the Archive Snapshot on the Offline Target System

  • Through some mechanism, you will need to get the snapshot.tar from the source to the target system. Perhaps on a USB stick, or otherwise.
  • Extract the archive on the target system (in this case, in /home/ubuntu)
    • tar xvf snapshot.tar
  • Add the local, offline source to /etc/apt/sources.list
    • echo "deb file:/home/ubuntu/archives /" | sudo tee -a /etc/apt/sources.list
  • Update the package list
    • sudo apt-get update
  • Install the packages as desired
    • sudo apt-get install byobu run-one bikeshed dotdee powernap


Solution:12

For offline installation you will need the packages. If you are using a Debian system

  • Get the package file with the .deb file extension and use dpkg -i package_name to install it
  • Get the source tarball with the .tar.gz or .tar.bz2 file extension, then extract and install them with:

    tar -zxvf your_pack.tar.gz` or tar `-jxvf your_pack.tar.bz2  make  sudo make install  make clean        (optional, and may prevent uninstallation)  

You may have problems with dependencies. You need to install all those first for a successful offline installation.


Solution:13

Yes. You can download the DVD iso, burn it on a DVD, and install the software from the DVD. See here CDs and DVDs can be given as source to package managers in the same way as online archives.


Solution:14

The first thing you could do before an offline package installation is update the repository/repositories that you need. You should for sure like an updated the Main repository (for free and officially supported software).

The applications which you are looking to install might be in some other repositories like the Universe (free but no official support), or the Restricted (non-free, officially supported), or the Multiverse (non-free, no official support) repository. So you might want one or more of these too.

So the first step in the process is to build an updated offline repository; then generate the "to-download" list and download them, and finally the insatllation. Here's how it's done: source

  1. Enter the url: http://archive.ubuntu.com/ubuntu/dists/suiteCodename where suiteCodename should be appropriately substituded say precise for Ubuntu 12.04 (Precise Pangolin) [or utopic for Ubuntu 14.10 (Utopic Unicorn)] so that you'd now be in http://archive.ubuntu.com/ubuntu/dists/precise/ or any other specific to the suite you have.

  2. Download the files Release, Release.gpg, and the Contents-????.gz file for your architecture (i.e Contents-i386.gz , assuming you architecture is i386). Save these three files in a directory/folder named after your suiteCodename (precise for Precise Pangolin).

  3. Next you'll have to do the following for each of the repositories (among Main, Universe, Restricted, Multiverse) you want.

    a. go to the target repository directory eg. main and then to the architecture directory eg. binary-i386 so that you'd be in http://archive.ubuntu.com/ubuntu/dists/suiteCodename/repositoryName/binary-????/

    b. download the contents Packages.bz2, Packages.gz, Release and save them in a directory named after the repositoryName eg. main and place this directory in the previously created suiteCodename directory.

    c. repeat a. and b. for each of the repositories you want.

  4. Finally you should have a structure something like this:

     precise   â"œâ"€â"€ Contents-i386.gz   â"œâ"€â"€ main   â"‚   â""â"€â"€ binary-i386   â"‚       â"œâ"€â"€ Packages.bz2   â"‚       â"œâ"€â"€ Packages.gz   â"‚       â""â"€â"€ Release.txt   â"œâ"€â"€ Release.gpg   â"œâ"€â"€ Release.txt   â""â"€â"€ universe       â""â"€â"€ binary-i386           â"œâ"€â"€ Packages.bz2           â"œâ"€â"€ Packages.gz           â""â"€â"€ Release.txt  

    (assuming your suiteCodename = precise, architecture is i386, and you need main and universe repositories)

  5. Next, after having the updated repositories downloaded, you'd place the downloaded files arranged in a proper structure (as shown above) in a directory of the target offline computer. Save the directory structure precise in a folder named offlineRepository/dists/precise in your user home (~/offlineRepository/dists/precise) or anywhere else (/home/offlineRepository/dists/precise using sudo previleges in a terminal or with Nautilus file manager started with gksu nautilus; also make sure you have the right permissions for the copied structure). Your offline repository information would then be ready for use.

  6. Add the local repository in your sources list. With Ubuntu Software Centre, go to Edit -> Software Sources ... -> Other Software -> Add... and then in the field for APT line, add: deb file:///home/offlineRepository precise main universe and click Add Source. Be sure you modify the line as to your directory/file structure and suite. Then reload the packages or run sudo apt-get update in a terminal. snap1

  7. Now with updated (and probably newly added repositories too), you can dump the list of urls for the packages and dependencies.

    I borrow the following line of code from one of the previous askUbuntu post:

    sudo apt-get install packageName --print-uris | grep -o '\'http.*\' | tr "\'" " " > /tmp/package-list.txt  

    eg. to install Synaptic Package Manager:

    sudo apt-get install synaptic --print-uris | grep -o '\'http.*\' | tr "\'" " " > /tmp/package-list.txt  

    (You can also generate update lists in a similar way.)

    The generated list can be used to download the package and the entire dependencies on an online computer. Create a script to download or use the list for batch download in some download managers. (Also note the text file generated uses Unix/Linux line ending, and which you might want to change to Windows.) There used to be an easier way for this when Synaptic Package Manager was a default application in Ubuntu.

  8. Finally in the target system, you can install the packages with dpkg or using any other way.

Getting the updated package database including the security updates

The following structure, in addition to above explanation, should give you the idea:

/opt/offlineRepoList/  â""â"€â"€ dists      â"œâ"€â"€ precise      â"‚   â"œâ"€â"€ Contents-i386.gz      â"‚   â"œâ"€â"€ main      â"‚   â"‚   â""â"€â"€ binary-i386      â"‚   â"‚       â"œâ"€â"€ Packages.bz2      â"‚   â"‚       â"œâ"€â"€ Packages.gz      â"‚   â"‚       â""â"€â"€ Release.txt      â"‚   â"œâ"€â"€ Release.gpg      â"‚   â"œâ"€â"€ Release.txt      â"‚   â""â"€â"€ universe      â"‚       â""â"€â"€ binary-i386      â"‚           â"œâ"€â"€ Packages.bz2      â"‚           â"œâ"€â"€ Packages.gz      â"‚           â""â"€â"€ Release.txt      â"œâ"€â"€ precise-security      â"‚   â"œâ"€â"€ Contents-i386.gz      â"‚   â"œâ"€â"€ main      â"‚   â"‚   â""â"€â"€ binary-i386      â"‚   â"‚       â"œâ"€â"€ Packages.bz2      â"‚   â"‚       â"œâ"€â"€ Packages.gz      â"‚   â"‚       â""â"€â"€ Release      â"‚   â"œâ"€â"€ Release      â"‚   â"œâ"€â"€ Release.gpg      â"‚   â""â"€â"€ universe      â"‚       â""â"€â"€ binary-i386      â"‚           â"œâ"€â"€ Packages.bz2      â"‚           â"œâ"€â"€ Packages.gz      â"‚           â""â"€â"€ Release      â""â"€â"€ precise-updates          â"œâ"€â"€ Contents-i386.gz          â"œâ"€â"€ main          â"‚   â""â"€â"€ binary-i386          â"‚       â"œâ"€â"€ Packages.bz2          â"‚       â"œâ"€â"€ Packages.gz          â"‚       â""â"€â"€ Release          â"œâ"€â"€ Release          â"œâ"€â"€ Release.gpg          â""â"€â"€ universe              â""â"€â"€ binary-i386                  â"œâ"€â"€ Packages.bz2                  â"œâ"€â"€ Packages.gz                  â""â"€â"€ Release  


Solution:15

After browsing the answers on here: How can I install software or packages without Internet (offline)? , I found this code by Arnel A. Borja the most useful.

sudo apt-get install PACKAGE --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > install.sh


Anyway, here are some instructions for complete newbies. I hope that you will find them useful.

Complete download instructions for others new to Ubuntu 15.10+:

  1. Open the Terminal (shortcut CTRL + ALT +T)
  2. Navigate to the folder that you would like the package to be downloaded to by using the command:

    cd FOLDERNAME
    (Example: cd Desktop)
    Tip: You can also use the dir command to list the folders.

  3. In the code above the instructions, replace PACKAGE with the package that you wish to download.
  4. Copy and paste the modified code (shortcut CTRL + SHIFT + V) and press Enter

    Example code to download Synaptic Package Manager:
    sudo apt-get install synaptic --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > install.sh

    Example code to download VLC player:
    sudo apt-get install vlc --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > install.sh

  5. If asked, type in the root password and press Enter. (Do not panic if the characters for the password do not show. It's just a security measures.)
  6. The "install.sh" file should be now generated. All dependencies that are needed are included within the script.
  7. Now we need to run the script with this command:
    sh install.sh
  8. Wait for the files to be downloaded
  9. Afterwards, you can either use this command to install all the packages within the folder:

    sudo dpkg -i *.deb

    Or you could use a program like Synaptics to install the packages. (Synaptics: File - Add downloaded packages)
    Alternatively, you can also just double click the files. That will open the Ubuntu Software Center. Once software center is loaded, press the install button. Repeat this until all the files in the folder are installed.


Solution:16

For a system that will always be kept offline, it is usually best to use one of the robust offline package management methods presented in some of the other answers, since they facilitate keeping already-installed packages up to date rather than merely installing a handful of packages, one time.

However, for isolated cases where you just want to quickly install packages on a system that doesn't have an Internet connection (and you have the ability to download them on another machine and bring them over), you can do so. The main complication is determining what you need, since a package often has other packages it depends on, and which must therefore be installed before, or at the same time as, the package is installed.

This answer is motivated by the duplicate question g++ in Ubuntu 14.04, and uses the case of needing to install g++ as its core example.

I emphasize that this method should not be used long-term as an alternative to something that at least facilitates automatically determining and installing needed security updates. Never connecting to a network reduces the potential for an attack considerably, but some security bugs can be exploited via data from any source.

While this method may look complex, it usually only takes a few minutes to actually use. For packages with a large number of dependencies, it may take longer. For installing metapackages that pull in a very large number of dependencies (e.g., ubuntu-desktop on a minimal system), it can take much longer to download all the necessary .deb files and this method is unlikely to be suitable.

Determining Needed Dependencies

You can simulate the installation to determine which other packages are needed to satisfy the package's dependencies. Passing the -s flag to apt-get (before you specify any action) does this.

apt-get -s install g++  

I've omitted sudo, since this is just a simulation, so root privileges aren't needed.

If you actually want to install all the most common tools for building packages, rather than just g++, you might prefer:

apt-get -s install build-essential  

The output (for g++) will look something like this:

NOTE: This is only a simulation!        apt-get needs root privileges for real execution.        Keep also in mind that locking is deactivated,        so don't depend on the relevance to the real current situation!  Reading package lists... Done  Building dependency tree         Reading state information... Done  The following extra packages will be installed:    g++-4.8 libstdc++-4.8-dev  Suggested packages:    g++-multilib g++-4.8-multilib gcc-4.8-doc libstdc++6-4.8-dbg    libstdc++-4.8-doc  The following NEW packages will be installed:    g++ g++-4.8 libstdc++-4.8-dev  0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.  Inst libstdc++-4.8-dev (4.8.2-19ubuntu1 Ubuntu:14.04/trusty [amd64])  Inst g++-4.8 (4.8.2-19ubuntu1 Ubuntu:14.04/trusty [amd64])  Inst g++ (4:4.8.2-1ubuntu6 Ubuntu:14.04/trusty [amd64])  Conf libstdc++-4.8-dev (4.8.2-19ubuntu1 Ubuntu:14.04/trusty [amd64])  Conf g++-4.8 (4.8.2-19ubuntu1 Ubuntu:14.04/trusty [amd64])  Conf g++ (4:4.8.2-1ubuntu6 Ubuntu:14.04/trusty [amd64])  

This says that to install g++ on my system, I need packages g++, g++-4.8, and libstdc++-4.8-dev.

Going by the results of a simulation is usually better than simply looking up a package's dependencies (or assuming that what you need is the same as the above), because:

  1. You may already have some dependencies installed.
  2. The dependencies (i.e., the other packages that a package needs to install or work) themselves may have dependencies that you don't already have installed.

Getting the Packages

Once you know what packages you need, you can download them. I suggest using Launchpad for this, because the downloads are SSL-encrypted, which helps prevent file corruption.

  • This is not just a safeguard against deliberate manipulation by a malicious safeguard; it also helps prevent accidental file corruption, which is a far more problem for downloaded files.
  • There's one kind it doesn't prevent: when a file downloads only partially but you think it finished.
  • Installing a package normally with apt-get or the Software Center doesn't require HTTPS because its hash is verified against a digitally signed list of hashes. If you end up putting these packages in your package cache and using apt-get to install them, that will happen.
  • But if you end up having to install the manually downloaded packages with dpkg -i, that won't be done.

You can search for a package by typing its name under Packages at https://launchpad.net/ubuntu and clicking "Find a Package." For example, searching for g++-4.8 brings you to the gcc-4.8 source package page.

Then scroll down to the codename of your Ubuntu release. You're running 14.04, so that's Trusty Tahr. Codenames for all Ubuntu releases are listed on the releases wiki page. Click the rightward-pointing triangle to view package downloads for it.

screenshot showing the rightward facing triangle with which one expands a release to see downloads for it

For some packages you may be able to expand lists of downloads from more than one pocket. You may see:

  • release, the version of a package shipped with an Ubuntu release (or available at the time of release);
  • security, security updates shipped after release;
  • updates, any updates shipped after release;
  • proposed, updates that are available to be installed, but are still in testing and not recommended for general use;
  • backports, software originating in a later Ubuntu release and rebuilt for an earlier release.

For example, here's what's available for Firefox in 14.04:

Launchpad screenshot showing expandable selections of package downloads for multiple pockets in the same release

Generally you'll want packages in security or updates if they exist, and otherwise packages in release.

Once you expand the list of packages, find the .deb file for your architecture. The debs are named name_version_architecture.deb. The most common architectures are:

  • 64-bit PC/Mac (called amd64, for both Intel and AMD processors)
  • 32-bit PC/Mac (called i386, also for both)

For example, to get the g++-4.8 package for the 64-bit version of Ubuntu, you might download g++-4.8_4.8.4-1ubuntu15_amd64.deb.

Installing the Packages

If the packages you retrieved are the same versions apt-get's install action would've automatically retrieved and installed (if your system were network-connected), then you can put the packages in /var/cache/apt/archives and simply run that command:

sudo apt-get install g++  

If this system was never connected to the Internet, then this will probably be the case when all the packages you retrieved were from the release pocket. Regardless of whether or not the system was ever connected to the Internet, this will also almost always be the case if no packages in any other pockets were shown on Launchpad. (Essentially the only situation it won't is if you installed an alpha or beta system and never updated it.)

In the specific case of installing g++, I would use apt-get.

In cases where that doesn't work or you expect it won't, install the packages by putting them in an otherwise empty folder and running:

sudo dpkg -Ri /path/to/folder

Or you can name the packages individually. This example supposes the packages are in the current directory (i.e., that you've cded to the directory containing them):

sudo dpkg -i package1.deb package2.deb ...

Unless the number of packages being installed is very small and you know the precise order in which they need to be installed for dependencies to be satisfied, it's considerably more efficient to use those methods than to manually install each package individually.


Solution:17

If you have no connection to internet whatsoever and have not got anyone near where you can connect to the internet there is an option not mentioned yet: have someone send the source files via the regular post.

You can get the whole Ubuntu OS through mail by paying for a DVD. The same way you could ask an on-line friend to send you the DEB files or even the source files for a package like VLC to you. Though it might be worth it to have someone send a complete DVD with all packages. That way you can install it from that DVD.


Solution:18

I have a small python script that can be run on Windows that parses the ubuntu package web site to find the dependency tree and download all needed packages + doing checksum verification.

This might obviously download more than needed, but was the simplest solution for me.

https://gist.github.com/Zitrax/2bad212a3b0571357e1b

All downloaded packages can then be installed with dpkg -i E pkg\*. It avoids reinstallation of packages that are already installed.

Usage:

usage: ubuntu-deps.py [-h] [-a ARCH] [-r RELEASE] [-m MIRROR] [-f FALLBACK] [-d DIRECTORY] dep [dep ...]    Download ubuntu dependencies    positional arguments:    dep                                  The main/top package    optional arguments:    -h, --help                           show this help message and exit    -a ARCH, --arch ARCH                 The architecture to use (default: amd64)    -r RELEASE, --release RELEASE        Ubuntu release (default: trusty)    -m MIRROR, --mirror MIRROR           Mirror to use for download (default: http://no.archive.ubuntu.com/)    -f FALLBACK, --fallback FALLBACK     Mirror to use when main mirror is not found (default:                                         http://security.ubuntu.com/)    -d DIRECTORY, --directory DIRECTORY  Target directory (default: pkg)  


Solution:19

This is not a fully detailed answer, but at a high level you could:

  1. get the desired .deb pkgs (and create a list of them) (include packages they depend on that are not already installed)
  2. create an apt archive that contains them
  3. copy the apt archive to a CD or USB
  4. insert the CD or USB into the target system
  5. configure apt on the target system to include the CD or USB apt archive as a source
  6. install the packages from your list with apt-get install (list of pkgs)


Solution:20

I suggest to customize Live CDs and install them.

You also can download the files on http://packages.ubuntu.com/filename, but then you have to pay attention to the dependencies, too.


Solution:21

Another possibility is to use remastersys. This tool allows you to make an iso image from your own system and after creating a bootable usb stick via unetbootin you can install a customized system to as many computers you want.


Solution:22

I have a couple of simple suggestions. You can go to the library. Look in the computer section for the operating system that you want, some of the books have DVD's inside of them. Also, if you want the most up to date operating system, I would reccomend this website where you can purchase a DVD for a nominal fee. www.ubuntu.com/download/desktop.


Solution:23

This question is a bit old so an answer at this time may be redundant, but perhaps you could also try using dpkg-offline. Install bzr, then:

bzr branch lp:dpkg-offline  

there's a tutorial and a readme file included in there.

Assuming you want to install git on an Ubuntu 14.04 amd64 system, even if your system is e.g. 12.04 i386, you can:

  • download the ubuntu-14.04-desktop-amd64.iso image
  • Run dpkg-offline ubuntu-14.04-desktop-amd64.iso git
  • You'll obtain a tar.gz which you can transport to the target system, it will contain the seed package (git) and all its dependencies. It also includes a helper script to add a local repository, so you can use apt-get to install your packages.

dpkg-offline will work with any Ubuntu desktop version from 10.04 onwards (I haven't tested with older versions but they should also work), and with any Ubuntu server version from 12.10 onwards. It should also work with amd64, i386 and armhf images regardless of the host architecture. Again, I haven't tested with arm64 or powerpc/ppc64el but they may also work.

Disclaimer: I wrote dpkg-offline.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »