apt-get sometimes displays a message that some packages have been installed automatically and can be removed with apt-get autoremove . This means that a sign is stored somewhere for which reason a particular package was installed.

How to get a list of packages installed by user request, without automatically added dependencies, and, if possible, with the installation date?

    1 answer 1

    1. using “warm tube” aptitude :

       $ aptitude search -F '%p' '!~M ~i' 
    2. using apt-mark :

       $ apt-mark showmanual 

    The start date / time (as well as parameters and many other information) of the apt-get program can be found in the files /var/log/apt/* , the aptitude program in the files /var/log/aptitude* , the dpkg program (you can run manually to install the package from the manually downloaded file) - in the /var/log/dpkg.log* files. which is bad - all these files are rotated and (as far as I remember, but it’s worth clarifying in the logrotate settings) are deleted over time.


    additional information:


    addition about the date of installation. in general, it is not fixed in the dpkg “database”, but a more or less relevant result can be obtained, for example, by the date of the last modification of the /var/lib/dpkg/info/имя-пакета* (for example, имя-пакета[:архитектура].list containing a list of package files).

    When unpacking the archives contained in the file with the package, the dpkg program overwrites the specified files (at least) (for a more accurate algorithm, see the dpkg documentation, or directly in its source codes).

    somehow like this:

     #!/bin/bash export arch=$(dpkg --print-architecture) dostat() { stat --printf="$1\t%y\n" $2 } apt-mark showmanual | while read p; do if [ -f /var/lib/dpkg/info/$p.list ]; then dostat $p /var/lib/dpkg/info/$p.list elif [ -f /var/lib/dpkg/info/$p:$arch.list ]; then dostat $p /var/lib/dpkg/info/$p:$arch.list else echo $p fi done 

    example output:

     2vcard 2010-03-25 11:56:42.000000000 +0300 abcde 2013-07-20 20:50:31.000000000 +0400 abiword 2013-07-20 22:48:50.000000000 +0400 abook 2013-07-20 22:48:51.000000000 +0400 acl 2013-07-20 22:46:20.000000000 +0400 acpi 2013-07-20 20:50:34.000000000 +0400 acpid 2013-07-20 20:50:34.000000000 +0400 adduser 2013-07-20 20:48:04.000000000 +0400 alien 2013-07-20 20:50:38.000000000 +0400 alsa-base 2013-07-20 22:45:48.000000000 +0400 
    • requested the opposite is not automatic, but thanks anyway - sercxjo
    • Sorry, this is a typo. I typed this command manually, but did not copy it from the terminal emulator, where I ran both commands to find out the full identity of their output. - aleksandr barakin
    • one
      @sercxjo, added the answer again. - aleksandr barakin
    • aptitude works much slower apt-mark - sercxjo
    • one
      @sercxjo, no wonder: a more versatile tool is usually inferior to a more specialized one. - aleksandr barakin