Debian: Listing all user-installed packages? Debian: Listing all user-installed packages? linux linux

Debian: Listing all user-installed packages?


This command may shorten your work:

apt-mark showmanual

It is supposed to show what packages were installed "manually". It is not 100% reliable though, as many automatically installed packages are flagged as manually installed (because of reasons too long to describe here).

You may also (if allowed) run security tools such as clamav and/or rkhunter to scan your computer for malicious programs.


Below is a line from a "health" script I run on my desktop every night. Besides gathering information from sensors, network usage, HDD temperature, etc. it also gets a list of all the software I've installed manually from the command line.

I'm running Kubuntu 14.04.5 (Trusty) at the moment and I don't know the details of any differences between Ubuntu and Debian's package management but hopefully this will work for you as well as it does for me.

( zcat $( ls -tr /var/log/apt/history.log*.gz ) ; cat /var/log/apt/history.log ) | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | egrep '^Commandline:' | egrep 'install' 1>>installed_packages.txt


All Packages

Most all the code that I found for this question used a search from the history log:

$ cat /var/log/apt/history.log | grep 'apt-get install '

or listed all Debian Packages installed on the machine:

$ dpkg --get-selections

Manually Installed

I found the above answers to be inadequate as my history log was incomplete and I didn't want to do the work to separate built-in packages with manually installed packages. However, this solution did the trick of showing only manually initiated installed packages. This one uses the log: /var/log/dpkg.log, and it should be executed as a bash script.

#!/usr/bin/env bashparse_dpkg_log() {  {    for FN in `ls -1 /var/log/dpkg.log*` ; do      CMD="cat"      [ ${FN##*.} == "gz" ] && CMD="zcat"       $CMD $FN | egrep "[0-9] install" | awk '{print $4}' \        | awk -F":" '{print $1}'    done  } | sort | uniq}list_installed=$(parse_dpkg_log)list_manual=$(apt-mark showmanual | sort)comm -12 <(echo "$list_installed") <(echo "$list_manual")

I found the code here: https://gist.github.com/UniIsland/8878469