How To Use The Mac Terminal: The Basics

One of the most powerful (and underused) apps in macOS is the Mac terminal. It’s an app that gives you a high level of control over your computer and can help you better understand how your machine works.

However, most users don’t have a clear idea of what the terminal even is, let alone how to use it.

In this post, I’m going to change that. By the end of this guide, you should have a solid idea of how the Mac terminal works, what it’s used for, and what it does and doesn’t do. I’ll also give you some basic commands that will help you put the terminal to use as well as impress your friends.

Let’s get into it!

What is the Mac terminal?

The Mac terminal is the built-in shell environment on Mac that allows you to directly issue UNIX commands. That’s the technical definition, anyway.

In simpler terms, you can think of it as an app that gives you access to a deeper level of your Mac’s operating system. Kind of like lifting the hood of your car and poking around the engine, but for your Mac’s software.

The Mac terminal is not a way to “hack” your computer, and it generally isn’t going to break your computer. When I was first learning how the terminal worked, I remember worrying that I was going to enter the wrong command and completely brick my Mac.

But Apple doesn’t give you this kind of power easily. You can technically ruin your Mac by entering certain commands into the terminal (make sure you copy trusted commands from the internet on sites like StackExchange) but it’s unlikely that you’ll run into these commands during daily use.

In short: The Mac terminal is an app that gives you greater control over your Mac, but has a learning curve and the occasional risk. That said, it’s far from dangerous to experiment with.

How does the Mac terminal work?

The Mac terminal works via commands. Unlike a traditional app (or GUI app), where you navigate by clicking buttons with the mouse, the terminal is a LUI app. This means you interact with the terminal by typing in keywords and phrases (i.e., commands) that tell the terminal what to do.

Many of these commands supplement things you can do with a mouse and keyboard, but once you get past those, you’ll run into thousands of features that aren’t possible without the terminal.

That’s why lots of people tend to associate using the terminal with being a programmer. Programmers need the extra level of depth that the terminal offers to do their work, while the average user rarely does. But anyone can (and I’ll argue should) learn the basics of the Mac terminal.

Why should you use the Mac terminal?

I believe everyone who wants to better understand their Mac/PC should learn the basics of the terminal. Your terminal is a low-level method for interfacing with your computer.

In the computer world, high-level interfaces abstract what’s really happening on your Mac. We all know that at a basic level, our Mac is just a bunch of ones and zeroes. However, high-level interfaces allow us to interact with those ones and zeroes through buttons and colorful apps.

A low-level interface brings you closer to the foundational level of your Mac. When you use the terminal, you’re interacting with your Mac in a way that is more true to how your Mac operates – via text-based commands.

Even if you never use the terminal, using the Mac terminal will deepen your understanding of your machine significantly. And it can also help you better understand your other devices, how things like servers work, and how digital politics (like automation and privacy) are played out on your computer.

When should you use the Mac terminal?

Another important question you’re probably asking yourself is when you should use the terminal. If you’re a developer or studying to be a developer, the answer is all the time. You should be learning about your terminal and becoming comfortable with it right now. So good job on seeking out this article!

For everyone else, you’ll find that the Mac terminal doesn’t have as much practical use for you. Many of the features I’ll cover below and in other posts are things you could just as easily do with a mouse and keyboard. So you probably don’t need to use the terminal very often.

That said, it’s not like you’ll never need to use the terminal. And knowing these fundamentals can be a big help when you do need to interact with it. Plus, if you find that you enjoy it, you can start getting into Homebrew apps and other power-user hobbies.

Learn the basics of the Mac terminal

Ok, that’s enough preface. Let’s start using the terminal. Below, I’ll primarily be covering the basics of the terminal, not the basic commands. There are some commands near the end, but I’m primarily trying to help you understand the terminal. For basic terminal commands, scroll to the bottom of this post and/or read this other AppleToolBox article.

Launching the Mac terminal

First things first, launching the Mac terminal. This is the easiest step, and there are several ways to do this.

My favorite way to launch the terminal is by typing “terminal” into Spotlight and pressing the return key. You can activate Spotlight by pressing cmd + spacebar.

Alternatively, you can open the Finder app, click on the Applications folder, then the Utilities folder, then scroll down and double-click the Terminal app.

Once opened, your terminal should look something like this:

You’ll see a blinking cursor at the start of the line of text. That’s called the command line, and it’s where you enter your commands.

Before that, you should see your username, followed by the name of your Mac, followed by a % sign. If you’re in a particular folder (called a “directory” when you’re in the terminal), you’ll see that displayed next to your name. For instance, this is what it looks like when you’re in your Desktop.

The % sign is just there to show you where your line command starts. If you press return, you’ll see another line with a % sign, indicating that the previous line has been abandoned.

You cannot go back and edit lines you’ve already executed, though you can press the Up Arrow on your keyboard to copy what you typed in the previous line down to your current line.

You may have already noticed, but you can’t interact with the terminal with your mouse. You can only use the arrow keys and keyboard. That means you can’t highlight text or copy/paste text in the terminal.

Changing the Mac terminal’s appearance

Another thing you may have noticed is that the terminal is kind of ugly. It looks really simple and bland because it doesn’t need to look any different, and the simple graphics help it load and run super fast and with minimal hardware.

But even still, you probably want to change the appearance of the Mac terminal. Luckily, this is pretty easy to do.

In the Menu Bar of your Mac, click Terminal and then click Preferences….

In the popup that appears, click the Profiles tab.

