Create A List Of Installed Packages And Install Them Later From The List In Arch Linux

Create A List Of Installed Packages in Arch Linux
Image source: Google

Today, I am going to teach you an useful tip that explains how to create a list of installed packages and install them later from the backup list in new a system or in the existing Arch Linux system after fresh installation. This method can be useful for error reporting or discussion of installed packages with your colleagues or Technical support team. More importantly, if you want similar set of packages in a group of Arch Linux systems, this is one such a way to achieve it.

Create A List Of Installed Packages And Install Them Later In Arch Linux After Reinstallation

Let us generate the list of explicitly installed packages using command:

$ pacman -Qqe > pkglist.txt

This command will create a list of explicitly installed packages in alphabetical order, and save them in a text file called “pkglist.txt”.


  • Q – Queries the package database. This option allows you to view installed packages and their files, other useful meta-information about individual packages (dependencies, conflicts, install date, build date, size).
  • q – Shows less information for certain query operations. This is useful when pacman’s output is processed in a script.
  • e – Lists explicitly installed packages that are not required by any other package.
  • pkglist.txt – It is the output file where you store the list of installed files.

Now, format and reinstall the system. After reinstalling your system, run the following command to install packages from the backup list.

$ sudo pacman -S - < pkglist.txt

Just in case, the backup list includes foreign packages, such as AUR packages, remove them first, and then install the rest of packages using command:

$ sudo pacman -S $(comm -12 <(pacman -Slq | sort) <(sort pkglist.txt))

The above command will you remove the foreign packages. Type ‘y’ and hit ENTER to remove them. Finally, type ‘y’ to install the rest of the packages from the list.

You don’t need to install all packages one by one. Pacman will read the list and install packages listed in there.

To remove all the packages on your newly installed system that are not mentioned in the backup list, run:

$ sudo pacman -Rsu $(comm -23 <(pacman -Qq | sort) <(sort pkglist.txt))

For more details, refer the man pages.

$ man pacman

Recommended Read:

This handy method will make your life easier when you want to reinstall your Arch Linux system or its derivatives like Antergos, Manjaro Linux. Don’t bother installing packages one by one. Just export the list of installed packages to a file, and save it to a safe place, and then install the packages from the backup list after reinstalling your Arch system. You can also use the same backup list to any newly installed Arch Systems on your home/office. It will save you a lot of time from searching and installing packages one by one.

Want to know how to do the same in YUM based and DEB based systems? Great! Refer the following guide.

And, that’s all. Hope this helps. If you find our guides useful, please share them on your social, professional networks, and support OSTechNix.

More good stuffs to come. Stay tuned!



Thanks for stopping by!

Help us to help you:

Have a Good day!!

You may also like...

3 Responses

  1. Dan St.André says:

    Does a similar article exist for Debian-family (*buntu, Mint, etc) package managers? My search efforts only found this article.

    ~~~ 8d:-} Dan

  2. dataloss says:

    Works but doesn’t play nice afterwords with maintenance commands like;
    sudo pacman -Rns $(pacman -Qtdq)
    sudo pacman -Sc
    sudo paccache -rk 1
    sudo paccache -ruk0
    It’s as if the packages are not registered in the pacman as installed and being used database or whatever and are treated as not needed/not used packages by pacman, you can test the listed commands above and see what I mean jest “don’t” press “y” especially with the first one.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.