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.

I am new to ubuntu and trying to find out the way to list all installed packages and its details like version, release, install time, category on Ubuntu. Found that following commands will help me get some of this information:

1) dpkg -l

2) dpkg-query -W -f='${PackageSpec}\t${version}\t${Description}\n'

Unlike Redhat the install time and category information is missing in this. Can anyone know of a way to retrieve these details?

Thanks in advance.

share|improve this question

6 Answers 6

up vote 2 down vote accepted

Simple and elegant:

sudo dpkg -l | more

or

sudo dpkg -l | less

If you want to get the description of some specific packages say firefox:

sudo dpkg -l | grep firefox

Here is my output of:

sudo dpkg -l | more

 Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                        Version                                 Description
+++-===========================================-=======================================-==============================================================
================
ii  accountsservice                             0.6.15-2ubuntu9.4                       query and manipulate user account information
ii  acl                                         2.2.51-5ubuntu1                         Access control list utilities
ii  acpi-support                                0.140                                   scripts for handling many ACPI events
ii  acpid                                       1:2.0.10-1ubuntu3                       Advanced Configuration and Power Interface event daemon
ii  activity-log-manager-common                 0.9.4-0ubuntu3.2                        blacklist configuration for Zeitgeist (assets)
ii  activity-log-manager-control-center         0.9.4-0ubuntu3.2                        blacklist configuration for Zeitgeist (control center integrat
ion)
ii  adduser                                     3.113ubuntu2                            add and remove users and groups
ii  adium-theme-ubuntu                          0.3.2-0ubuntu1                          Adium message style for Ubuntu
ii  aisleriot                                   1:3.2.3.2-0ubuntu1                      Solitaire card games
ii  akonadi-backend-mysql                       1.7.2-0ubuntu1                          MySQL storage backend for Akonadi
ii  akonadi-server                              1.7.2-0ubuntu1                          Akonadi PIM storage service
ii  alacarte                                    0.13.2-2ubuntu4                         easy GNOME menu editing tool
ii  alsa-base                                   1.0.25+dfsg-0ubuntu1                    ALSA driver configuration files
ii  alsa-utils                                  1.0.25-1ubuntu5                         Utilities for configuring and using ALSA
ii  anacron                                     2.3-14ubuntu1                           cron-like program that doesn't go by time
ii  apg                                         2.2.3.dfsg.1-2                          Automated Password Generator - Standalone version
ii  app-install-data                            0.12.04.4                               Ubuntu applications (data files)
ii  app-install-data-partner                    12.12.04.1                              Application Installer (data files for partner applications/rep
ositories)
ii  apparmor                                    2.7.102-0ubuntu3.7                      User-space parser utility for AppArmor
ii  appmenu-gtk                                 0.3.92-0ubuntu1.1                       Export GTK menus over DBus
ii  appmenu-gtk3                                0.3.92-0ubuntu1.1                       Export GTK menus over DBus
ii  appmenu-qt                                  0.2.6-0ubuntu1                          appmenu support for Qt
ii  apport                                      2.0.1-0ubuntu17.1                       automatically generate crash reports for debugging
ii  apport-gtk                                  2.0.1-0ubuntu17.1                       GTK+ frontend for the apport crash report system
ii  apport-symptoms                             0.16.1                                  symptom scripts for apport
ii  apt                                         0.8.16~exp12ubuntu10.7                  commandline package manager
ii  apt-transport-https                         0.8.16~exp12ubuntu10.7                  https download transport for APT
ii  apt-utils                                   0.8.16~exp12ubuntu10.7                  package managment related utility programs
--More--

To get the date and time of packages being installed

cat /var/log/dpkg.log | grep " install "

To get for specific package:

cat /var/log/dpkg.log | grep " install " | grep banshee

2013-12-12 12:51:48 install banshee <none> 2.4.1-3ubuntu1~precise2
2013-12-12 12:51:51 install banshee-extensions-common <none> 2.4.0-1ubuntu1
2013-12-12 12:51:51 install banshee-extension-radiostationfetcher <none> 2.4.0-    1ubuntu1
2013-12-12 12:51:51 install banshee-extension-soundmenu <none> 2.4.1-3ubuntu1~precise2

To get the section

apt-cache show firefox | grep Section

Section: web

See Also: ListInstalledPackagesByDate

share|improve this answer
    
I Had seen these two ways but was not sure if these are the consistent ways to use on all versions of Ubuntu. One more concern was if apt-cache reports in certain conditions only (like if caching is enabled). Can I rely on these commands to get the details? –  user1787572 Dec 16 '13 at 8:58
    
It seems that apt cache can be deleted and that command won't return all the information. Correct me if I am wrong. Will dpkg --print-avail <package_name> help me get the same details if apt cache is deleted? –  user1787572 Dec 16 '13 at 9:10
    
@user224730: I don't know how you'll delete apt-cache, but yes you are right. dpkg --print-avail will do the same job if you want to get the sufficient information. One thing you should note that sudo apt-cache show command always gives you some extra information. You can verify it by comparing these two commands output. 1.sudo apt-cache show firefox | wc and 2. sudo dpkg --print-avail firefox | wc You'll notice that 1st command returns more number of lines, words and characters than the 2nd one. Reply if you've still some doubts.. –  Saurav Kumar Dec 16 '13 at 10:09
    
