Catatan Sistem Manajemen Paket Ubuntu dari Berbagai Sumber




With this suggestion, I’m assuming your old installation will still boot!

To replicate one set of packages on another machine:

On System A, run: dpkg --get-selections | grep -v deinstall > my-selections

Move the my-selections file over to System B.

On System B, run: dpkg --set-selections < my-selections

and then:

sudo apt-get dselect-upgrade

Important note: if you have installed packages from non-standard repositories and/or PPAs, you will also want to copy /etc/apt/sources.list and the contents of /etc/apt/sources.list.d/ from System A to System B before you run the upgrade.

You can use dpkg to see what you’ve removed as well (NB: this will also include packages that you manually installed and removed):

dpkg --get-selections | grep deinstall

You can see your results in the terminal, or, of course, redirect to a file.



This thread from gives this solution:

aptitude search '?installed ?not(?automatic)'



If your apt logs are in /var/log/apt, something like this should work:

gunzip -c /var/log/apt/history.log.*.gz | grep "apt-get install"

Or if you want to get rid of some of the repetitive junk in the output:

gunzip -c /var/log/apt/history.log.*.gz | grep "apt-get install" \ | cut -f4- -d" " | sort | uniq



You could use apt-mark, but I recommend debfoster:

sudo apt-get install debfoster
sudo debfoster

This will inspect all installed packages and figure out which ones are keeping the others installed:

texlive-full is keeping the following 161 packages installed:
  cm-super cm-super-minimal context doc-base dvipng feynmf
  fonts-gfs-artemisia fonts-gfs-baskerville fonts-gfs-bodoni-classic
Keep texlive-full? [Ynpsiuqx?], [H]elp:

As you answer “y” to each question (just push Enter to move quickly), debfoster will collect the package list and write them line-by-line to a file. By default this is at /var/lib/debfoster/keepers. It looks like this:


I configure debfoster via /etc/debfoster.conf to put this list at /etc/debfoster-keepersand track the file with etckeeper to keep history and backups. The answer here shows how to install a list of packages from a newline-delimited text file:

sudo apt-mark manual $(cat debfoster-keepers)

Note a limitation here, packages you purged have a ‘-‘ in front of them. So you want to remove those lines before calling apt-mark.

Even though the debfoster’s website says that debfoster is deprecated in favor of aptitude, I prefer debfoster’s prompt and simple configuration. It puts you in the middle of your package database and lets you clean things up, making the auto and manual packages more obvious.

Type “h” at the debfoster prompt to explain your options. Type “?” to see the package description. The how-to here might be useful.



I finally got it now:

outfile="$(mktemp)" pattern='([INSTALLIEREN]|[INSTALL])' if [[ -f "/var/log/aptitude.1.gz" ]] then gunzip -c /var/log/aptitude.*.gz | grep -E "$pattern" | awk '{ print $2; }' > "$outfile" fi if [[ -f "/var/log/aptitude" ]] then grep -E "$pattern" "/var/log/aptitude" | awk '{ print $2; }' >> "$outfile" fi sort "$outfile" rm "$outfile"



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

Gives all manually installed packages (not system packages, not dependencies). For examples it shows build-essential but not gcc.



didn’t see any solutions here work for me, I have installed quite a few deb packages with dpkg and a few of the items I was particularly looking for were missing.

A rather lengthy one liner, but convenient to copy and paste would be:

