List All Commands in Bash

List All Commands in Bash

Sometimes, we wish to see all commands in Bash. There are many tricks to do that, but they are rather complicated. However, we can do that in a simple way. We can use compgen that is a command for generating possible completion matches for word. But we can use it to list all commands in Bash. Let’s do that:

linux-7tpy:/home/poganin # compgen -abc -A function

But there are a lot of commands, so better use this way:

linux-7tpy:/home/poganin # compgen -abc -A function | less

Thousands commands to use in Bash. 8319 in my operating system. Let’s look at the options:

-a – aliases

-b – builtins

-c – commands

-A function – shell functions

So you don have to list all of them. For example, you can see all aliases by running:

linux-7tpy:/home/poganin # compgen -a
+

..

beep
cd..
dir
egrep
fgrep
grep
l
la
ll
ls
ls-l
md
o
rd
rehash
unmount
you
It’s a very useful command, isn’t it?

If we wish to find one in these all commands, just run:

linux-7tpy:/home/poganin # compgen -abc -A function | grep wc
wc
b43-fwcutter
showchar
wcgrep
showconsolefont
hwclock
showconsole
pwconv
hwclock
iwconfig
pwck
showconsolefont
wc
b43-fwcutter
showchar
wcgrep
showconsolefont
We have got all commands that can be associated with our wc.

We can also sort our commands:

linux-7tpy:/home/poganin # compgen -abc -A function | sort | less

Now our commands are sorted in a fine way.

Leave a comment