Use ‘apt’ To Download A Program And Its Dependencies

In this article, we’ll discuss a way to use ‘apt’ to download a program and its dependencies. The usual reason to do this is to install said program on an offline computer. We’ll be doing it all nice and neatly, just using the ‘apt’ application along the way. It won’t be all that difficult, but will be easy to link to and reference.

As I said, the usual reason to do this is because you have a computer that’s not online and you want to install some software on that computer. This could be a remedy for when you need wireless drivers in order to connect the device, or other sorts of situations. It’s a handy way to get those drivers up and running, so we might as well learn how to do so today.

We’ll be using ‘apt’ for this. We’ve used ‘apt’ for all sorts of software management tasks in the past. In fact, in the past this required a bit more effort. You’d use the ‘–download-only’ flag and get some files in your apt archives directory. Today, it’s just a quick task that outputs a handy file that is extremely portable.

In fact, this article really only needs one command, making ‘apt’ do its thing. It’s not all that difficult, either. By the way, if you don’t already know, ‘apt’ stands for Advanced Package Tool. Anyhow, I’ll still make it an article – as it’s a useful one to know and reference.

Download A Program And Its Dependencies:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal emulator now open, you need to know the name of the program you want to download. For example, I tested this with ‘openjdk-17-jre’ and it worked as expected. (For the commands you’ll use, I’ll just use my traditional brackets.) Before I tested with openjdk, I made sure it had dependencies, and it did. To see if it had dependencies, I used this command:

Once you see that it has dependencies, you can go straight to downloading the program and its dependencies. You no longer need any long commands, it’s just (even if it doesn’t have dependencies):

All you have to do at that point is wait for the files to download. When they’re done downloading you can find the file in your ~/Downloads directory combined into a single compressed file. In my case, the filename was openjdk-17-jre.tar.gq and the download completed without error.

The process is the same if you have dependencies or not. The reason we pay attention to dependencies in this article is so that you know to check and make sure those dependencies are included, so that you’re able to install the software on your offline computer.

And, with all that said, now is a good time to verify that it contains all the files it should contain. Assuming the files are what you expected, with dependencies as needed, now is the time to sneakernet them to the offline computer, where you can install the program by first installing the dependencies before installing the program.

NOTES: It does build an ‘install.sh’ which should let you install the program and dependencies in one fell swoop, but it accessed the ‘net in my testing. So, just do ’em manually if you want to be sure, otherwise make it executable and give it a shot. This will only work if the versions are all compatible with the offline computer. If that’s not the case, you could end up in dependency hell or perhaps not able to install the program at all.

Closure:

And there you have it… You have yet another article! This one is handy if you want to install a program and its dependencies on an offline computer. It may also be handy if you want to establish a base-line and standardize on that specific version of the software. In that case, you’ll have a copy of what it once was. It’s something you can reference and restore as needed. But, yeah, it’s most likely to be used by people who want to install software on offline computer.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.