0

I have 12.04 and I'm looking for a way to store all the currently installed packages names into a file or archive. Not the packages themselves, but the names. Or the package management's state.

I'd like to do this in order for the ability to synchronize the installed packages on demand on two computers. The idea would be to save the installed names on computer A, go to computer B, make a diff of the names and uninstall extra packages from B and install the missing ones.

For this it would be good if the version could also be saved for each package. Also I'm not sticking to the names if there is something that better suits my scenario, something that the package management can work with as automatic as it can be.

Out of preference, I'd like to do it without the use of a sync-server. Looking for file-based solutions.

n611x007
  • 545
  • 2
  • 14
  • 2
    `dpkg --get-selections` Lists the packages you have installed, but doesn't print out the version. `dpkg --set-selections` reads that in and (should) install/remove packages to meet those conditions. – saiarcot895 May 22 '14 at 11:19
  • @saiarcot895 seems good as an answer! – n611x007 May 22 '14 at 11:24
  • Welcome to Ask Ubuntu. Please, could you put some of your time to read [What should I do when someone answers my question?](http://askubuntu.com/help/someone-answers) – Sylvain Pineau Jun 03 '14 at 09:02

2 Answers2

1

This command will give you all the installed packages and their respective versions:

dpkg-query -W -f='${binary:Package}\t${Version}\n'

Or even shorter (the above command is the default output for -W):

dpkg-query -W

See dpkg-query man pages for further format options.

To backup and restore your packages, please see this answer.

Sylvain Pineau
  • 61,564
  • 18
  • 149
  • 183
0

You could also run the below command to list the installed packages along with their versions.

dpkg -l | awk '{print $2,$3}'
Avinash Raj
  • 77,204
  • 56
  • 214
  • 254