Bundle Discount!
Save 30% when you build your own bundle of three or more books, including Take Control of...
(30% discount overrides other coupons and is calculated on the first screen of our cart.)
Take Control of the Mac Command Line with Terminal
Learn how to release your inner geek!
If you've ever thought you should learn how 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! This 111-page ebook will help you become comfortable working on the Mac's command line, starting with the fundamentals and walking you through more advanced topics as your knowledge increases. And if you're uncertain how to put your new-found skills to use, Joe includes numerous real-life "recipes" for tasks that are best done from the command line.
More Info
Contents & Intro
FAQ
Blog
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 edit a text file in nano (even if you are not named Mork)
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 consult the man pages)
You'll extend your skills as you discover how to:
Create and run scripts to automate repetitive tasks.
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 using ssh.
Understand and change an item's permissions, owner, and group.
Run commands as the root user using sudo.
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?
Finally, to help you put it all together, the book showcases 40 real-world "recipes" that combine commands you've learned to perform useful tasks, such as listing users who've logged in recently, figuring out why a disk won't eject, changing filename extensions, copying the source code of a Web page, downloading a file via FTP, determing which programs have open connections to the Internet, learning details about a domain name, and deleting stubborn items from the Trash.
Book Info
111 pages
Version 1.0.2
Updated 25-Mar-09
1.8 MB download
ISBN: 1933671556
Free sample with Table of Contents, Introduction, Quick Start, and section starts.
About the Author
Joe Kissell has written numerous books about the Macintosh, including many popular Take Control ebooks. He's also Senior Editor of TidBITS, contributes frequently to Macworld, and previously spent ten years in the Mac software industry.
Welcome to Take Control of the Mac Command Line with Terminal, version 1.0, published in March 2009 by TidBITS Publishing Inc. This book introduces you to Mac OS X’s command line environment, teaching you how to use the Terminal utility to accomplish useful, interesting tasks that are either difficult or impossible to perform in the graphical interface. The book was written by Joe Kissell and edited
by Geoff Duncan.
Introduction
Back when I began using computers, in the early 1980s, user interfaces were pretty primitive. A computer usually came with only a keyboard for input—mice were a novelty that hadn’t caught on yet. To get your computer to do something, you typed a command, waited for some result, and then typed another command. There simply was no concept of pointing and clicking to make things happen.
When I finally switched from DOS to the Mac (without ever going through a Windows phase, I should mention!), I was thrilled that I could get my work done without having to memorize lists of commands, consult manuals constantly, or guess at how to accomplish something. Everything was right there on the screen, just a click away. It was simpler—not in the sense of being less powerful, but in the sense of requiring less effort to access the same amount of power. Like most everyone else, I fell instantly in love with graphical interfaces.
Fast forward a couple of decades, and I find myself faced with some mundane task, such as renaming all 500 files in a folder to use a different extension, deleting a file that refuses to disappear from the Trash, or changing an obscure system preference. After wasting some time puzzling over how to accomplish my task—and perhaps doing some Web searches—I finally discover that Mac OS X’s graphical interface does not, in fact, offer any built-in way to do what I want. So I have to hunt on the Internet for an application that seems to do what I want, download it, install it, and run it (and perhaps pay for it, too), all so that I can accomplish a task with my mouse that would have taken me 5 seconds in DOS 25 years ago.
That’s not simple.
I’m a Mac user because I don’t have time to waste. I don’t want my computer to put barriers between me and my work. I want easier ways to do things instead of harder ways. Ironically, Mac OS X’s beautiful Aqua graphical interface, with all its menus, icons, and buttons, doesn’t always provide the easiest way to do something, and in some cases it doesn’t even provide a hard way. The cost of elegance and simplicity is sometimes a lack of flexibility.
Luckily, Mac OS X isn’t restricted to the graphical realm of windows and icons. It has another whole interface that lets you accomplish many tasks that would otherwise be difficult, or even impossible. This other way of using Mac OS X looks strikingly like those DOS screens from the 1980s: it’s a command-line interface, in which input is done with the keyboard, and the output is sent to the screen in plain text.
The usual way of getting to this alternative interface (though there are others) is to use a program called Terminal, located in the Utilities folder inside your Applications folder. It’s a simple program that doesn’t appear to do much at first glance—it displays a window with a little bit of text in it. But Terminal is in fact the gateway to vast power.
If you read TidBITS, Take Control books, Macworld, or any of the numerous other publications about the Mac, you’ve undoubtedly seen tips and tricks from time to time that begin, “Open Terminal and type in the following…”. Many Mac users—especially those without prior experience in DOS or Unix—find that sort of thing intimidating. What do I click on? How do I find my way around? How do I stop something I’ve started? Without the visual cues of a graphical interface, lots of people get stuck staring at that blank window, frustrated that they can’t accomplish whatever task they’re trying to perform.
If you’re one of those people, this book is for you. It’s also for people who know a little bit about the command line—perhaps just enough to be dangerous—but don’t fully understand what they can do, how to get around, and how to stay out of trouble. By the time you’re finished reading this book and trying out the examples I give, you should be comfortable interacting with your Mac by way of the command line, ready to confidently use Terminal whenever the need arises.
It’s not scary. It’s not hard. It’s just different. And don’t worry—I’ll be with you every step of the way!
Much of this book is concerned with teaching you the skills and basic commands you must know in order to accomplish genuinely useful things later on. If you feel that it’s a bit boring or irrelevant to learn how to list files or change directories, remember: it’s all about the end result. You learn the fundamentals of baking not because measuring flour or preheating an oven is intrinsically interesting, but because you need to know how to do those things in order to end up with cookies. And let me tell you, the cookies make it all worthwhile!
Speaking of food—my all-purpose metaphor—this book doesn’t only provide information on individual ingredients and techniques. The last section is full of terrific, simple command-line recipes that put all this power to good use while giving you a taste of some advanced capabilities I don’t explore in detail. Among other things, you’ll learn:
How to figure out what’s preventing a disk from disconnecting (unmounting or ejecting)
How to tell which applications are currently accessing the Internet
How to rename lots of files at once
How to change a number of hidden preferences
How to understand and change file permissions
How to automate command-line activities with scripts
Astute readers may note that some of these tasks can be accomplished with third-party utilities (most of which simply carry out command-line tasks in response to a mouse click). That’s true, but the command line is infinitely more flexible—and Terminal is free! It’s like the difference between buying supermarket cookies and being able to bake your own—in any variety, and in any quantity. Sure, there’s a place for prepackaged solutions, but it’s often quicker, easier, and more effective just to type a command into Terminal.
I should be clear, however, that this book won’t turn you into a command-line expert. I would need thousands of pages to list everything you can accomplish using the command line. Instead, my goal is to cover the basics and get you up to a moderate level of familiarity and competence. I may not answer every question you have, but you should get a solid foundation and be able to figure out how to learn more. I’ll take your feedback into account, too: if there’s sufficient interest, I may expand on this information in a future version of this book (or another Take Control title).
Most of the examples in this book work with any version of Mac OS X, but a few of them require Mac OS X 10.5 Leopard or newer. If you’re following along in Mac OS X 10.4 Tiger or earlier, you’ll notice that the Terminal application isn’t identical—it omits tabs and some other customization options—but mostly works the same.
Mac OS X Command Line Quick Start
This book is almost entirely linear—later sections build on earlier sections. I strongly recommend starting from the beginning and working through the book in order (perhaps skimming lightly over any sections that explain already-familiar concepts). You can use the items in the final section, Command-Line Recipes, at any time, but they’ll make more sense if you understand all the basics presented earlier in the book.
Find your bearings:
Learn about the command line and its terminology; see Understand Basic Command-Line Concepts.
Become familiar with the most common tool for accessing the command line; see Get to Know (and Customize) Terminal.
Navigate using the command line; see Look Around.
Learn basic skills:
Create, delete, and modify files and directories; see Work with Files and Directories.
Run or stop programs and scripts; see Work with Programs.
Make your command-line environment work more efficiently; see Customize Your Profile.
Go beyond the fundamentals:
Integrate the command line and Mac OS X’s graphical interface; see Bring the Command Line into the Real World.
Use the command line to control another Mac; see Log In to Another Computer.
Learn some slightly advanced techniques; see Venture a Little Deeper.
Do cool stuff; see Command-Line Recipes.
Which versions of Mac OS X does this ebook cover?
Most of the examples in this book work with any version of Mac OS X, but a few of them require Mac OS X 10.5 Leopard or newer. If you’re following along in Mac OS X 10.4 Tiger or earlier, you’ll notice that the Terminal application isn’t identical—it omits tabs and some other customization options—but mostly works the same.
I know only three commands that work on the command line, but I'd like to know more, and feel more comfortable, and my boss has asked me to develop my Unix skills with respect to my Mac. Is this a good book for me?
Absolutely! This ebook was written with you in mind.
I have lots of Unix experience, but I'd like a reference book that has lots of examples of real-life problems and command-line based solutions. Will this ebook be of any use?
Most of this ebook will be too easy for you, sorry. It is possible that we'll publish a more advanced edition in the future.
Ask a Question
Feel free to ask us if you have a question about this book!
Send Us Your Comments!
How could we not publish such kind words? If you'd like to send us your comments (good or bad, though we hope they're all good), just click the Feedback link on the cover of your copy of the ebook. Be sure to let us know if we can publish your comment. Thanks!
April 1, 2009 -- With nearly all the Take Control ebooks, including this one, once you've purchased and downloaded the PDF, you can print it yourself or you can buy a print-on-demand copy (at $10 off, since you already bought the ebook). In the case of this ebook, the print-on-demand version is delayed slightly because we need to check the fonts and margins. You can click the Order Print Copy button on the cover (page 1 of the PDF) at any time to check on the print-on-demand availability.
The print-on-demand version has the advantage of acting much like a normal book, with double-sided printing, book-like dimensions, and double-sided printing. However, you certainly can print the book on your own printer. In so doing, we recommend that you test-print a few of the pages in the Command-Line Recipes section, since some of those recipes extend into the right margin (we did this so that you can copy and paste them into Terminal without accidentally introducing line breaks). If your printer cuts off these wide lines, you can make everything fit by printing with a small reduction—try setting the Scale to 90 percent, for instance, or if it appears in your Print dialog, try the "Scale each page to fit paper" radio button.
For years now, Take Control readers have been requesting a basic ebook on how to use the Mac's command line, and we've finally done it. Take Control of the Mac Command Line with Terminal, written by the award-winning Joe Kissell and edited by Geoff Duncan, distills both Joe's own expertise and many suggestions from savvy geeks into 111 pages about getting more out of your Mac from the command line. Written entirely from a Mac user's point of view, the ebook starts with the fundamentals and walks you through more advanced topics as your knowledge increases. And to help you put new-found skills to use, you'll also find 40 real-life "recipes" for tasks that are best done from the command line.
Put simply, if you've ever thought you should learn how to use the Mac's command line, or worried about doing something wrong while following command-line-related instructions from the Web, this $10 ebook will give you the skills and confidence you need to make your Mac even more capable than ever before.