Is there a way to get a list of added packages so they can be re-installed after a clean installation (as opposed to upgrade)?

Sajan Parikh sajan at parikh.io
Thu May 8 12:09:20 UTC 2014


On 05/08/2014 06:41 AM, Chris Green wrote:
> I'd really prefer to do a clean new installation occasionally rather
> than doing a distribution upgrade.  On one system in particular I have
> a number of issues which I think would probably be sorted out by doing
> a clean installation.
>
> It's easy enough to make a copy of (or use a different partition) for
> /home so that that can be restored.
>
> The difficult bit is to get back all the extra packages I have
> installed in addition to the basic ones installed with Ubuntu/Xubuntu.  Is
> there any reasonably clean and easy way to get a list of added
> packages that one could feed into apt-get (or dpkg) to re-install all
> the extras?
>

You should be able to use a command like the following...

  dpkg --get-selections | awk '{print $1}' | tr '\n' ' '

Perhaps save the output to a file...

  dpkg --get-selections | awk '{print $1}' | tr '\n' ' ' > packages

You'll also want to backup anything in /etc/apt/soures.list and all 
files in /etc/apt/sources.list.d/

Then when you do your installation assuming it's the same version, 
should be able to just restore /etc/apt/sources.list and 
/etc/apt/sources.list.d/, run 'apt-get update' then copy and paste 
everything from the packages file we create first and do a giant past 
for 'apt-get install'.

Should work?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3195 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20140508/4d026575/attachment.bin>


More information about the ubuntu-users mailing list