Lesson 02: macOS Setup

Hello and thank you for joining me as we cover basic setup for someone using a mac. This is Lesson 2 of my class Unix Basics Fast and I’m so glad you are joining me today.

In this lesson, I’ll cover basic ideas around keystrokes, modifier keys, using the macOS-provided program called Terminal to interact with the linux that is powering your mac operating system. In addition to a basic understanding of how to keystroke, I’ll cover how to set the cursor, what the control and meta keys mean for Unix, and how to enable the Meta key on your Terminal in macOS.

If you have a Windows operating system, please skip this lesson and go directly to Lesson 3.

The agenda for today is:

  1. Keyboard concepts
  2. Meet the Terminal window
  3. Your Cursor
  4. Keystroke Modifier Keys
  5. How to Enable the Meta Key in Terminal’s Settings

Keyboard Concepts

To start with Linux, you’ll need a Terminal. A terminal is a window that you will type commands in. We’ll get to Terminals in just a minute, but first let’s talk about your keyboard.

The characters or keys you type are called keystrokes. If you type characters normally, the Terminal window typically will accept what you type as letters to be inserted. These keystrokes are called non-modified, because you aren’t using a modifier key to make the keystroke.

—- typing into a terminal —

What is a modifier key? Most of us are already familiar with the shift key. The shift key will produce the uppercase letter instead of the lowercase letter.

As well, you can use the shift key to type the special characters that appears above the normal character on your keyboard. For example, all of the numbers on your standard keyboard have cooresponding special characters: Shift-2 produces an @ symbol, Shift-3 produces a # symbol.

For programmers these symbols have special names. Let’s go over the special names of the special characters associated with the numbers on your keyboard.

Remember, the names of these special characters are specific to hackers and the programmer community. The names are typically not used by non-programmers.

What you pressHow it looksCommonly calledWhat programmers call this character
Shift 1!exclamation markbang
Shift 2@At symbolwhirlpool
Shift 3#Pound or hatch* symbolmesh, hash
Shift 4$money signmoney, dollar, big money
Shift 5%division symbolpercent, mod
Shift 6^Footnote symbolcarrot
Shift 7&ampersandampersand
Shift 8*astericksstar, splat
Shift 9(Open parenLeft paren
Shift 0)Close parenRight paren

Here are a few others you should note. Take note that programmers call { and } the “brackets” and [ and ] the “braces”. If you cannot remember the difference between “brackets” and “braces” (which is easy to confuse in your head), the “square” and “curly”. We will often “enclosed in curly brackets” or “square braces” to talk about wrapping a part of code or configuration.

Shift-comma<Less thanLess than
Shift-period>Greater thanGreater than
[ key (not modified)[open braceOpen brace, open square brace (or “square bracket”)
] key (not modified) ]close braceclose bracket, close square brace (or “square bracket”)
Shift-[{open bracketopen bracket or curly bracket
Shift-]}close bracketclose bracket or curly bracket
//slashforward slash
\\reverse slashbackslash
Shift-backslash|Vertical bar, pipepipe

When you are talking with other programmers, if you use the programmer names for these characters you will set yourself apart as someone who knows the correct terms.

It will demonstrate to other developers that you are not a n00b (which is programmer speak for newbie) because you have studied the correct names and know how to refer to the special characters using their programmer names.

Some Windows users or users who come from or go to Windows operating systems, where the backslash (\) is used to refer to the filesystem, often will conflate the words “slash” and “backslash,” sometimes referring to a slash as a “backslash” or a backslash as a “slash.” Note the one that goes from the upper left to the lower right is the backslash, and the one that goes from the lower left to the upper right is the forward slash or just slash.

Terminals

A terminal is a window that you will type commands in. These commands let you interact with the Linux operating system directly, and give you a powerful set of tools to control your operating system. Note that a terminal interface is unlike what you typically use to navigate folders and files a Mac, which is called GUI file system (GUI stands for “graphical user interface”) or a “desktop environment.”

If you are using a Mac, you have a few options for Terminal programs to use.

You can use the program called Terminal that ships with the operating system.

You will find this program in the Applications folder, inside a folder called Utilities.

You also have some paid options. Some popular ones are iTermTerminator, or ZOC which are available in the macOS app store.

In this class, we will set up and show how to use the Terminal program provided by Apple. You’ll find this program under /Applications/Utilities.

Notice how I referred to the location of this utility: A slash character (/), the folder named Applications then another slash (/), then the folder Utilities. This is the standard way you refer to folders and files in Linux: The slashes separate folders from each other or, for the final slash, it separates the folder containing the file from the file name. Slahes denote the file hierarchy — a directed tree structure where each folder can contain any number of other folders or files.