export DPKG_INITIAL=$(mktemp) DPKG_INSTALLED=$(mktemp) DPKG_CUSTOM=$(mktemp) DPKG_DEPS=$(mktemp); zgrep -E '^Package' /var/log/installer/initial-status.gz | awk '{ print $2 }' | sort -u > $DPKG_INITIAL && awk '$3 !~ /install|remove|purge/ { next } { gsub(/remove|purge/, "uninstall", $3) ; gsub(/:.+/, "", $4) ; a[$4]=$3 } END { for (p in a) { if (a[p] == "install") { print p } } }' /var/log/dpkg.log | sort -u > $DPKG_INSTALLED && comm -23 $DPKG_INSTALLED $DPKG_INITIAL > $DPKG_CUSTOM && function rdep() { apt-cache rdepends $1 | tail -n +3 | sed -e 's/^ //' -e '/^ /d' | cut -d':' -f1 | sort -u; } ; echo "$(for i in $(cat $DPKG_CUSTOM) ; do rdep $i ; done)" | sort -u > $DPKG_DEPS && comm -23 $DPKG_CUSTOM $DPKG_DEPS > my-packages ; rm $DPKG_INITIAL $DPKG_INSTALLED $DPKG_CUSTOM $DPKG_DEPS

The above command saves a list of packages to a file in your current working directory named my-packages.


I first built a list of packages that composed the baseline of packages selected during installation.

zgrep -E '^Package' /var/log/installer/initial-status.gz | awk '{ print $2 }' | sort -u > $DPKG_INITIAL

Followed by a long list of items installed in general.

awk '$3 !~ /install|remove|purge/ { next } { gsub(/remove|purge/, "uninstall", $3) ; gsub(/:.+/, "", $4) ; a[$4]=$3 } END { for (p in a) { if (a[p] == "install") { print p } } }' /var/log/dpkg.log | sort -u > $DPKG_INSTALLED

I then compared the two files $DPKG_INITIAL and $DPKG_INSTALLED to list only the items unique to $DPKG_INSTALLED.


From there I wanted to filter out the dependencies, this is where this method may miss some desired packages, it is unaware of dependencies that are also explicitly installed.

I wrote a quick bash function to shorten this steps in processing these items.

function rdep() { apt-cache rdepends $1 | tail -n +3 | sed -e 's/^ //' -e '/^ /d' | cut -d':' -f1 | sort -u; }

After that I passed each line from my file $DPKG_CUSTOM into this function with xargs.

echo "$(for i in $(cat $DPKG_CUSTOM) ; do rdep $i ; done)" | sort -u > $DPKG_DEPS

Once I had the long list of every possible dependency, (not sure on the every possible statement), I once again got the lines that were unique to a single file.

comm -23 $DPKG_CUSTOM $DPKG_DEPS > my-packages

And my finished list of packages is now in a file named my-packages available for me to review.



cd /var/log/apt
cat  history.log | grep Commandline

this way you see the list of commands performed in the past.

Remove the grep code if you need more information:

less history.log

if the log is compressed (i.e. end with gz)

gunzip <filename>

to zip it again when finished you can do:

gzip <filename>



Someone linked to which does have a good solution, but, it doesn’t behave correctly as the output from aptitude has changed. Here is an updated version, based around compared currently installed packages compared to 12.04 LTS. You will need aptitude installed, that is the only requirement.

aptitude search '~i !~M' -F '%p' | sort -u | tr -d ' ' > currentlyinstalled && wget -qO - | cut -f 1 | sort -u > defaultinstalled && comm -23 currentlyinstalled defaultinstalled

To break the above command down into parts, this bit outputs one package per line of everything installed on the system

aptitude search '~i !~M' -F '%p' | sort -u | tr -d ' ' > currentlyinstalled

And this downloads the default package list & crops the redundant information.

wget -qO - | cut -f 1 | sort -u > defaultinstalled

and comm compares the two files and outputs the packages which arent in the default list.

comm -23 currentlyinstalled defaultinstalled



Use a distribution manifest file as the base package set. Sort the manually installed results into package groups by architecture and section, so it’s easier to focus on groups of packages (maybe you don’t care about some sections).

