Commandline complete list of commands

Is there a way/command to get a listing of all the commands available on my system from the commandline prompt?


Solution 1:

Usually pressing tab once or twice will display a message such as:

Display all 435 possibilities? (y or n)

Pressing Y will display all commands you can run that are on your default path.

Solution 2:

If you want to display all commands available in your $PATH, you may use this command:

ls $(echo $PATH | tr ":" " ")

If you want to display all executable files available on your filesystem, you may use this command (beware, it might take some time):

find / -type f \( -perm -u=x -o -perm -g=x -o -perm -o=x \) 2>/dev/null

The files listed by this command are not necessarily commands, they are just set as executable.

(you might need to run it as root if you want to search, remove the 2> /dev/null part to know where the find command did not search as a normal user)

You may also want to list your aliases, to do so , you can use this command:

alias

Solution 3:

In bash, you can use compgen -c to get all command completions generated to stdout (so you can use grep, etc. instead of just paging through the list). You can also add a prefix:

$ compgen -c ls
ls
lsbom
lsbom
lsdiff
lsof
lsvfs
lsvfs

$ compgen -c | grep zcat
bzcat
bzcat
bzcat
gzcat
gzcat
lzcat
zcat
zcat

$ compgen -c | sort -u | grep zcat
bzcat
gzcat
lzcat
zcat