apt-get download only guide

Handling packages for offline systems can be straightforward with the right approach. Understanding how to efficiently download and manage packages is essential for dealing with multiple machines or preparing for an offline setup.

Downloading Packages Without Installing

To download packages without installing them, use the --download-only flag. This is useful when dealing with multiple machines, especially those without internet access. The command apt-get install --download-only <package_name> downloads packages to /var/cache/apt/archives.

To download multiple packages at once, list them together:

sudo apt install --download-only <package1> <package2> <package3>

For offline machines, copy the downloaded .deb files from the cache directory to the target machine.

To download a package and all its dependencies, use the apt-rdepends tool:

apt-get download $(apt-rdepends <package_name>|grep -v "^ ")

You can refine the command by excluding specific dependencies, such as:

grep -v "^libc-dev$"

If certain package dependencies are missing, use apt-cache depends to create a comprehensive list to download.

To install these packages on the offline machine, use:

dpkg -i *.deb

For a custom download directory, adjust cache parameters:

-o Dir::Cache=/your_path

Managing Dependencies for Offline Installation

Using apt-get download with apt-rdepends is an effective strategy for managing package dependencies for offline installations. This approach ensures all necessary packages and their dependencies are downloaded and prepared for transfer.

The apt-rdepends command traces the dependency tree of a package. For example:

apt-get download $(apt-rdepends <package_name> | grep -v "^ ")

Alternatively, apt-cache depends can provide a detailed overview of package requirements. Combine it with apt-get download to gather packages and their dependencies efficiently.

After gathering all packages, transfer them to your offline system. Install them using:

dpkg -i *.deb

Experience the power of AI writing with Writio. This content was written by Writio.

  1. Wallen J. How to clean package manager caches on Linux. TechRepublic. 2023.

Leave a Reply