How to quickly find all the commands on a terminal on your Mac

The Mac command line interface Terminal contains a confusing set of commands. Google searches and manual pages will help you get a better idea of ​​what your machine can do, but they won’t tell you the name of every Mac command. If you want to see all the available commands at once, or if you’re trying to find a specific command, you can search for all the terminal commands on your Mac by following the instructions below.

Displays all available terminal commands

1. Open a terminal (Applications / Utilities / Terminal.app).

2. Hold down the Esc key (or the MacBook Pro touchbar button) for one second.

3. When you see the prompt “Show all 1456 opportunities?” »Press the« Y »key. Note that the exact number of commands available varies depending on the installation, but should be around 1400.

terminal-list-all-commands-1

4. The terminal now lists all available commands in alphabetical order. To move through the list line by line, press Enter. There is no way to go back, so read slowly.

terminal-list-all-commands-2

5. To return to the command prompt, press “Ctrl + C” or “Delete” to exit the list of available commands. You can also continue to press Enter until you have scrolled through all the commands, which will automatically return you to the command prompt.

list-terminal-all-commands-3

Create a list of commands with Compgen

What if you don’t want to see a list of commands in the terminal window, but want to create a text file that contains all the available terminal commands? You can use compgen Create a list of all available commands, and then send the result of the command to a new text file. You can also use grep quickly find the combination result.

See also  Top 5 Apple Mail Options for Mac

1. Open a terminal (Applications / Utilities / Terminal.app).

2. To immediately list all available terminal commands (and command aliases), enter compgen -ac and press “Enter”.

list-terminal-all-commands-compgen-1

3. To create a text file that lists all of these commands, type the following command and press Enter:

list-terminal-all-commands-compgen-2

This sends compgen printing the command to a new text file called “commandlist.txt”. This file will then appear in your current working directory (home directory by default).

More options for Compgen

1. Use compgen -b shows only built-in commands. These are commands that are “built-in” to Bash, MacOS’s default command line interpreter, such as cd and kill.

list-terminal-all-commands-compgen-3

2. Find the result of the compgen using grep, which is another terminal command for finding text strings. For example, to find each command named “net”, type the following command and press Enter:

compgen-4a-list-terminal-all-commands

This will display a short list of all commands with “net” in the header.

compgen-5a-all-command-terminal-list

3. Use compgen -k list all available “keywords”. These keywords are commands that you can use when typing command-line scripts to get bash to run.

compgen-6-list-terminal-all-commands

Conclusion

To manually search for a list of all available terminal commands, use the Esc key trick. However, this is not the best way to find a particular order. To find and export a directory of available commands, use compgen one of many ordering options.

About the author

admin

Leave a Comment