#!/bin/bash manifest_url='' manifest_file=$(echo $manifest_url | sed -e 's#.*/##g') if [ ! -e $manifest_file ]; then wget -q $manifest_url fi cat $manifest_file | cut -f1 | sort -u > default_installed.txt aptitude search '~i !~M' -F '%p' --disable-columns | sort -u > currently_installed.txt comm -23 currently_installed.txt default_installed.txt > manually_installed.txt # sort the 'mannually_installed.txt' packages by architecture and section mkdir -p package_files while read p; do apt-cache show $p > info.txt arch=$(grep -m1 'Architecture: ' info.txt | sed -e 's/Architecture: //') section=$(grep -m1 'Section: ' info.txt | sed -e 's/Section: //' -e 's/\//_/g') file="${arch}_${section}_packages.txt" echo $p >> "package_files/$file" done <manually_installed.txt rm info.txt



apt-rdepends –-dotty git-arch | dot -Tpng > git_deps.png



apt-cache rdepends packagename should do what you want



aptitude has a fairly nice way of handling this:

$ aptitude why bash
i foomatic-filters PreDepends bash (>= 2.05)
It only lists one reason, but that’s usually enough…



There are more than one way, with each method showing a different output.

For a detailed view of the dependency tree; aptitude install apt-rdepends apt-rdepends bash


apt-cache showpkg bash

Or a concise list:

apt-cache rdepends bash



apt-cache showpkg <pkgname> 


apt-cache showpkg lightdm



Reverse depends

Reverse depends means you want a list of packages that depend on a given package.


$ apt-cache rdepends jetty
Reverse Depends:

Recursive depends

Using a tool such as apt-rdepends shows what packages a given package is dependent on, plus what packages these packages are also dependent on. This is performed recursively until the entire dependency tree is exhausted.


$ apt-rdepends jetty | head -10
Reading package lists... Done
Building dependency tree       
Reading state information... Done
  Depends: adduser
  Depends: apache2-utils
  Depends: default-jre-headless
  Depends: java5-runtime-headless
  Depends: jsvc
  Depends: libjetty-java (>= 6.1.26-1ubuntu1)
  Depends: debconf
  Depends: debconf-2.0

Above you can see that jetty is dependent on adduser which itself is dependent on debconf.

Reverse recursive depends

This one shows what packages depend on a package that depends on a given package. This is again done recursively.


$ apt-rdepends --reverse jetty 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
  Reverse Depends: solr-jetty (>= 3.6.1+dfsg-0ubuntu2)
  Reverse Depends: chef-solr (>= 10.12.0+dfsg-1)
  Reverse Depends: chef-expander (>= 10.12.0-1)
  Reverse Depends: chef-server-api (>= 10.12.0-1)
  Reverse Depends: chef-server-webui (>= 10.12.0+dfsg-1)

Again here as the tree is explored the first package that lists jetty as a dependency is solr-jetty, which in turn is listed as a dependency for chef-solr, etc.

Types of depends

It can get a little confusing but there are a variety of depends. Looking at the man page for apt-rdepends:

-f, --follow=DEPENDS A comma-separated list of DEPENDS types to follow recursively. By default, it only follows the Depends and PreDepends types. The possible values for DEPENDS are: Depends, PreDepends, Suggests, Recommends, Conflicts, Replaces, and Obsoletes. In --build-depends mode, the possible values are: Build-Depends, Build-Depends-Indep, Build-Conflicts, Build-Conflicts-Indep.



You can use tools like apt-cacher, apt-mirror or apt-offline (which sounds like it fits your requirements best).

apt-offline –

apt-offline is an Offline APT Package Manager

apt-offline can fully update and upgrade an APT based distribution without connecting to the network, all of it transparent to apt

apt-offline can be used to generate a signature on a machine (with no network). This signature contains all download information required for the apt database system. This signature file can be used on another machine connected to the internet (which need not be a Debian box and can even be running windows) to download the updates. The downloaded data will contain all updates in a format understood by apt and this data can be used by apt-offline to update the non-networked machine.



I would go with this:

apt-get download PACKAGE && apt-cache depends -i PACKAGE | awk '{print $2}' | xargs apt-get download

Then you can install it with dpkg -i *.deb in the directory you downloaded these.


Mohon jangan gunakan emotikon:

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s