How do I list all installed programs?
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
oreix -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
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.
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.