How to Use Terminal on a Mac

Your complete Mac Terminal tutorial

The Terminal app on a Mac is the command line interface that allows you to use Unix commands to accomplish some tasks much faster than you could execute them using the graphical user interface (GUI). Using Terminal commands, you can open files, improve your Mac's performance, and much more. Here's how to use Terminal on a Mac, including some commands to get you started.

Start by Opening Terminal

Of course, your first step will be to open Terminal. There are several options to do that, but the easiest is to press Command + Spacebar to open Spotlight, then search for "Terminal." The Top Hit should be the Terminal app. Double-click to open it.

Screenshot of locating Mac Terminal using the Spotlight.

When the Terminal window opens, you can resize it by dragging one of the corners to expand. You can also change the look of the app by going to Terminal > Preferences or pressing the Command+, (comma) keyboard combination. In the Profiles dialog box that appears, you can change the appearance of the command windows to match your style or needs.

Screenshot of the Terminal Profiles dialog box.

Once your Terminal window has the appearance you prefer, then you can start using it to execute commands on the computer.

The Basics of Terminal Commands

You can do a lot of cool (and useful) things with the terminal. For example, if you really want to, you can use a Terminal command to make your Mac speak to you. But before you start, it's helpful to know how Terminal commands are written.

Each Terminal command has three parts.

  • The command: This is the actual letters that you'll type into the Terminal window to execute a command. Be very careful when using Terminal commands, because some commands can delete files or cause other damage to your system that might stop your computer from working.
  • An argument: This part of a command tells which resources the command should work on. For example, should a cp, or copy, command copy this window or another?
  • An option that modifies the output: This is a directive about where the results of a specific command should appear.

For example, if you want to move a file, you would use the command mv. The argument for that command would be the location of the file you want to move. And the output would be the location you want the file moved to. So to move a file from your desktop to your Documents file might look like this:

mv ~/Desktop/TerminalTestFile.rtf ~/Documents

That command says, "Move (the command) the file TerminalTestFile.rtf (the argument) from my Desktop to my Documents (the output)."

In Terminal the tilde character ~ is a shortcut for your Home folder. Both the desktop and the Documents folder exist in the Home folder.

Rules for Using Terminal Commands

Now that you understand the basics of how to write and use Terminal commands, there are a few rules that you need to understand.

  • When using terminal, you must always type the command and then press Enter or Return on your keyboard.
  • You cannot use the mouse to interact with the Terminal window beyond using the Close, Expand, and Hide buttons in the upper left corner of the window.
  • To interrupt a command that is running type Control+C.
  • To quit Terminal without using your mouse, type Command+Q.
  • Commands automatically execute in the last used location on your computer. If you want to specify a different location for a command to execute, you'll need to use the cd command and a directory path to specify the location you want to command to execute in.

An alternative way to change directories that's especially useful if you don't know the exact directory path, is to use the GUI to navigate to location you want to include and then drag and drop the directory into the Terminal window. It will not move the directory, instead, it will copy the path to the directory into the command you are writing.

One more note before moving on. If you've never used terminal before you may be confused when you execute a command and nothing happens in the Terminal window. Don't worry. In many cases, that's exactly what is meant to happen.

For example, when you type cd ~ you'll be returned to the Home directory. In your Terminal window, your cursor will advance to the next line with no indication that anything happened. Rest assured, you're now back in your Home directory.

Screenshot of Terminal with an executed command line and a new command line.

Using Terminal Commands on a Mac

With the basics out of the way, you can start using Terminal commands to move around faster and be more efficient as you're using your computer. Here are a few Terminal commands that you can try to get your feet wet, but there are dozens of Mac Terminal commands you can use to fit nearly all your needs.

Syntax matters! Be sure when using Mac Terminal commands that you write them exactly as they appear here or in other lists. Capitalization and even spaces and punctuation are specific and changing one element could completely alter the outcome of the command.

Most basic Terminal commands involve navigating files or directories on your computer. For example, you can use the command ls (that's a lower case L, lower case S) to view a list of all the files in the current directory. So, if you are in Documents and you type ls, you'll see a list of all the files in the Documents directory (or folder).

A screenshot of the ls command executed in Terminal.

You can modify (or change the output) of the ls command by adding operators. For example, ls -C sorts the files in the requested list by size.

Here are some additional basic commands you can try:

open <directory path> Opens the file you specified with the directory path.
rm Remove files
cp Copy
mkdir Make directory
ditto <original folder> <new folder> Duplicate a file between folders.
caffeinate Keeps your computer from going into sleep mode as long as Terminal is open
clear Clears the Terminal screen
pwd Returns the path to the working directory
.. Takes you to the Parent directory
man <command> Takes you to the manual page for that command so you can read about the command, what it does, and how to use it.
say <type what you want your computer to say> This command will result in your Mac speaking whatever you wrote after the say command.
history View your Terminal command history.
history -c Delete your Terminal command history.
Was this page helpful?