Hello, friends. In this short but interesting post, you will learn how to download packages using APT without installing them. This way we can take them to another site and run an installation there without needing the internet. This is quite useful in enterprise environments.
What is APT?
APT is the package manager for Debian and Debian-derived distributions, such as Ubuntu. Thanks to this tool we can install, remove, update and search for packages to be installed on the system.
By default, when we run the command
sudo apt install <package> command
APT will search for it in the added system repositories, calculate the necessary dependencies, and from there start downloading and installing them. However, sometimes we don’t need to install them but download them so that we can move them to other machines.
So that’s the aim of our post. Let’s go for it.
Download packages using APT without installing them
Since recent versions, APT incorporates the
download subcommand to download a package to the current directory.
For example, to download the VLC package, you can run
mkdir vlc cd vlc sudo apt download vlc
Check the download
Remove the downloaded file and now let’s download it and its dependencies.
The command that downloads a package along with all its dependencies is as follows
sudo apt install --download-only vlc
sudo apt install -d vlc
The only disadvantage is that the packages will be downloaded to a single directory as
/var/cache/apt/archives. So, before downloading the packages, it is advisable to clear the entire cache
sudo apt clean
And now, yes, run the command. This time I will do it with VIM.
sudo apt install -d vim
Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: vim-runtime Suggested packages: ctags vim-doc vim-scripts The following NEW packages will be installed: vim vim-runtime 0 upgraded, 2 newly installed, 0 to remove and 26 not upgraded. Need to get 7,720 kB of files. After this operation, 36.3 MB of additional disk space will be used. Do you want to continue? [Y/n]
Accept the changes, and you will see a message like this
Download complete and in download only mode
Now check the directory where APT packages are downloaded.
Try running the
vim command to see that it has not been installed and only the packages have been downloaded as dependencies.
Now you just need to move these packages and install them locally.
In this short but useful post, you learned how to download packages without installing them using APT. So, you can take these packages to another computer and install them manually.