Linux Get List of Installed Software for Reinstallation / Restore All the Software Programs

Hardware and software failures are part of life. And that is why you need to have a backup plan. I have already written about backing up files and MySQL databases. There is no need to backup all installed binaries and software programs. The following tip will not just save your time, but both Debian/Ubuntu and CentOS/Fedora/RHEL based distro can be updated and restored when required.



In order to reinstall or restore your installed software you need to have a list of all installed software. The package manager in Linux can be used to save installed/removed packages on a source system and duplicate those changes on other systems. This post will help you through do the same.

ADVERTISEMENTS



HowTo: Create a Backup list of all installed software on a Debian / Ubuntu Linux

If you are using a Debian or Ubuntu Linux, use the dpkg command to list installed software:

$ dpkg --get-selections

You can store list of installed software to a file called /backup/installed-software.log, enter:

$ dpkg --get-selections > /backup/installed-software.log

HowTo: Create a Backup list of all installed software on a RHEL/Fedora/Suse/CentOS Linux

RPM based distributions (RHEL, Fedora, Redhat, CentOS, Suse Linux) user try the rpm command to get list of all installed software, enter:

$ rpm -qa

OR

$ rpm -qa > /backup/installed-software.log

OR remove software version number (recommended):

rpm -qa --qf "%{NAME}

" | sort > /backup/installed-software.log

How do I restore installed software from a backup List?

Under a Debian/Ubuntu Linux type the following two commands to reinstall all the programs:

# dpkg --set-selections < /backup/installed-software.log

Once list is imported, use the dselect command or other tools to install the packages, enter:

# dselect

Select 'i' for install the software. OR use the following command:

# apt-get dselect-upgrade

Restoring packages on rpm based distro

As far as I know RPM based distro does not offers dpkg kind of facility. But, with a little shell scripting technique you can easily install all software programs:

# LIST="$( cat /backup/installed-software.log )"

If you are using the yum command, type the following bash for loop to install all software:

# for s in $LIST; do yum -y install $s; done

Or try out the following command (HT to gt):

# yum -y install $(cat /backup/installed-software.log)

A Note About RHEL version 4

If you are using RHEL/CentOS v4.x or older, enter:

# for s in $LIST; do up2date -i $s; done

Alternatively, you can use the following up2date command:

# up2date -i $(cat /backup/installed-software.log)