Learn how to unleash your inner Unix geek!

Take Control of
the Mac Command Line with Terminal

Third Edition
Joe Kissell

Release your inner geek and harness the power of the Unix underpinnings of macOS! This book from Joe Kissell explains everything you need to know to become comfortable working on the command line in Terminal, and provides numerous “recipes” for performing useful tasks.

All Take Control books are delivered in two ebook formats—PDF and EPUB—and can be read on nearly any device.

Clear

If you’ve ever thought you should learn to use the Unix command line that underlies macOS, or felt at sea when typing commands into Terminal, Joe Kissell is here to help! With this 226-page book, you’ll become comfortable working on the Mac’s command line, starting with the fundamentals and adding more advanced topics as your knowledge increases.

Joe includes 66 real-life “recipes” for tasks that are best done from the command line, as well as directions for working with permissions, carrying out grep-based searches, creating shell scripts, and installing Unix software.

I found answers to many questions in your book, and I enjoyed reading it. I am definitely more confident now in facing the Mac command line. Thank you for the time and art that you spent to create such a clarifying text.
—Mona Hosseini, grad student in Genomic Medicine and Statistics at the University of Oxford

The book begins by teaching you these core concepts:

  • The differences among Unix, a command line, a shell, and Terminal
  • Exactly how commands, arguments, and flags work
  • The basics of Terminal’s interface and how to customize it

Next, it’s on to the command line, where you’ll learn:

  • How to navigate your Mac’s directory structure
  • Basic file management: creating, copying, moving, renaming, opening, viewing, and deleting files
  • Creating symbolic links
  • The types of command-line programs
  • How to start and stop a command-line program
  • How to edit a text file in nano
  • How to customize your prompt and other shell defaults
  • The importance of your PATH and how to change it, if you need to
  • How to get help (Joe goes way beyond telling you to read the man pages)

You’ll extend your skills as you discover how to:

  • Create basic shell scripts to automate repetitive tasks.
  • Make shell scripts that have variables, user input, conditional statements, loops, and math.
  • See which programs are running and what system resources they’re consuming.
  • Quit programs that refuse to quit normally.
  • Enable the command line to interact with the Finder.
  • Control another Mac via its command line with ssh.
  • Understand and change an item’s permissions, owner, and group.
  • Run commands as the root user using sudo.
  • Handle output with pipe (|) or redirect (> or <).
  • Use grep to search for text patterns in files and filter output.
  • Install new command-line software from scratch or with a package manager.
  • Use handy shortcuts in the Terminal app itself and in zsh.

Questions answered include:

  • What changed on the command line in macOS 12 Monterey and macOS 11 Big Sur? (Not much, unless you have an M-series Mac!)
  • What changed on the command line in macOS 10.15 Catalina? (A lot!)
  • What are the differences between the zsh shell and the bash shell?
  • Which shell am I using, and how can I change my default shell?
  • How do I quickly figure out the path to an item on my Mac?
  • How can I customize my Terminal window so I can see man pages behind it?
  • How can I make a shortcut to avoid retyping the same long command?
  • Is there a trick for entering a long path quickly?
  • What should I say when someone asks if I know how to use vi?
  • How do I change my prompt to suit my mood or needs?
  • What is Command Line Tools for Xcode?
  • When it comes to package managers, which one should I use?

Very good! A pleasure to read, the right balance of coverage and clarity.
—Brian G.

Finally, to help you put it all together, the book showcases 66 real-world “recipes” that combine commands to perform useful tasks, such as listing users who’ve logged in recently, manipulating graphics, using a separate FileVault password, creating and editing user accounts, figuring out why a disk won’t eject, copying the source code of a webpage, determining which apps have open connections to the internet, flushing the DNS cache, finding out why a Mac won’t sleep, sending an SMS message, and deleting stubborn items from the Trash.

Joe Kissell

About Joe Kissell

Take Control publisher Joe Kissell has written more than 60 books about technology, including many popular Take Control books. He formerly wrote for publications such as Macworld, Wirecutter, and TidBITS. He lives in Saskatoon with his wife and their two sons.

What’s New in Version 3.2.1

This small update makes the book current with macOS 13 Ventura:

  • Added a brief “What Changed in Ventura?” topic
  • Added tip about using 1Password 8 in “Set Up a Password-less SSH Login”
  • Updated “Read man Pages in Preview” with a new technique that still works in Ventura
  • Updated mentions of Preferences windows to reflect Ventura’s use of the term Settings

What Was New in Version 3.2

