The Advanced Packaging Tool (APT) and its predecessor, apt-get, are essential for managing packages in Debian-based systems like Ubuntu. These tools simplify the process of searching, downloading, and installing .deb packages and their dependencies from official repositories. APT ensures that all necessary dependencies are resolved and installed, making software management seamless for system administrators.

One of APT's useful features is its ability to download packages without installing them. This feature is valuable for downloading .deb files for purposes other than immediate installation, such as offline installations or inclusion in custom scripts.

With the download-only option, APT will download the .deb packages of the specified program and all its dependencies to the cache directory without installing them. You can then view and use the downloaded packages as needed.

Step-by-step video guide:

Steps to only download deb packages and dependencies using apt or apt-get:

  1. Launch the terminal.
  2. Clear the apt cache directory to delete existing package downloads (optional).
    $ sudo apt clean
    [sudo] password for user:
  3. Search for the exact package name if unknown (optional).
    $ sudo apt search mysql
    Sorting... Done
    Full Text Search... Done
    akonadi-backend-mysql/hirsute,hirsute 4:20.12.3-0ubuntu1 all
      MySQL storage backend for Akonadi
    
    apophenia-bin/hirsute 1.0+ds-8build1 amd64
      Apophenia Statistical C Library -- binary package
    
    apophenia-doc/hirsute,hirsute 1.0+ds-8build1 all
      Apophenia Statistical C Library -- reference manual
    
    asterisk-mysql/hirsute 1:16.16.1~dfsg-1 amd64
      MySQL database protocol support for the Asterisk PBX
    
    audiolink/hirsute,hirsute 0.05-4 all
      makes managing and searching for music easier
    
    automysqlbackup/hirsute,hirsute 2.6+debian.4-3 all
      daily, weekly and monthly backup for your MySQL database
    
    autopostgresqlbackup/hirsute,hirsute 1.1-1 all
      Automated tool to make periodic backups of PostgreSQL databases
    
    backup-manager/hirsute,hirsute 0.7.14-1.2 all
      command-line backup tool
    
    backupninja/hirsute,hirsute 1.2.1-1 all
      lightweight, extensible meta-backup system
    
    bacula-common-mysql/hirsute 9.6.7-3 amd64
      network backup service - MySQL common files
    
    bacula-director-mysql/hirsute,hirsute 9.6.7-3 all
      network backup service - MySQL storage for Director
    ##### snipped
  4. Download the package and its dependencies using apt.
     $ sudo apt --download-only --assume-yes install mysql-server
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmecab2 libprotobuf-lite23
      mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
    Suggested packages:
      libipc-sharedcache-perl mailx tinyca
    The following NEW packages will be installed:
      libaio1 libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmecab2 libprotobuf-lite23
      mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0
    0 upgraded, 20 newly installed, 0 to remove and 0 not upgraded.
    Need to get 29.1 MB of archives.
    ##### snipped
    Fetched 29.1 MB in 19s (1,525 kB/s)                                                                                                                                                 
    Download complete and in download only mode
  5. Check the downloaded .deb archives in the apt cache folder.
    $ ll /var/cache/apt/archives/
    total 28524
    drwxr-xr-x 3 root root    16384 Ogos 31 10:06 ./
    drwxr-xr-x 3 root root     4096 Ogos 31 10:04 ../
    -rw-r--r-- 1 root root     6972 Mac  23 05:18 libaio1_0.3.112-9ubuntu1_amd64.deb
    -rw-r--r-- 1 root root    10520 Jul  18  2019 libcgi-fast-perl_1%3a2.15-1_all.deb
    -rw-r--r-- 1 root root   186112 Okt  29  2020 libcgi-pm-perl_4.51-1_all.deb
    -rw-r--r-- 1 root root    89368 Jul  12  2020 libevent-core-2.1-7_2.1.12-stable-1_amd64.deb
    -rw-r--r-- 1 root root     7364 Jul  12  2020 libevent-pthreads-2.1-7_2.1.12-stable-1_amd64.deb
    -rw-r--r-- 1 root root    26076 Jan  12  2021 libfcgi0ldbl_2.4.2-2_amd64.deb
    -rw-r--r-- 1 root root    10744 Jan  12  2021 libfcgi-bin_2.4.2-2_amd64.deb
    -rw-r--r-- 1 root root    21604 Jan  31  2021 libfcgi-perl_0.79+ds-2_amd64.deb
    -rw-r--r-- 1 root root    59124 Dis  24  2020 libhtml-template-perl_2.97-1.1_all.deb
    -rw-r--r-- 1 root root   216892 Dis   8  2020 libmecab2_0.996-14build3_amd64.deb
    -rw-r--r-- 1 root root   189840 Mac  29 14:38 libprotobuf-lite23_3.12.4-1ubuntu2_amd64.deb
    -rw-r----- 1 root root        0 Apr  20 18:59 lock
    -rw-r--r-- 1 root root  6717648 Mei  19  2020 mecab-ipadic_2.7.0-20070801+main-3_all.deb
    -rw-r--r-- 1 root root     4384 Mei  19  2020 mecab-ipadic-utf8_2.7.0-20070801+main-3_all.deb
    -rw-r--r-- 1 root root     4916 Dis   8  2020 mecab-utils_0.996-14build3_amd64.deb
    -rw-r--r-- 1 root root    22016 Jul  26 22:25 mysql-client-8.0_8.0.26-0ubuntu0.21.04.3_amd64.deb
    -rw-r--r-- 1 root root  3918928 Jul  26 22:25 mysql-client-core-8.0_8.0.26-0ubuntu0.21.04.3_amd64.deb
    -rw-r--r-- 1 root root     7496 Ogos 23  2019 mysql-common_5.8+1.0.5ubuntu2_all.deb
    -rw-r--r-- 1 root root     9536 Jul  26 22:25 mysql-server_8.0.26-0ubuntu0.21.04.3_all.deb
    -rw-r--r-- 1 root root  1423236 Jul  26 22:25 mysql-server-8.0_8.0.26-0ubuntu0.21.04.3_amd64.deb
    -rw-r--r-- 1 root root 16211156 Jul  26 22:25 mysql-server-core-8.0_8.0.26-0ubuntu0.21.04.3_amd64.deb
    drwx------ 2 _apt root     4096 Ogos 31 10:06 partial/

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.