How to Use Apt-Offline to Install Debian or Ubuntu Packages

Linux TLDR
Last Updated:
Reading time: 4 minutes
๐Ÿ’ญ
Scenario

You have one computer thatโ€™s connected to the internet (online system) and another computer thatโ€™s not connected to the internet (offline system), but you want to install or update software on the offline system. Here comes the Apt-Offline utility as a solution.

What is Apt-Offline?

Apt-Offline is an amazing command-line tool in Linux, particularly designed for Debian or Debian-based distributions like Ubuntu, Linux Mint, or Pop!_OS, allowing users to perform package management tasks on a system without internet access.

This is especially handy for installing or updating packages and their dependencies on a computer without internet access. You can download the necessary packages from a different system with internet access and transfer them to the offline system for installation or updates.

Donโ€™t worry if your online system is running a different operating system like Windows; you can still download the packages because this tool is cross-platform, written in Python, and offers both CLI and GUI options.

Tutorial Details

DescriptionApt-Offline
Difficulty LevelModerate
Root or Sudo PrivilegesYes
OS CompatibilityDebian, Ubuntu, Linux Mint, etc.
Prerequisitesโ€“
Internet Requiredโ€“
๐Ÿ“
This tool isnโ€™t designed for upgrading your entire system from an earlier distribution version to the latest one (e.g., Ubuntu 20 to 22).

Prerequisites for the Offline Update and Upgrade Process

  • A Windows or Linux system with internet connectivity for downloading packages, which can be your workplace, school, cyber cafe, etc.
  • An โ€œoffline systemโ€ for installing the above downloaded packages, which should be compatible with Debian or Debian-based distributions.
  • Transfer downloaded packages from an online system to an offline system using either a USB or a hard disk.

How to Install Apt-Offline on Online and Offline Systems

Letโ€™s begin the installation of this tool on your online system and then offline system using the following steps:

Installing Apt-Offline on Linux or Windows (๐ŸŸข Online System)

Assuming you have a Debian-based distribution like Ubuntu, Linux Mint, or any other, you can easily install it on this system using the APT package manager.

$ sudo apt install apt-offline

If youโ€™re using Ubuntu 22.04 LTS (Jammy Jellyfish) or Ubuntu 20.04 LTS (Focal Fossa), then running the above command will install an older version (1.8.4) of Apt-Offline, which has Python-related deprecation issues.

To avoid this, consider downloading and installing version 1.8.5 from Ubuntu 23.04 (Lunar Lobster) from [pkgs.org](https://pkgs.org/download/apt-offline) and using the โ€œsudo apt --fix-broken installโ€ command if any broken package error occurs.

For instance, if your online system is running on Windows, you can easily download the Python package for this tool from the project release page.

Installing Apt-Offline on Debian or Ubuntu (๐Ÿ”ด Offline System)

If your offline system has even low-speed internet access, you can still use the previously mentioned steps to install Apt-Offline via the APT package manager.

However, if there is no internet access, you can download an Apt-Offline deb package from [pkgs.org](https://pkgs.org/download/apt-offline) on an internet-connected system and then transfer it to your offline system and install it by running:

$ sudo dpkg -i apt-offline_*_all.deb

Now that we have installed Apt-Offline in both our online and offline systems, let us look into the steps required to download packages from the online system and then install them on the offline system.

Update and Upgrade Offline Debian-based Distribution via Apt-Offline

To begin the update or upgrade process for your offline Debian-based distribution using Apt-Offline, you need to perform the below steps.

  1. Access your offline system, create a directory with any preferred name within your home directory, such as โ€œLocalPackageโ€œ, and generate a database file that lists all the packages requiring updates.
  2. Transfer the โ€œLocalPackageโ€ directory containing the database file to your online system using a USB or any other suitable method, and proceed to download all the package updates mentioned in the database file.
  3. Finally, transfer the downloaded package update to your offline system via USB or any other suitable method, and proceed to install all of the package updates using Apt-Offline.

Letโ€™s perform these steps practically and update our offline system, waiting for updates.

1. Generating an Apt-Offline Signature File on the Offline System

Create a directory with any preferred name in your home directory, such as โ€œLocalPackageโ€œ, and navigate into it via the cd command.

$ mkdir ~/LocalPackage
$ cd ~/LocalPackage

Output:

Creating a directory to store signature file for package update

Then run the following command to generate the signature file name โ€œapt-offline.sigโ€œ, which contains information about the packages that need to be downloaded.

$ sudo apt-offline set --update --upgrade apt-offline.sig

Output:

Generating signature file for the lists of software you want to install or update

The above result indicates the successful creation of a signature file for updating the APT database and upgrading necessary packages.

If you want to create a signature file for specific packages (e.g., package1 and package2), then you can use the following command:

$ sudo apt-offline set apt-offline.sig --install-packages package1,package2

Now, copy the โ€œLocalPackageโ€ directory containing the signature file from your offline to your online system via USB or any other suitable method.

2. Downloading Package Updates Using Apt-Offline from the Online System

If youโ€™ve placed the โ€œLocalPackageโ€ directory in your home directory on your online system, start by entering that directory.

$ cd ~/LocalPackage

Then, run the following command:

$ sudo apt-offline get apt-offline.sig --threads 2 --bundle apt-offline-bundle.zip

Output:

Downloading packages required update from signature file

It will begin the process of downloading the package requiring an update based on the signature file and bundle all the downloaded packages in a single archive file named โ€œapt-offline-bundle.zipโ€ in the current working directory.

Also, feel free to tweak the โ€œ--threads 2โ€ option to perform more parallel downloads, but with caution as it might create issues like network congestion and timeouts.

Now, you have to wait a few minutes based on your list of packages wanting updates and internet speed on your online system. Once the process is finished, you will get the following output and a file named โ€œapt-offline-bundle.zipโ€ in your โ€œLocalPackageโ€ directory.

Offline packages requiring updating are downloaded

Now, copy the โ€œLocalPackageโ€ directory containing the โ€œapt-offline-bundle.zipโ€ archive file from your online to offline system via USB or any other suitable method.

3. Applying the Package Updates Using Apt-Offline on the Offline System

Assuming youโ€™ve placed the โ€œLocalPackageโ€ directory in your home directory on your offline system, start by entering that directory.

$ cd ~/LocalPackage

Then, begin the update process from the downloaded packages in the archive file by running:

$ sudo apt-offline install apt-offline-bundle.zip

Output:

installing all the downloaded packages

It will begin updating the APT database and upgrading the necessary packages with their dependencies from the downloaded packages in the archive file.

Thatโ€™s it! Youโ€™ve successfully updated or installed software on your offline system without needing an internet connection on that computer.

Final Word

This is helpful when you have one computer with internet access that can assist in keeping another computer up to date.

Now, if you have any questions or have encountered any errors while following the steps mentioned in this article, feel free to reach out to us in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

2 thoughts on โ€œHow to Use Apt-Offline to Install Debian or Ubuntu Packagesโ€

  1. the command โ€œsudo apt-offline set โ€“install-packages package1,package2 apt-offline.sigโ€ is no correct, an alternative runnable one is as follow:

    sudo apt-offline set apt-offline.sig โ€“install-packages package1 package2

    Reply