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?


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
$ compgen -A function -abck | sort -u | wc -l

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


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

  • 2
    <pedantry>It's actually appending, not writing.</pedantry> – wizzwizz4 Jun 10 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.