The Mac Terminal: An Introduction

Posted by Alex Galonsky on 03/08/07 in Apple, Tips & Tricks, Utilities 

This article is a piece in a series of upcoming articles.
spacer
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.

share spacer permalink spacer ping spacer 127 Comments

Comments

127 Responses to “The Mac Terminal: An Introduction”

  1. Sherb on March 12th, 2007 8:43 pm
    spacer

    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 spacer

  2. socks_ on March 13th, 2007 9:16 pm
    spacer

    # 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.

  3. Jack Cory on March 14th, 2007 7:20 pm
    spacer

    this made front page at digg.com!

  4. Jarrod Young on March 14th, 2007 7:55 pm
    spacer

    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.

  5. Miles Evans on March 14th, 2007 8:26 pm
    spacer

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

  6. Justin on March 14th, 2007 8:55 pm
    spacer

    Gary….way to be a dickhead.

  7. Tim on March 14th, 2007 10:47 pm
    spacer

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

  8. Dalton Cummings on March 14th, 2007 11:39 pm
    spacer

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

    Other than that, tis great. spacer

    –Dalton

  9. .: SLACKDOT.COM :. » Blog Archive » Introduction to the Mac OS X Terminal for Noobs (Part 1) on March 15th, 2007 12:56 am

    [...] read more | digg story [...]

  10.   Get to know the Terminal…intro for newbies by Apple Gazette on March 15th, 2007 9:51 am

    [...] you’re interested in learning about the Terminal, but don’t know where to start, this article from MacApper is a great place to get your feet [...]

  11. Linux Guy on March 15th, 2007 3:14 pm
    spacer

    Just like linux … mac sucks, linux rulez

  12. Chris on March 16th, 2007 1:33 am
    spacer

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

  13. matthews on March 16th, 2007 1:35 am
    spacer

    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

  14. Knight on March 16th, 2007 11:43 am
    spacer

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

  15. Salmonized » Blog Archive » links for 2007-03-16 on March 16th, 2007 6:17 pm

    [...] MacApper » Blog Archive » The Terminal: An Introduction Kanske om jag ska göra nÃ¥t nÃ¥n gÃ¥ng i terminalen, läs dÃ¥ här dÃ¥ (tags: mac osx terminalen) [...]

  16. Mike on March 17th, 2007 4:12 pm
    spacer

    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

  17. MacApper » Blog Archive » The Mac Terminal II: Simple File Operations on March 21st, 2007 6:30 am

    [...] the last Terminal Tutorial, I went over the two commands cd and ls, which just allow you to view your files. In this segment [...]

  18. MyMac.ca » Introduction to the Mac OS X Terminal for Noobs (Part 1) on March 22nd, 2007 9:55 am

    [...] covers the basics of the Terminal, and two basic commands to get new Terminal users on their feet.read more | digg [...]

  19. Technogab| Technology News Podcast with a touch of Rock on March 23rd, 2007 1:54 pm

    [...] The Mac Terminal: An Introduction  An introduction to the powerful Terminal in OSX [...]

  20. Gary Roberts on April 24th, 2007 5:18 pm
    spacer

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

  21. Gary Roberts on April 24th, 2007 5:19 pm
    spacer

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

  22. Gary Roberts on April 24th, 2007 5:20 pm
    spacer

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

  23. Gary Roberts on April 24th, 2007 5:22 pm
    spacer

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

  24. Gary Roberts on April 24th, 2007 5:23 pm
    spacer

    gary roberts has better ratings than you

  25. Gary Roberts on April 24th, 2007 5:23 pm
    spacer

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

  26. Configuring Eudora on Macintosh? - Forum di FreePOPs on September 6th, 2007 2:36 pm

    [...] I don’t know the Mac and of course if a Mac user read this thread he can help you much more than me. Anyway, the Mac can use command line commands (Unix style) using the terminal. [...]

  27. MacOS » Blog Archive » Introduction to the Mac OS X Terminal for Noobs (Part 1) on October 10th, 2007 4:48 pm

    [...] read more | digg story [...]

  28. Introduction to the Mac OS X Terminal for Noobs (Part 1) « Apple Top News on October 16th, 2007 9:50 am

    [...] read more | digg story [...]

  29. Switch to a mac? Try Linux on that old PC | View from the Dock on December 13th, 2007 3:58 am

    [...] also serves, simply, as an extra PC around the house. True, I can also learn Unix commands via the Terminal on my mac (on Mac OSX or using a virtual machine to run Linux), but it gives me greater peace of [...]

  30. What is Darwin? | MacApper on April 8th, 2008 6:00 am

    [...] read the Mac Terminal Introduction by Alex and learn [...]

  31. san on April 8th, 2008 4:12 pm
    spacer

    Welcome to Darwin
    sudo rm gary roberts
    $

  32. Gary is a Dick on June 4th, 2008 3:02 am
    spacer

    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.

  33. gary roberts is a dick on June 15th, 2008 6:13 pm
    spacer

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

  34. Wireless Time Machine Backups | Morph8 on December 14th, 2008 6:51 pm

    [...] just in case, you do not see your drive there, close the Time Machine settings window, launch Terminal and run the following [...]

  35. wise on December 29th, 2008 4:19 pm
    spacer

    You call this in introduction? cd and ls? what do you call advanced?

  36. PC to Mac Resources | WebDazzling.com on January 27th, 2009 1:01 am

    [...] a free download text editor. The Mac Terminal: An Introduction Top 50 Terminal Commands Common Terminal [...]

  37. Jake on January 29th, 2009 5:41 pm
    spacer

    If I have several terminal windows open, I can go to the first by typing command 1, the second by typing command 2, etc. I think this is referred to as “making the first window active,” “making the second window active,” etc.

    Is it possible to write a unix alias that can be typed in *any* of the Terminal windows and will make, say, the third window active?

    Alternatively, is it possible to create a keystroke (say, using Quicken or Applescript) that I can perform no matter which application is currently active, that will make, say, the third window active?

    Thanks for any insight

    Jake

  38. anais on February 8th, 2009 12:29 pm
    spacer

    Hola yo utilizo muxo la terminal en linux me comprado un mabook y mi ermana lo ha borrado de la carpeta aplcaciones, como puedo volver a instalarlo e metido el cd de instlacion y con el pacfist e explorado y mirado todos los paketes, q mas ago?

  39. >__< ughh . help? on February 24th, 2009 9:09 pm
    spacer

    ughh i need help. please! i have a G4 emac. i recently updated to leopard 10.5. I have everything on here EXCEPT “Terminal” ; i go into “Utilities” and its not there. Is there any way i can download it? Or am i *ssed out? =/

    PLEASE HELP

  40. Scholars’ Lab Blog - STAGING » Blog Archive » Day of Digital Humanities 2009 on May 5th, 2009 4:00 pm

    [...] The Mac Terminal: An Introduction [...]

  41. Packets of Consciousness » Chrome for Mac HowTo: Braindead Walkthrough, Step by Step, Handhold Edition on May 21st, 2009 8:46 pm

    [...] Terminal. If you don’t know how, the learning starts here. You can do it, Happy [...]

  42. rue64ja on July 17th, 2009 9:10 pm
    spacer

    I am so freaking happy that I finally figured out how to navigate my way through terminal. Thanks alot for this.

  43. contrarian on July 23rd, 2009 12:21 pm
    spacer

    How do I restart from terminal? Lately, if I use applejack on my iMac, OS 10.5.7 it leaves me after saying restarting, which doesn’t happen, then a line saying killing all processes

  44. links for 2009-08-02 | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster? on August 2nd, 2009 9:01 pm

    [...] The Mac Terminal: An Introduction | MacApper Great post introducing people to Mac Terminal (tags: mac osx apple reference tutorial shell programming) [...]

  45. links for 2009-08-03 | AndySowards.com :: Professional Web Design, Development, Programming, Hacks, Downloads, Math and being a Web 2.0 Hipster? on August 4th, 2009 1:52 am

    [...] The Mac Terminal: An Introduction | MacApper Great post introducing people to Mac Terminal (tags: mac osx apple reference tutorial shell programming) [...]

  46. nuxis on August 10th, 2009 3:25 pm
    spacer

    Great topic, though it’s not an advance introduction it’s good enough to know there is a terminal. I’ve been working with linux most of my short life and when I actualy find out my new macbook also had a terminal I really was so happy (:

  47. Alberto on September 21st, 2009 8:43 am
    spacer

    Question about autocomplete in the mac terminal,

    In linux when you press the tab key completes the word if possible and if not show the possible options is this also possible in the mac terminal?

  48. Alice on October 31st, 2009 9:14 am
    spacer

    I didn’t even think about terminal usage on Mac. I love it on my linux box but Mac hmmmm. Maybe I should get a mac.

  49. Show Me Your Dock Series! Part 22 | Hi, I'm Grace Smith on November 3rd, 2009 3:22 pm

    [...] Terminal – Too geeky to get into¦ [...]

  50. Snow Leopard Maven Install | XENOSEED on November 8th, 2009 5:27 pm

    [...] extracting the archive open the Terminal, which can be found in /Applications/Utilities/Terminal.app, and navigate to the directory in [...]

  51. Joining .wmv video clips? - Mac-Forums.com on November 9th, 2009 7:54 pm

    [...] to the Mac Terminal on Macapper.com. The link to the article is here if anyone else needs help- The Mac Terminal: An Introduction | MacApper. I will try this approach as well. [...]

  52. The Rossatron on November 17th, 2009 6:35 am
    spacer

    I was t

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.