On the left side of this new screen, you’ll see different themes for you to choose from. Double-click each one to create a new terminal window with that theme. Once you find one you like, click Default in the lower-lefthand corner to make that theme your new default.

You can also change things like font, window behavior, and more, but I’ve found that this generally does more harm than good. Many of the fonts don’t work with the terminal very well, and the other features are complicated.

Just pick a theme you’re happy with or create your own by clicking the + at the bottom of the themes and move on to the next step.

Every character matters

One of the most important things to understand about the Mac terminal is that every character counts. Every letter, space, quote, hyphen, and slash will affect how the terminal interprets your commands.

Now, this doesn’t mean that entering a faulty command (like typing in the letter a) is going to break your Mac. 9/10, you’re just going to get an error. Always make sure that you’re entering your commands in properly, and if a command isn’t accepted, check its spelling first.

This is also the reason why I use this formatting:

your command here

…and not quotation marks when spelling out terminal commands. That’s because when I (or most people online) type a command like this, they want you to exactly copy that text into your terminal. Leaving out quotation marks makes this simpler.

Commands are always executed in your current location

This is one of the key rules to remember when you’re working in the Mac terminal. Whichever folder you’re in when using the terminal, that’s where the command you execute is going to take place. If you enter a command to create a new text file while you’re in the Desktop, the text file will show up in your desktop.

If this doesn’t make sense to you, it’s probably because you don’t have a sense of place when using the terminal yet. But in the same way you enter different folders when using the Finder app, you enter different folders and locations in the terminal.

As mentioned before, you can tell which folder you’re in by checking the text next to your name.

Learning how to navigate your computer with the Mac terminal will help you get a better grasp on this idea. I’ll cover navigation briefly below and in more depth in a future tutorial.

For now, just make sure you’re always in your intended folder when executing a command. Otherwise, you might end up deleting things that you didn’t mean to, copying the wrong file to the wrong place, or losing track of certain files.

Know how to navigate your computer using the Mac terminal

Ok, so now on to navigation. This is where we’ll start getting into basic commands.

Several commands allow you to navigate from folder to folder on your Mac. I plan on covering all of these in detail in a future post. But we’re going to stick to three.

The first command is ls. Go ahead and paste that into your terminal and press return. You should see the names of all of the folders inside of the folder you’re currently in appear.

That’s because ls is short for “list”. It lists all of the folders inside of the folder you’re currently in.

To navigate into one of these folders, you’re going to use the cd command. cd stands for “change directory”. A “directory” is just what you call a folder when you’re in the terminal; there’s no difference between the two.

To move into one of the folders you just listed using ls, type cd [folder name] replacing “[folder name]” with the name of the folder you want to move into. For instance, if I wanted to move into the Desktop, I would enter this into my terminal:

cd Desktop

Now, let’s say I’m done with hanging out in the Desktop and want to go back. To do this, use cd ... This command moves you back to the previous directory you were in, like a back button.

None of these commands can damage your Mac in any way, so don’t be afraid to experiment with them until you get the hang of it. Generally, I find myself entering ls to figure out where I am, then using cd and cd .. to move between folders.

The fundamental Mac terminal commands: history, clear, *, and sudo,

Once you get the hang of moving around the Mac terminal, you’re ready to start learning the fundamental commands. In my opinion, that means understanding how history, clear, *, and sudo work.

history is a straightforward command. It shows you a brief history of the commands you’ve recently entered into the terminal. This is helpful when you need to remember what you’ve done so far.

Next is clear. This is arguably a pointless command, though I use it a lot. When you enter clear into the Mac terminal, it clears the window back to a basic terminal screen. Go ahead and try it.

I find this useful for decluttering the window and making it easier to focus on what I’m currently trying to do.

After that is *. This isn’t so much a command as it is an important symbol to be familiar with. It’s known as the “wildcard” symbol and is used to reference anything within certain criteria.

For instance, the terminal will interpret a command that uses *.jpg to refer to every JPG file in your current folder. This is helpful for searching, running commands on multiple files at once, and so on.

Lastly, the sudo command is one that you’re going to run into a lot, and it’s probably the most important command in this article. sudo is used to run commands as a superuser, or as an admin. It means that you’re overriding some basic protection of your Mac and making an alteration to your computer.

sudo isn’t a bad thing, of course. You’ll need to use it every time you install an app through your terminal. It is serious, though, and you shouldn’t enter a sudo command into the terminal without knowing that what you’re doing is completely safe. Verify sudo commands by googling them before using them.

Make your Mac talk

I wanted to close things out on a fun note since most of this post has been pretty technical and expository. This last one is a fun trick you can show to your friends or just use to make yourself laugh at home.

All you have to do is type say hello into the Mac terminal, and you should be greeted by a response from your Mac. Make sure the volume is on!

If you want to get your Mac to say more complicated things (such as sentences with question marks, commas, apostrophes, etc.) then you’ll want to put your phrase in quotation marks. For example, if I wanted my Mac to say, “Hello there! How are you?” I would paste this into my Mac terminal:

say "Hello there! How are you?"

Ready to learn more?

Congratulations! You’ve just learned the basics of using the Mac terminal. For the average user, this is probably everything you’ll ever need to know. If you plan on becoming a developer, however, then your journey is only just beginning.

There are tons of other things you can do with the Mac terminal. I’ll be contributing more tutorials for the terminal later this week, so be sure to be on the lookout for them!

Until then!

Leave a Reply

Discover more from Ultimatepocket

Subscribe now to keep reading and get access to the full archive.

Continue reading