Create A List Of Installed Packages And Install Them Later From The List In Arch Linux
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 a new 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.
Save the “pkglist.txt” file in USB drive or somewhere safe.
Now, format and reinstall the system. After reinstalling your system, copy the “pkglist.txt” file to your newly installed system and 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
- The Easy Way To Install And Remove A Package Group In Arch Linux
- How To Install Softwares Offline In Ubuntu 16.04
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!