How do I get a list of all available shell commands How do I get a list of all available shell commands bash bash

How do I get a list of all available shell commands


You could use compgen. For example:

compgen -c

You also could grep it, like this:

compgen -c | grep top$

Source: http://www.cyberciti.biz/open-source/command-line-hacks/compgen-linux-command/


You can list the directories straight from $PATH if you tweak the field separator first. The parens limit the effect to the one command, so use: (...) | grep ...

(IFS=': '; ls -1 $PATH)


"tab" twice & "y" prints all files in the paths of $PATH. So just printing all files in PATH is sufficient.

Just type this in the shell:

 # printf "%s\n" ${PATH//:/\/* } > my_commands

This redirect all the commands to a file "my_commands".