Is it possible to know from apt if the package was installed explicitly or as a dependency of another package?
You can check whether a package was installed manually by displaying the list of all automatically installed packages with apt-mark showauto
.
apt-mark showauto | grep -x B
aptitude -v why B
shows which packages depend on B. Sticking with aptitude, aptitude version B
displays an A
in the third column if B is marked as automatically installed.
apt-cache show A
or dpkg -s A
(if A is installed) shows A's dependencies. apt-cache rdepends B
shows what depends on B.