Hack the Day

Productivity, life and computer tips. Tricks for a better day.

  • Blog
  • About
  • Contact me!
« Alcohol drinking tips Heat survival tips you can learn from Animal Planet »

Beginner’s guide to Apple Terminal, part 1

June 7th, 2007 |

Apple OSX Terminal Let’s be honest - Apple has gained a lot in market share last year, so there are plenty of former Windows users who just switched to the Mac. This tutorial is for those new switchers who never had the courage to open up Terminal, OSX’s most underrated power-tool. This tutorial is not for the Linux/Unix gurus, but for the casual daily worked who wants to improve his computer operating skills and

First, the basics: you probably remember Windows Command Prompt, though chances are you never had to use it. Well now, Terminal is like Command Prompt on steroids. This is because Apple’s OSX is built around Unix, the most powerful geek-oriented Operating System ever, but with a nice-looking user-friendly gift-wrap. The result? OSX is an operating system that kicks Window’s buttocks any time of the day. Chances are you’ll never have to use Terminal, but I strongly suggest it - as any real Power User will tell you, mastering the command prompt commands is the ultimate swiss-knife for the computer geek.

In today’s lesson you’ll learn to start the Terminal, move around, look around, open up things from within and remove things.

  • How do you launch it? - easily - just start Finder open Applications, and from within open the Utilities folder. There it is, Terminal. Looks complicated, but you only have to do it once - you can drag the Terminal icon into the dock for easy launching it in the future. The real power user, though, can find and launch it in less than a second - if you have QuickSilver installed on your system, just type Ctrl+Spacebar, then start typing Terminal. Usually just typing “T” is enough. See? Real power at your fingertips!
  • What can you do with Terminal? - anything. Back in the old days, when there were no cute icons, windows or graphic menus, people did their daily office tasks via the command line. You can do it as well, as sometimes it’s a lot faster then dragging the mouse around, copying files, moving them, looking for the etc…

Let’s look at some basic useful operations you can do with the Terminal:

  • going to any given folder - you might have noticed that Finder won’t let you see plenty of system folders. But the geek in you really wants to see what’s inside his new shiny MacBook. Nothing simpler: once you fire up Terminal, at the command line prompt type:
  • cd /

    followed by

    ls

    What you see is the list of all the main folders on your disk. It should look similar to :

    my_computer_name:/ username$ ls
    Applications   System      cores      mach_kernel usr
    Desktop DB     User Guides And Information
    dev        mtasc.yaml  var
    Desktop DF     Users       etc        opt
    Developer      Volumes     home       private
    Library        automount   mach       sbin
    Network        bin         mach.sym   tmp

    The cd command (short for Change Directory) allows you to move to a different folder than the current one. Just type the name of the target folder after it, and press Enter at the end. The ls (short for LiSt) command lists the contents of the current folder.

    One extremely useful Power User trick: after you type the name of a command, try pressing the Tab key. The system will try to auto-complete your command and will show you what you can do with it. For instance, typing cd (notice the blank space ater it) and pressing Tab will show you the names of the folders you could go to from the current one. Same goes for most other commands, actually. In time you’ll get accustomed to only starting typing your command, pressing Tab and letting the system complete the rest. For now, though, just take notice that it exists.

    The folder named / is called “root” and represents the root of your operating system. Every other folder is just one of its branches. Any user registered on the computer has its own personal folder, much like in Windows. Your personal folder is named after you and it’s a subfolder of the Users one. Go ahead, try it - cd Users followed by ls. Once you see the name of your username type cd username. A shortcut for this is cd ~ (on a MacBook with US keyboard, the little snake (tilda) is to be found near the ‘z’ key). Under your personal folder, you’ll find your usual subfolders, the ones you use everyday - Documents, Desktop, Movies, Pictures, etc. Go ahead, try to navigate by ‘cd’ there. Oh, and at any time, if you just want to go back to the parent folder, just type
    cd ..
    . Here .. is a command line word meaning “parent”. the root folder is it’s own parent.

    So far so good, though I probably didn’t impress you much. Let’s try this then:

  • open up any folder, file or program - once you open up Terminal, you just go in the folder that interests you by means of cd. Then, just type open followed by the name of the folder, file or program that you want to open. Magically, it will get opened with the associated program. For instance, let’s do this:
  • my_computer_name:/ Alex$ cd ~
    my_computer_name:~ Alex$ cd /Applications/
    my_computer_name:/Applications Alex$ open Utilities/

    What happened here is that I opened up the Utilities folder from within Applications by using just my magic Terminal skills. I could have opened any text document, picture, mp3, movie, application, etc. The open command rocks.

  • remove files without going to the Trash
  • You know the Trash, the place where things go after you delete them. The place you need to empty whenever you want to really erase something. Well, as any power user knows, if you really want to erase something you’ll have to do it yourself:
    Step 1. go to the file that you want to remove
    Step 2. make sure you got the rights to remove it (should be one of your files, from within your directories) and that you’re not really breaking anything(careful here, you don’t want to erase any of the system files, do you?)
    Step 3. call the command rm followed by the name of the file to be erased. rm is short for ReMove.

    Warning! If the name of the file you want to erase contains a space, then you’ll have to mention it by typing a ‘\’ character before the space. This looks complicated and it really is; using the ‘tab’ shortcut mentioned above might help you a bit in the process.

Did you succeed? Great! You didn’t? Don’t worry - using the Terminal is for pros, you’ll have time to catch on as we go into the next lessons.

Until then, let’s look back - in today’s lesson you’ve learned what Terminal is, how to start it, how to move around the system, look around, open up any things from within and, carefully, how to remove things. Next lesson will include tips on how to quickly move and erase entire folders, how to quickly learn your IP address(without going to the System Preferences app and more). Stay tuned and let us know what you think, by dropping a word in the comments!

