20 Mac Terminal Commands You Should Actually Know

Most Mac users never open Terminal. Then they discover one command that saves them hours and they wonder how they survived without it. Terminal commands let you do things the graphical interface either makes slow or doesn't allow at all.

I've picked 20 Terminal commands that are genuinely useful for everyday Mac users. Not the deep system administration stuff, the practical commands that solve common problems faster than clicking through menus.

Code on dark terminal screen with green text

How to open Terminal

Press Cmd+Space to open Spotlight, type Terminal, hit Return. The Terminal app opens. You see a prompt with your username and computer name.

Type commands at the prompt and press Return to run them. Some commands need administrator permissions, prefix those with sudo and you'll be asked for your Mac password.

Find your IP address

To find your local IP, run:

ipconfig getifaddr en0

That gives you your WiFi IP. For Ethernet replace en0 with en1. Useful for printer setup, SSH, file sharing.

For your external (public) IP, run:

curl ifconfig.me

Make Mac stay awake

Run a long download or render and don't want the Mac to sleep. Run:

caffeinate

The Mac stays awake until you stop the command with Ctrl+C. To keep it awake for a specific time, like 1 hour:

caffeinate -t 3600

The number is seconds. 3600 equals 1 hour.

Show hidden files in Finder

macOS hides system files and dot files by default. To show them all the time:

defaults write com.apple.finder AppleShowAllFiles -bool true

Then restart Finder:

killall Finder

Hidden files now show in Finder. To toggle quickly without Terminal, use Cmd+Shift+Period in any Finder window.

Empty the Trash forcefully

Sometimes Trash refuses to empty because a file is in use. Force it:

sudo rm -rf ~/.Trash/*

Enter your password. Trash empties no matter what. Be careful with this command, it permanently deletes everything in Trash without any second chance.

MacBook with terminal window showing commands

Restart core macOS services

When something acts up, you can restart specific Mac services without rebooting the whole computer.

Restart the Dock:

killall Dock

Restart the menu bar (SystemUIServer):

killall SystemUIServer

Restart Finder:

killall Finder

Disable Dock auto hide animation

The Dock auto hide animation is slow by default. Speed it up:

defaults write com.apple.dock autohide-time-modifier -float 0.15

Then restart Dock:

killall Dock

The 0.15 is animation speed in seconds. Lower equals faster. Set to 0 for instant.

Check system uptime

How long has your Mac been on?

uptime

Returns days, hours, minutes since last boot, plus current load averages.

Battery health quick check

See your battery's cycle count and condition:

system_profiler SPPowerDataType | grep -E "Cycle Count|Condition|Maximum Capacity"

You see Cycle Count (how many charges your battery has been through), Condition (Normal or Service Recommended), and Maximum Capacity (percentage of original).

Make a screenshot folder

Screenshots clutter your Desktop. Move them to a dedicated folder:

defaults write com.apple.screencapture location ~/Pictures/Screenshots

Then make sure the folder exists:

mkdir -p ~/Pictures/Screenshots

Restart the screencapture process (or just log out and back in). Future screenshots save to Pictures/Screenshots instead of Desktop.

Speed up Mission Control

Mission Control animation can be sped up like the Dock:

defaults write com.apple.dock expose-animation-duration -float 0.15

Then:

killall Dock

Download files with curl

Sometimes Safari fails to download a file. Try curl instead:

curl -O https://example.com/file.zip

The file downloads to your current Terminal directory (usually Home). Useful for scripted downloads or when browsers misbehave.

Find big files

Looking for what's eating disk space? Find files larger than 1 GB in your Home folder:

find ~/ -size +1G

For files larger than 500 MB, use +500M. Way faster than clicking through folders one by one.

Reset Dock to defaults

Messed up your Dock? Reset to factory defaults:

defaults delete com.apple.dock; killall Dock

The Dock resets completely. You'll need to re-pin your apps but otherwise it's back to a clean state.

List your wifi password

Forgot your home wifi password but it's saved on your Mac:

security find-generic-password -ga "YourWiFiName" | grep password

Replace YourWiFiName with your actual network name. Enter your Mac password when prompted. The wifi password prints in Terminal.

Make Spotlight forget a file

Sometimes Spotlight indexes get corrupted. Rebuild from scratch:

sudo mdutil -E /

This forces Spotlight to delete its index and rebuild. Takes a few hours but fixes weird Spotlight issues that no other fix solves.

Got a Terminal command that's changed how you use your Mac? Drop it in comments. I'm always looking for new tricks.

Leave a Comment