5

I can retrieve the softwares using the dpkg command but is there a command to get the associated category for the software . For example if I have Firefox installed can I somehow retrieve a tag for it that says browser or may be a more abstract term say internet tools.

1 Answer 1

5

You can use dpkg-query and format the output to get the binary name and its Debian section:

dpkg-query -W -f='${binary:Package} (${Section})\n' firefox

For firefox it will simply return firefox (web) (the same section used when querying packages.ubuntu.com)

Of course you can also use the same command without a package name:

dpkg-query -W -f='${binary:Package} (${Section})\n'

See the dpkg-query man page for further details.


To get the categories as shown in the Software Center you need to parse files in /usr/share/applications like this:

$ grep Categories /usr/share/applications/* | grep firefox
/usr/share/applications/firefox.desktop:Categories=GNOME;GTK;Network;WebBrowser;

To get only the most specific applicable category, you could try this:

$ grep Categories /usr/share/applications/firefox.desktop | awk -F';' '{print $(NF-1)}'
WebBrowser
5
  • Thanks for spending some of your valuable time with Ask Ubuntu. :)
    – Raja G
    May 5, 2014 at 12:32
  • I tried the command it returns me web for the firefox but gnome for rhythmbox but when i see software center it lists it under sound and video category .So any other query to produce the same outcome ? May 5, 2014 at 12:44
  • Moreover when i run software-center in debug mode it seems like it queries the software internal tools and gets the categories the way i want them for eg. Ruby python are coming under developer tools and more. Can anything be done about it ? May 5, 2014 at 12:51
  • I've updated my answer using the freedesktop Categories May 5, 2014 at 13:23
  • Thanks alot. Would not have got a better answer than yours.Very much appreciated. @SylvainPineau May 5, 2014 at 14:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .