# [FAQF] GF3: How do I get a list of installed packages?

## pjp

This is the feedback thread for GF3: How do I get a list of installed packages?.

----------

## rojaro

what about /usr/lib/portage/bin/pkglist ...?

----------

## pjp

Didn't know about that.  Interesting, that by default, /usr/lib/portage/bin/ is not in the PATH.  I wonder why.

----------

## securiteaze

You could also use 'epm'  an rpm workalike for Gentoo Linux

Install it :

```
emerge sync && emerge epm
```

List all installed packages :

```
epm -qa
```

Determine what package provides a file :

```
epm -qf /usr/bin/host

bind-tools-9.2.1
```

----------

## janneand

You think the solutions above are too slow? Try this -

```
find /var/db/pkg/ -mindepth 2 -maxdepth 2 -printf "%P\n"
```

If you prefer them wihtout the leading group, use %f instead of %P.

TIPS: Add this to you ~/.bashrc

```
alias listinstalled='find /var/db/pkg/ -mindepth 2 -maxdepth 2 -printf "%P\n"'
```

Save it and...

```
source ~/.bashrc
```

-J

----------

## S_aIN_t

thanks for the find alias. that works much faster than qpkg..  :Very Happy: 

----------

## janneand

I continued to hack a little bit on that command and came up with this, called qportage. The idea is to be faster than qpkg.

To get this to work - paste it into a file, watch so you don't get a space after the EOF-line and append all lines separated by \.

EDIT:

New version has been added as an ebuild to Bugzilla, Bug#: 11637. Now support for listing files in installed ebuilds, colors and extra information (homepage and ebuild description).

-J

```
#!/bin/bash

# Copyright 2002 Jan Andersson

# Distributed under the terms of the GNU General Public License v2

usage() {

  cat <<EOF

Tool to quickly list ebuilds in Gentoo.

qportage [options...] [filters...]

Parameters without option specifiers are filtering the output.

Options:

  -h       Show this help

  -i       List installed packages only

  -v       List and print all versions

  -g       Hide group name

Examples:

# qportage 

List all available ebuilds.

# qportage -i dev

List everything installed that is dev-related.

# qportage -vig ^glib-

List available versions of glib.

# qportage quake doom

List available quake and doom packages.

EOF

}

TEMP=`getopt -o igvh --long help -n 'qportage' -- "$@"`

if [ $? != 0 ]

then

   exit 1

fi

eval set -- "$TEMP"

group=1

while true

do

   case "$1" in

      -h|--help)

         usage; exit;;

      -g)

         unset group; shift;;

      -v)

         version=1; shift;;

      -i)

         installed=1; shift;;

      --) shift; break;;

      *) echo "Internal error."; exit 1;;

   esac

done

if [ -z $1 ]

then

   filter=".?"

else

   for f in $@

   do

      filter="$filter --regexp=$f"

   done

fi

if [ $group ]

then

   field=P

else

   field=f

fi

if [ $installed ]

then

   if [ $version ]

   then

      find /var/db/pkg -mindepth 2 -maxdepth 2 -printf \

         "%$field\n"|grep $filter|sort

   else

      find /var/db/pkg -mindepth 2 -maxdepth 2 -printf \

         "%$field\n"|awk -F- ' 

      { 

         # Remove version

         for (i=1; i <= NF; i++) { 

            if ($i ~ /^[0-9]/) 

               break;

            if (i>1) 

               printf "-"; 

            printf $i; 

         } 

         printf "\n"; 

         next; 

      } '|grep $filter|sort|uniq

   fi

else

   if [ $version ]

   then

      find /var/cache/edb/dep -mindepth 2 -maxdepth 2 -printf \

         "%$field\n"|grep $filter|sort

   else

      if [ $group ]

      then

         find /usr/portage -type d -mindepth 2 -maxdepth 2 \

            -printf  "%P\n"|awk -F/ '

         {

            # Print only real ebuilds (and not packages etc)

            if ($1 ~ /-/) 

               printf $1 "/" $2 "\n" 

         }'|grep $filter|sort|uniq

      else

         find /usr/portage -type d -mindepth 2 -maxdepth 2 \

            -printf "%P\n"|awk -F/ '

         {

            # Print only real ebuilds (and not packages etc)

            if ($1 ~ /-/) 

               printf $2 "\n" 

         } '|grep $filter|sort|uniq

      fi

   fi

fi

```

----------

## Beefrum

```
# Build Gentoo version file

equery l > version

# Build Gentoo world file

equery -C -q list | cut -d ' ' -f 5 | sed -n 's/-[0-9]\{1,\}.*$//p' > world
```

----------

## beatryder

 *pjp wrote:*   

> Didn't know about that.  Interesting, that by default, /usr/lib/portage/bin/ is not in the PATH.  I wonder why.

 

That file does not exist on my compy... running portage 2.1

----------

## kallamej

 *beatryder wrote:*   

>  *pjp wrote:*   Didn't know about that.  Interesting, that by default, /usr/lib/portage/bin/ is not in the PATH.  I wonder why. 
> 
> That file does not exist on my compy... running portage 2.1

 

Well, the post you quoted is over 3½ years old. IIRC, it was gone also in the later 2.0.x versions.

----------

## beatryder

 *kallamej wrote:*   

>  *beatryder wrote:*    *pjp wrote:*   Didn't know about that.  Interesting, that by default, /usr/lib/portage/bin/ is not in the PATH.  I wonder why. 
> 
> That file does not exist on my compy... running portage 2.1 
> 
> Well, the post you quoted is over 3½ years old. IIRC, it was gone also in the later 2.0.x versions.

 

 :Laughing:   :Embarassed:   hehe, that'll learn me to read post dates I guess :p

----------

## geophotog

qpkg has been deprecated and replaced with "equery" in current gentoolkit

----------

## Dralnu

To get a quick list of installed packages:

eix -I >> installed_apps

If you keep your database updated (daily cronjob of update-eix), that will list everything REAL fast.

Also, you could also cat the file, and if you want,

eix -vI >> installed_apps

to give you a good listing of all your installed files with nice little descriptions of which you can then cat && grep through for a refrence from then on.

Enjoy.

P.S. You could run update_eix && eix -vI >> /path/to/file to keep an updated list handy. Personally, I drop those files in my /home/user dir, and then I can just cat from there. Makes things rahter quick  :Smile: 

----------

## PLum

im really happy that i find that post here

i need to make almost same gentoo server but on really difrent machine and i use

```

update-eix

eix -I|grep "\[I\]"| cut -d\  -f2 

```

and that make me a list of packages to emerge on the new machine.

----------

## mv

Awakening dead threads again?

Meanwhile there is "qlist -I". And since quite a while also eix doesn't need posprocessing for what you want:

```
eix -I --only-names
```

----------

## khayyam

More necromancy!

If eix is installed (current version 0.23.10) then the following can be used:

```
eix-installed ALL
```

The resulting list is practically instantanious, but obviously this due the fact that eix uses a cache and therefore 'eix-update' will need to be run to keep this cache up-to-date.

best ... khay

----------