apt-get clean is the command I learned about which deletes the cache. I ran both the commands you mentioned about on my system and found that apt-cache show firefox | wc returned me some record, however dpkg --print-avail | wc did not. I checked if firefox is installed on my system by running dpkg -l | grep firefox and I got nothing. I ran the same commands for the package which is installed on the system and found that apt-cache show command also prints the information about the latest patch that is available for this package. That means, the package is the candidate for update. –  user1787572 Dec 16 '13 at 11:11
    
Well, that takes me to the decision that dpkg --print-avail is the command I am looking for which gives me the actual information of the package level installed on the system. –  user1787572 Dec 16 '13 at 11:12

open text editor and paste following with anyname.sh and make it executable with

chmod +x  anyname.sh   

code :

#!/bin/bash
#pkginstalls.sh
#creates text file with a list of all packages installed by date

#first append all info from archived logs

i=2
mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
nlogs=$(( $mycount + 1 ))

while [ $i -le $nlogs ]
do
if [ -e /var/log/dpkg.log.$i.gz ]; then
zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))

done

#next append all info from unarchived logs

i=1
nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
nulogs=$(( $nulogs - $nlogs + 1 ))
while [ $i -le $nulogs ]
do
if [ -e /var/log/dpkg.log.$i ]; then
cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt
fi
i=$(( $i+1 ))

done

#next append current log

cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt

#sort text file by date

sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt

rm $HOME/pkgtmp.txt

exit 0

credit goes to ubuntu community

share|improve this answer
    
Thanks for the reply. The script will have to be modified to get few more details like category. –  user1787572 Dec 16 '13 at 8:59

Now it is far easier to get the installation details of packages.

Here are the simple steps:

  1. Copy and paste following script in a file and save it with any name say pkgdetails.

    #!/bin/bash
    
    #Get the details and section of installed packages
    # usage:
    # pkgdetails <pkgname1> <pkgname2>
    
    #first append all info from archived logs
    
    i=2
    mycount=$(ls -l /var/log/dpkg.log.*.gz | wc -l)
    nlogs=$(( $mycount + 1 ))
    
    while [ $i -le $nlogs ]
    do
    if [ -e /var/log/dpkg.log.$i.gz ]; then
    zcat /var/log/dpkg.log.$i.gz | grep "\ install\ " >> $HOME/pkgtmp.txt
    fi
    i=$(( $i+1 ))
    
    done
    
    #next append all info from unarchived logs
    
    i=1
    nulogs=$(ls -l /var/log/dpkg.log.* | wc -l)
    nulogs=$(( $nulogs - $nlogs + 1 ))
    while [ $i -le $nulogs ]
    do
    if [ -e /var/log/dpkg.log.$i ]; then
    cat /var/log/dpkg.log.$i | grep "\ install\ " >> $HOME/pkgtmp.txt
    fi
    i=$(( $i+1 ))
    
    done
    
    #next append current log
    
    cat /var/log/dpkg.log | grep "\ install\ " >> $HOME/pkgtmp.txt
    
    #sort text file by date
    
    sort -n $HOME/pkgtmp.txt > $HOME/pkginstalls.txt
    
    rm $HOME/pkgtmp.txt
    
    # Now displaying the installation details of packages passed as arguments
    
    for pkg in $@
    do
    echo "--------------------- Installation Details of $pkg ----------------------"
    echo 
    cat $HOME/pkginstalls.txt | grep -i $pkg
    echo
    apt-cache show $pkg | grep "Section" | sort -u
    echo
    done
    
    exit 0
    
  2. Make the file executable and copy to /bin to use it as a command.

    chmod a+x pkgdetails && sudo cp pkgdetails /bin/
    
  3. Now use pkgdetails command to get the installation details and section of packages:

    pkgdetails qbittorrent artha
    

Here is my output:

--------------------- Installation Details of qbittorrent ----------------------

2013-07-24 07:52:27 install qbittorrent <none> 2.9.7-1
2013-07-24 09:11:32 install qbittorrent <none> 3.0.x-0~4366-20130722~precise1
2013-10-19 05:32:27 install qbittorrent <none> 3.0.x-0~4389-20130802~precise1

Section: net
Section: universe/net

--------------------- Installation Details of artha ----------------------

2013-07-11 23:50:16 install artha <none> 1.0.2-1ubuntu1

Section: universe/utils
share|improve this answer

you must look this site https://help.ubuntu.com/community/AptGet/Howto You will see in here,

apt-cache show

apt-cache pkgnames

share|improve this answer

I have a partial answer (and not enough rep points to make this a comment) - the install log is here:

sudo less /var/log/apt/term.log 

As you seem to be a bit more command line savvy than me, you might try modifying the script here to parse it:

http://lists.debian.org/debian-user/2002/08/msg01219.html

share|improve this answer

apt-cache showpkg <package> will give you details about what package versions are available, forward and reverse dependencies etc.

apt-cache show <package> will provide description, category (Section) etc.

I'm not aware of a way to see at what time a package was installed.

share|improve this answer
    
Okay. Thanks for the reply. –  user1787572 Dec 16 '13 at 9:24

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.