Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Is there a way to show the history of installed packages that were installed by apt-get via commandline?

share|improve this question
add comment

3 Answers

up vote 17 down vote accepted

All actions with apt (apt-get) are logged. These files are available in /var/log/apt/. To view the most recent history log, execute:

less /var/log/apt/history.log

These logs gets rotated (every month I guess), old files will be suffixed with a number and compressed. So to view the next history log, use:

zless /var/log/apt/history.log.1.gz

To view the logs available:

ls -la /var/log/apt/
share|improve this answer
    
This is excellent. The only thing missing is who ran the commands. –  Limited Atonement Apr 3 '12 at 17:33
1  
@LimitedAtonement Have a look at /var/log/auth.log, it may contain the user running the installation. (this won't help if the installation was invoked through a shell/program running as root) –  Lekensteyn Apr 3 '12 at 17:41
add comment

I find this one better:

  • add custom fun in ~/.bashrc

    ### pars for fun: install | remove | rollback
    function apt-history(){
          case "$1" in
            install)
                  cat /var/log/dpkg.log | grep 'install '
                  ;;
            upgrade|remove)
                  cat /var/log/dpkg.log | grep $1
                  ;;
            rollback)
                  cat /var/log/dpkg.log | grep upgrade | \
                      grep "$2" -A10000000 | \
                      grep "$3" -B10000000 | \
                      awk '{print $4"="$5}'
                  ;;
            *)
                  cat /var/log/dpkg.log
                  ;;
          esac
    }
    
  • and call it in terminal like this:

    kreso@h17:~$ apt-history install
    2013-08-06 14:42:36 install gir1.2-nautilus-3.0:amd64 <none> 1:3.8.2-0ubuntu1~ubuntu13.04.1
    2013-08-06 14:42:36 install python-nautilus:amd64 <none> 1.1-3ubuntu1
    2013-08-06 14:42:37 install insync-nautilus:all <none> 1.0.20
    2013-08-07 14:41:37 install powertop:amd64 <none> 2.1-0ubuntu1
    2013-08-07 18:44:10 install libdiscid0:amd64 <none> 0.2.2-3build1
    2013-08-07 18:44:11 install sound-juicer:amd64 <none> 3.5.0-0ubuntu1
    

Taken from here

share|improve this answer
add comment

You can also use the following command to list recently installed packages

cat /var/log/dpkg.log | grep "\ install\ "
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.