Ubuntu – Is it possible to know from apt if the package was installed explicitly or as a dependency of another package

aptdpkgpackage-management

Let's say there are A, B and C package.

A and C were installed manually with apt-get install, and B is a dependency of A and was installed by apt automatically.

Is it possible to know that with some apt-* or dpkg command?

Best Answer

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.

Related Question