Linux Commands – Generating List of All Available Commands and Functions

autocompletebashcommandlinux

In Linux (I am using CentOS 7), there is a built in functionality to view all runnable commands. The command is run by pressing tab twice in the console followed by the prompt:

Display all 1130 possibilities? (y or n)

Pressing y outputs a huge list of commands to the console.

Is there a way to capture this output in a file?

Or is this list already stored locally? If so, how can I access this?

Best Answer

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

Related Question