33

The Mac Terminal: An Introduction

This article is a piece in a series of upcoming articles.
Terminal
Mac OS X isn’t just known for it’s fancy GUI. It’s known for it’s powerful underlying core OS, UNIX, and the Terminal is the way that you can access the UNIX base. For you new switchers, the Terminal is equivalent to the Command Prompt in Windows, or the Command Line/Shell/Terminal in Linux. Many Mac users never even open Terminal, however these users are missing out on some of the most powerful features.

To open Terminal, navigate to your Applications folder, open Utilities, and double click on Terminal. You will be greeted with a message similar to this:

Last login: Tue Mar 6 17:21:36 on console
Welcome to Darwin!
ibook:~ Alex$

The last line you see is called the prompt. This will appear after every command you enter and this is where you type your commands. It consists of your computer name, your current directory, and your short username. When you first start Terminal, your current directory will be “~”, which is short for your home directory (/Users/Your username).

One of commands you will use most is ls. The ls command will show you the files and directories that are contained in your current directory. Here’s an example:

ibook:~/Desktop/mammoth Alex$ ls
final1.jpg final3.jpg final5.jpg final6.jpg final7.jpg

By typing ls and hitting enter, the terminal shows me all the files that are in my “mammoth” directory. If you want to see the contents of a directory besides the one you are in, just type ls followed by the directory.

You are probably wondering how to change your current directory. This is done with the cd (change directory) command. Just type cd followed by the directory you want to change to. Example:

ibook:~/Desktop/mammoth Alex$ cd /Users/Alex/Desktop
ibook:~/Desktop Alex$

If you want to get to a directory that is inside of your current directory, just type cd followed by the directory name, as there is no need for a full path. To save time, the terminal has an autocomplete feature (most command lines have this). To use it, press tab when typing a file or directory and Terminal will guess what you are trying to type. Don’t forget about ~. Entering cd ~ will get you back to your home directory. A final, and very useful cd tip is that cd .., will navigate you to the directory above the one that you were in.

If you are experimenting with UNIX commands and need help with a certain command, it is always available. Either type:

command --help (quick help) or man command (full manual) Typing q will get you out of a command’s man page.

Although cd and ls don’t do much, they are a good foundation for further command line adventures.

22 Comment(s)

Legend: Guest Article Author Contributor
  • 1

    Sherb said on

    March 12th, 2007 at 8:43 pm

    Best thing to use terminal for if you’re not at home and you need to send an email.

    For those who don’t know:

    mail somone@someone.com
    Subject: Something
    Your message
    .

    And you have sent an email :D

     Add karma Subtract karma  +5
  • 2

    socks_ said on

    March 13th, 2007 at 9:16 pm

    # command –help

    will only work on the GNU tools, thus, using the man pages is much more ideal, that said, mistyping the flags of a command will tell you the usage, as long as you understand it, then its ok.

     Add karma Subtract karma  +2
  • 3

    Jack Cory said on

    March 14th, 2007 at 7:20 pm

    this made front page at digg.com!

     Add karma Subtract karma  +1
  • 4

    Jarrod Young said on

    March 14th, 2007 at 7:55 pm

    For you new guys out there, don’t do what Gary said, he’s being an *sshole.
    That would delete your entire harddrive. So, yeah, don’t do it.

     Add karma Subtract karma  +4
  • 5

    Miles Evans said on

    March 14th, 2007 at 8:26 pm

    Unsafe comments deleted. What a lame thing to do :/

     Add karma Subtract karma  +2
  • 6

    Justin said on

    March 14th, 2007 at 8:55 pm

    Gary….way to be a dickhead.

     Add karma Subtract karma  +0
  • 7

    Tim said on

    March 14th, 2007 at 10:47 pm

    Please ignore comment no 5 - if you are a newbie and you type that command you will basically delete everything on your hard disk.

     Add karma Subtract karma  +4
  • 8

    Dalton Cummings said on

    March 14th, 2007 at 11:39 pm

    Not bad. Make some references to other *nix articles on the net. :P

    Other than that, tis great. :)

    –Dalton

     Add karma Subtract karma  +0
  • 9

    Linux Guy said on

    March 15th, 2007 at 3:14 pm

    Just like linux … mac sucks, linux rulez

     Add karma Subtract karma  -16
  • 10

    Chris said on

    March 16th, 2007 at 1:33 am

    Linux Guy, grow up. Just let people use the OS that they want to use for whatever reason they want.

     Add karma Subtract karma  +3
  • 11

    matthews said on

    March 16th, 2007 at 1:35 am

    i think the macs are nice… i would get one if they had linux drivers/certification and nividia cards would be nice ati is bad for linux

     Add karma Subtract karma  +1
  • 12

    Knight said on

    March 16th, 2007 at 11:43 am

    What exactly is the point of terminal though? I mean, who would want to know what’s in your current mammoth directory?

    (subscribed to comments)  Add karma Subtract karma  -1
  • 13

    Mike said on

    March 17th, 2007 at 4:12 pm

    Knight — there’s a lot more to it than that. Terminal is just as much an interface to Mac OS X as the Finder is; more so, in some ways. Almost anything you want to do on your computer can be done from Terminal

    (subscribed to comments)  Add karma Subtract karma  +0
  • 14

    Gary Roberts said on

    April 24th, 2007 at 5:18 pm

    ********* Edited for the terminal code could seriously b0rk your HD if you didn’t know what it was you were doing.

     Add karma Subtract karma  -48
  • 15

    Gary Roberts said on

    April 24th, 2007 at 5:19 pm

    gary roberts is a pirate in the off=season and sails the seven seas pillaging villages!

     Add karma Subtract karma  -23
  • 16

    Gary Roberts said on

    April 24th, 2007 at 5:20 pm

    man, that guy, gary roberts, he’s so awesome!

     Add karma Subtract karma  -28
  • 17

    Gary Roberts said on

    April 24th, 2007 at 5:22 pm

    macs are not as good as gary roberts. Gary Roberts can do more floating-point operations in a second than any macintosh.

     Add karma Subtract karma  -29
  • 18

    Gary Roberts said on

    April 24th, 2007 at 5:23 pm

    gary roberts has better ratings than you

     Add karma Subtract karma  -32
  • 19

    Gary Roberts said on

    April 24th, 2007 at 5:23 pm

    Gary Roberts: a sitcom, a truck….. a legend.

     Add karma Subtract karma  -23
  • 20

    san said on

    April 8th, 2008 at 4:12 pm

    Welcome to Darwin
    sudo rm gary roberts
    $

     Add karma Subtract karma  +14
  • 21

    Gary is a Dick said on

    June 4th, 2008 at 3:02 am

    To Knight – The point of using Terminal is basically threefold. First, it’s often faster to use. Second, it can be used to carry out commands with a lot more force, especially the “sudo” command. Third, it allows you to modify preference files that can’t be altered from a “Preferences” menu, and it does it in a way much easier than opening it as a text file.

     Add karma Subtract karma  +0
  • 22

    gary roberts is a dick said on

    June 15th, 2008 at 6:13 pm

    i almost deleted my entire hard drive because of you a**hole!!

     Add karma Subtract karma  +1
  • 11 Link(s) Referencing this Post

    More at MacApper

    • Discuss 'The Mac Terminal: An Introduction' in our new Mac Forums

    Post a Comment


    Post your comment below (spam filtered)