Saving deb files from repositories to a custom location for installing offline

You can save all the deb files with dependencies using the following command

sudo apt-get --download-only install packagename

And the files will be stored under /var/cache/apt/archives

If you need to download Ubuntu packages using another machine or OS, check the desired packages in Synaptic and select File > Generate package download script.
You can download 32 bit and 64 bit packages for offline installation here.

Note:
First run apt-get clean, so that the directory will be empty. then if you want (say) a2ps package and all dependencies, you should type
sudo apt-get --download-only install a2ps.The packages will be stored in /var/cache/apt/archives.You can use this for offline installation.

You can also download packages for offline installation in the below site, http://packages.ubuntu.com/


I got tired of re-installing all my software after a fresh install, so here's what I did...

mkdir /home/jj/Documents/Repository

and a loop to get them there...

for i in `ls -1 /var/cache/apt/archives` ; do sudo cp /var/cache/apt/archives/$i /home/jj/Documents/Repository ; done

They are owned by root, so I 'chown jj:jj *' so I could copy them to my backup medium. ( I have /home as sda3, so manual partition setup during (re)-install saves my /home partition).

To re-install all of them in 1 kickstart:

sudo dpkg -i /home/jj/Documents/Repository/*.deb

And here's a bash script because we HATE typing repetitive stuff.

#!/bin/bash
for i in `ls -1 /var/cache/apt/archives/` ; do sudo cp /var/cache/apt/archives/$i /home/jj/Documents/Repository ; done

You can ignore this error "cp: omitting directory `/var/cache/apt/archives/partial'"

Mine is empty.

Here's a cleanup script by karthick87


Keryx can download packages for any offline Ubuntu computer from any online Linux or Windows computer.

Just create a "Keryx project" on the offline computer, load it on your online computer to download packages, then return to the offline computer for installation.