Alex Kaloostian

Apple Certified Master Trainer | Systems Integrator | Video Editor | Motion Graphics Artist

1 Comment

Command Line Basics 4 – targets

Lesson 1 – The Terminal
Lesson 2 – Command options
Lesson 3 – Man pages

Last time, I showed you how to read a man page for a command by typing man followed by the command. In lesson 2, I showed you how to list files in long format by typing ls followed by a hyphen and an option, like ls -l. Why does one command use a hyphen, and the other not?

It’s all in the difference between options and targets.  Here’s how most commands are entered:

command -options target

The command is the thing you want to do, the option is how you want to do it, and the target is where you want to do it. Some commands need an option, some don’t. Some commands need a target, some don’t. But if you use them, the computer can only tell the difference between an option and a target based on that little hyphen. Imagine it wasn’t there, and you tried typing

ls a

Are you telling the computer to list all items, or list the folder named “a”? The hyphen is how the computer knows you are typing an option or a target. Options have a hyphen before them, targets don’t.

Continue reading


Command Line Basics – lesson 3 – man pages

Okay, in earlier lessons, I showed you how to use the uptime command, and the ls command, with and without options. But how did I know what those options were? -l, -a, -G, what the what? The answer, my friend is, RTFM!

Every command line command has an instruction manual included FREE, at NO EXTRA CHARGE! its easy, just type man, a space, and the command you want to know about. Like this:

man uptime

And press return. You will see something like this:

UPTIME(1) BSD General Commands Manual UPTIME(1)
 uptime -- show how long system has been running
 The uptime utility displays the current time, the length of time the system has been up, the number of users, and the load average of the system over the last 1, 5,
 and 15 minutes.

And a bit more, but I’ve cut it for space. You get the idea. Exciting, right? That right there is the hottest writing since Twilight. Ahem. This is a basic one- some man pages are hundreds and hundreds of lines long.

Now, you probably have noticed something new. You don’t see the usual prompt, waiting for you to type a new command. And if you DO try a new command, things are going to get wonky. The commands we tried earlier were one-time commands: you run them, they run, and they’re done, nice and easy. A one-night stand, so to speak. But the man command sticks around. It stays open until you’re don’t with it.

How can you quit the man command and get back to the normal prompt? press q. (no period, just the letter q). If you’re ever stuck in some command, the q key will usually get you out. If not the q key, than control-c will do it. Thats a break command. q quits gracefully, control-c is more of a panic switch. And if you ever get REALLY stuck, just close the Terminal window and open a new one.

Continue reading


Command Line Basics – Lesson 2 – Command Options

Okay, last time we didn’t cover a lot, true. In fact, we didn’t cover much more than launching the Terminal. But the journey of 1,000 lines of code begins with a single prompt, or something like that.

By the way, side note… check out In The Beginning was the Command Line, a fascinating article written by Neil Stephenson in 1999, about the inevitable death of paid operating systems in the face of the rising free software movement. You probably are thinking to yourself, you paid for the operating system you’re using right now. Well, so did I, and so did Neil. He admits he got a lot wrong. But the article is just as interesting for what it got wrong as what it got right. And it’s been posted online for free. We now return you to your lesson.

Okay, let’s try some more commands. Launch the Terminal, and type the following:


And press return. Assuming you haven’t done anything else, and just launched the Terminal, you will be in your home folder, and when you type ls, you should see something similar to this:

Desktop     Downloads   Library    Music   Public
Documents   Movies      Pictures   Sites

Figure out what ls does? That’s the list command. It will list the items in your home folder. Yours might differ slightly; You may have a Dropbox folder, or some other custom folders, but basically, you will see a list of the folders and files in your home folder.

Continue reading


Terminal basics – lesson one

The command line is scary! It’s all, like, black and white, and you can’t use the mouse, and, and, why would anyone want to subject themselves to such madness? Here are 5 good reasons:

  1. Its faster. There’s no graphical interface to get in the way, and no annoying warnings and safeguards. You type a command, hit enter, and your command is simply, instantly performed.
  2. It’s more powerful. You can bypass precautions in the Finder, see invisible files, and delve into deep corners and recesses of the System that are usually off-limits. You can even customize settings that the Mac usually doesn’t allow.
  3. Remote access. Every Mac supports screen sharing, but screen sharing can be slow, especially over a dial-up connection. And it can be hard to see a large screen scaled down to fit your laptop (or phone). The command line is crisp, clear text, very low bandwidth and easily pushed over even the slowest connection.
  4. It’s scriptable. Anything you can do in the command line, you can script to do automatically. You’ll be amazed to see just how easy it is to get into scripting.
  5. Its cool. Lets face it, when you’re in the command line, you get to pretend you’re Matthew Broderick in War Games, and who doesn’t like that?

So how do you access the command line? There are a bunch of ways, but until we get into the really advanced stuff, we’re going to stick with the easiest and most popular method: The Terminal.

A lot of people use the word “terminal” to refer to the command line, but the Terminal is a utility. A Utility you use to access the command line. Think about, um, okay, think about baseball. Usually you’d play baseball on a baseball diamond in the park, but you wouldn’t say the diamond is baseball. The diamond is just the most popular place to do it. You could play baseball in a parking lot, or the middle of the street, or the beach, or even on a video game. The command line is the same way. You could access the command line from the login screen, or from a remote SSH session, or from single-user mode, but the most popular method by far is the Terminal app.

So open your Utilities folder, and launch the Terminal app. Now you’ll probably see something like this:

That’s your command line. We will talk all about the ins and outs and details in a later post, but this is getting long, so let me finish by having you type your very first command! Don’t be nervous, now, just put your hands on the keys and type:


Press return, and see what it does. Figure it out? It’s just a simple command to show you how long your Mac has been up and running without a restart. Easy! next time we will explore some more complex commands, promise. TTFN!

1 Comment

Tricking myself into being awesome

I’ve been trying to keep a low profile on this blog, and only post articles of relevancy, of substance. I don’t want to flood people with meaningless stuff- that’s what the rest of the web is for. But I’ve also been at a loss for good content, and perhaps neglecting you more than I should.

I’ve been inspired by Chris Strom’s blog post on Lifehacker, 366 Days, or How I Tricked Myself Into Being Awesome. In one year, Chris wrote three books on topics he had not even been an expert in. If he can do that, I should be able to write TWO books on things I DO know, right?

So over the next few weeks I’m going to do my best to post more here. Not every day, but I am making a commitment of at least 3 posts a week, on 2 topics, and hopefully at the end of the year I’ll be able to collect all that stuff together into some sort of e-book.

The topics are something I hope many of you will find useful, and I’ll tag them so you can follow or ignore them at your choice. The topics will be Learning The Mac Command Line and iPads For Kids.

Even more than usual, I will be hoping all of you will comment, feedback and ask questions so that this can be a living, evolving project. Wish me luck!