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):
rpm -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)

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

55 comments… add one
  • cambo81 Jun 24, 2007 @ 0:08

    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 Oct 20, 2007 @ 18:50

    That’s why I LOVE LINUX!

  • peace Mar 9, 2008 @ 11:57

    nice tut man I LOVE LINUX too much

  • Don Mar 11, 2008 @ 10:02

    Just what I needed 🙂
    Linux is great!!!

  • ZaK Apr 10, 2008 @ 22:42

    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

    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

    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 Nov 5, 2008 @ 18:54

    For Slackware-based distros:

    ls /var/log/packages

  • johnhere Apr 7, 2009 @ 22:26

    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 Jan 5, 2010 @ 2:27

    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 Jan 31, 2010 @ 5:58

    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 Nov 6, 2011 @ 20:31

      This guy IS the guy! Thanks men!

      The article should be updated with this argument.

  • elyograg Feb 26, 2010 @ 23:39

    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 Mar 23, 2010 @ 20:28

    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 "nnSoftware list missing please make sure file 'software' existsn"
        echo -e "hint: run Installed Software Dump 'getInstalled.sh' on old systemn"
        echo -e "then copy the 'software' file to this systemnn"
    ## Lets pipe in the software list to a single yum command using 'tr' ##
    yum install $(cat software | tr 'n' ' ')
  • Kumar Apr 8, 2010 @ 20:43

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

  • AO Jun 23, 2011 @ 17:01

    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 Aug 17, 2011 @ 10:13

    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 Oct 3, 2011 @ 16:49

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


  • Gerald Oct 10, 2011 @ 18:09

    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 Nov 17, 2011 @ 16:24

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

  • cyrixmorten Nov 18, 2011 @ 19:46

    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

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.