`apt-mark showmanual` shows almost all packages. messed up?
apt-mark showmanual
lists a lot of packages for me:
root@hcompneu:~# apt-mark showmanual | wc -l
4013
root@hcompneu:~# apt-mark showmanual | head
a11y-profile-manager-indicator
abiword
abiword-common
abiword-plugin-grammar
account-plugin-facebook
account-plugin-flickr
account-plugin-google
account-plugin-identica
account-plugin-twitter
accountsservice
root@hcompneu:~# apt-mark showmanual | tail
yelp-xsl
zeitgeist
zeitgeist-core
zeitgeist-datahub
zenity
zenity-common
zip
zlib1g
zlib1g-dev
zlib1g:i386
As I understand, it should only list those packages which I manually installed. I don't remember in each case anymore but I'm pretty sure I did not install all of those manually. Actually, I rarely installed any software on this system, despite Chrome, OpenOffice and some other very basic things. So I would expect a list of maybe 10-100 packages but not more. Maybe it also includes ubuntu-desktop, grub and linux or so from the base Ubuntu installation.
Maybe in the past though I wrote some scripts to fix up a broken system by automatically calling apt-get install XXX
on various packages. Or maybe I did other things. I don't really remember anymore.
Could that be the case here? So I somehow messed it up? If that is the case, what would you suggest? Mark all to automatically installed, and then by hand add some selected packages like ubuntu-desktop?
Or is such output correct and I understand it wrongly? I read this and I'm not sure. It looks like it is much more complicated to get the list of manually installed packages? Or why is the answer so complicated?
Or is apt-mark showmanual
buggy?
root@hcompneu:~# ls -ld /var/log/installer/
drwxr-xr-x 2 root root 4096 Dez 27 11:27 /var/log/installer/
root@hcompneu:~# grep -r cdrom /etc/apt/ --include=*.list
root@hcompneu:~# dpkg -l | grep ^ii | wc -l
3812
Solution 1:
TL;DR No, your system is not messed up. Moreover, you can leave all things as they are, so in the current state.
Let's consider three systems:
Current System | Installation media | Age | dpkg -l | grep ^ii | wc -l |
apt-mark showmanual | wc -l |
---|---|---|---|---|
Ubuntu 18.04.6 LTS with MATE desktop(*) | Ubuntu 12.04.4 LTS | 7 y.o. | 5680 | 3953 |
Ubuntu 18.04.6 LTS with MATE desktop(*) | Ubuntu 10.04 LTS | 11 y.o. | 6395 | 3947 |
Yours Ubuntu 18.04 LTS (**) | ~Ubuntu 8.04 LTS | ~13 y.o. | 3812 | 4013 |
Notes:
- (*) my systems were originally installed from Ubuntu desktop installation disks, thus shipped with GNOME and/or Unity (not a flavour). Then I have installed MATE desktop using official PPAs for 12.04 LTS, 14.04 LTS and their meta-packages; then when 16.04 LTS were released I have re-installed MATE desktop as task package using commands like
sudo apt-get install ubuntu-mate-desktop^
. This installation of task package causes all such packages to be marked as manually installed and thus protects them from removal. All other software were installed manually during life-span of the both systems. - (**) the strange thing about your system is that you have total number of installed packages 3812 less than manually installed packages 4013. You have to investigate this using Synaptic.
I tried to conduct some research with fresh installations of old and new systems. Below is the table about clean installations of ordinary Ubuntu desktop ISOs.
Ubuntu version | dpkg -l | grep ^ii | wc -l |
aptitude search '~i!~M' | wc -l |
apt-mark showmanual |
Synaptic: Status → Installed (manual) |
---|---|---|---|---|
6.06 LTS | 1046 | 1046 | n/a | n/a |
8.04 LTS | 1102 | 1087 | n/a | n/a |
10.04 LTS | 1296 | 1286 | n/a | 1286 |
12.04 LTS | 1392 | 1367 | 1367 | 1342 |
14.04 LTS | 1722 | 1690 | 1690 | 1666 |
16.04 LTS | 1745 | 220 | 220 | 195 |
18.04 LTS | 1602 | 1557 | 1557 | 1529 |
20.04 LTS | 1607 | 49 | 49 | 49 |
22.04 LTS (dev) | 1700 | 44 | 44 | 31 |
We can understand here that functionality of Ubiquity installer and APT by itself have changes over time.
From the above table we can see that old systems have huge numbers of manually installed packages from their day 0 of installation.
Newer Ubuntu versions have smaller numbers, this ease their maintenance. They probably have more meta-packages installed which prevent package removal because of dependencies.
Another experiment I have done: I upgraded fresh Ubuntu installation from 8.04 LTS to 10.04 LTS → 12.04 LTS → 14.04 LTS → 18.04 LTS → 20.04 LTS and in the resulting 20.04.3 LTS system I have 1867 manually installed packages of 2913 total packages.
The "manual" installation status of package prevents its removal, so you should not set package as auto-installed.
Good resources to read:
-
Chapter 2. Debian package management of Debian Reference.
-
man apt-mark
locally or online, the below quote is essential:apt-mark
- show, set and unset various settings for a package
[...]showmanual
can be used in the same way asshowauto
except that it will print a list of manually installed packages instead.
Solution 2:
The output of the showmaual option includes any package that ever got updates, so not really what you want. The below command I copied from some other answer (don't recall where or I'd attribute it), and compares the output against the initial install list, producing the packages you installed yourself. Put it into a file in your bin area for convenience.
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
The first time I ran apt-mark showmanual, I knew the list was too big because things like "tar" were included, which I knew I had never manually touched. "tar" however had had an update applied, which caused it to be output. Since "tar" was included in the initial system packages, it gets removed by the script, just leaving things that "showed up" after the initial system installation.