Posted: . At: 9:27 PM. This was 7 years ago. Post ID: 10496
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.

How to download a package on a Debian system without installing it.

On a Debian system, if you wish to download a package on your Linux system without installing it, use these commands. This is very useful if you wish to copy them to a USB drive and put them on another machine with the same Linux distribution.

This is the aptitude package manager, this command allows the user to download the package to a directory for later installation.

jason@jason-virtual-machine ~/packages $ aptitude download zsh
Get: 1 http://archive.ubuntu.com/ubuntu xenial/main amd64 zsh amd64 5.1.1-1ubuntu2 [651 kB]
Fetched 651 kB in 0s (0 B/s)

Now we have the deb package in a folder.

jason@jason-virtual-machine ~/packages $ ls -hula
total 648K
drwxr-xr-x  2 jason jason 4.0K Apr 14 20:58 .
drwxr-xr-x 21 jason jason 4.0K Apr 14 20:58 ..
-rw-r--r--  1 jason jason 637K Feb  8  2016 zsh_5.1.1-1ubuntu2_amd64.deb

This is how to do it with the apt package manager.

jason@jason-virtual-machine ~/packages $ apt download mc
[sudo] password for jason: 
Hit:1 http://archive.canonical.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]                        
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [512 kB]                
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [500 kB]                 
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [207 kB]                
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [457 kB]            
Get:9 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]                        
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [443 kB]            
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [175 kB]           
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [8,916 B]        
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 Packages [7,720 B]         
Ign:14 http://packages.linuxmint.com serena InRelease                                             
Hit:15 http://packages.linuxmint.com serena Release                                               
Fetched 2,617 kB in 16s (164 kB/s)                                                                
Reading package lists... Done
Building dependency tree       
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
 
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 mc amd64 3:4.8.15-2 [462 kB]
Fetched 462 kB in 6s (74.3 kB/s)                                                                  
 
The package mc is already installed. Its deb file was downloaded in the current directory.

The package was already installed, but it let me download it to the current working directory.

To create a deb package of installed software, install this utility.

jason@jason-virtual-machine ~/packages $ sudo apt-get install dpkg-repack

Then run this command.

jason@jason-virtual-machine ~/packages $ sudo dpkg-repack mc
dpkg-deb: building package 'mc' in './mc_4.8.15-2_amd64.deb'.

Now the package has been created in the current working directory.

jason@jason-virtual-machine ~/packages $ ls m*[A-Z]
mc_4.8.15-2_amd64.deb

This command will print a directory listing of all files in a deb package.

jason@jason-virtual-machine ~/packages $ dpkg -c zsh_5.1.1-1ubuntu2_amd64.deb

If you wish to extract the contents to the current working dir, use this command.

jason@jason-virtual-machine ~/packages $ ar -x mc_4.8.15-2_amd64.deb

Now the contents are in tar files, which are easily extracted in turn.

jason@jason-virtual-machine ~/packages $ ls -hula
total 1.6M
drwxr-xr-x  2 jason jason 4.0K Apr 14 21:18 .
drwxr-xr-x 21 jason jason 4.0K Apr 14 20:58 ..
-rw-r--r--  1 jason jason 3.6K Apr 14 21:18 control.tar.gz
-rw-r--r--  1 jason jason 448K Apr 14 21:18 data.tar.xz
-rw-r--r--  1 jason jason    4 Apr 14 21:18 debian-binary
-rw-r--r--  1 root  root  452K Apr 14 21:14 mc_4.8.15-2_amd64.deb
-rw-r--r--  1 jason jason 637K Apr 14 21:15 zsh_5.1.1-1ubuntu2_amd64.deb

Now I extract the data.tar.xz file.

jason@jason-virtual-machine ~/packages $ tar -xvf data.tar.xz

And the data is extracted.

jason@jason-virtual-machine ~/packages $ ls -hula
total 1.6M
drwxr-xr-x  5 jason jason 4.0K Apr 14 21:22 .
drwxr-xr-x 21 jason jason 4.0K Apr 14 20:58 ..
-rw-r--r--  1 jason jason 3.6K Apr 14 21:18 control.tar.gz
drwxr-xr-x  2 jason jason 4.0K Apr 14 21:22 data
-rw-r--r--  1 jason jason 448K Apr 14 21:22 data.tar.xz
-rw-r--r--  1 jason jason    4 Apr 14 21:18 debian-binary
drwxr-xr-x  3 jason jason 4.0K Apr 14 21:22 etc
-rw-r--r--  1 root  root  452K Apr 14 21:14 mc_4.8.15-2_amd64.deb
drwxr-xr-x  5 jason jason 4.0K Apr 14 21:22 usr
-rw-r--r--  1 jason jason 637K Apr 14 21:15 zsh_5.1.1-1ubuntu2_amd64.deb

This is how easy working with packages is. These tips will be very useful if you cannot install a package, but need the contents. Such as a theme or wallpaper package for another distribution.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.