compgen is a bash built-in command which is used to list all the commands that could be executed in the Linux system. This command could also be used to count the total number of commands present in the terminal or even to look for a command with the specific keyword. This command is even used to print the bash details like bash builtin functions and stuff.
Working with compgen command in Linux
1. To list all commands available to be directly executed.
compgen -c

This will list all the commands available to you for direct use.
2. To search for commands having a specific keyword
compgen -c | grep gnome

This will search the commands having the keyword gnome in them.
3. To count total number of commands available for use
compgen -c | wc -l

This command will count the total number of commands that could be used.
4. To list all the bash alias
compgen -a

This command will list all the bash alias present in your system.
5. To list all the bash built-ins
compgen -b

This command will list all the bash built-ins present in your system.
6. To list all the bash keywords
compgen -k

This command will list all the bash keywords present in your system.
7. To list all the bash functions.
compgen -A function

This command will list all the bash functions present in your system.
Recommended Posts:
- mv command in Linux with examples
- df command in Linux with Examples
- until command in Linux with Examples
- pwd command in Linux with Examples
- let command in Linux with Examples
- ip command in Linux with examples
- du command in Linux with examples
- ps command in Linux with Examples
- apt command in linux with examples
- seq command in Linux with Examples
- arp command in Linux with examples
- apt-get command in Linux with Examples
- pv command in Linux with Examples
- cal command in Linux with Examples
- cmp Command in Linux with examples
- cut command in Linux with examples
- atq command in linux with examples
- cp command in Linux with examples
- yes command in Linux with Examples
- ed command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

