Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I log the installation of packages in Ubuntu? I want to send a message to log every time after a package is installed, like, "Package Installed" with the name of package & it should do that after uninstalling too. Is this possible? I am logging all this in a file called "Local3.log".

share|improve this question

It appears that apt logs this data here:


This blog had this and more info on package logging:

share|improve this answer

Yes you can do it. (You can use /var/log/apt/history.log* files or the method below)

First you have to create a shell script named apt-get(as shown below)

Then you have to add it to your PATH variable. You can do it by adding it to the /etc/profile for example if your script is located in /home/ankur/ you have to add a line to /etc/profile like the line below. export PATH=/home/ankur/:$PATH

Now whenever you execute apt-get our script executes first

(This might not be the perfect script) apt-get

if [ $1 = "install" ] || [ $1 = "remove" ] || [ $1 = "purge" ];
    sudo /usr/bin/apt-get $*
    echo $* >> /home/ankur/Local3.log
    /usr/bin/apt-get $*
share|improve this answer

Your Answer


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.