Skip to main content

Terminal Commands Every Mac Owner Should Know — and Three to Avoid

Media Terminal Commands Every Mac Owner Should Know — and Three to Avoid

Terminal is one of the most powerful applications included with macOS. It allows you to communicate with your Mac through typed commands rather than menus, buttons and Finder windows.

For everyday users, Terminal can quickly reveal storage usage, locate files, test a network connection, open hidden locations and gather useful diagnostic information. For IT professionals, it can also support automation and advanced troubleshooting.

However, Terminal does exactly what it is instructed to do. A mistyped path, destructive option or command copied from an unreliable website can delete information, weaken security or leave the Mac unable to work correctly.

The objective is not to memorise hundreds of commands. It is to learn a small collection of safe, practical tools—and to recognise commands that deserve extreme caution.

What Is Terminal on a Mac?

Terminal is Apple’s command-line interface application. Commands are interpreted by a shell, which allows users to interact with the UNIX-based components of macOS and combine commands into scripts.

The default shell in current macOS versions is zsh, although administrators can configure another shell where required. Apple describes Terminal as primarily intended for advanced users and developers, but many basic commands are suitable for ordinary Mac owners when used carefully. 

You can open Terminal from:

Applications > Utilities > Terminal

Alternatively, open Spotlight, type Terminal and press Return.

Before Entering Any Command

Terminal commands are sensitive to spelling, spaces, punctuation and capital letters.

Paths identify where files and folders are located. The following shortcuts are particularly useful:

  • ~ represents your user home folder.
  • . represents the current folder.
  • .. represents the parent folder.
  • / at the beginning of a path refers to the top level of the startup disk.

Paths containing spaces should normally be enclosed in quotation marks or have the spaces escaped. Apple also allows users to drag a file or folder from Finder into Terminal, which automatically inserts its complete path and can reduce typing mistakes. 

Before pressing Return, check:

  • Is the command spelled correctly?
  • Is the path definitely the intended location?
  • Does the command contain sudo?
  • Will it change information or only display it?
  • Is a wildcard such as * present?
  • Have you backed up anything important?

1.

pwd

— Confirm Where You Are

pwd means print working directory.

Enter:

pwd

Terminal will display the complete path of the folder in which the current shell is operating.

For example:

/Users/carl/Documents

This is one of the safest and most useful commands to run before moving, copying or creating files. It confirms your current location and reduces the risk of performing an action in the wrong folder.

2.

ls

— List Files and Folders

The ls command displays the contents of a directory. Apple uses it as its introductory example for working in Terminal. 

Basic use:

ls

A more informative version is:

ls -lah

The options mean:

  • -l displays a detailed list.
  • -a includes normally hidden items.
  • -h presents sizes in easier-to-read units.

To inspect a specific folder without entering it:

ls -lah ~/Downloads

This can be useful when checking whether files exist, examining permissions or identifying hidden configuration items.

Do not delete something simply because its name begins with a full stop. Hidden files frequently contain application and macOS settings.

3.

cd

— Move Between Folders

cd means change directory.

To move into your Documents folder:

cd ~/Documents

To move into the parent folder:

cd ..

To return directly to your home folder:

cd ~

To enter a folder containing spaces:

cd "~/Documents/Customer Projects"

After changing folders, use pwd to confirm your location and ls to inspect its contents.

A useful sequence is:

cd ~/Downloads

pwd

ls -lah

This navigates to Downloads, confirms the path and displays the folder’s contents.

4.

open

— Open Files, Folders and Applications

The open command connects Terminal with the familiar macOS graphical interface.

To open the current folder in Finder:

open .

To open the Downloads folder:

open ~/Downloads

To open a document using its default application:

open "~/Documents/Business Plan.pdf"

To launch an application:

open -a "Activity Monitor"

Apple documents open -a as a method for launching a named Mac application from the command line. 

This command is particularly useful when Terminal has helped you locate a file but you want to continue working with it through Finder or another normal application.

5.

mkdir

— Create New Folders

mkdir means make directory.

To create a new folder:

mkdir ~/Documents/Invoices

To create several levels of folders at once, use -p:

