≡ Menu

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.

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
$ rpm -qa > /backup/installed-software.log
OR remove software version number (recommended):

pm -qa --qf "%{NAME}\n" | 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)

Share this on:

{ 54 comments… add one }

  • gt August 24, 2006, 7:15 am

    better run yum only once:

    rpm -qa > /backup/installed-software.log
    for i in $(cat /backup/installed-software.log) ; do packages+="$i " ; done
    yum install $packages

  • nixCraft August 24, 2006, 7:56 am

    Much better :)

    Appreciate your post/script

  • textshell August 24, 2006, 1:40 pm

    xargs yum install

  • nuclearjoker August 24, 2006, 2:01 pm

    And if you use Gentoo Linux it would be as follows:

    # cat /var/lib/portage/world
    to get the list of packages

    #emerge -av $(cat /path/to/backupworldfile.txt)


  • gsiems August 24, 2006, 3:02 pm

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

    yum install `cat /backup/installed-software.log | tr "\n" " "`

  • gt August 24, 2006, 5:40 pm

    or barely:
    yum install $(cat /backup/installed-software.log)
    so simple!

  • nixCraft August 24, 2006, 6:27 pm

    Dam … I should have used this one liner :)

  • patrick August 24, 2006, 6:31 pm

    nuclearjoker, not to troll out of u

    But whole point of this article is about binary software install/update, IMPO. What you pointing is source compile under gentoo linux

    Please correct me if I am wrong.

    • Cavin July 30, 2010, 9:38 pm

      Well, Gentoo does compile all packages from sources, yes, but it uses a package management system. And the packages that are installed, are of course, binaries. Just because they were compiled on the system, doesn’t make them any less so. So it is applicable to this.

  • Arun August 24, 2006, 6:38 pm

    Good article. Thanks.

  • Jarl August 24, 2006, 6:41 pm

    For me this approach is the same that install from DVD/CDROM with the regular installer. Where are the own files? configuration files, customizated setups, and so on.

  • nixCraft August 24, 2006, 6:48 pm

    As I said earlier, I am assuming that you are having a backup of /etc config file and other important data to tape or FTP or NAS server. Please read following url. This article is actually follow-up to earlier article.
    Once application installed you can simply restore both data and configuration file.

    Also, consider the CD/DVD media is not up-to-date or does not carries patched version. This method offers out of box protection as both up2date, yum or apt-get installs patched/up-to-date version.


  • Daniel M. Webb August 24, 2006, 6:59 pm

    You can also use “apt-get dselect-upgrade” instead of dselect.

  • TQ August 24, 2006, 7:16 pm

    Instead of dselect, can aptitude be used instead? What are the parameters involved?


  • nixCraft August 24, 2006, 7:45 pm

    Short answer YES

    Long answer – Both dselect and aptitude act as a Debian package management frontend.

  • Matthew Hall August 24, 2006, 10:06 pm

    Even easier – Fedora users should get their installed packages list automagically updated every day to ‘/var/log/rpmpkgs’ – so, assuming you’ve taken a backup and restored the file the following should suffice:

    yum -y install $(cat /var/log/rpmpkgs)

  • zerohalo August 25, 2006, 2:51 am

    How would you do this on Ubuntu using apt-get instead of dpkg?

    • James March 5, 2011, 3:49 am

      Just to note. apt-get isn’t Ubuntu only. It’s another frontend to dpkg. On Ubuntu just use dpkg as you would on a Debian system.

  • nixCraft August 25, 2006, 4:47 am

    apt-get command does not support this kind of facility. You need to use dpkg command only.

  • Grant August 25, 2006, 7:24 am

    When you install with CentOS it puts the list of installed rpms in /root/install.log. If root’s home dir is backed up you’re in business. Although I doubt if it’s update after the install.

    Couldn’t you just create a kickstart disk after install/config and pop it in to reinstall then do a yum update? That would get you closer than just reainstalling packages. Of course all of this is fun to talk about but realistically you’d have backups and you’d just restore… I backup MBRs and files. Throw a live cd in the machine to be restored and from the backup server – dd if=/backup/MBR.bin | ssh “cat | dd of=/dev/hda”

    It’s late and this is from memory but I think that’ll work to restore the MBR across the network. Then format and restore from backup.

  • chewie August 25, 2006, 6:10 pm

    For Debian systems, you can also grab the debconf database and use it to preseed the installation questions that occur, including how to partition your hard drive. This allows you to completely automate the installation process. Check out the debian-installer Install manual at http://d-i.alioth.debian.org/manual/en.i386/apb.html.

  • Motin March 5, 2007, 2:55 am

    There is a huge disadvantage using package lists – it lists a lot packages that one have not chosen to install but are installed because they are dependencies. This makes it veeery tedious to restore if the list is somewhat old or using another distro since dependencies change a lot.

    For debian-based system: Install “debfoster” and run it. After answering a lot of questions about your packages you will have a system without unnecessary packages and a short list of only the packages that you have actively chosen to install.

  • cambo81 June 24, 2007, 12:08 am

    hi im new to this comp. stuff but i just got 1 question. i installed a game as imess around my laptop i uninstalled the game that i just installed. how can i recover that lost game cause i do not have the disc anymore please help me.

  • Caio October 20, 2007, 6:50 pm

    That’s why I LOVE LINUX!

  • peace March 9, 2008, 11:57 am

    nice tut man I LOVE LINUX too much

  • Don March 11, 2008, 10:02 am

    Just what I needed :-)
    Linux is great!!!

  • ZaK April 10, 2008, 10:42 pm

    Im new to linex i was viewing utorrent in VNC i closed it by mistake how do i run it again so i can view the current activities

  • Narendra Sisodiya May 14, 2008, 12:39 pm

    suppose i have 3 software A B and C
    now i have taken backup..in log file..
    now,, I have installed D and E , and removed B
    — If Now i will restore then i will be having A B C D E , but is now a full restore,,,
    ideally,, you need to create a new backuplist of software which has A C D and E
    and then find the diff so that you can get D and E are extra software to remove first and B is need to installed. also,, you need to check that software are available or not, but nice article ,,, can be integrated in Yumex

  • Diabolic Preacher May 28, 2008, 6:55 am

    for debian/ubuntu method. will it reinstall all the 1313 packages that i noted as being saved to the backup log or will it skip the packages that need not be updated?

  • JK Wood November 5, 2008, 6:54 pm

    For Slackware-based distros:

    ls /var/log/packages

  • johnhere April 7, 2009, 10:26 pm

    Nice to see Debian and RPM based distro’s working so peacefully together in this
    gr8 tutorial. I gonna give it a try to put this as an aftercare script in a kickstart file.
    I want to call it a ‘clone kickstart’. ;-)

    ks.cfg extracted/edited from a fedora distro /root/anaconda-ks.cfg

    for rpm:

    for i in $(cat /some_network/kickstart_server/installed-software.log) ; do
    packages+=”$i ” ; done
    yum install -y $packages

    Just an idea so correct me if i am wrong. That saves time. ;-)

  • AShok1288 January 5, 2010, 2:27 am

    i can’t automate the installation process in fedora since it is asking
    “Total Download size:xxMB
    Is this ok [y/n]?”
    every time for all packages i have to give ‘y’ to download the package …………

    is there any other way to automate the process?

    please helpme……………………

  • Doc January 31, 2010, 5:58 am

    rpm -qa
    Returns the long name, with version number, distro and arch,
    for ex. gnome-utils-libs-2.28.3-1.fc11.i586
    And if you try to install this list on a newer version distro you get
    No gnome-utils-libs-2.28.3-1.fc11.i586 package availabe.

    You shoud use:

    rpm -qa --queryformat "%{NAME}\n" > packages.log

    The problem is that I’ve just figure out this, just when I’ve formatted and installed a newer version of Fedora. Is there a trick to use the list I have? because there is no pattern at all to use sed/awk, isn’t it?

    • Elder November 6, 2011, 8:31 pm

      This guy IS the guy! Thanks men!

      The article should be updated with this argument.

  • elyograg February 26, 2010, 11:39 pm

    This is what I did. It ensures that if the list is long enough to exceed the length limit on a command, it will still work:

    cat installed-software.log | xargs yum -y install

  • SwiftLayer March 23, 2010, 8:28 pm

    Can be done to allow for upgrading to newer systems be removing arch dependency:

    ## Installed Software Dump
    ## by SwiftLayer.com
    ## Dump the list of installed software ##
    yum list installed | awk '{print $1}' > software
    ## Strip out the arch with sed replace ##
    sed -i 's/.noarch//g' software
    sed -i 's/.i386//g' software
    sed -i 's/.i686//g' software
    ## Strip out the lines we dont want ## sed -i '/ /d' software
    sed -i '/Installed/d' software
    sed -i '/MySQL/d' software
    sed -i '/mysqlclient/d' software
    sed -i '/ftp/d' software
    sed -i '/dummy-centos-4/d' software
    sed -i '/sendmail-cf/d' software
    sed -i '/sendmail-doc/d' software
    sed -i '/http/d' software
    sed -i '/indexhtml/d' software
    sed -i '/bind/d' software
    sed -i '/postgresql/d' software
    sed -i '/gpg/d' software
    sed -i '/x11/d' software
    sed -i '/caching-nameserver/d' software
    sed -i '/yum/d' software
    sed -i '/da_/d' software

    Then use this to install on other system:

    ## Yum install from list
    ## by SwiftLayer.com
    if [ ! -e "software" ]; then
        echo -e "\n\nSoftware list missing please make sure file 'software' exists\n"
        echo -e "hint: run Installed Software Dump 'getInstalled.sh' on old system\n"
        echo -e "then copy the 'software' file to this system\n\n"
    ## Lets pipe in the software list to a single yum command using 'tr' ##
    yum install $(cat software | tr '\n' ' ')
  • Kumar April 8, 2010, 8:43 pm

    How do you view partial list? I get the lists but I can’t view anything on top.

  • AO June 23, 2011, 5:01 pm

    I need a debian command to find which packages I have installed from backports. dkpg –get-selections only gives me the package name.

    Any ideas?

  • MKZA August 17, 2011, 10:13 am

    Works GREAT !!! Thanks for a great site with really great stuff for Nix Admins.

    If anyone gets a permission denied error when running the dpkg –get-selections > /etc/installed-applications.log command

    First create your .log file in your chosen folder, give yourself or root full permission to write to the file then run it again.

    What I then did was I added this command to the FTPbackup.sh script also posted on this site so now it does this automatically everyday making sure I have a complete up to date list of applications installed.

  • joe October 3, 2011, 4:49 pm

    Looking for information on how to restore out of rpm/yum upgrade/install (off all installs done on 09/22/2011)


  • Gerald October 10, 2011, 6:09 pm

    Yum’s package management is really abysmal:

    After searching for intensely on the web for ways to retrieve a list of packages that had been manually installed in CentOS 5 (so I can clean up no longer needed apps), I finally had to give up: It’s just not possible – the only thing you can get is useless lists which include gazillion dependencies as if they were programs you had actually ‘installed’.

    In RHEL/CentOS/SL 6.x, the situation has gotten slightly better with yumdb.

    But IMHO you can ONLY _manually_ generate a list if you do
    yumdb search installed_by 0 (lists everything installed by user root, not including things from the initial installation)

    and then remove (by hand) everything that isn’t also in the following list
    – yumdb search reason user (everything that wasn’t installed as part of a dependency. This however also includes everything from the initial installation)

    If you then manually generated a list from those 2 outputs, you should get a list of individual apps that have been installed. To get yum to also remove non-needed dependencies you of course also have to add clean_requirements_on_remove=1 to /etc/yum.conf.

    If you run an OS with good package management, such as Gentoo things are so much simpler: edit /var/lib/portage/world and remove what you no longer need, then run emerge –depclean and you’re done.

  • rainmaker November 17, 2011, 4:24 pm

    You can also do:
    #cat installed.log |xargs yum -y install

  • cyrixmorten November 18, 2011, 7:46 pm

    I used the following command to clean up the list of packages generated in fedora:

    sed -r –in-place ‘s/-[0-9][a-z 0-9_.-]*//’ installed-software.log

    This removes any version dist and architecture information leaving only the packagename suitable for yum to consume using the command as suggested by rainmaker:

    cat installed.log |xargs yum -y install

  • cyrixmorten November 18, 2011, 8:53 pm

    correcting the command above

    sed -r –in-place ‘s/-[0-9][a-z 0-9_.-]*//’ installed-software.log

  • cyrixmorten November 18, 2011, 8:55 pm

    correcting the command above

    sed -r –in-place ‘s/-[0-9][a-z 0-9_.-]*//’ installed-software.log

  • Nicholas Blasgen November 25, 2011, 4:16 am

    if mount -o remount,exec /tmp && pear channel-update pear.php.net && pear upgrade –force Console_Getopt && pear upgrade –force pear && pear upgrade-all && pecl install json; then
    echo “extension=json.so” > /etc/php.d/json.ini
    mount -o remount,noexec /tmp
    mount -o remount,noexec /tmp
    error_exit “JSON was unable to be installed”

  • prasanna January 9, 2012, 10:50 am

    Is there any way to get the software manufacturer name with dpkg/rpm command for those softwares.

  • cmcanulty January 13, 2012, 6:02 pm

    I run the 1st command and get the list but on the second command
    i get this this error
    “cmcanulty@Darcy25:~$ dpkg –get-selections > /backup/installed-software.log
    bash: /backup/installed-software.log: No such file or directory”
    but I did make a bckup folder in my home and created a test file called
    installed-software.log before I ran the 2nd command what am I doing wrong?

    • kohrime January 28, 2012, 11:58 pm

      Kindly delete the “installed-software.log” that you made (I think).

      Home’s directory is actually /home//

      Maybe try doing this command instead:
      dpkg –get-selections > ~/backup/installed-software.log

  • tw March 4, 2012, 3:27 pm

    Hey all, little trouble here, hopefully I didn’t just jack up like I think I might have…
    I created the .log file and saved it, all my docs/files and a febe file for firefox to flash before install of precise pangolin beta, I tell it to:
    # dpkg –set-selections < /backup/installed-software.log after recreating the location and placing the file there where it should be…net result:0 , it didn't pull the packages
    Any ideas on what to do now?

    • tw March 4, 2012, 7:45 pm

      I am thinking I should still be using dpkg but with the refuse downgrade command in conjunction with the set selections command to reinstall all my packages from before, but apparantly I’m not getting that right…

  • Jas June 6, 2012, 5:34 pm

    i have remove vnc RPM`s from my Linux Server & again install it but its not working,when i try to open
    #vino-preferences its not working
    can someome please tell why this heppning

  • bodhi.zazen July 6, 2012, 9:47 pm

    Small suggestion on your rpm backup strategy –

    rpm -qa

    Includes package version numbers, which are subject to change.

    You can strip them with a “simple” modification

    rpm -qa --qf "%{NAME}\n" | sort > /backup/installed-software.log

    Restore is the same (careful with the -y):

    yum -y install $(cat /backup/installed-software.log)
  • AAMAA September 24, 2013, 8:15 pm

    Please help
    When I try to update
    Or the installation of any tool
    Always having a this message
    root@bt:~# apt-get install software-center
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Couldn’t find package software-center
    I’ve tried a lot of solutions to no avail

Leave a Comment

   Tagged with: , , , ,