Version 3.2 updated the book to cover macOS 12 Monterey and added a few other small but useful changes:

  • Added the topic “What Changed in Monterey?” to cover the removal of PHP and Python from macOS and changes to proxy icon support
  • Updated “Clear the Screen” with more accurate information
  • Mentioned a new flag available starting in Monterey for the rm command; see the sidebar “Warning! The rm Command Has No Safety Net”
  • Mentioned that you can run shortcuts from the Shortcuts app on the command line; see “Run a Script”
  • Added the topic “Open a URL” to describe a new option for the open command starting in Monterey
  • Added a link to an article about grep, sed, and awk; see “Get a Grip on grep”
  • Adjusted the text in “Homebrew” to account for the new default installation location on M-series Macs
  • Updated the recipe “Remove the Proxy Icon Hover Delay in Big Sur” to reflect the fact that it’s no longer needed in Monterey
  • Added a recipe to “Use Old-Style Alerts in Big Sur and Later”
  • Added a recipe to “Turn Off Auto Boot”

What Was New in Versions 3.1.1 and 3.1.2

Version 3.1.1 corrected a small error involving differences between how bash and zsh determine whether strings are equivalent; see “Flow Control.” Version 3.1.2 corrected a couple of small typos.

What Was New in Version 3.1

Besides a handful of small corrections and terminology updates, version 3.1 brought the book up to date with Big Sur and included the following notable changes:

  • Added a “What Changed in Big Sur?” topic (spoiler: nothing of any serious consequence when it comes to the command line)
  • Added a sidebar “About Recovery Mode,” which details differences using this mode between Intel-based and M-series Macs
  • Sprinkled in a few tips and clarifications about working with the split system volume in Catalina and later
  • Noted how zsh may behave slightly differently with the exit command; see “End a Shell Session”
  • Included PHP and Tcl in the list of scripting languages discussed in “Scripting Languages Are Deprecated” and “Run a Script”
  • Added a tip about using Touch ID in place of a password with the sudo command; see Using sudo
  • Updated the description of Nix to mention new installation workarounds for Catalina and later
  • Added a recipe for making proxy icons easier to use in Big Sur and later: see “Remove the Proxy Icon Hover Delay”
  • Included basic information about using Swift in command-line scripts; see “Run a Script”
  • Adjusted the recipe “Enable or Disable Your Mac’s Startup Chime” to account for the fact that Apple re-enabled the startup chime in Big Sur

What Was New in Version 3.0.1

This small update makes a few minor changes:

  • Clarified in the sidebar “Which Programs Can I Run?” that the double-Esc trick works only with bash, not with zsh
  • Added a new Terminal tip: “Erase Output from the Previous Command”
  • In “Scroll Back to the Previous Command,” noted that you can move in either direction
  • Added instructions to run a shell script from the Finder
What’s New in Version 3.0

Even though the Terminal window is the same blank slate it always was, and shells like bash and zsh operate just as they have for years, changes to Mac hardware and software since the previous edition of this book in 2016 required quite a few adjustments to the text. I also expanded coverage of several topics in response to reader requests. Here are the most significant changes in this edition:

  • Added coverage of zsh throughout the book; see especially “What’s a Shell?”, “Zsh Becomes the New Default Shell,” and “Zsh Tips and Shortcuts”
  • Provided detailed coverage of changes in Catalina that affect the command line, of which there were quite a few besides the new default shell of zsh; see “What Changed in Catalina?”
  • Adjusted the instructions for setting preferences in Terminal to match what’s in recent versions of macOS; see “Change the Window’s Attributes”
  • Included instructions for switching the current shell (see “Change Your Current Shell”) and additional techniques for changing your default shell (see “Change Your Default Shell”)
  • Explained how to deal with the read-only system volume starting in Catalina; see “See What’s Here”
  • Added instructions for using the head command (to complement tail); see “Head”
  • Included a sidebar called Which Programs Can I Run? that tells you how to list all available command-line programs
  • Significantly expanded “Customize Your Defaults” to cover the use of startup files in both zsh and bash
  • Added coverage of the “Redirect Input ()”
  • Massively revised “Use a Package Manager” with updated details and my latest recommendations, and added a mention of Nix
  • Added an entirely new chapter, “Learn Command-Line Shortcuts,” that includes tips for both the Terminal app itself and the zsh shell
  • In “Command-Line Recipes,” edited many of the recipes for compatibility and to add detail; also removed six command-line recipes that no longer work with modern Mac hardware and/or software, but…
  • Added 13 brand-new recipes! They are:
    • Show Half-Star Ratings in Music or iTunes
    • Disable Inline Attachment Viewing in Mail
    • Create and Edit User Accounts
    • Reset a Lost Password
    • Download Old Versions of macOS
    • Manipulate Graphics
    • Set Up a Password-less SSH Login
    • Use Disk Utility from the Command Line
    • Reboot in macOS Recovery
    • Use Terminal in macOS Recovery
    • Get Quick Answers to Programming Questions
    • Unhide Your User Library Folder
    • Find Item Frequency in a CSV File

Which versions of macOS does this ebook cover?

