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
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