How to Use Terminal for Basic Mac Maintenance

How to Use Terminal for Basic Mac Maintenance
How to Use Terminal for Basic Mac Maintenance

Most Mac users rarely open Terminal, and that’s perfectly fine. macOS includes a polished graphical interface that handles almost everything you need. Still, there are times when Terminal is the quickest and most reliable way to maintain your Mac, especially when you need to clear caches, check storage, repair file permissions, monitor system performance, or troubleshoot issues that Finder and System Settings cannot easily show.

The good news is that you don’t need to become a command-line expert. A small set of safe, built-in Terminal commands can help you keep your Mac running smoothly without installing third-party cleaning software.

This guide explains what each command does, when you should use it, and the precautions you should take before pressing Return.

What Is Terminal on Mac?

How to Use Terminal for Basic Mac Maintenance
How to Use Terminal for Basic Mac Maintenance

Terminal is Apple’s command-line application for macOS. Instead of clicking buttons and menus, you type commands that communicate directly with the operating system.

You can find it by opening Applications > Utilities > Terminal, or by pressing Command + Space, typing Terminal, and pressing Return.

Every command you enter performs a specific task. Some simply display information, while others modify files or system settings. Because Terminal has direct access to macOS, it’s important to understand each command before running it.

For basic maintenance, you’ll mostly use read-only commands or commands that safely clear temporary files.

Before You Start

Before making any system changes, keep a few best practices in mind.

  • Back up important files with Time Machine or another backup solution.
  • Read every command carefully before running it.
  • Avoid copying commands from random websites without understanding what they do.
  • Never use commands that begin with sudo unless you know why administrator access is required.
  • If a command requests your administrator password, Terminal will not display the characters as you type. This is normal.

These precautions help prevent accidental changes that could affect your Mac.

Check Available Storage Space

Low storage is one of the most common reasons a Mac feels slow. Before deleting files, check how much free space remains.

Run:

df -h

The -h option displays sizes in a human-readable format such as GB or MB.

Look for the disk mounted as /. If the available space is very low, macOS may struggle with updates, virtual memory, and temporary files.

For a broader view of your storage devices, use:

diskutil list

This command lists every connected drive and partition.

Find Large Folders Taking Up Space

Sometimes the Storage settings don’t make it obvious where your disk space has gone.

To identify large folders inside your home directory, run:

