Mac in the Shell: Where to Begin
Volume Number: 26
Issue Number: 02
Column Tag: Mac in the Shell
Mac in the Shell: Where to Begin
The path to learning
begins with you
by Edward Marczak
The Mac in the Shell column has covered a lot of ground in its five year run. Its initial mission was to introduce OS X Administrators to the shell (typically using Terminal.app). There's a whole different, wonderful, powerful world hiding behind the GUI. Well, working in a shell is a somewhat nebulous, expansive area. I've also covered some shell-like topics, such as using Vim, Apache configuration, scripting languages like Python and more. It's time now, to revisit the roots of all this.
Now, I don't plan on covering very basic shell information. I've already done that, and it's all online. There are several factors leading me to this path. First, I've had some letters from readers asking, "hey, can you cover some shell scripting?" Second, I've had people say to me on several occasions, "you're really good at this, you're a natural." Finally, I had a conversation recently with someone looking to move her career forward a bit. She knows what to tackle, but not exactly how to get there. She started looking at programming classes, but without a real purpose. I find that most people don't retain much - or the right things - when they are taught *what* can be accomplished without being able to tie it into anything real-world.
So, to answer those things: first: sure! I can cover shell scripting! Second, no, I'm not a natural. If anyone could see the behind the scenes practice, obsession and dedication to the craft, it might not look so easy or natural. Third, I get the sense there are many people in my friend's position: having an idea and knowing a direction, but not knowing where to get started. Welcome to the next few columns of Mac in the Shell. Let's go.
Just for the record, this is still the Mac in the Shell column. Meaning, I'll be focusing on how to learn about shell tools. While some of the information I'm presenting could be used generically, I'm really not going to be talking about how to better learn Adobe Photoshop or other package. There is certainly an uptick in the need for people that have shell and scripting skills, and that's what I'll be guiding people through getting some traction on. Now let's get started.
Luckily for you, you're not the first to travel this path. There are plenty of resources out there for you to learn from. The sticking point usually is your learning style. While some prefer just to dive in, other like reading at length first and others learn best in a classroom environment. This is critical: make sure you match how you learn best with the method of learning. Unfortunately, different methods can have wildly different costs in both time and money.
I'm not formally an educator, so, I won't try to detail everything about a learning style. However, I feel most people recognize the style that suits them best pretty well. Here are some styles I've identified and will focus on here:
- Self-starter, self-directed: Just popping open Terminal.app and having at it matches this style. The help that's built-in to the tool or system is enough to work by.
- Reader: the reader, well, reads! Magazines and books make up the bulk of this learning style. This is essentially the self-starter style, but provides self-paced learning and requires dedication and focus.
- Classroom led: Some people perform best in a classroom (or classroom-like) situation. The ability to ask questions of a teacher as you're going through the material and try out examples right in class are hallmarks of this style.
- One-on-one: This is really just an extension of the classroom-lead style, with two important distinctions: first, it's one-on-one, with no additional students to distract you or take up time with the leader (or possibly, mentor in this case). Secondly, this style will typically come to pass in a work situation where there is some real project or end-goal, so the "labs" will be decidedly more real world.
You may have noticed yourself in one of those descriptions. That's great! You may have also noticed yourself in several of those descriptions. That's great, too! There's no reason these styles can't be combined. Like most people, though, you likely more strongly identify with one style over the others.
If you're a self-starter, well, you're most likely not even reading this, but fiddling about with code. Even self-starters, though, look for help from time-to-time. Unlike people in some of the other styles, the self-starter will likely look for help, not in books, but from their peers: advice from mailing lists, web searches, Twitter posts and simple messages directly to people that may have the answer they seek.
If you feel that you're in the self-starter style, but are just getting started-perhaps you're an experienced user, just new to Mac OS X-here are some places for quick answers:
- man pages: This should already be a familiar resource, and they're no different under OS X. Apple has thankfully provided man pages as resources for nearly every OS X-specific shell command.
- Command help: most commands will yield help by providing no parameters, or, via an '-h' switch.
- Mailing lists: Apple runs a bevy of lists that are of great use. You can find the full list at lists.apple.com, but I'll highlight some I find useful:
- cocoa-dev - Just about all technical Mac people should be at least moderately familiar with the Cocoa framework, as it influences everything on the system. http://lists.apple.com/mailman/listinfo/cocoa-dev
- Darwin-userlevel - A Unix-y jaunt through Mac OS X and the underpinnings in the shell. http://lists.apple.com/mailman/listinfo/darwin-userlevel
These lists may be a bit over your head if you're just starting out. Howver, don't let that discourage your signing up. Every bit of reinforcement helps and before you know it, you'll have greater understanding and will be helping out others.
Well, you're here, aren't you? Really, though, the "reader" I have in mind is looking at longer, in-depth resources (which is why I'm leaving out blog posts and most web articles, as they tend to cover one, focused topic, rather than leading a reader through an arc of learning). Reading a single tome about, say, bash scripting, is different than reading several web-articles about bash-scripting.
So, what resources are there for The Reader? Plenty! Well-written books with a staff behind them haven't gone away. I'm referring to a publisher with an editorial staff that can find authors, copy and tech edit, properly index a book and more.
It may seem that I'm being a little tough on blogs or web articles, but that's not exactly true. You just need to understand the source. For every wonderful article I've seen, I've also read error-filled articles with poor advice. It's not that this can't happen in the traditional publishing world, but it's less likely as there are jobs on the line. (Really: the tech editor of a book should be pressed when there are these types of errors in a tech book).
Where to go?
O'Reilly http://www.oreilly.com: I have to start with the stalwart of tech material. O'Reilly has long brought a subject's best along to write. Their huge catalog has something for everyone. Specifically, for bash scripting, there are the following:
- Learning the bash Shell, 3rd Edition. While you can find most of this online in one place or another, it's much nicer to have it in one consolidated tome. This book brings you from beginner to quite advanced. http://oreilly.com/catalog/9780596009656/
- The bash Cookbook: Once you know what you're doing, doing it is sometimes a chore when you know that someone has already tackled the problem you're trying to solve. Additionally, it's often instructive just to see how others have come up with a solution. http://oreilly.com/catalog/9780596526788/
I'll also mention that as far as I've found, the entire catalog is available electronically, both in the subscription-based Safari service (http://safari.oreilly.com) and in the for-purchase, you-own-it kind. Pretty soon, I'm going to need a twelve-step program for the e-books here.
Pragmatic Programmers. Somewhat new to the scene, Pragmatic Programmers has quickly built up an impressive, accessible catalog.
- TextMate - when you're working in the shell, you'll ultimately need to edit text files. You want a text editor that's working with you and making your job easier. Textmate is one of those editors. There are certainly other editors available on the Mac (for instance, vim/MacVim is my utility of choice), but TextMate has a huge community and availability of resources available to it. If TextMate is your preferred editor, or you haven't chosen one yet, give TextMate: Power Editing for the Mac a look. http://pragprog.com/titles/textmate/textmate
Peachpit Press. Home to the official Apple guides to certification, there are a wide-variety of titles. The advanced guides to configuration, deployment and server administration contain the shell equivalents to their GUI counterparts, encouraging scripting for the admin. Even if you're not planning on getting Apple certification or taking any of the exams, worthwhile reading includes:
- Mac OS X Unix 101 Byte-Sized Projects: Gentle introductions and uses for Unix commands under Mac OS X. http://www.peachpit.com/store/product.aspx?isbn=0321374118
Peepcode. Now, this isn't actually "reading," but "watching"-they're screencasts. I'll include it here as it is reading-like, more than it's any of the other styles (it's a one-way medium, like a book). Personally, I'm generally not a fan of screencasts, but I know plenty of people that are, and that like learning this way. Also, I'm singling out Peepcode as they make some of the only screencasts that I'll watch. They're factual, exceptionally well-produced and, most importantly, to the point. Nothing like a meandering screen-or-pod-cast to allow you to lose focus. Peepcode produces no-cruft screencasts.
Check out these titles:
- Meet the Command Line - https://peepcode.com/products/meet-the-command-line
- Advanced Command Line - https://peepcode.com/products/advanced-command-line
- Ruby 1.9, Part 1 - https://peepcode.com/products/ruby19-i
Apress. Apress has been making a strong push into the Mac market. With titles specific to iPhone and Mac development, Mac system administration and general scripting, you can find titles that suit your needs.
- Pro Bash Programming: Scripting the GNU/Linux Shell: a bash scripting guide for those that are past the basics. http://apress.com/book/view/1430219971
If you've determined that the classroom-led style is best for you, you're in luck - there are many resources out there. I'll drop these into three categories: Apple-certified, non-Apple-certified and "informal."
Apple-certified training centers jump through some hoops to call themselves as such. First, people are charged with creating course and training material. This material is focus-group tested with subject matter experts. The books become the Peachpit Press materials mentioned above. There is also classroom material created at this time that is only available when you take a course. Once this material is locked in, the course creators train "Master Trainers." The Master Trainers in turn train the trainers that offer the certified courses.
Non-Apple-Certified training centers are just that: training centers that have no formal affiliation with Apple. Most training centers are reputable and can prepare you for an Apple exam just as well as an Apple-certified trainer. Even better: a non-Apple-certified trainer isn't constricted in the material they teach. While an Apple-certified trainer must teach a certain curriculum, a non-Apple-certified trainer is free to tell you that the book says one thing, but that in practice, things work a little differently. (Also remember the converse here: every Apple-certified training center is free to offer non-Apple courses as well, such as Linux and Windows training).
Informal classes are those given at user-group meetings, Macworld conferences and so on. While they may not seem "informal," especially since you may be paying, these setups are temporary, and the person teaching in one session may not be the same next time. I tend to speak at Macworld, and while I don't treat it as "informal" - I carefully prepare all material, typically have handouts, etc. - I will concede that it is an informal class: you'll see me teach, and then won't see me again for a year. Cocoa-heads user group meetings also fit this mold: meeting one a month is regular, but the person presenting a subject at one meeting will likely be different the next. All in all, though, you have an expert at your disposal for a period of time and get to ask questions.
Apple-certified training centers are easily found-just visit http://train.apple.com. You can search for locations close to you.
Non-Apple-certified training centers won't necessarily have a central location to be found - unless you consider a search engine that central location. Running a Google search on "NY shell scripting class" brought back appropriate results.
The informal classes will just pop up on your radar if you're looking for them. Keep an eye out for local user groups, Cocoaheads meetings (http://cocoaheads.org) and events like Macworld where you'll find these gatherings.
One-on-One, or, Mentoring
Since this is a much more rare and privileged situation, there isn't much in the way of a central place to find someone who will mentor you. The mentor relationship usually goes beyond simple hire-me-and-I'll-teach. There is, however, something incumbent on you if you desire this type of learning: seek it out. This scenario isn't going to come to you.
You can certainly ask someone you respect if they can take you under their wing. This is easiest in a work setting, but doesn't always have to be. Depending on the topic, sometimes a phone or e-mail relationship will suffice. Some companies have a more formal mentoring program. Again, you should be seeking that out. It's amazing what can happen when you ask.
Some resources may exist in local/regional user groups or special interest groups. Many regions have Macintosh Users Groups ("MUGs"). For the developer types, there are locally run CocoaHeads meetings around the globe. Apple runs the Apple Consultants Network ("ACN"), which, despite being aimed towards independent consultants, is appropriate to a broader group. Most regions have locally run meetings that feature vendors and members that give presentations on technical topics.
This column is the result of several things with a common thread: someone asked me to teach them or how to get started. I'd like to continue to hear from people about topics that they would like to see covered. None of this is magic or innate; it takes some amount of work. Most importantly, whatever your learning style, there are resources available to you. Stay aware, and you'll find learning material nearly everywhere you look.
Media of the month: Twin Peaks on CBS (http://www.cbs.com/video/?showname=classics/twin_peaks&showtype=classics). It's a bit of a cult classic, but I've been into cult classics lately; this fits right in. Plus, it's available for free, which is a double win.
Next month, I'll focus on problem solving: integrating Drop Box into your bash experience. Until then, keep your eyes open!
Ed Marczak is the Executive Editor of MacTech Magazine. He has written the Mac in the Shell column since 2004.