mkdir -p ~/Documents/Projects/2026/Customer-A

Without -p, the command may fail when one of the parent folders does not already exist.

Always review the path first. Accidentally creating a folder is normally easy to correct, but creating it inside an application or system directory can cause confusion.

6.

cp

— Copy Files and Folders

The cp command creates a copy of a file.

Example:

cp -i ~/Desktop/Report.pdf ~/Documents/Report.pdf

The -i option asks before overwriting an existing item with the same name.

To copy a complete folder and its contents:

cp -R ~/Documents/Invoices /Volumes/BackupDrive/Invoices

Apple documents cp -R for recursively copying a folder and everything inside it. It also notes that Finder is usually easier for routine copying, which is sensible advice for less experienced users. 

For important business information, copying a folder to another location should not automatically be considered a complete backup. A proper backup should be scheduled, monitored and tested.

7.

mv

— Move or Rename an Item

The mv command moves a file or folder from one location to another. It can also rename an item.

To move a file:

mv -i ~/Downloads/Proposal.pdf ~/Documents/Proposal.pdf

To rename it within the same folder:

mv -i ~/Documents/Proposal.pdf ~/Documents/Customer-Proposal.pdf

Apple confirms that mv removes the item from its original location and places it in the new one. 

Use the interactive -i option where practical, because it asks before overwriting an existing destination.

For routine business file management, Finder may still be safer because it provides clearer visual confirmation.

8.

df -h

— Check Available Disk Space

To review storage capacity and free space across mounted drives, enter:

df -h

The -h option presents values in readable units such as gigabytes.

To focus on the startup disk:

df -h /

This command can help determine whether low free storage may be contributing to:

  • Slow performance.
  • Failed macOS updates.
  • Application errors.
  • Backup failures.
  • Excessive virtual-memory use.

The result may show several system and virtual volumes, so it can look more complicated than the Storage page in System Settings. Most ordinary users should use:

System Settings > General > Storage

for everyday storage management, while df -h is useful for a quick technical check.

9.

du

— Find Folders Consuming Storage

du estimates how much disk space files and folders are using.

To review the items inside Downloads:

