Every Flavour Beans

“The time has come…to talk of many [technologies].” –Lewis Carroll(’The Walrus and the Carpenter’)
Development Tools. Web Frameworks. GNU/Linux. Nokia N800. Video Encoding.

May 6, 2006

Update or Install Applications on Debian/Ubuntu Without an Internet Connection

Filed under: GNU/Linux, Ubuntu — tabrez @ 6:57 pm

Update: There is a simpler way for the Ubuntu 6.10(Edgy Eft) users:
Simple Way to Update Ubuntu Edgy With Slow/No Internet Connection

If you use a Debian based system(Ubuntu etc) with a slow/no Internet connection, you will be limited to installing only those applications that come with the installation CD/DVD set. The issue is more serious with Ubuntu like operating systems where there is only one installation CD/DVD. But there is a way in which the required files can be downloaded on a machine with fast Internet connection and then copied over to your local machine(using a media like CD etc) and make them available to the Advanced Package Manager(apt). Below is the complete procedure to do the same.

Note to Ubuntu users: You need to add “sudo” before all the commands specified below.

  1. On your local machine, run the following command to generate a list of files needed for the application(s) you wish to install:
    sh# apt-get –qq ––print-uris install {packagelist} | awk -F\‘ ‘{ print $2}‘ > get.lst
  2. The URIs from where to download all the files needed to install the packages listed in {packagelist} will be added to the get.lst file. Copy this file over to the machine with fast Internet connection and run the following commnad there:
    sh# wget -c -i get.lst

    This will download all the .deb files listed in get.lst file in the current directory. Copy all these .deb files to your local machine in a directory, say /root/sharedebs.

  3. Move to /root directory and run the following command:
    sh# dpkg-scanpackages sharedebs /dev/null | gzip > sharedebs/Packages.gz
  4. Now add the following line to your /etc/apt/sources.list file:

    deb file:/root sharedebs/

    Run the command ‘apt-get update’ once to update the apt cache.

Now you can install the applications in the normal way by running the
‘apt-get install’ command or using Synaptic Package Manager like tools.

You can also use the above procedure to share the .deb files that you have downloaded on your machine to install any applications with another machine(say your friend’s machine) if you want to install the same applications on it without having to download the same .deb files again. Just copy all your .deb files from /var/cache/apt/archives/partial/ to your friend’s machine(in /root/sharedebs directory) and follow the steps from Step 3 on your friend’s machine.

Here is an example of how you can install the package lynx on your local machine using the above procedure:

  1. On local machine:
    sh# apt-get -qq ––print-uris install lynx | awk -F\‘ ‘{ print $2 }‘ > get.lst
    sh# cp get.lst /media/cdrom
    sh# umount /media/cdrom
  2. Update: If you are getting errors with the above awk command, you can try with a perl script. More details in this comment.

  3. Copy the file get.lst to the machine with fast Internet connection(using a CD etc):
    sh# mkdir /home/user/debs
    sh# cp /media/cdrom/get.lst /home/user/debs
    sh# cd /home/user/debs
    sh# wget -c -i get.lst
    sh# cp *.deb /media/cdrom
    sh# umount /media/cdrom
  4. Copy all the .deb files to the local machine(again, using CD etc) in
    /root/debshare directory:

    sh# mkdir /root/debshare
    sh# cp /media/cdrom/*.deb /root/debshare
    sh# cd /root
    sh# dpkg-scanpackages sharedebs /dev/null | gzip > sharedebs/Packages.gz
  5. Add a line in the /etc/sources.list file and install the application using apt-get:
    sh# emacs -nw /etc/apt/sources.list

    deb file:/root sharedebs/

    sh# apt-get update
    sh# apt-get install lynx


If you want to receive future posts by email, enter your email address here:

Related Posts:

  • Simple Way to Update Ubuntu Edgy With Slow/No Internet Connection
  • Update or Install Applications on a Gentoo Machine Without an Internet Connection
  • Connecting To Nokia N800 From a Computer Using VNC
  • GNU/Linux Users vs Rest of the world :)
  • ‘wget -c’ Bug in Download Script Generated by Synaptic in Ubuntu 7.10(Feisty Fawn)
  • Google Does It Again - Another Elaborate April Fool Scheme(TiSP)
  • Accessing the Windows Desktop Remotely From Nokia N800 Using rDesktop

  • Readers who viewed this page, also viewed:


    17 Comments »

    1. great! this is what I just wanted for a long time… thanx, pro!

      I wonder where you learn that! I read the ubuntu manual, and has not find an answer for this until I found your blog. Are you a tutor or some school lecturer?

      I’m really appreciate your contribution. Keep up the good work.

      Quote

      Comment by huasing — June 24, 2006 @ 8:41 am

    2. if the app i want to install requires me to download updated lists of the files in the net first (like universe, restricted, etc), but the box i want to update doesn’t have an internet connection — what do i have to do first?

      thanks. great tutorial.

      Quote

      Comment by nocti — July 25, 2006 @ 2:17 pm

    3. Use ‘apt-get upgrade’ in place of ‘apt-get install {package}’ (in the first step) to generate file names needed for upgrading the system. For example, replace the following text in the command specified in the first step of the post:

      tabrez on July 28, 2006 at 4:28 pm said:

      apt-get -qq –print-uris install {packagelist}

      with the following text:

      tabrez on July 28, 2006 at 4:28 pm said:

      apt-get -qq –print-uris upgrade

      It will be a good idea to first run ‘apt-get update’ to update the sources before attempting an upgrade.

      Quote

      Comment by tabrez — July 28, 2006 @ 4:28 pm

    4. nocti on August 6, 2006 at 10:06 pm said:

      tabrez on July 28, 2006 at 4:28 pm said:

      Use ‘apt-get upgrade’ in place of ‘apt-get install {package}’ (in the first step) to generate file names needed for upgrading the system. For example, replace the following text in the command specified in the first step of the post:

      nocti on August 6, 2006 at 10:06 pm said:

      apt-get -qq –print-uris install {packagelist}

      with the following text:

      nocti on August 6, 2006 at 10:06 pm said:

      apt-get -qq –print-uris upgrade

      It will be a good idea to first run ‘apt-get update’ to update the sources before attempting an upgrade.

      how can i run `apt-get update` if there’s no internet connection? that seems moot isn’t it?

      but i’ve found a way to update the pkg lists in a non-connected box, you need to get someone (with an updated ubuntu box with the same specs as yours) and ask him to send you a tarball of /var/lib/apt/lists, copy that to your non-connected box, and _then_ you can do this tutorial :)

      Quote

      Comment by nocti — August 6, 2006 @ 10:06 pm

    5. The best course of action for those who have no Internet connection at all(instead of a slow connection) would be to keep it completely synchronised with another Ubuntu machine(with same or higher version as that of the local machine) that has got the Internet connection. In that case, it becomes very important to keep ‘/etc/apt/sources.list’ and ‘/var/lib/apt/lists/*’ files synchronised on these two machines(‘/etc/apt/sources.list’ file is not needed if you never EVER run ‘apt-get update’ on the local machine). I find it to be a very awkward way to update the apt cache when compared to the elegant way to update Gentoo offline. Someone needs to write some scripts to automate this process for Debian/Ubuntu in the same way.

      But if atleast the updating part can be done on the local machine, then the rest of the procedure can be followed to install/update applications on Ubuntu by downloading the required files even from a non-Ubuntu machine(say Windows).

      Quote

      Comment by tabrez — August 7, 2006 @ 1:04 pm

    6. Does anyone have a freshly installed Ubuntu 6.06 so that she can generate the “get.lst” file?

      I plan to give out some Ubuntu 6.06 CDs to friends, and I would like to add an easy update CD.

      Quote

      Comment by Simos — August 17, 2006 @ 3:42 pm

    7. I am a newbe and would like to use ubuntu without internet

      I have had difficulty executing your command
      apt-get -qq ––print-uris install lynx | awk -F\‘‘{ print }‘ > get.lst
      This command just produces errors

      In a text editor the command becomes
      apt-get -qq ––print-uris install lynx | awk -F\”{ print }’ > get.lst
      which also does not work
      If I remove the pipe then it works
      I looked up the awk command and find that -F indicated the field separator
      I cannot see why this is required because the { print } will print every field anyway
      I want to install java on my ubuntu machine and have heard that this is available as a package. Update does not work as I have no internet connection so I suppost I use
      apt-get -qq ––print-uris update | awk -F\’ ‘{ print }’ > get.lst
      to get the new list of packages.
      I am not sure how to proceed as this command results in several websites

      any help would be appreciated and thanks for providing this info.

      Quote

      Comment by TonyP — September 14, 2006 @ 6:18 pm

    8. Σίμος on September 15, 2006 at 1:53 am said:

      TonyP on September 14, 2006 at 6:18 pm said:

      I am a newbe and would like to use ubuntu without internet

      I have had difficulty executing your command
      apt-get -qq ––print-uris install lynx | awk -F\‘‘{ print }‘ > get.lst
      This command just produces errors

      In a text editor the command becomes
      apt-get -qq ––print-uris install lynx | awk -F\”{ print }’ > get.lst
      which also does not work
      If I remove the pipe then it works
      I looked up the awk command and find that -F indicated the field separator
      I cannot see why this is required because the { print } will print every field anyway
      I want to install java on my ubuntu machine and have heard that this is available as a package. Update does not work as I have no internet connection so I suppost I use
      apt-get -qq ––print-uris update | awk -F\’ ‘{ print }’ > get.lst
      to get the new list of packages.
      I am not sure how to proceed as this command results in several websites

      any help would be appreciated and thanks for providing this info.

      When you copy paste the commands, make sure you type again the ‘ characters.
      This blog autoconverts those characters with special ticks that are not recognised by the system. For example, compare ‘the correct’ with ‘the wrong’.

      Quote

      Comment by Σίμος — September 15, 2006 @ 1:53 am

    9. apt-get -qq ––print-uris update | awk -F\’ ‘{ print $2}’ > get.lst

      Do not copy/paste the above command from the web page; instead, type it in the command shell character by character. Here is a text file containing the above command if you are still confused(Right-click -> Save Link As).
      Download

      You can also try using the following Perl script to do the same job, if the problem with the awk command persists(Right-click -> Save Link As):
      Download

      After downloading the file, rename it to match.pl and then use the following command to generate the list of URIs:
      #sudo apt-get -qq –print-uris install sun-java5-jdk | perl -e match.pl > get.lst

      After running this commnad, the get.lst file should contain list of URIs like this:

      http://in.archive.ubuntu.com/ubuntu/pool/main/libt/libtool/libltdl3_1.5.22-2_i386.deb
      http://in.archive.ubuntu.com/ubuntu/pool/main/u/unixodbc/odbcinst1debian1_2.2.11-11build1_i386.deb
      http://in.archive.ubuntu.com/ubuntu/pool/main/u/unixodbc/unixodbc_2.2.11-11build1_i386.deb
      http://in.archive.ubuntu.com/ubuntu/pool/multiverse/s/sun-java5/sun-java5-bin_1.5.0-06-1_i386.deb
      http://in.archive.ubuntu.com/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jre_1.5.0-06-1_all.deb
      http://in.archive.ubuntu.com/ubuntu/pool/multiverse/s/sun-java5/sun-java5-demo_1.5.0-06-1_i386.deb
      http://in.archive.ubuntu.com/ubuntu/pool/multiverse/s/sun-java5/sun-java5-jdk_1.5.0-06-1_i386.deb

      This file needs to be carried over to the machine with good Internet connection and the instructions of the blog post need to be followed from Step 2.

      Quote

      Comment by tabrez — September 17, 2006 @ 2:39 pm

    10. Here’s how I updated completely without internet.

      First choose repo you need and run:
      apt-get -qq ––print-uris update | awk -F\’ ‘{ print $2}’ > get.lst
      Then use wget -c -x -i get.lst, you’ll get directories named something like security.ubuntu.com
      Now create local directory on your computer for example /root/localrep/
      copy whole directories you downloaded in to this localrep directory.
      then you must edit sourceslist. change http:// into file:/root/localrep/ on all entries. backup your original sources.list first.
      After that you can apt-get update and follow instructions to generate new get.lst
      Now you have to replace ‘file:/root/localrep/’ to http:// in get.lst and wget those files and follow instruction to install them.
      Next time you need to update copy use original sources.list and start from beginning

      This isn’t very elegant but it works. of course you could create scripts to make things little easier but I haven’t bothered

      Quote

      Comment by Jerze — September 29, 2006 @ 6:25 pm

    11. An Ubuntu project has been launched in may 2006 to answer to that question : “How could I update Ubuntu without internet”. See it in the launch pad and perhaps help it : https://wiki.ubuntu.com/OfflineUpdateSpec

      Quote

      Comment by netangel — October 20, 2006 @ 4:00 am

    12. Yeah, I have been keeping track of it since the past few months as it is one of the developments that is of most importance to me. I was pleasantly surprised to actually see the “Generate Download Script” option in the Synaptic Package Manager similar to what was being discussed in the wiki pages. I was about to blog about it but restrained from it for two reasons:

      1. this feature is so crucial for some people that it may tempt them to upgrade their Dapper machines to Edgy, without realising that Edgy is still a beta product.
      2. the feature may still go through some changes before the final version is released.

      I hope to update this post with the latest at the earliest after october 26th.

      Quote

      Comment by tabrez — October 20, 2006 @ 12:09 pm

    13. [...] Update Debian/Ubuntu Without Internet Connection C# Mono [...]

      Quote

      Pingback by Every Flavour Beans » Simple Way to Update Ubuntu Edgy With Slow/No Internet Connection — November 3, 2006 @ 3:18 pm

    14. There is also a script to handle an apt-medium at:

      http://wiki.debian.org/AptMedium

      Quote

      Comment by HB10 — January 12, 2007 @ 1:10 am

    15. Perhaps that Ubuntu project is what we are trying to do : https://launchpad.net/aptoncd ?

      Quote

      Comment by netangel — April 5, 2007 @ 5:43 am

    16. [...] Every Flavour Beans Update or Install Applications on Debian/Ubuntu Without an Internet Connection (tags: ubuntu Linux) [...]

      Quote

      Pingback by The Days » Blog Archive » links for 2007-05-11 — May 12, 2007 @ 1:57 am

    17. This information was very useful. I am a fedora user and will try to make some changes to your method to get it working with Yum also. Will this approach work even if my friend happens to have different architecture than what I have ???

      Quote

      Comment by positivecharge — November 18, 2007 @ 10:47 pm

    RSS feed for comments on this post. TrackBack URI

    Leave a comment

    Subscribe without commenting


    Copyright (c) 2006, 2007 Tabrez Iqbal.
    Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved. A copy of the license is included in the section entitled "GNU Free Documentation License".


    Powered by WordPress
    This website is hosted by Dreamhost