On a particular Debian VM, I want to know how did xterm and x11-utils got installed : were they installed directly (an administrator running
apt-get install xterm for example) or as a requirement for other packages ?
Packages which are installed because they’re dependencies are normally flagged as automatic; you can see that with
apt-mark showauto xterm
If that outputs
xterm, the package was installed automatically; otherwise it was installed manually.
You can use
aptitude to see which dependencies keep a package installed:
aptitude why xterm
aptitude why will also explicitly say if a package was installed manually.