In this article, we cover how to list all Linux commands with compgen Bash Builtin. Most of us would press TAB to check if a command is available or not. For instance, to check whether steam command is there or not. We may enter ste and press TAB. It would show us all the command-line tools available. But, if its not there then there would be no response.
There is another way to get this done. And, that is through compgen Bash Builtin command.
List all Linux commands with compgen Bash Builtin
To list all Linux commands that we could use, we can use the following –
If you want to know how many of those commands are there. Then, it can be done through wc command-line utility –
compgen -c | wc -l
For us, the number of available commands were 5427. The number of available commands would depend on our system configuration.
Just listing all Linux commands won’t be enough. To check if a specific Linux command is available or not –
compgen -c | grep mkdir
Or, for all those commands which contain the word – dir
compgen -c | grep dir
Apart from Linux commands, we can also get sub-directory names as well –
compgen -d /var/
To get a list of all shell builtin commands –
For all shell variables –
To get a list of all users –
In conclusion, we have covered compgen Bash Builtin command which can be used to list all Linux commands. For more info –