Skip to content

Instantly share code, notes, and snippets.

@pradyumnac
Created December 29, 2022 12:13
Show Gist options
  • Save pradyumnac/d6ffea4f12ec77cb284c7d370e981beb to your computer and use it in GitHub Desktop.
Save pradyumnac/d6ffea4f12ec77cb284c7d370e981beb to your computer and use it in GitHub Desktop.
Get a list of all manually installed packages using apt
#!/usr/bin/env bash
cat /var/log/apt/history.log 2>/dev/null |
egrep '^(Start-Date:|Commandline:)' |
grep -v aptdaemon |
egrep '^Commandline:'|rg 'apt install'|sed 's/Commandline: apt install//'
# Last tested on ubuntu 22.04 (29/12/2022)
@PankajN18
Copy link

PankajN18 commented Sep 12, 2023

:)

following should be the correct and more appropriate command. ( In your cmdline, 'rg' has no meaning and it may give duplicates as well, plus the log files rotates therefore the archives logs should also be considered. )

zcat /var/log/apt/history.log.*.gz | egrep '^(Start-Date:|Commandline:)' | grep -v aptdaemon | grep 'apt install' | sed 's/Commandline: apt install//' | tr ' ' '\n' | sort -u

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