du -sh ~/*

This displays the size of each top-level folder such as Downloads, Documents, Movies, and Pictures.

If Downloads is consuming dozens of gigabytes, you immediately know where to start cleaning.

To inspect a specific folder, use:

du -sh ~/Downloads/*

This approach is much faster than opening every folder manually.

Empty the Trash from Terminal

If Finder cannot empty the Trash because a file is locked or appears to be in use, Terminal may succeed.

First, move to the Trash folder:

cd ~/.Trash

View its contents:

ls

Remove everything:

rm -rf ~/.Trash/*

Be extremely careful with the rm -rf command. It permanently deletes files without moving them back to the Trash.

Double-check the command before pressing Return. A typo can delete the wrong files.

Clear User Cache Files

Applications create cache files to improve performance. Over time, these files may become outdated or consume unnecessary disk space.

To see your cache folder:

open ~/Library/Caches

This opens the folder in Finder, allowing you to inspect it before deleting anything.

If you’re troubleshooting an application, you can remove the contents of its cache folder while the app is closed.

Avoid deleting system cache folders unless you’re following specific troubleshooting instructions.

Flush the DNS Cache

If websites load the wrong version, fail to resolve correctly, or you’ve recently changed DNS settings, flushing the DNS cache can help.

Run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

You’ll be prompted for your administrator password.

This command clears cached DNS information so macOS requests fresh records from your DNS server.

It won’t speed up your internet connection, but it can resolve certain networking issues.

Verify Your Startup Disk

If you suspect drive problems, macOS includes built-in tools to verify the file system.

Run:

diskutil verifyVolume /

If the volume is healthy, you’ll receive a confirmation message.

If problems are detected, macOS may recommend running First Aid from Disk Utility or booting into Recovery Mode for repairs.

Verification is safe because it only checks the disk without making changes.

Repair Disk Permissions

Older versions of macOS allowed manual permission repairs.

Modern versions of macOS protect system files differently, so manual permission repair is generally unnecessary.

If you need to reset permissions in your home folder, you can use Recovery Mode instead of Terminal during normal startup.

If you find guides recommending repairPermissions, they’re referring to older versions of macOS and those commands no longer work on current releases.

Check Running Processes

If your Mac suddenly becomes noisy, hot, or slow, an application may be consuming excessive CPU or memory.

Run:

top

Terminal continuously updates system activity.

Press Q to quit.

You’ll see:

  • CPU usage
  • Memory usage
  • Running processes
  • Process IDs
  • Load averages

If one application consistently uses an unusually high percentage of CPU, you may want to close or update it.

Find Processes Using the Most Memory

You can sort processes by memory usage with:

ps aux | sort -nrk 4 | head

This displays the processes consuming the most RAM.

It’s useful when Activity Monitor isn’t already open or when you’re connected remotely to another Mac.

Force Quit an Unresponsive Application

Sometimes an app refuses to close.

First, identify its process:

ps aux | grep AppName

Replace AppName with part of the application’s name.

Then terminate it:

kill PID

Replace PID with the process ID.

If the process ignores the request:

kill -9 PID

Use kill -9 only as a last resort because it immediately terminates the application without giving it a chance to save data.

Check System Uptime

To see how long your Mac has been running without restarting:

uptime

This command also displays the current system load.

If your Mac has been running continuously for weeks and starts behaving strangely, a restart can sometimes resolve temporary software issues.

Monitor Disk Usage in Real Time

If you’re trying to identify heavy disk activity, use:

iostat

To update continuously:

iostat 2

The number represents the refresh interval in seconds.

This helps determine whether storage activity is causing slow performance.

Check Battery Health from Terminal

On MacBooks, you can display battery information with:

system_profiler SPPowerDataType

The output includes information such as:

  • Battery cycle count
  • Condition
  • Maximum capacity
  • Charging status

Battery health naturally declines over time. A high cycle count combined with reduced capacity may explain shorter battery life.

See macOS Version Information

When troubleshooting, it’s often helpful to confirm the exact macOS version.

Run:

sw_vers

You’ll see:

  • Product name
  • Version number
  • Build number

This information is useful because some Terminal commands behave differently across macOS releases.

Check System Integrity Protection Status

System Integrity Protection (SIP) prevents unauthorized changes to critical parts of macOS.

To check whether it’s enabled:

csrutil status

Most users should leave SIP enabled.

If a guide instructs you to disable it, make sure you understand the reason and the security implications before doing so.

Update Software from Terminal

You don’t have to use System Settings to install updates.

Check for available updates:

softwareupdate -l

Install all available updates:

sudo softwareupdate -ia

Some major macOS upgrades still require additional user interaction, but regular system updates can often be installed entirely from Terminal.

Keeping macOS updated helps fix bugs, improve security, and maintain compatibility with newer applications.

Useful Commands You Can Run Safely

The following commands are commonly used for basic maintenance and information gathering.

Command Purpose
pwd Show the current folder
ls List files and folders
cd Change directories
whoami Show the current user
date Display the current date and time
hostname Show the Mac’s network name
history Display recently used Terminal commands
clear Clear the Terminal window

These commands don’t modify your system and are good starting points if you’re new to Terminal.

Common Mistakes to Avoid

Many Terminal problems come from simple typing errors rather than the commands themselves.

Some of the most common mistakes include:

  • Copying commands without understanding them.
  • Running commands that require administrator access unnecessarily.
  • Using rm -rf on the wrong directory.
  • Forgetting spaces within commands.
  • Assuming commands written for Linux always work on macOS.
  • Following outdated guides written for older macOS versions.

Reading each command before executing it greatly reduces the chance of making an unwanted change.

When Terminal Isn’t the Best Tool

Terminal is powerful, but it isn’t always the easiest solution.

For some maintenance tasks, macOS provides better graphical tools.

Use Disk Utility for disk repairs, Activity Monitor for viewing system resource usage, Storage Management for deleting large files, and System Settings for software updates and security preferences.

Choosing the right tool often makes troubleshooting simpler, especially if you’re unfamiliar with command-line environments.

Troubleshooting Terminal Commands That Don’t Work

If a command produces an error, the message usually provides a clue about the problem.

Here are a few common issues:

  • Command not found usually means the command was typed incorrectly or isn’t available in your version of macOS.
  • Permission denied indicates that your user account doesn’t have the required privileges. In some cases, you’ll need to run the command with sudo.
  • No such file or directory means the path is incorrect or the file no longer exists.
  • Operation not permitted may occur because System Integrity Protection prevents changes to protected parts of macOS.

When troubleshooting, copy the error exactly instead of guessing what went wrong. Even small differences in the message can point to different causes.

Final Thoughts

Learning how to use Terminal for basic Mac maintenance doesn’t require memorizing dozens of commands. A handful of safe, built-in tools can help you monitor storage, inspect system performance, clear temporary data, verify your startup disk, manage software updates, and troubleshoot common problems more efficiently than using the graphical interface alone.

The key is understanding what each command does before you run it. Start with read-only commands that display information, then move on to maintenance tasks such as clearing caches or updating software when you’re comfortable.

Used carefully, Terminal is one of the most useful troubleshooting tools built into macOS, and it can save time whenever your Mac needs a little attention.

Related Articles


If you think there’s been a mistake here, please do let us know by commenting on this post or Contact Us. And a member of our Content Integrity Team will review this decision with you.

You Might Also Like:

Muili Muhammed

Muili Muhammed Kolawole is the founder and editor of DeepHacks.ng, where he publishes practical technology tutorials, troubleshooting guides, and software recommendations. His mission is to help readers understand technology through clear, accurate, and easy-to-follow content covering Windows, Android, iPhone, MacBook, software, and everyday tech solutions.

Leave a Reply

Your email address will not be published. Required fields are marked *