This book is fully up to date with macOS 13 Ventura, but almost everything in the book is applicable to at least 10.9 Mavericks onward, and much of it works with any version of Mac OS X/OS X/macOS.

  • Read Me First
    • Updates and More
    • Basics
    • What’s New in Version 3.2
    • What Was New in Versions 3.1.1 & 3.1.2
    • What Was New in Version 3.1
    • What Was New in Version 3.0.1
    • What Was New in the Third Edition
  • Introduction
  • macOS Command Line Quick Start
  • Understand Basic Command-Line Concepts
    • What’s Unix?
    • What’s a Command Line?
    • What’s a Shell?
    • What’s Terminal?
    • What Are Commands, Arguments, and Flags?
    • What Changed in Catalina?
    • What Changed in Big Sur?
    • What Changed in Monterey?
    • How to Download Scripting Languages
  • Get to Know (and Customize) Terminal
    • Learn the Basics of Terminal
    • Modify the Window
    • Open Multiple Sessions
    • Change the Window’s Attributes
    • Change Your Current Shell
    • Set a Default Shell
  • Look Around
    • Discover Where You Are
    • See What’s Here
    • Repeat a Command
    • Cancel a Command
    • Move into Another Directory
    • Jump Home
    • Understand How Paths Work
    • Understand the macOS Directory Structure
    • Use Tab Completion
    • Find a File
    • View a Text File
    • Get Help
    • Clear the Screen
    • End a Shell Session
  • Work with Files and Directories
    • Create a File
    • Create a Directory
    • Copy a File or Directory
    • Move or Rename a File or Directory
    • Delete a File
    • Delete a Directory
    • Use Symbolic Links
  • Work with Programs
    • Learn Command-Line Program Basics
    • Run a Program or Script
    • Run a Program in the Background
    • See What Programs Are Running
    • Stop a Program
    • Edit a Text File
    • Create Your Own Shell Script
  • Customize Your Defaults
    • About Startup Files
    • Edit .zshrc or .bash_profile
    • Create Aliases
    • Modify Your PATH
    • Change Your Prompt
  • Bring the Command Line into the Real World
    • Get the Path of a File or Folder
    • Open the Current Directory in the Finder
    • Open a Hidden Directory without Using Terminal
    • Open the Current Folder in Terminal
    • Run a Shell Script from the Finder
    • Open a macOS App
    • Open a URL
    • Open a File in macOS
  • Log In to Another Computer
    • Start an SSH Session
    • Run Commands on Another Computer
    • End an SSH Session
    • Transfer Files with sftp or scp
  • Work with Permissions
    • Understand Permission Basics
    • Change an Item’s Permissions
    • Change an Item’s Owner or Group
    • Perform Actions as the Root User
  • Learn Advanced Techniques
    • Pipe and Redirect Data
    • Get a Grip on grep
    • Add Logic to Shell Scripts
  • Install New Software
    • Use Command Line Tools for Xcode
    • Install Unix Software from Scratch
    • Use a Package Manager
  • Learn Command-Line Shortcuts
    • Terminal Tips and Shortcuts
    • Zsh Tips and Shortcuts
  • Command-Line Recipes
    • Change Defaults
    • Perform Administrative Actions
    • Modify Files
    • Work with Information on the Web
    • Manage Network Activities
    • Do More with SSH
    • Work with Remote Macs
    • Troubleshoot and Repair Problems
    • Get Help in Style
    • Do Other Random Tricks
  • About This Book
    • Ebook Extras
    • About the Author and Publisher
  • Also by Joe Kissell
  • Copyright and Fine Print

Joe Kissell Talks Command Line with Chuck Joiner

Posted by Joe Kissell on February 29, 2020

Chuck Joiner of MacVoices interviewed Joe Kissell about the third edition of Take Control of the Mac Command Line with Terminal. Discover what has changed on the Mac command line in recent years and what you’ll learn in the new version of this book.

Joe and Chuck Take a Bash at Using the Command Line on MacVoices

Posted by Michael E. Cohen on May 13, 2015

Chuck Joiner and Joe Kissell sit down to discuss Joe’s latest edition of his guide to the Mac command line on MacVoices. Together they ls the changes Joe made to the book to bring it current with Terminal in Yosemite, and man up to the challenge of explaining this essential but technical tool to typical Mac users. (By the way, if you don’t know what bash or ls or man mean, you need to read the book!)

Reviews

There are no reviews yet.

Be the first to review “Take Control of the Mac Command Line with Terminal”

David Smith writes:

I purchased this book a while back, just in case I needed to refresh Unix skills. However, the “tyranny of the immediate” (stuff we have to do NOW) kept me from doing much in terminal. However, in past couple days, I actually NEEDED to do some work in Terminal. Thus, I went through your whole book. It reminded me of a lot of things I had forgotten from 15 years ago, and presented some that I never knew. Thanks for this work, it is both informative and readily comprehensible.

Reader Luciano Fuentes writes:

I just wanted to say thank you. I expected to slog through the book and not derive a lot of pleasure out of it. I was very wrong. I almost worked through it all in one sitting, and I now find myself enjoying working in the command line! I never imagined this would end up being the case.

Mark Greco writes:

I have been trying to learn UNIX for quite a wile. I have worked through several books and watched many videos. I found your ebook the best I have used yet. You take the basic and make it easy to understand and work through.

You may also like…