Introduction to OS X command line

Mac users are not normally known for their command-line prowess, Mac OS 9 and below famously had no built-in shell access at all. Mac OS X is built on a BSD foundation, and as such is possible to be a formidable platform for command-line warriors.

Of course another option is to install a full GNU/Linux/BSD system alongside or over Mac OS X. This is what I do but we will save that option for another time.

Older versions of Mac OS X came with the C Shell. Mac OS X 10.4 comes with a version of Bash, the undisputed king of the command-line shells.

If you are a Mac user then this may be your first exposure to the command-line. Don't worry, I will hold your hand and provide the odd screenshot to help you get going.

Not every Mac user will know there is a command-line available. In this first post we will look at the simple matter of getting shell access.

Finding the xterm

Mac OS X is provided with an 'xterm' a way to access the shell within a normal graphical user interface window.

  1. Open the 'Finder' (click on it), it is in your dock and looks like the picture below:

    http://www.commandline.org.uk/images/posts/macosx/1.png
  2. Click on 'Applications':

    http://www.commandline.org.uk/images/posts/macosx/2.png
  3. Double-click on Utilities:

    http://www.commandline.org.uk/images/posts/macosx/3.png
  4. Click on the 'Terminal' icon:

    http://www.commandline.org.uk/images/posts/macosx/4.png

Now the xterm opens and appears in your 'Dock', as shown below:

http://www.commandline.org.uk/images/posts/macosx/5.png

You should now hold the mouse button down on the Terminal icon in the Dock and select 'Keep in dock'.

You can now access an xterm whenever you need the command line while using OS X. The more you learn how to use it, the more you will want to use it. You can now read all the posts in this blog and have a go at them.

Finding the full console

A little xterm is one thing. There may come a time where you want to access the full-screen console.

You will need to know your Mac OS X username and password for this step, if you have lost them then go through the normal Mac documentation to find out how to recover them. even for fairly basic Mac OS X usage you need to know your username and password.

For accessing the Mac OS X full-screen console, you need to undertake one little configuration task first.

  1. Click on the 'System Preferences' icon in your dock:

    http://www.commandline.org.uk/images/posts/macosx/6.png
  2. Click on accounts:

    http://www.commandline.org.uk/images/posts/macosx/7.png
  3. Click on the little padlock (shown below) to unlock the preferences window, you will need to enter your username and password at this point.

    http://www.commandline.org.uk/images/posts/macosx/8.png
  4. Click on login options:

    http://www.commandline.org.uk/images/posts/macosx/9.png
  5. Under 'Display login window as:', change the ticked box to 'Name and password', as in the image below:

    http://www.commandline.org.uk/images/posts/macosx/10.png
  6. This step is optional, but will make your life easier and increase the physical security of your Mac. Turn off automatic logon but untick the box labelled 'Automatically log in as ...', as shows in the image below:

    http://www.commandline.org.uk/images/posts/macosx/11.png

Now when you turn on your Mac, you have a choice of logging on to the Aqua interface or the full console. Unauthorised users of your computer will now not be able to access anything.

  1. Log out. To do this press shift, command and Q (all at the same time), or press the Apple logo and then "Log Out John" (if your name is John).
  2. You will now be presented with the log on screen. Type the following into the username box:

>console

That is the less than symbol< followed by 'console'. Press Enter.

  1. You now can see a typical Bash login box, type your username and press enter, then type your password followed by the enter key.

You will now have a full-screen GNU/BSD/Darwin environment and you have now entered the world of command-line computing, you have made your first few steps towards becoming a true Command Line Warrior.

Try typing things and pressing Enter. A good last thing to try is 'logout' - this is the command to finish your console session.

One thought on “Introduction to OS X command line”

  1. <p>You've got ahold of a &quot;less-than&quot; symbol instead of &quot;greater-than&quot; to get to
    the console:</p>
    <p>A greater-than B
    A &gt; B</p>

How about Global Thermonuclear War? Wouldn't you prefer a good game of chess? Powered by zpress