Introducing the Shell


The UNIX shell is the command-line interface between the user and the operating system kernel, which is the process-executing core of the operating system. If you have worked with MS-DOS, you can think of the shell as being similar to the DOS prompt, where you type commands to work with your files and the data in them. In a looser sense, you could also think of the Windows or Macintosh desktops as being shells, because even though they're a lot more flashy and specialized than the command-line interfaces they replaced, they fulfill the same purpose to you as a user: they interpret your commands and communicate them to the operating system's kernel. The shell acts as a translator, rendering human language into machine language that the kernel can understand. The shell also translates machine language from the kernel into language that humans can understand. When you log in to FreeBSD, a shell program is executed on your behalf, and when you type commands you're actually working within that shell program. Without a shell, you wouldn't even be able to type anything.

The terminology of the "shell" and "kernel" describe a metaphor for the operating system in which the innermost functions of software, which are the only ones capable of accessing the computer's hardware, are protected from interference by users who might potentially execute unsafe code. These users are thought of as existing in an "outer" layer, further away from the hardware than the kernel, and this separation is deepened in UNIX by having users run with a lower level of permissions (see Chapter 13, "User, Groups, and Permissions") than the kernel. The shell is the interface between these two discrete layers of the operating system, the shield around the sensitive core of the "nut" that is FreeBSD. Its job is to give youthe usera safe, structured way to access the kernel and the hardware devices it controls. As a command interpreter, the shell takes your commands and translates them into processes that access files and devices through the kernel. It should prevent you from executing unsafe code that could crash the kernel, and it helps you find and execute the programs that run the system.

Figure 8.1 shows the relationship between the system hardware, the kernel, the shell, and the user.

Figure 8.1. The relationship between the hardware, kernel, shell, and user.


You learn about the role of the kernel in detail in Chapter 18, "Kernel Configuration." For now, simply be aware that the kernel is a special piece of software that controls and regulates all the interactions of other software (and the actions of users) with the computer's hardware. Normally, you do not need to concern yourself with the kernel because it is transparent to the user, does its job in the background, and is "out of sight, out of mind."

In UNIX, the term shell refers almost exclusively to command-line interface (CLI) shells, which hardly look like software programs at all: all you see, when you're working with a shell, is a prompt and the text you type (and the output of the programs you run). The shell itself is so minimal in appearance that it's difficult to tell at a glance what makes one shell different from another. This chapter, however, will demonstrate how important some of those subtle differences can be.




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net