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.

After log<strong>in</strong> receives your username and password, it looks through the file /etc/passwd for an entry<br />

match<strong>in</strong>g the <strong>in</strong>formation you provided. If it f<strong>in</strong>ds a match, log<strong>in</strong> executes a shell and exits.<br />

As an example, on my system the match<strong>in</strong>g entry for my username, ranga, <strong>in</strong> file /etc/passwd is:<br />

ranga:x:500:100:Sriranga Veeraraghavan:/home/ranga:/b<strong>in</strong>/bash<br />

As you progress through the book, I will expla<strong>in</strong> the <strong>in</strong>formation stored here.<br />

Note - For those readers who are not familiar with UNIX files or filenames such as /etc/passwd, this<br />

topic is covered extensively <strong>in</strong> Chapters 3, "Work<strong>in</strong>g with Files," and 4, "Work<strong>in</strong>g with Directories."<br />

I will discuss files briefly <strong>in</strong> this chapter. A general idea from other operat<strong>in</strong>g systems of what files are is<br />

enough to understand these examples.<br />

If no match is found, the log<strong>in</strong> program issues an error message and exits. At this po<strong>in</strong>t the getty<br />

program takes over and displays a new log<strong>in</strong> prompt.<br />

The shell that log<strong>in</strong> executes is specified <strong>in</strong> the file /etc/passwd. Usually this is one of the shells that I<br />

covered <strong>in</strong> the previous chapter.<br />

In this book I assume that the shell started by the log<strong>in</strong> program is /b<strong>in</strong>/sh. Depend<strong>in</strong>g on the version of<br />

UNIX you are runn<strong>in</strong>g, this might or might not be the Bourne shell:<br />

● On Solaris and FreeBSD, it is the Bourne shell.<br />

● On HP-UX, it is the POSIX shell.<br />

● On L<strong>in</strong>ux, it is the Bourne Aga<strong>in</strong> shell.<br />

<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 />

© <strong>Copyright</strong> Macmillan Computer Publish<strong>in</strong>g. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!