6

I can browse Ubuntu Softwares in Gnome-Software. And they are catagorised very well . I am looking for a CLI version of this. That is, I would like to browse apps from terminal where I could list all apps under a specific category (say games) .

enter image description here

Why am I looking for this ?

If I could could browse apps from terminal, The search results could be highly customized using tools like grep , awk etc...

1
  • i think their's no direct solution but you can change the xml files to what you need on java i use Document to xml files anyway go to gnome software directory cd /usr/share/gnome-software/modulesets.d/ and list then open using terminal file you want for example xmllint --format popular.xml Jun 22, 2016 at 5:11

2 Answers 2

4

There already exists command apt-cache dumpavail which will list all available packages from all enabled repositories. Behind the scenes it actually reads from files stored in /var/lib/apt/lists/ directory (I've done strace of the command, and that's what the output shows) . My guess would be that Gnome Software parses those very same files and organizes those into categories.

Problem is that the actual data has lines that start with Package: for package names and Section: to which they belong, but Section: lines are not organized exactly the same as in Gnome Software. However, with a little bit of command line magic, we can come close to something like that. What I propose is a function

filter_sections()
{
  apt-cache dumpavail | \
  awk -v SEARCH="$@" '/^Package:/{ PKG=$0  }\
    /Section:/ && $0~SEARCH {printf PKG" "$0"\n"}'
}

With that function we can list all packages by sections, for instance:

$ filter_sections web | head                                                   
Package: apache2 Section: web
Package: awstats Section: web
Package: curl Section: web
Package: heat-api Section: web
Package: heat-api-cfn Section: web
Package: heat-api-cloudwatch Section: web
Package: heat-common Section: web
Package: heat-engine Section: web
Package: javascript-common Section: web
Package: libapache2-mod-apparmor Section: web

The code itself is fairly simple: we pass on the output of apt-cache dumpavail to awk which stores every package name into a varialbe , and if the Section: line also contains a string that we are matching, we will print both package name and the section.

As for listing the sections themselves, it's fairly easy as well

apt-cache dumpavail | awk '/Section:/' | sort | uniq 

What is also nice about this approach is that some of the Sections mention which repository the package belongs to, for example universe/python or multiverse/web . The function , however, will search for all and of them , but if so desired we can always filter with awk even more

1

You are probably looking for aptitude. If this is not installed in your system, go ahead and open a terminal and type sudo apt-get install aptitude then sudo aptitude to start it.

If you want to search and filter results with grep, you can use either sudo apt-cache search or sudo aptitude search

2
  • I have aptitude installed. But can I list all Audio apps or all games using aptitude ? If yes, I don't know how to do that, It would be nice if you include them in your answer. Jun 22, 2016 at 5:05
  • You can. Both 'sound' and 'games' categories seem to exist in aptitude. If the categories are not available to you, try running a sudo aptitude update or press u while in the aptitude ncurses interface
    – Squall5668
    Jun 22, 2016 at 5:11

You must log in to answer this question.

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