Home Linux DistributionsDebian Download Recursive Dependencies Of A Package In Ubuntu
How To Download Recursive Dependencies Of A Package In Ubuntu

Download Recursive Dependencies Of A Package In Ubuntu

By sk

We already knew how to download a package along with all of its dependencies in Ubuntu-like systems. Today, we will see how to download recursive dependencies of a package in Ubuntu. In other words, we are going to download the dependencies of dependencies. Let us say you are trying to install a package named a.deb. The a.deb package depends on package b.deb and again package b.deb depends on package c.deb. In this method, we not only download the dependencies of a.deb, but also the dependencies of b.deb and c.deb. This could be useful when you can't install the package even after you downloaded all of the required dependencies using apt-rdepends command.

Downloading packages with dependencies locally serves three main purposes.

  1. Avoid the repetitive download of the same set of packages over and over. For example, if you want to install Vim editor on multiple systems, you can download Vim with all required dependencies, save them in a USB drive (or transfer them via LAN) and install Vim on other system.
  2. Save the Internet bandwidth and time.
  3. Install Packages on non-internet connected systems. This is the main reason for downloading packages with dependencies locally. You can download the packages in an Internet-connected system and then transfer them to the offline system via USB drive or LAN and install them in it without Internet.

The reasons could be vary for you. If you ever wanted to install packages on an offline system, this method would definitely help.

Download Recursive Dependencies Of A Package In Ubuntu

For the purpose of this guide, we will take Vim program as an example.

First, let us list recursive dependencies of the Vim package using the following command:

$ apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances vim | grep "^\w" | sort -u

Replace vim with your own package. If you want to display the output in column format for easy reading, run:

$ apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances vim | grep "^\w" | sort -u | column

Sample output:

cdebconf		libacl1			libdb5.3		liblzma5:i386		libpython3.6-stdlib	libtinfo5		vim
debconf			libacl1:i386		libdebian-installer4	libmpdec2		libreadline7		libzstd1		vim-common
dpkg			libattr1		libexpat1		libncursesw5		libselinux1		libzstd1:i386		vim-runtime
dpkg:i386		libattr1:i386		libffi6			libnewt0.52		libselinux1:i386	mime-support		xxd
gcc-8-base		libbz2-1.0		libgcc1			libpcre3		libslang2		perl-base		xxd:i386
gcc-8-base:i386		libbz2-1.0:i386		libgcc1:i386		libpcre3:i386		libsqlite3-0		readline-common		zlib1g
install-info		libc6			libgpm2			libpython3.6		libssl1.1		tar			zlib1g:i386
install-info:i386	libc6:i386		liblzma5		libpython3.6-minimal	libtextwrap1		tar:i386

list recursive dependencies of a package in ubuntu

These are the dependencies of dependencies of Vim program. Please note that all of these may not required to install Vim.

Let us go ahead and download recursive dependencies of the Vim package with command:

$ apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances vim | grep "^\w" | sort -u)

This command will download vim along with its dependency programs in the current directory. It will also download the dependencies of the Vim's dependencies.

download recursive dependencies of a package in ubuntu

Check all of the dependencies have been downloaded using "ls" command:

$ ls

Here is the list of Vim program's dependencies and the dependencies of its dependencies in my Ubuntu 18.04 desktop:

Recursive dependencies of a package in ubuntu

Now move all of the downloaded files via a USB drive or LAN to the offline system. And then go to the location where you saved all downloaded packages in your offline system and install them using command:

$ sudo dpkg -i *

Alternatively, you can build the index of all downloaded packages and install them using APT package manager.

To build index of the downloaded packages, go to the location where the packages are stored and run the following command:

$ dpkg-scanpackages . | gzip -c9 > Packages.gz

Add this folder to APT source list using the following command:

$ echo "deb[trusted=yes] file:///home/sk/vim ./" | sudo tee -a /etc/apt/sources.list

Here, I have saved all the files in /home/sk/vim folder in my offline system. You need to replace this path with your own.

Update the package index using command:

$ sudo apt-get update

Finally, install the vim package using APT package manager:

$ sudo apt-get install vim

Similarly, you can download and install other packages as well.

Suggested Read : 

Hope this helps.

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like


Sergey June 15, 2020 - 7:28 pm

is it possible to download packages for another edition of Debian?
I have two computers with different Debians editions installed on: 9, Stretch on netbook and 10, Buster on desktop (without Internet).
I tried to install packages (with dpkg -i * command) direct but it broked my Debian Buster (the system had installed reduced version of critical important dlls and for some reason it did not asked my for).

sk June 16, 2020 - 3:00 pm

I guess it is possible with Synaptic package manager. Install Synaptic on your Debian systems. Generate package download script in your Debian system and run the script to download all the packages from any other Internet-connected system. Finally, move the downloaded packages to the Debian and install them using “dpkg” package manager. For more details, refer this link -> https://ostechnix.com/install-softwares-offline-ubuntu-16-04/


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More