Skip to content

Instantly share code, notes, and snippets.

@UniIsland
Created February 8, 2014 08:20
  • Star 31 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save UniIsland/8878469 to your computer and use it in GitHub Desktop.
List all manually installed packages on a debian/ubuntu system
#!/bin/bash
## List all manually installed packages on a debian/ubuntu system
## manually installed means:
## 1. not pre-installed with the system
## 2. not marked auto-installed by apt (not dependencies of other
## packages)
## Note: pre-installed packages that got updated still needs to be
## filtered out.
parse_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
}
## all packages installed with apt-get/aptitude
list_installed=$(parse_dpkg_log)
## packages that were not marked as auto installed
list_manual=$(apt-mark showmanual | sort)
## output intersection of 2 lists
comm -12 <(echo "$list_installed") <(echo "$list_manual")
@ai2ys
Copy link

ai2ys commented Jan 5, 2020

Shell script works perfect on Raspbian

Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment