Gangmax Blog

自由之思想,独立之精神

How to List All the Repositories, PPAs and Manually Installed Packages on Ubuntu

| Comments

From here and here.

If I want to rebuild an Ubuntu environment as an existing one, a question is that how I can list all the manually installed PPAs and pacakges. Here is the answer.

List repositories and PPAs

Create the following bash script and run:

listppa.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#! /bin/sh
# Script to get all the PPA installed on a system
for APT in `find /etc/apt/ -name \*.list`; do
    grep -Po "(?<=^deb\s).*?(?=#|$)" $APT | while read ENTRY ; do
        HOST=`echo $ENTRY | cut -d/ -f3`
        USER=`echo $ENTRY | cut -d/ -f4`
        PPA=`echo $ENTRY | cut -d/ -f5`
        #echo sudo apt-add-repository ppa:$USER/$PPA
        if [ "ppa.launchpad.net" = "$HOST" ]; then
            echo sudo apt-add-repository ppa:$USER/$PPA
        else
            echo sudo apt-add-repository \'${ENTRY}\'
        fi
    done
done

List manually installed packages

Run the following command:

1
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)

Comments