How to download a software package with all dependencies and sub-dependencies?

10,223

You need to run a command that automatically resolves all the .deb file's dependencies and installs the .deb file and its missing dependencies with the same command. You will need a working internet connection (which you have) and your installed software to be updated with sudo apt update && sudo apt upgrade to download any missing dependencies. Open the terminal and type:

apt download package-name  
apt install --simulate ./package-name.deb # dry run doesn't install anything

where package-name should be replaced by the name of the package that you are trying to download and package-name.deb should be replaced by the name of the .deb file that you are trying to install.

The second command doesn't install anything, it's just a dry run simulation to list the dependencies that need to be installed on the offline machine. You might also have to run the apt install --simulate ./package-name.deb command again in case one or more of the .deb files that you download itself has unmet dependencies.


In case the Ubuntu is not installed on the computer that you are downloading packages from, then you can either boot from the same bootable media that you used to install Ubuntu and download the .deb files from an Ubuntu live session or visit the official Ubuntu Package Search website and download the .deb files manually.

Share:
10,223

Related videos on Youtube

karel
Author by

karel

Updated on September 18, 2022

Comments

  • karel
    karel over 1 year

    Similar questions have been asked already but none of them have solved my problem:

    I need to install a package on a standalone Linux box, specifically kdbg. Now I tired the command

    sudo apt-get install --download-only kdbg

    on a box connected to the internet, but it only downloads the package and dependencies that I don't have installed. Some of those dependencies (that command downloaded 117 total packages) have sub dependencies, and those sub dependencies have even more dependencies and I'm going down a rabbit hole trying to fish those packages out of the repo.

    Now I tried using a couple of other commands that supposedly will download all dependencies, even the ones I have installed. I've tried

    1. apt-get download PACKAGE && apt-cache depends -i PACKAGE | awk '/Depends:/ {print $2}' | xargs apt-get download

    and

    1. apt-get download $(apt-rdepends <package>|grep -v "^ ").

    Command one only downloads the direct dependencies, like the ones you'd find on packages.ubuntu.com if you were to search kdbg, and command two gives me the error message:

    Can't select candidate version for package <package> as it has no candidate
    

    for several different packages.

    So, to restate my question, is there a way for me to download kdbg, all of its dependencies, all of those dependencies' dependencies, so on and so forth? Or perhaps I am using one of the above commands incorrectly?

    Thanks in advance.

    • user535733
      user535733 about 6 years
      Run apt install <package> --simulate on the offline machine to get the complete list of packages the offline machine needs.
  • aderchox
    aderchox almost 4 years
    what does the --simulate switch do? It's not mentioned in the man apt.
  • karel
    karel almost 4 years
    Please run this magic command man apt-get | sed -n '/-simulate/,/^$/p' to get the complete description that starts as follows: -s, --simulate, --just-print, --dry-run, --recon, --no-act No action; perform a simulation of events that would occur based on the current system state but do not actually change the system. Locking will be disabled (Debug::NoLocking) so the system state could change while apt-get is running. source
  • aderchox
    aderchox almost 4 years
    Ahhh it's in the man apt-get not man apt...! Thank you & sorry for the ping.