25.03.2013 Views

Copyright Sams Teach Yourself Shell Programming in 24 Hours

Copyright Sams Teach Yourself Shell Programming in 24 Hours

Copyright Sams Teach Yourself Shell Programming in 24 Hours

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Sams</strong> <strong>Teach</strong> <strong>Yourself</strong> <strong>Shell</strong> <strong>Programm<strong>in</strong>g</strong> <strong>in</strong> <strong>24</strong> <strong>Hours</strong> Contents Index<br />

Hour 2: Script Basics<br />

Sections <strong>in</strong> this Chapter:<br />

Previous Chapter Next Chapter<br />

The UNIX System Summary<br />

<strong>Shell</strong> Initialization Questions<br />

Gett<strong>in</strong>g Help Terms<br />

Previous Section Next Section<br />

Hour 2<br />

Script Basics<br />

In Chapter 1, "<strong>Shell</strong> Basics," I <strong>in</strong>troduced the concept of a shell and commands. I showed you how the shell<br />

reads your <strong>in</strong>put and executes the command you requested.<br />

In this chapter I will expla<strong>in</strong> <strong>in</strong> detail what the shell is and how it works. You will learn how the shell is started<br />

dur<strong>in</strong>g the log<strong>in</strong> process and what happens when you log out.<br />

After I expla<strong>in</strong> this behavior, I will show you how to group commands that are normally executed <strong>in</strong>teractively<br />

<strong>in</strong>to a file to create a script. Scripts are the power beh<strong>in</strong>d the shell because they enable you to group<br />

commands together to create new commands.<br />

The UNIX System<br />

Logg<strong>in</strong>g In<br />

The UNIX system consists of two components:<br />

● Utilities<br />

● The kernel<br />

Utilities are programs you can run or execute. The programs who and date that you saw <strong>in</strong> the<br />

previous chapter are examples of utilities. Almost every program that you know is considered a utility.<br />

Commands are slightly different than utilities. The term utility refers to the name of a program,<br />

whereas the term command refers to the program and any arguments you specify to that program to change<br />

its behavior. You might see the term command used <strong>in</strong>stead of the term utility for simple commands, where<br />

only the program name to execute is given.<br />

The kernel is the heart of the UNIX system. It provides utilities with a means of access<strong>in</strong>g a mach<strong>in</strong>e's<br />

hardware. It also handles the schedul<strong>in</strong>g and execution of commands.<br />

When a mach<strong>in</strong>e is turned off, both the kernel and the utilities are stored on the mach<strong>in</strong>e's hard disks. But<br />

when the computer is booted, the kernel is loaded from disk <strong>in</strong>to memory. The kernel rema<strong>in</strong>s <strong>in</strong> memory<br />

until the mach<strong>in</strong>e is turned off.<br />

Utilities, on the other hand, are stored on disk and loaded <strong>in</strong>to memory only when they are executed. For

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!