Ubuntu, how to setup a new machine like an existing one

Solution 1:

Aswell as the dpkg tricks mentioned by pjz, you may also want to look at etckeeper (tutorial ) - an app that puts your /etc/* under version control, making it easier to find any changes you've done and replicate them to other servers.

Also, for a shorter list than that produced by pjz's method, you can use

$ deborphan -a --no-show-section > /tmp/mypackagelist

This will give you a list of packages that will install all the other packages you require as dependencies. Can be useful if you actually want to look through the list. (dpkg --get-selections will produce a loooong list). In addition the list is short enough that you could add newlines and comment out entries with '#'. Then when installing the extra packages you can do

$ grep -v '#' /tmp/mypackagelist | xargs apt-get install -y

This way, if there are some packages you only want to install on some machines, you don't have to delete them from the package list altogether.

Solution 2:

dpkg --get-selections >/tmp/mypackagelist

should do the trick. Then, after making sure that your /etc/apt/sources.list on the new machine has the same set of entries as on the old, copy mypackagelist over to the new machine and do:

cat mypackagelist | xargs apt-get -y install 

and you should be good to go.

Note that the dpkg --get-selections line is also good info to put into your /etc/dir ocassionally - it means you don't have to bother to back up /bin/ and /usr/bin/ and such because you know what packages are on the system.


Solution 3:

Ubuntu Forums has a good answer

  1. On the old machine: $ dpkg --get-selections > installed-software
    • This gets your list of installed apps
  2. On the new machine: $ dpkg --set-selections
    • This sets the new machine to install the packages not currently installed on the new machine.
    • It might be interesting to see if the new machine has some packages not installed on the old machine, so you could find the dpkg --get-selections> command on the new machine, and then use diff to compare the output files from both.
  3. Finally, on the new machine: $ dselect and the packages will be installed.

Some additional links from the forums discussion:

  1. Don't forget your gpg keys (from the same thread)
  2. How to install all the desired packages and uninstall all the undesired packages

Solution 4:

The better dpkg commands may be [original machine]

dpkg --get-selections | grep -v deinstall > packages_list

then when installing [new machine; after transferring the packages_list]

sudo dpkg --set-selections < packages_list
sudo apt-get -u dselect-upgrade

Tags:

Linux

Ubuntu