1

I am completely reinstalling kubuntu to my machine since gnome crashed occasionally for its long standing bugs.

How could retrieve a list of all the packages I have ever apt installed and install them to a fresh kubuntu system with one command line?

Wizard
  • 2,891
  • 1
    Kubuntu uses KDE, yet you mention GNOME crashed? Gnome is pretty stable but has issues with extensions designed for different releases of gnome (ie. abi breakage) but these shouldn't impact a KDE/Qt based Kubuntu. dpkg -l will all list packages installed, but you can re-install using 'something-else' without formatting your partitions, your added packages are noted, system directories are wiped & installed done, then software on your system is added back (if from known Ubuntu repos); without a single command. Have you considered that option for re-install? – guiverc Jul 23 '19 at 04:56

1 Answers1

2

There are several ways to list installed packages

dpkg -l
# or
dpkg-query -f '${binary:Package}\n' -W
# or
dpkg --get-selections | grep -v deinstall
# or
apt list --installed

Now, you want to save the list of installed packages and use the list with a fresh install.
- Save the installed packages list to a file
- Launch an apt install command feeded with the file

# SourcePC : Save a list of installed packages
dpkg-query -f '${binary:Package}\n' -W > /path/to/installList.txt

# TargetPC : Prepare, Install, Clean
# -- Prepare
sudo apt update 
sudo apt-get dist-upgrade
# -- Install packages list from file
sudo apt install $(< /path/to/installList.txt)
# -- Clean: Fix eventually broken dependencies and remove unnecessary
sudo apt -f install
sudo apt autoremove
cmak.fr
  • 8,696