Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

List All Terminal Commands Mac? Full Guide

· 6 min read · Home Tech

In this article
  1. What “Terminal Commands” Actually Means on macOS
  2. How to List Every Command on Your Mac
  3. How to Learn What Each Command Does
  4. Common Problems and Misconceptions
  5. How to Choose the Right Command for a Task
  6. Safety and Precautions
  7. Alternatives to Listing Commands
  8. Frequently Asked Questions

There is no single built-in command that lists every possible Terminal command on a Mac, because the total set includes thousands of built-in Unix utilities plus any commands added by installed software. However, you can list most of the commands available on your system using compgen -c (if you use bash) or by searching the directories in your PATH with ls and find. This article explains the practical ways to enumerate commands, how to learn what each one does, and how to manage them safely.

What “Terminal Commands” Actually Means on macOS

Terminal on a Mac is an interface to a Unix-like shell, and the commands you type are mostly standard Unix tools (like ls, cd, cp) plus macOS-specific utilities (like open, pbcopy, sips). The shell itself (default is zsh since Catalina, previously bash) also has built-in commands that are not separate files. So “all terminal commands” really means three overlapping sets:

  • Shell built-ins – commands built into the shell itself, e.g. cd, echo, export.
  • Executable files in your PATH – programs installed in directories like /bin, /usr/bin, /usr/local/bin, and others.
  • Aliases and functions – custom shortcuts defined in your shell configuration files.

No single command covers all three, but you can get a comprehensive list with a few commands.

How to List Every Command on Your Mac

Here are the most effective methods, from quickest to most thorough.

1. Use compgen -c (in bash)

If you switch your shell to bash (or run bash inside zsh), compgen -c lists every command that the shell can find, including built-ins and executables in your PATH. Example:

bash -c 'compgen -c'

This outputs a long list, one command per line. You can pipe it to sort and less to browse it:

bash -c 'compgen -c' | sort | less

2. Use whence -m '*' (in zsh)

In the default zsh shell, whence -m '*' lists all commands that zsh knows about, including built-ins, functions, and aliases:

whence -m '*'

This is the zsh equivalent of compgen -c.

3. List Executables in Your PATH

Every command that is not a built-in is a file in one of the directories listed in your PATH environment variable. To see those directories:

echo $PATH

Then list the contents of each directory. For example, to list all executables in the standard system directories:

ls /bin /usr/bin /usr/local/bin /opt/homebrew/bin 2>/dev/null

For a cleaner list that only shows files you can actually execute, use find with the -perm flag:

find /bin /usr/bin /usr/local/bin -type f -perm -111 2>/dev/null

This finds regular files that have execute permission. Note that some commands are symlinks, so you might want to add -type l as well.

4. Use apropos to Search by Description

apropos searches the man page database for keywords. For example, to list all commands related to “file”, you can run:

apropos file

This is not a complete list, but it helps you discover commands you didn’t know existed.

How to Learn What Each Command Does

Once you have a list, you can get details for any command using:

  • man command – opens the manual page (e.g. man ls).
  • command --help – many commands show a brief help message.
  • type command – tells you whether it’s a built-in, an alias, or an external program, and where it lives.
  • which command – shows the full path to an external command.

For example, to find out what sips does, you would run man sips.

Common Problems and Misconceptions

One common misconception is that there is a file containing all commands. There isn’t. Another is that ls /usr/bin shows everything – it misses shell built-ins and commands in other PATH directories. Also, commands installed via Homebrew go to /opt/homebrew/bin (on Apple Silicon) or /usr/local/bin (on Intel), so they won’t appear if you only look at system folders.

Another issue: compgen -c only works in bash, not in zsh. If you try it in the default Terminal, you’ll get an error. Use whence -m '*' instead, or run bash first.

Finally, the list can be huge – hundreds or even thousands of entries – so don’t try to read it all at once. Use grep to filter, for example:

compgen -c | grep -i network

How to Choose the Right Command for a Task

When you need a command to do something, the best approach is to search the web or use apropos. For example, if you want to resize an image, you might search apropos image and find sips. If you want to edit text, you’ll find nano, vim, and sed. The manual pages are your best friend – they explain options and examples.

For common tasks, here are a few go-to commands:

  • File management: ls, cd, cp, mv, rm, mkdir
  • Text processing: cat, grep, sed, awk
  • System info: top, ps, df, du, system_profiler
  • Network: ping, curl, ssh, netstat

Safety and Precautions

Some commands can modify or delete files, change system settings, or affect security. Always read the manual before running a command you don’t recognize. Be especially careful with rm, sudo, and any command that writes to system directories. Never run a command that you found online without understanding what it does – it could be malicious.

Also, be aware that sudo gives you administrative privileges; using it incorrectly can damage your system. Always double-check the syntax.

Alternatives to Listing Commands

If your goal is to discover commands, you can also:

  • Use the man page index: man -k . (same as apropos .) lists all man pages.
  • Install a tool like tldr (via Homebrew) for simplified man pages.
  • Browse online resources like the ss64 macOS commands reference.

These are not built-in, but they are helpful for learning.

Frequently Asked Questions

How do I list all commands in Terminal on a Mac?

Use bash -c 'compgen -c' if you have bash, or whence -m '*' in zsh. For external programs, list the directories in your PATH with ls or find.

Why doesn’t compgen -c work in my Terminal?

Because the default shell is zsh, not bash. compgen is a bash built-in. You can either run bash first or use the zsh equivalent whence -m '*'.

Is there a command to see all commands with descriptions?

No single command gives descriptions for all commands. You can use apropos keyword to search man pages, or open the man page for each command individually with man.

How many commands are there on a typical Mac?

There is no fixed number. A typical macOS system has several hundred built-in commands, but the total can be in the thousands if you count every executable in all PATH directories, including those from third-party software.

Can I add my own commands?

Yes. You can create a shell script, make it executable with chmod +x, and place it in a directory in your PATH (like /usr/local/bin). You can also define aliases and functions in your .zshrc file.