74

How do I list both programs that came with my distribution and those I manually installed?

3
  • 8
    Which distribution? Each distribution has different installing tools.
    – Matteo
    Sep 18, 2011 at 19:43
  • Hm, I'm interested in Red Hat, Ubuntu, and cygwin. Is there a distribution-free way to list the programs with some command line argument? Sep 18, 2011 at 20:07
  • 2
    No, there isn't, as the package managers differ.
    – Chris Down
    Sep 18, 2011 at 20:19

4 Answers 4

96

That depends on your distribution.

  • Aptitude-based distributions (Ubuntu, Debian, etc): dpkg -l
  • RPM-based distributions (Fedora, RHEL, etc): rpm -qa
  • pkg*-based distributions (OpenBSD, FreeBSD, etc): pkg_info
  • Portage-based distributions (Gentoo, etc): equery list or eix -I
  • pacman-based distributions (Arch Linux, etc): pacman -Q
  • Cygwin: cygcheck --check-setup --dump-only *
  • Slackware: slapt-get --installed

All of these will list the packages rather than the programs however. If you truly want to list the programs, you probably want to list the executables in your $PATH, which can be done like so using bash's compgen:

compgen -c

Or, if you don't have compgen:

#!/bin/bash
IFS=: read -ra dirs_in_path <<< "$PATH"

for dir in "${dirs_in_path[@]}"; do
    for file in "$dir"/*; do
        [[ -x $file && -f $file ]] && printf '%s\n' "${file##*/}"
    done
done
9
  • 4
    And for RPM based systems (Red Hat, SuSE, CentOS, etc.): rpm -qa
    – nos
    Sep 18, 2011 at 21:10
  • 2
    Debian / Ubuntu is dkpg -l | grep ^ii.
    – Rolf
    Feb 6, 2018 at 10:37
  • 1
    @Rolf, you mean dPKg May 12, 2018 at 17:52
  • 1
    Hrmph... The BSDs are not Linux distributions...
    – Kusalananda
    May 13, 2018 at 14:44
  • 2
    It would be better to distinguish between package managers instead of "distributions". NetBSD's pkgsrc runs on any Linux, and some package managers can be used on multiple Uinces.
    – Kusalananda
    May 14, 2018 at 13:43
13

Answering the second part of the question (nothing really to be added to Chris' answer for the first part):

There is generally no way of listing manually installed programs and their components. This is not recorded anywhere if you didn't use a package manager. All you can do is find the binaries in standard locations (like Chris suggested) and in a similar way, guess where some libraries or some manual pages etc. came from. That is why, whenever possible, you should always install programs using your package manager.

9

All the other answers (so far) deal with packages and binaries. If you mean "desktop applications", the ones that appear in your start menu, you can try:

ls /usr/share/applications | awk -F '.desktop' ' { print $1}' -

More solutions in another question.

1
  • That's not true. My answer doesn't list packages at all and not only binaries but shell scripts too. May 16, 2022 at 2:12
8

Programs should be reachable via the PATH, so just list everything in the path:

ls ${PATH//:/ }

Expect a result of about 3k-4k programs.

To exclude a probable minority of false positives, you may refine the approach:

for d in ${PATH//:/ } ; do 
    for f in $d/* ; do  
        test -x $f && test -f $f && echo $f
    done
done

It didn't make a difference for me.

3
  • 2
    Note that this will also potentially list various non-programs as well (subdirectories of directories in $PATH, etc).
    – Chris Down
    Mar 25, 2012 at 3:03
  • 1
    I added a test, but it didn't make a difference for me (how useful is a directory in a directory in the path, which isn't itself in the path?). But for cases, where you rely on correctness, it might be useful. Mar 25, 2012 at 5:42
  • 1
    awesome! I wasn't able to know version of Linux ( long story - but nothing criminal ) but this code saved my day :)
    – obenjiro
    Jan 12, 2015 at 18:15

You must log in to answer this question.

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