I'd like to get a list of packages installed manually by apt
or aptitude
and be able to find out whether a foobar
package was installed manually or automatically. Is there any neat way of doing that from the command line?
Ubuntu – Generating list of manually installed packages and querying individual packages
aptaptitudepackage-management
Best Answer
You can use either of these two one-liners. Both yield the exact same output on my machine and are more precise than all solutions proposed up until now (July 6, 2014) in this question.
Using
apt-mark
:Using
aptitude
:Very few packages still fall through the cracks, although I suspect these are actually installed by the user, either right after the installation through the language localization setup or e.g. through the Totem codec installer. Also, the linux-header versions also seem to accumulate, even though I've only installed the non version-specific metapackage. Examples:
How does it work:
sed
strips out remaining whitespace at the end of the line.Other possibilities don't work as well:
ubuntu-14.04-desktop-amd64.manifest
file (here for Ubuntu 14.04) instead of/var/log/installer/initial-status.gz
. More packages are shown as manually installed even though they are not.apt-mark showauto
instead of/var/log/installer/initial-status.gz
.apt-mark
for example doesn't include the xserver-xorg package, while the other file does.I used various other StackExchange posts as references, however none work as well as the above solution:
Both list more packages than the above solution.
EDIT: What to do if you've upgraded from a previous release:
If you've upgraded Ubuntu from one release to the next, you will probably need to adjust this process. In that case, I would check the manifest file of the newer release (see above) in addition to the initial-status.gz file from the current release. You can easily do that by just adding another comparison. Using just the manifest file will not work, as the manifest file unfortunately does not contain everything that the initial_status.gz file does (I checked).