When you request that a package is installed, and as a result other packages are installed to satisfy its dependencies, the dependencies are marked as being automatically installed, while the package you installed explicitly is marked as manually installed. Once an automatically installed package is no longer depended on by any manually installed package it is considered no longer needed and e.g. apt-get or aptitude will at least suggest removing them.
Some front-ends like apt-get dselect-upgrade can be used to apply previously scheduled changes to the install state of packages. Such changes can be scheduled with the install, remove (also known as deinstall) and purge commands. Packages with a specific selection can be displayed with showinstall, showremove and showpurge respectively. More information about these so called dpkg selections can be found in dpkg(1).
apt-mark returns zero on normal operation, non-zero on error.
m[blue]APT bug pagem. If you wish to report a bug in APT, please see /usr/share/doc/debian/bug-reporting.txt or the reportbug(1) command.