How to generate list of *all* available commands and functions?

The solution I chose was to run the command:

$ compgen -A function -abck | sort -u >> cmds.txt

which appends all runnable commands, functions and aliases to a text file cmds.txt

Taken from: https://stackoverflow.com/questions/948008/linux-command-to-list-all-available-commands-and-aliases

Edit: added sort -u to command to remove duplicates as suggested by glenn jackman


It seems compgen outputs duplicates: perhaps programs that appear in multiple locations in your PATH:

autocomplete says:

$ [tab][tab]
Display all 2328 possibilities? (y or n)

compgen says:

$ compgen -A function -abck | wc -l
2647
$ compgen -A function -abck | sort -u | wc -l
2328

I don't know if this is important for you.