It is called a “directed” tree because it has one direction: from the root of the hard drive down (or up, depending on your perspective) into the folders and files on the system.

The terminal opens and begins with a prompt.

Open the Terminal for the first time, and you will see this:

— TERMINAL WINDOW OPENS FOR FIRST TIME —-

The first thing to do is find out where we are, which is the first terminal command we will learn (and is covered again in the next lesson).

Type the letters pwd and hit return. pwd is our very first Unix command!

It stands for print working directory, and it does just that. “Print” means it displays to the screen. What it will display is that directory we are currently working inside of.

The terminal responds with something like:

— EXAMPLE “PWD” ——–

This tells you “where you are” in your hard drive. This is the specific folder your Terminal prompt will use as the directory for any further Unix commands.

Specifically, this is referred to as the working directory.

The working directory is the point where you are currently browsing, right there in this terminal session. It’s kind of like in a GUI the folder you have open.

The working directory is unique to this terminal session. If you start a new terminal session (for example, in another tab or another window), that terminal session will have its own working directory.

Your Cursor

Let’s talk about your cursor. The cursor is the actual little marker on the screen that tells you the place where your next keystroke will be.

For a cursor, you have choices of a block, underline, or vertical cursor, and you can choose whether or not to have it blink.

In the Terminal program, you have several “Profiles” which you get to through the settings screen. Here you can set the background, text color, font size, and the cursor. You often will have several tabs open and you may choose to customize them by having different colors for them. When you open a new tab, you’ll choose the “Profile” you want to use, which will determine the colors, font size, and cursor settings for the newly created tab.

Remember, your settings here are specific to each of the listed profiles, so to make a change to all of them you have to click through each one and change each one by one.

You’ll see the cursor settings at the bottom of this screen.

Block

The block cursor is the easiest to see and is the recommended default.

Underline

The underline cursor is elegant but can be difficult to spot on the screen. Try it out to see if you like it.

Vertical

The vertical cursor is also very elegant but can also be hard to spot on the screen. Play around with different options and ensure you can see your cursor on the terminal window easily, no matter where it is. This is a necessary step before moving forward with this course.

Blinking Cursor

The blinking cursor is the best way to see your cursor, but some programmers find it distracting.

Take some time now to try out different ones and pick one that you like.

Keystroke Modifier Keys (C- and M-)

In Unix, we have a concept of keyboard modifiers. These are keys you see on the lower left (and sometimes lower right) of your keyboard. In the mac, you’ll see (from left to right):

• fn (for “function”)

• control key (marked with ^)

• option key (marked with a ⌥ symbol). On Mac hardware, the option key is always marked “Option.” If you are using a non-Mac keyboard connected to your Mac, it might be marked Alt on your keyboard

• The command key (marked with ⌘ which is called a “looped square”). On Linux this is known as the super key. On Macs, this has always been known as the command key, but note that on non-Mac hardware, it maps to the “Windows” key on a Windows system. (On Windows it does not use the ⌘ symbol, instead using the Windows logo.)

Unix keystrokes come in either or a combination of C- (for control key) and M- for meta. When you read Unix documentation, you’ll see markers like these to indicate keystrokes you should type on your keyboard to activate that function.

When a Unix documentation tells says a keystroke begins with C- it is telling you that the modifier key for that keystroke is the control key (marked “control”) on your keyboard. When Unix documentation tells you that a keystroke begins with M-, it is telling you that the modifier key for that keystreak is the meta key. These two are commonly found throughout Unix documents.

But which one is the Meta key? The meta ket must be explicitly set in your terminal of choice, and often you can choose which of your system’s natural keys becomes the Meta key. In the case of the program we are using for this exercise, macOS Terminal, the only option to enable the Meta key is to enable the “Option” as the meta key on your keyboard. Thus, when you see a M- in Linux docs, you will know that is the option key on your keyboard.

If you miss this step, you won’t be able to use Meta keystrokes.

How to enable the option key as the Meta Key for macOS Terminal

Go to Settings > Profiles.

Here, you will see several Profiles — as discussed earlier, these let you define the default font size, background color, text color and cursor settings for each profile.

Select a Profile and switch to the “Keyboard” tab.

There is a setting for “Use Option as Meta key” that you must enable. Unfortunately, you must enable it for every profile you’ll use— Apple has provided 10 default profiles here for your use.

I typically go through each profile here and enabled “Use Option as Meta key” for each one.

Once you are comfortable with keystroking, you can skip Lesson 3 (intended for Windows users) and proceed to Lesson 4. In Lesson 4, we’ll put these modifier keys to use by learning how to move our cursor around the terminal window.