Oh, and, if you’re impatient, there are lots of other resources around that will help you in the meantime. For instance, check this O’Reilly series of tutorials, this command list with descriptions over here or Apple’s description of the Terminal.app.

Related posts:
  • 3 tips you probably didn’t know on your Mac Book
  • Beginner’s guide to Apple Terminal, part 2
  • Forget the Apple Terminal, now you have Quicksilver
  • Usability on the Mac - tricks for Mobility Impaired Programmers
  • 7 geek tricks for a fresh OSX Tiger install
  • 1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
    Loading ... Loading ...

    Posted in osx, tips | RSS 2.0 comments feed | Go ahead and comment; Trackback.

    10 Responses to “Beginner’s guide to Apple Terminal, part 1”

    1. Gravatar Beginner’s guide to Apple Terminal, part 2 | tips | Hack the Day:
      June 12th, 2007 at 4:37 pm

      [...] Beginner’s guide to Apple Terminal, part 1 [...]

    2. Gravatar spencer:
      July 5th, 2007 at 3:04 pm

      Hey, great tutorial. I’ve been searching for a while “how to use Terminal” after switching over to Mac, and I stumbled upon your site. I’ll check out some of the other Terminal links you posted. Great intro for noobs like myself. I don’t know what I really intend on doing with Terminal but nice to show off like I know what Unix really is!

    3. Gravatar Alex:
      July 5th, 2007 at 6:02 pm

      Glad you found this tutorial useful, Spencer. There are plenty of uses for the Mac Terminal out there, and although it might look scary for the noob, Terminal is worth the effort to use.

    4. Gravatar 3 tips you probably didn't know on your Mac Book - Hack the Day:
      July 13th, 2007 at 10:06 am

      [...] do this you need the Terminal (if you’re a beginner, see our terminal tutorials first). You’ll first need to change directories to the USB drive location - all drives [...]

    5. Gravatar morc:
      July 16th, 2007 at 10:29 am

      Hello
      I couldnt get past the “cd/1s thing, i tried all different combos cd / 1s ,, cd/1s,, cd / ls,, it just says No such file or directory?? am i stupid ? brad new imac 20 inch 2 months old.
      thanks

    6. Gravatar Alex:
      July 16th, 2007 at 3:11 pm

      Morc, sorry if I wasn’t too clear. After each command shown in the tutorials, you have to press the Enter/Return key. So cd / and ls are not on the same line, they are two different commands to be executed at different moments.

    7. Gravatar morc:
      August 21st, 2007 at 3:33 pm

      Ah please forgive me for sounding so frustrated in that email, (quite embarrassing ) . Months have passed since then. i was just slime, a single celled life form drowning in a sea of code and text.
      I have now evolved limbs and and will soon walk upright on two legs.
      thnx for this page

    8. Gravatar morc:
      August 21st, 2007 at 3:36 pm

      P.S. my god only one month , where dose the time go ??

    9. Gravatar Nick:
      January 23rd, 2008 at 9:17 pm

      Nice beginners guide. It’s good to show people that the command line isn’t scary, but is a really useful tool. Because I run both Linux and OS X, The command line works itself into everything. You might want to explain more than file navigating though!

    10. Gravatar Alex:
      January 23rd, 2008 at 11:30 pm

      you might be interested in the other articles of the series..

    Leave a Reply

    •   Subscribe in one click and stay notified!

    • I use Dreamhost!

      use Dreamhost promo code discount BRIEPROMOCODE for 70$ off your bill

      Dreamhost huge discount
    • UserOnline

      • 4 Users Online
    • Recent Comments

      • Bleu Star on Alcohol drinking tips
      • Giovanni on Get rid of the MobileMe sync icon in Leopard’s menu bar
      • e-cigarette on Happiness is like a pair of sunglasses
      • Kfz Versicherung on 7 geek tricks for a fresh OSX Tiger install
      • Alex on Alcohol drinking tips
    • Recent Posts

      • Get rid of the MobileMe sync icon in Leopard’s menu bar
      • Happiness is like a pair of sunglasses
      • Create any kind of charts easily with Google Visualization API
      • DIY a Firefox Search Engine - Twitter People
      • Zen of debugging - remember the Seiza
      • HackTheDay - top 100 productivity blogs
      • Top 10 Firefox search engines
      • Usability on the Mac - tricks for Mobility Impaired Programmers
      • My question for 2008
      • 7 geek tricks for a fresh OSX Tiger install
      • How I applied the 4-hour workweek principles for the last 2 months. Part 1.
      • How to read 728 new feed articles in less than one second
      • Make up your mind. Faster!
      • Mobile Geeks use Mobile GMaps - now better than ever, despite threats from Google
      • Forget the Apple Terminal, now you have Quicksilver
    • Categories

      • beautiful life
      • brain
      • d-i-y
      • firefox
      • gtd
      • hack the day
      • inspirational
      • life hacks
      • links
      • linux
      • mac
      • osx
      • productivity
      • psychology
      • software
      • tips
      • win
    • Tags

      apple browsing charts debugging firefox google happiness launchers meditation mycroft online osx quicksilver search engine Seiza software spreadsheet step by step terminal thoughts tips tutorial Twitter Zen
    • Archives

      • October 2008
      • July 2008
      • May 2008
      • April 2008
      • March 2008
      • January 2008
      • November 2007
      • October 2007
      • September 2007
      • August 2007
      • July 2007
      • June 2007
      • May 2007
    • Add to Technorati Favorites

    Entries (RSS) and Comments (RSS).
    Copyright ©  2008 Hack the Day Powered by WordPress. Theme AlexCrunchLite by Alex Brie . net.