How do I get a list of obsolete packages?
Solution 1:
aptitude search '~o'
Aptitude has some very powerful searching available. Unfortunately the syntax is a bit unwieldy and you have to dig past the manpage to find the documentation, but its worth it.
apt-show-versions can also be helpful:
apt-show-versions | grep 'No available version'
Solution 2:
To get a list of apps that are not in a Registered Repository or PPA do this:
sudo apt-get install apt-show-versions
apt-show-versions | grep 'No available version'
That should output text like this:
app1 1.0.0.14 installed: No available version in archive
app23 0.3.6 installed: No available version in archive
app332 7.0.9377 installed: No available version in archive
For me this worked and showed three apps I installed using DEB packages and weren't available in a Repo or PPA.
Do remember though that it's impossible to check for all programs, only the ones that went through dpkg
. For instance, some apps are installed by simply extracting them into the correct folders, or others use a standalone installer bin or script. So the best way is for you yourself to keep a list of apps you installed via any method other than APT.
Solution 3:
If you have aptitude installed use,
aptitude search '?obsolete'
or its short form
aptitude search '~o'
Here it is a sample output
i A gcc-4.7-base - GCC, the GNU Compiler Collection (base package)
id libdb4.7 - Berkeley v4.7 Database Libraries [runtime]
i libudev0 - libudev shared library
The first character of each line indicates the current state of the package. The most common states are:
- p, meaning that no trace of the package exists on the system,
- c, meaning that the package was deleted but its configuration files remain on the system,
- i, meaning that the package is installed, and
- v, meaning that the package is virtual.
The second character indicates the stored action to be performed on the package, if any, otherwise a blank space is displayed. The most common actions are:
- i, meaning that the package will be installed,
- d, meaning that the package will be deleted, and
- p, meaning that the package and its configuration files will be removed.
If the third character is A, the package was automatically installed.
For a complete list of the possible state and action flags, see the section Accessing Package Information in the aptitude reference guide.
Solution 4:
Starting with Ubuntu 19.10 it is also possible to run
apt list ?obsolete
to get the list of obsolete packages.
For any release you could use the following Bash one-liner:
comm -23 <(dpkg-query -W -f '${db:Status-Abbrev}\t${Package}\n' | grep '^.[^nc]' | cut -f2 | sort) <(apt-cache dumpavail | sed -rn 's/^Package: (.*)/\1/p' | sort -u)
No need to install extra packages for this, plus this is relatively fast. This will also find partially installed packages (but will not find those that have only configuration files remaining; that could be changed easily, though). Note: this does not care of which architecture the packages are.
If you want to include packages that have a different version installed than what is available from the repositories, you could you one of the following:
Use modern apt:
apt list --installed | awk -F/ '/\[installed,local\]/{print $1}'
Yet another option is to run
ubuntu-support-status --show-unsupported
and read the package names under "No longer downloadable:" section.
Solution 5:
More info to investigate.
ubuntu-support-status echo "$(sudo apt-mark showmanual | wc -l) packages marked as 'manually installed'."
... ubuntu-support-status and apt-mark may require installation.