Solve Apple ID Problems for Just $7.99!

Learn all the ins and outs of your Apple ID and what to do when something
goes wrong with Take Control of Your Apple ID by Glenn Fleishman.

Take Control of the Mac Command Line with Terminal

Automating Your Mac + Mac Command Line Bundle

Save $10.00! Buy with Take Control of Automating Your Mac for only $20.00!

Feb 02, 2016

Take Control of the Mac Command Line with Terminal, Second Edition

Learn how to unleash your inner Unix geek!

If you’ve ever thought you should learn to use the Unix command line that underlies Mac OS X, or felt at sea when typing commands into Terminal, Joe Kissell is here to help! With this 167-page ebook, 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 50 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

More Info

The book begins by teaching you these core concepts:

  • The differences between 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 file system
  • 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
  • What a profile is, why it’s cool, and how to customize yours
  • 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 (>).
  • Use grep to search for text patterns in files and filter output.
  • Install new command-line software from scratch or with a package manager.

Questions answered include:

  • 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 over 50 real-world “recipes” that combine commands to perform useful tasks, such as listing users who’ve logged in recently, using a separate FileVault password, figuring out why a disk won’t eject, copying the source code of a Web page, 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.

What's New

What’s New in Version 2.1

Version 2.1 is a minor update that does the following:

  • Makes a few tiny updates to cover OS X 10.11 El Capitan

  • Explains how the sudo command functions differently starting with El Capitan; see Perform Actions as the Root User

  • Updates the numbers of packages available in Fink and Homebrew

  • Adds a note about a key icon that appears at password prompts; see Interactive Programs

  • Updates the instructions to Flush Your DNS Cache in 10.10.4 Yosemite and later

  • Mentions the removal of Secure Empty Trash in El Capitan, as well as how to clear the system and user “immutable” flags; see Delete Stubborn Items from the Trash

What Was New in Version 2.0

This revised and expanded second edition brings the book up to date with OS X 10.10 Yosemite (while maintaining compatibility back to 10.6 Snow Leopard) and adds material that’s more advanced than what was in the first edition, enabling you to go further, do more in Terminal, and enhance your command-line skills.

The most significant changes include:

  • Refreshed the text with many small changes and updated screenshots to accommodate changes in the latest versions of OS X

  • Added new sidebars about Using a Mouse in Terminal (in the chapter Get to Know (and Customize) Terminal) and Finding Text in the Terminal Window (in the chapter Look Around)

  • In the chapter Work with Files and Directories, added a new topic, Use Symbolic Links, and sidebars about Running Multiple Programs on One Line and Running Shell Scripts outside the Shell

  • Included a fun tip about using emoji in your prompt, in Change Your Prompt

  • Expanded the discussion of how to Open the Current Folder in Terminal to include the use of services in Mavericks and later

  • In the Log In to Another Computer chapter, added a topic about how to Transfer Files with sftp or scp

  • Renamed the chapter formerly called “Venture a Little Deeper” to Work with Permissions, which is more accurate and descriptive, and added a topic called Use the chmod Absolute Mode

  • Added two entirely new chapters for more-advanced readers: Learn Advanced Techniques, which covers piping and redirecting, grep, and adding logic to shell scripts; and Install New Software, which discusses Command Line Tools for Xcode, downloading and installing Unix software from scratch, and using package managers such as Homebrew and MacPorts

  • In the Command-Line Recipes chapter, removed 6 obsolete recipes that no longer function in Yosemite or Mavericks and added 18 new ones (for a net gain of 12)

  • Expanded several of the existing recipes with more details


Which versions of macOS does this ebook cover?

Although the book was last updated when 10.11 El Capitan was current, most of the examples in this book work with any version of macOS up through 10.12 Sierra. Note, however, that if you are using a much older version of OS X, you will notice a number of differences, and a few commands may not work as expected.

Reader Comments

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.

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

    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!)

    Posted by Tonya Engst (Permalink)

  2. Missing Safari 6 Font Preference? Terminal to the Rescue!

    Safari 6.0, which Apple released into the wild at the same time it did Mountain Lion, lacks the preference option, present in earlier versions, for setting the default proportional font and fixed-width fonts. Fortunately, you can still set them using a series of defaults commands in Terminal. To find out how, see the TidBITS article Fix Your Fonts in Safari 6.

    Posted by Tonya Engst (Permalink)

The Author

Take Control publisher Joe Kissell has written more than 60 books about technology, including many popular Take Control books. He also runs Interesting Thing of the Day and is a contributing editor of TidBITS and a senior contributor to Macworld.