Mac Os X 10.4 Tiger (Visual Quickstart Guides)

Terminal, the Shell, & Console

In the Utilities folder (Figure 1) inside the Applications folder is a utility called Terminal (Figure 2). This application is your window into the Unix world lurking deep inside Mac OS X. If you're old enough, you may remember using big, clunky video terminals to communicate with large mainframes. Terminal mimics the operation of those CRT terminals, but it uses your computer's screen, keyboard, and CPU instead of dumb-terminal hardware.

Figure 1. The contents of the Utilities folder includes applications for working with Unix.

Figure 2. A Terminal window with a shell prompt.

When you run Terminal, it connects to a communication process inside your Mac called a shell. The shell is a program that interprets human actions such as the typing of commands and the starting and stopping of jobs. It passes these requests to the computer and is responsible for sending the results of your actions to the Terminal window.

Each shell has its own set of features. The default shell that Mac OS X assigns to new accounts is called bash, which stands for Bourne-Again SHell (don't ask; there are far too many Unix in-jokes to deal with in this book). This is a change from Mac OS X 10.2 (Jaguar), which assigned tcsh (pronounced "t-shell") as the default shell.

Religious wars have been fought over which shell is best and the debate is certainly beyond the scope of this book. bash is a derivative of the bourne shell and tcsh is a derivative of the csh (c-shell). The bash shell is a powerful shell that includes many enhancements, some of which were borrowed from csh, such as a command line editor, file-name completion, and a command history. bash also contains a script command processor that allows you to build interactive programs and preprogrammed command series, similar to what you can do with AppleScript.

The Terminal application and the shell work together, allowing you to communicate with and control your computer. But they are separate entities. Terminal is responsible for accepting commands and displaying results, and the shell is responsible for interpreting and executing commands. You can use Terminal to talk to a variety of shells. You can open as many Terminal windows as you needthey each work independently.

Mac OS X also includes a utility called Console (Figure 3), which is an application that displays system messages. Keeping the console.log window open and watching it can tell you a lot about what's happening on your system.

Figure 3. The console.log window displays system messages.

Tips

  • bash is an extended version of the standard sh, or "bourne-shell," that's part of Unix. You can get more information about bash by typing man bash at the shell prompt. (More on the man command later.)

  • If you are debugging programs, use Console to view error messages.

To launch Terminal

Double-click the Terminal icon in the Utilities folder (Figure 1) inside the Applications folder. A Terminal window with a shell prompt appears (Figure 2).

Tip

  • The shell prompt shown in Figure 2 ([eMac:~] ronh$) includes the following components:

    • Computer name is the name of the computer you're logged into.

    • Directory is the current directory. ~ (the tilde character) is Unix shorthand for your home directory.

    • User name is your user name, which, in this example, is ronh.

To launch Console

Double-click the Console icon in the Utilities folder (Figure 1) inside the Applications folder. The console.log window appears (Figure 3).

Tip

  • Console is discussed in a bit more detail in Chapter 22.

Категории