10 Terminal Commands Every macOS User Should Know

macOS is known for its sleek interface and user-friendly design, but beneath its elegant surface lies a powerful UNIX-based command-line interface known as the Terminal. For many everyday users, the Terminal may seem intimidating, often associated with developers or advanced users. However, learning a few essential Terminal commands can significantly boost productivity, offer greater control over the operating system, and unlock powerful system functionalities that the graphical user interface (GUI) doesn’t always provide.

Whether you’re a casual user looking to optimize your workflow or a power user diving into macOS’s internals, these 10 Terminal commands are invaluable tools. This guide will walk you through each command in detail, explaining what it does, how to use it, and why it’s important. By the end, you’ll see the Terminal not as a scary black box, but as a key to unleashing the full power of your Mac.


1. ls – List Directory Contents

One of the most frequently used commands in the Terminal is ls, short for “list.” It allows you to view the contents of a directory, just like opening a folder in Finder.

Usage:

ls

This command lists files and folders in the current directory. However, ls becomes much more powerful with options. For instance:

ls -la
  • -l displays a long listing format with permissions, file size, and timestamps.
  • -a shows hidden files (those starting with a dot).

Why is this useful? Finder hides many files by default, especially system files. If you need to troubleshoot, view config files, or clean up hidden junk, ls -la is your go-to command.


2. cd – Change Directory

To navigate through your file system, use the cd (change directory) command. This is fundamental to moving around within Terminal.

Usage:

cd Documents

This moves you into the Documents directory. To go up one level:

cd ..

To return to your home directory:

cd ~

Terminal doesn’t have a graphical folder tree, so cd is your navigator. Understanding how to move around efficiently with cd sets the stage for all other command-line tasks.


3. sudo – Superuser Do

sudo is perhaps one of the most powerful commands, allowing you to execute commands as a superuser (administrator). It grants elevated privileges, letting you make system-level changes.

Usage:

sudo nano /etc/hosts

In this example, you’re editing the hosts file, which requires admin privileges. You’ll be prompted to enter your password.

Caution: With great power comes great responsibility. Incorrect use of sudo can damage your system. Only use it when necessary and when you understand the command you’re running.


4. defaults – Modify macOS Preferences

The defaults command allows you to read, write, and delete macOS user preferences directly from the command line. This command is a gateway to hidden settings that are otherwise unavailable through System Settings.

Example Usage:

defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder

This command reveals hidden files in Finder. To hide them again:

defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder

The killall Finder part restarts Finder to apply the changes. There are countless tweaks you can perform using defaults, including customizing screenshot formats, disabling animations, and more.


5. top – Monitor System Performance

Think of top as the Terminal version of Activity Monitor. It provides a live view of what’s happening in your system—CPU usage, memory usage, active processes, and more.

Usage:

top

You’ll see a real-time list of processes, much like Task Manager in Windows. This is particularly useful if your Mac is acting sluggish and you want to identify the process consuming the most resources.

Press q to quit the view.


6. ps and kill – Manage Processes

The ps command (process status) lists currently running processes, and kill allows you to terminate them.

Usage:

ps aux

This lists all running processes with user, PID (process ID), CPU usage, and more. Once you find the PID of the process you want to terminate:

kill 1234

Replace 1234 with the actual PID. For forceful termination:

kill -9 1234

These tools are essential for stopping unresponsive apps or background processes that aren’t visible in the GUI.


7. open – Open Files and Apps from Terminal

Want to launch apps or open files without clicking through Finder? Use the open command.

Usage:

open .

This opens the current directory in Finder. To open a specific file:

open myfile.pdf

To open an application:

open -a "Safari"

This is incredibly convenient when working with scripts, logs, or files in deeply nested folders.


8. curl – Transfer Data from URLs

curl is a powerful tool to transfer data from or to a server, using various protocols. It’s especially useful for downloading files or making API calls.

Usage:

curl -O https://example.com/file.zip
  • -O saves the file with its original name.

Want to get just the headers of a webpage?

curl -I https://apple.com

Developers use curl for testing REST APIs, but even casual users can benefit by using it to quickly fetch resources.


9. diskutil – Manage Disks and Drives

The diskutil command provides detailed control over your storage devices. Whether you want to format a drive, erase a partition, or mount/unmount disks, this is your tool.

View All Drives:

diskutil list

Erase and Format a Drive (Caution!):

diskutil eraseDisk HFS+ MyDrive /dev/disk2

This command erases and formats the drive /dev/disk2 as HFS+ and names it “MyDrive.”

Unmount a Disk:

diskutil unmountDisk /dev/disk2

Be cautious when using this command—choosing the wrong disk can result in data loss.


10. man – Manual Pages

If you ever forget how a command works or what its options are, man (short for manual) is your best friend.

Usage:

man ls

This displays the manual for the ls command. You can scroll using the arrow keys and press q to quit.

While online guides are useful, man pages are the most accurate and comprehensive reference available for command-line tools.


Bonus Tips and Shortcuts

Now that you’ve got the 10 must-know commands under your belt, here are a few extra tips to enhance your Terminal experience:

Use Tab Completion

Start typing a file or command and press Tab to auto-complete. If there are multiple possibilities, press Tab twice to see suggestions.

Use history to Recall Past Commands

history

You can recall previous commands using the up/down arrows or by typing ! followed by the command number:

!103

This reruns command number 103.

Create Aliases for Frequent Commands

Tired of typing long commands?

alias ll='ls -la'

Add aliases to your ~/.zshrc file to make them permanent.


Wrapping Up

The Terminal may initially seem daunting, but with a few key commands, it becomes an incredibly powerful tool. Commands like ls, cd, and sudo form the foundation of navigation and system control. Others, like defaults, top, diskutil, and curl, unlock capabilities that the macOS GUI hides or complicates. Mastering these commands enhances your efficiency, helps in troubleshooting, and gives you a deeper understanding of how macOS works under the hood.

While you don’t need to memorize every option or flag, becoming comfortable with these core commands will transform the way you use your Mac. Just like any other skill, the more you use the Terminal, the more confident and efficient you’ll become.

So the next time you find yourself needing to tweak a setting, open a hidden file, or monitor your system, remember that the Terminal is just a few keystrokes away from helping you get the job done—faster, smarter, and more effectively.