How to Quickly Find Out All the Terminal Commands on Your Mac

Mac’s command line interface, Terminal, ships with a bewildering array of commands. Google searches and man pages will help you get a better sense of what your machine is capable of, but they won’t tell you the name of every command on your Mac. If you want to see all available commands at once, or if you’re trying to find a particular command, you can follow the instructions below to find out all the Terminal commands on your Mac.

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

macos-window-management-terminal-fix-1

2. Hold down the “Escape” key (or button on a MacBook Pro Touchbar) for a second or two.

3. When you see the prompt that says “Display all 1456 possibilities?” press the “Y” key. Note that the exact number of available commands will vary based on your installation, but it should be approximately 1400.

terminal-list-all-commands-1

4. Terminal will now list all of the available commands in alphabetical order. You can navigate down the list line by line by pressing the “Enter” key. There’s no way to navigate backwards, so read slowly.

terminal-list-all-commands-2

5. To return to the command prompt, press “Control + C” or the “Delete” key to exit the list of available commands. You can also continue pressing the “Enter” key until you’ve scrolled through all the commands, at which point you’ll be automatically returned to the command prompt.

terminal-list-all-commands-3

What if you don’t want to see a list of commands in the terminal window, but you want to produce a text file containing all of the available Terminal commands? You can use compgen to generate a list of all available commands and then send the result of the command to a new text file. You can also use grep to search compgen’s output quickly.

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

2. To list all available Terminal commands (and command aliases) instantaneously, type in compgen -ac and press “Enter.”

terminal-list-all-commands-compgen-1

3. If you’d rather create a text file containing a list of all those commands, type the following command and press Enter:

compgen -ac > commandlist.txt

terminal-list-all-commands-compgen-2

This will send the compgen command’s output to a new text file named “commandlist.txt.” That file will then appear in your current working directory (your home directory, by default).

More Compgen Options

1. Use compgen -b to display only built-in commands. These are the commands that are “built-in” to Bash, macOS’s default command line interpreter, like cd and kill.

terminal-list-all-commands-compgen-3

2. Search compgen’s output using grep, which is another terminal command search for text strings. For example, to find every command with “net” in the name, type the following command and press Enter:

compgen -ac | grep net

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

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

terminal-list-all-commands-compgen-5a

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

terminal-list-all-commands-compgen-6

To manually search through a list of all available Terminal commands, use the Escape key trick. This isn’t the best way to find a particular command, however. For a searchable and exportable directory of available commands, use compgen along with one of its several command options.

Leave a Reply

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.