Getting started with the Mac Terminal

The Mac operating system is a Unix-based on graphical user interface. You can therefore interact with your Mac computer using many (most) of the same commands used in Unix/Linux systems. Many of these commands achieve the same things that you can achieve using 'point and click' methods. For instance, if you wanted to create a new folder on your Mac desktop you could click on your desktop, select File > New Folder. But you can also create a new folder using Unix commands in Mac's Terminal.app (which can be found in Applications/Utilities/Terminal). This will open a “command line” interface (meaning that you interact with the computer by typing out commands rather than pointing and clicking with your mouse/trackpad). By typing the following commands (press enter/return after each line) you will change the directory of your command-line interface to your desktop and create a new folder entitled “mynewfolder”

cd ~/Desktop
mkdir mynewfolder

EVERY Apple computer running OS X is built on the Unix platform and comes with the Terminal app pre-installed. If you have a Mac, you have Terminal! So you can get familiar with the Terminal on your own machine.

At this point you are undoubtedly thinking “It was way easier to just use the trackpad, so why would I ever want to use the command-line!?” However, the command-line gives you direct control over many aspects of your computer that would be hard (or impossible) to access via the graphical interface. More importantly for our purposes, we can write our commands into a text file and then tell the computer to read the commands from that file (this file is called a “bash script” because the particular Unix language that we'll be using is called “bash”.) This is great because it means that every time we do whatever task we've “scripted”, we can be certain that we're doing it exactly the same way we did it last time. Moreover, if we need to run the task 100 times (e.g. we want to create 100 new folders), we can just tell the computer to read the bash script 100 times. Imagine creating those same 100 new folders by pointing and clicking!

The majority of what we do in this course will rely on controlling your computer using the command-line. You should therefore dedicate a sufficient amount of time to getting comfortable with basic Terminal/Unix commands and behaviors. There are tons of useful OS X Terminal and Unix tutorials online. I've selected a few below that you can use to get started.

OS X Terminal Tutorials

Getting to know the command line

Introduction to the Mac OS X command line

25 Terminal Tips Every Mac User Should Know

Unix Tutorials

UNIX Introduction

UNIX Tutorial

UNIX Help

Linux.org tutorial

Linux tutorial - includes glossary and forums

Top 10 bash shell tips