Print Download URLs of Packages using APT

Print Download URLs of Packages using APT

On Debian-based Linux distributions (e.g. Ubuntu), sometimes you may want to download Debian packages (.deb) manually - maybe for offline installation, inspection, or caching. APT makes this easy with a built-in option that lets you print the direct download URLs of packages without actually installing them. This tutorial explains how to print download URLs of packages using APT.

The --print-uris option instructs APT to display the URLs of all .deb files it would download during installation - without downloading or installing anything. For example:

sudo apt-get install --print-uris tmux | awk -F"'" '/http:/{print $2}'

The --print-uris option also prints additional metadata like package size and filename. To isolate just the URLs from this output, we can use awk command, which extracts only HTTP links. This combination is ideal for extracting clean download URLs for manual or offline package installation.

Sample output:

http://archive.ubuntu.com/ubuntu/pool/main/libe/libevent/libevent-core-2.1-7t64_2.1.12-stable-9ubuntu2_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/main/libu/libutempter/libutempter0_1.2.1-3build1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/main/t/tmux/tmux_3.4-1ubuntu0.1_amd64.deb

Leave a Comment

Cancel reply

Your email address will not be published.