du -sh ~/Downloads/*

The options mean:

  • -s produces one summary per item.
  • -h uses readable sizes.

You might discover that an old installer, video export or virtual machine is using a significant amount of storage.

Do not remove an item solely because it is large. Application databases, Outlook profiles, creative libraries and virtual machines can be business-critical.

Use the result to investigate, then remove information through Finder or the application’s approved process.

10.

find

— Locate Files Using Detailed Criteria

The find command searches folders using conditions such as name, type and size.

To find PDF files inside Documents:

find ~/Documents -type f -name "*.pdf"

To make the name search case-insensitive:

find ~/Documents -type f -iname "*proposal*.pdf"

To locate files larger than 500 MB in Downloads:

find ~/Downloads -type f -size +500M -print

Search a limited, relevant folder instead of the entire startup disk whenever possible. A system-wide search can take a long time and may display many permission warnings.

find only lists results in these examples. It becomes considerably more dangerous when combined with actions such as deletion or execution.

11.

mdfind

— Search Using Spotlight

mdfind uses the Mac’s Spotlight metadata index.

To search for a file containing a particular word in its name:

mdfind -name "quarterly report"

To search for PDFs containing a phrase in indexed metadata or content:

mdfind 'kind:pdf "Hamilton Group"'

This is often faster than find because Spotlight has already indexed much of the Mac’s content.

However, results depend on Spotlight having indexed the location correctly. Files on excluded disks, unsupported network locations or unindexed folders may not appear.

12.

system_profiler

— Gather Mac Information

system_profiler displays detailed information about the Mac’s hardware, software and connected devices.

For a useful hardware summary:

system_profiler SPHardwareDataType

For macOS information:

system_profiler SPSoftwareDataType

For storage information:

system_profiler SPStorageDataType

This can help when you need to provide IT support with:

  • The Mac model.
  • Chip or processor details.
  • Installed memory.
  • Serial information.
  • macOS version.
  • Storage configuration.

The complete system_profiler report can be extremely long, so specifying a data type makes the output easier to use.

Avoid publishing the entire result online without reviewing it, because system reports may contain identifying device and network information.

13.

networkQuality

— Test Internet Performance

Current macOS versions include the networkQuality command:

networkQuality

It measures download and upload capacity as well as responsiveness.

This can help identify whether a poor Microsoft Teams call or slow cloud synchronisation may be associated with the internet connection.

A result from one test is not definitive. Network performance varies according to:

  • Wi-Fi signal.
  • Other users.
  • Router capacity.
  • Internet-provider congestion.
  • VPN use.
  • Security filtering.
  • The destination service.

Run several tests and compare the Mac with another device on the same network.

14.

ping

— Check Whether a Destination Responds

ping sends small network requests to a destination and reports whether replies are received.

To send five requests:

ping -c 5 1.1.1.1

To test a website name:

ping -c 5 apple.com

The -c 5 option stops the command after five attempts.

If an IP address responds but a website name does not, a DNS issue may be involved. If neither responds, the Mac may lack a working internet route.

Some networks and online services deliberately ignore ping requests, so a failed ping does not always prove that the destination is unavailable.

15.

softwareupdate --list

— Check for Apple Updates

To ask macOS which updates are available:

softwareupdate --list

This is useful for reviewing updates without immediately installing them.

Apple provides the softwareupdate command-line tool for update-related workflows, although for normal users it recommends using System Settings > General > Software Update. Software Update selects updates and upgrades compatible with the Mac model, and businesses may control availability through device-management policies. 

Do not force software installations on a company-managed Mac. The IT team may be testing compatibility or applying a planned deployment schedule.

16.

caffeinate

— Keep the Mac Awake Temporarily

The caffeinate command can prevent the Mac from sleeping while an important task is running.

To keep it awake for one hour:

caffeinate -t 3600

The time is entered in seconds.

This can be useful during:

  • A large download.
  • A file transfer.
  • An application installation.
  • A diagnostic test.
  • A long-running Terminal task.

It does not replace appropriate power or device-management policies. Avoid leaving a Mac awake indefinitely, especially when it is inside a bag or poorly ventilated.

17.

man

— Learn What a Command Does

The most important Terminal command may be:

man

Use it followed by the command you want to investigate:

man cp

man find

man softwareupdate

The manual page describes the command, its options and expected behaviour.

Press:

  • Space to move forward.
  • B to move back.
  • Q to exit.

Apple specifically recommends using man to read the built-in UNIX documentation before using unfamiliar commands. 

Useful Terminal Habits

Press Control-C to Stop a Running Command

When a command is taking too long or producing unexpected output, press:

Control-C

Apple states that this sends a termination signal that stops most commands. 

Use the Up Arrow to Recall Commands

Press the Up Arrow to display previously entered commands. Continue pressing it to move through the history.

Before pressing Return, review the recalled command carefully. It may contain a path or option that is no longer appropriate. 

Use Pipes Carefully

The vertical bar passes the output of one command into another:

system_profiler SPApplicationsDataType | grep -i "Microsoft"

Apple documents pipes as a way to combine commands and filter output. 

Understand Output Redirection

A single greater-than symbol writes output into a file:

system_profiler SPHardwareDataType > ~/Desktop/mac-hardware.txt

Two symbols append instead of replacing:

date >> ~/Desktop/support-log.txt

Be particularly careful with >. If the destination file already exists, its previous contents can be replaced. Apple distinguishes > for redirection and >> for appending. 

Three Terminal Commands to Avoid

These commands may have legitimate uses for experienced administrators, but ordinary Mac owners should not run them simply because an online guide recommends them.

1. Avoid

sudo rm -rf

The dangerous combination is:

sudo rm -rf [path]

Its components are:

  • sudo runs the command with elevated administrator privileges.
  • rm removes items.
  • -r processes folders recursively.
  • -f forces the removal without normal confirmation.

A mistaken path, misplaced space or wildcard can delete far more than intended. Adding sudo may give the command permission to remove information the normal user could not access.

We have intentionally not recommended rm as an everyday Mac command. Use Finder and the Bin for routine deletion because they provide a clearer and more recoverable process.

Apple warns that administrator and root-level commands have enough power to make the Mac stop working. 

2. Avoid

chmod -R 777

A command resembling:

chmod -R 777 [path]

changes permissions recursively and can give every user broad read, write and execution rights.

It is sometimes suggested online as a quick fix for “permission denied” errors. In reality, it may:

  • Expose confidential files.
  • Allow unauthorised modification.
  • Weaken application security.
  • Break expected macOS permissions.
  • Hide the original cause of the problem.

Permissions should be corrected precisely, not opened as widely as possible.

On a business Mac, ask the IT provider to investigate why access has failed. The underlying cause could be ownership, cloud permissions, external-disk formatting, privacy controls or device-management policy.

3. Avoid Commands That Disable macOS Security Protections

Be extremely cautious with instructions involving:

  • csrutil disable
  • Blanket removal of quarantine attributes.
  • Commands intended to bypass Gatekeeper.
  • Disabling security or endpoint extensions.
  • Changing protected system policies.

These commands are often suggested when an application will not open. The safer response is to establish why macOS blocked it and confirm that the software came from a trustworthy developer.

Apple changed Gatekeeper management in macOS 15 so that spctl can no longer be used to disable Gatekeeper. This also means that many old online tutorials are now outdated as well as unsafe. 

Do not weaken protection across the entire Mac just to install one questionable application.

Never Paste a Command You Do Not Understand

A long command copied from a website can combine several operations using:

  • Pipes.
  • Semicolons.
  • Redirection.
  • Download tools.
  • Scripts.
  • Administrator privileges.

It may download and execute software without showing you every step.

Before running a copied command:

  1. Break it into individual parts.
  2. Look up every command with man.
  3. Identify every file path.
  4. Check whether sudo is used.
  5. Check for rm, chmod, chown or security-related tools.
  6. Confirm who published the instructions.
  7. Create a current backup.
  8. Ask your IT provider when business data is involved.

Terminal should make a process more transparent—not persuade you to execute something you cannot explain.

Terminal on a Business Mac

Company Macs may be managed through Microsoft Intune, Apple device management or another platform.

Employees should avoid using Terminal to:

  • Remove management profiles.
  • Disable endpoint security.
  • Change company network settings.
  • Override application restrictions.
  • Alter FileVault configuration.
  • Install unapproved software.
  • Create hidden administrator accounts.
  • Circumvent update policies.

These actions may expose business data, breach company policy and make the device more difficult to support.

Terminal can be an effective diagnostic tool, but administrative changes should be documented and completed through the organisation’s approved process.

A Practical Starter Checklist

Safe commands to begin learning include:

pwd

ls -lah

cd ~/Documents

open .

df -h /

du -sh ~/Downloads/*

system_profiler SPHardwareDataType

networkQuality

softwareupdate --list

man ls

Before progressing further:

  • Learn how paths work.
  • Use quotation marks around names containing spaces.
  • Confirm your current folder with pwd.
  • Avoid sudo unless it is genuinely required.
  • Use -i with cp and mv when appropriate.
  • Back up important information.
  • Read the manual page.
  • Prefer Finder for routine file deletion.

How Hamilton Group Can Help

Terminal can be extremely useful for diagnosing and managing a Mac, but the wrong command can create a much larger problem than the one it was intended to solve.

Hamilton Group can help businesses manage Macs securely and use command-line tools as part of a controlled support and administration process.

Our Mac services can include:

  • macOS troubleshooting.
  • Terminal and command-line diagnostics.
  • Microsoft Intune management for Macs.
  • Apple device deployment.
  • Application and script management.
  • Endpoint security.
  • FileVault configuration.
  • Software-update management.
  • Backup and recovery.
  • Network troubleshooting.
  • Employee permissions and access reviews.
  • Ongoing business IT support.

Hamilton Group aims to make first contact on IT support requests within 15 minutes, helping employees receive an early response before an attempted Terminal fix causes further disruption.

To discuss Mac support for your business, contact Hamilton Group on 0330 043 0069 or visit hgmssp.com.