Sams Teach Yourself Unix In 24 Hours

Transcription

Dave TaylorUnix24HoursinFIFTH EDITION

Sams Teach Yourself Unix in 24 Hours, Fifth EdtionCopyright 2016 by Pearson Education, Inc.All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, ortransmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, withoutwritten permission from the publisher. No patent liability is assumed with respect to the use ofthe information contained herein. Although every precaution has been taken in the preparation ofthis book, the publisher and author assume no responsibility for errors or omissions. Nor is anyliability assumed for damages resulting from the use of the information contained herein.ISBN-13: 978-0-672-33730-7ISBN-10: 0-672-33730-4Library of Congress Control Number: 2015913255Printed in the United States of AmericaFirst Printing October 2015TrademarksAll terms mentioned in this book that are known to be trademarks or service marks have beenappropriately capitalized. Sams Publishing cannot attest to the accuracy of this information.Use of a term in this book should not be regarded as affecting the validity of any trademark orservice mark.Warning and DisclaimerEvery effort has been made to make this book as complete and as accurate as possible, but nowarranty or fitness is implied. The information provided is on an “as is” basis. The author andthe publisher shall have neither liability nor responsibility to any person or entity with respect toany loss or damages arising from the information contained in this book.Special SalesFor information about buying this title in bulk quantities, or for special sales opportunities (whichmay include electronic versions; custom cover designs; and content particular to your business,training goals, marketing focus, or branding interests), please contact our corporate salesdepartment at corpsales@pearsoned.com or (800) 382-3419.For government sales inquiries, please contact governmentsales@pearsoned.com.For questions about sales outside the U.S., please contact international@pearsoned.com.Acquisitions EditorMark TaberManaging EditorSandra SchroederSenior ProjectEditorTonya SimpsonCopy EditorKitty WilsonIndexerWordWisePublishingServices, LLCProofreaderLaura HernandezTechnical EditorsSiddhartha SinghBrian TiemannEditorial AssistantVanessa EvansCover DesignerMark ShirarCompositorcodeMantra

Contents at a GlanceIntroduction . 1HOUR 1 What Is This Unix Stuff? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Getting onto the System and Using the Command Line . . . . . . . . . . . . . . . . . . . . 233 Moving About the File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 Listing Files and Managing Disk Usage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595 Ownership and Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 836 Creating, Moving, Renaming, and Deleting Files and Directories . . . . . 1077 Looking into Files.1238 Filters, Pipes, and Wildcards!. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1419 Slicing and Dicing Command-Pipe Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16310 An Introduction to the vi Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17711 Advanced vi Tricks, Tools, and Techniques. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20912 An Overview of the emacs Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24113 Introduction to Command Shells. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26314 Advanced Shell Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27915 Job Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29516 Shell Programming Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31317 Advanced Shell Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33318 Printing in the Unix Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34719 Archives and Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36520 Using Email to Communicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38521 Connecting to Remote Systems Using SSH and SFTP . . . . . . . . . . . . . . . . . . . . . . . . 40322 Searching for Information and Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41523 Perl Programming in Unix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42724 GNOME and the GUI Environment. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441AppendixA Common Unix Questions and Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

Table of ContentsIntroduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1HOUR 1: What Is This Unix Stuff?What Is Unix?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3A Brief History of Unix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9What’s All This About Multiuser Systems? .Cracking Open the ShellGetting Help .5HOUR 2: Getting onto the System and Using the Command LineBeginning Your Session . . . . . . . . . . .23. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23. . . . . . . . . . . . . . . . . . . . . . . . . . .30. . . . . . . . . . . . . . . . . . . . . . . . . . . . .39Seeing What’s Going On Around You .HOUR 3: Moving About the File System .What a Hierarchical File System Is All AboutDirectory Separator Characters . . . . . . . . . . . . . . . . . . . . . .39. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45. . . . . . . . . . . . .47. . . . . . . . . . . . . . . . . . . . . . .59. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .60The Difference Between Relative and Absolute Filenames .HOUR 4: Listing Files and Managing Disk UsageThe ls Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70Special ls Command FlagsPermissions StringsHOUR 5: Ownership and PermissionsWorking with File Permissions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83HOUR 6: Creating, Moving, Renaming, and Deleting Files and Directories . . .107. . . . . . . . . . . . . . . . . . . . . . . . . . . .107. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123Manipulating the Unix File System .HOUR 7: Looking into Files .Looking Inside Files .HOUR 8: Filters, Pipes, and Wildcards!Maximizing the Command Line. . . . . . . . . . . . . . . . . . . . . . . . . . . . .141. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142

Table of ContentsHOUR 9: Slicing and Dicing Command-Pipe Data . . . . . . . . . . . . . . . . . . . . .163. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169The awk Programming System .How to Use cut in PipesInline Editing with sed and tr. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .HOUR 10: An Introduction to the vi EditorEditing the Unix Way171. . . . . . . . . . . . . . . . . . . . . . . . . .177. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178HOUR 11: Advanced vi Tricks, Tools, and TechniquesAdvanced Editing with vi . . . . . . . . . . . . . . . . .Summary of vi Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209238. . . . . . . . . . . . . . . . . . . . . . . . .241. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242HOUR 12: An Overview of the emacs Editor.The Other Popular Editor: emacsHOUR 13: Introduction to Command ShellsThe (Command) Shell Game. . . . . . . . . . . . . . . . . . . . . . . . . .263. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .263HOUR 14: Advanced Shell Interaction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .280. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295Which Shell Is Which?.HOUR 15: Job Control .vWrestling with Your Jobs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .HOUR 16: Shell Programming Overview .Building Your Own Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . .313. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .314HOUR 17: Advanced Shell Programming. . . . . . . . . . . . . . . . . . . . . . . . . . . .Searching a Database of Filenames with mylocate .334. . . . . . . . . . . . . . . . . . . . . . . . . .347. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .348HOUR 19: Archives and Backups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .The tar Tape Archive Utility .The zip Archive Utility333. . . . . . . . . . . . . . . .HOUR 18: Printing in the Unix EnvironmentMaking a Printed Copy295365. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372Shrinking Your Files with compress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .379Exploring the Unix Tape Command: cpioPersonal Backup Solutions .375Working with Linux Package Managers. . . . . . . . . . . . . . . . . . . . . . . . .381

viSams Teach Yourself Unix in 24 HoursHOUR 20: Using Email to CommunicateInteracting with the World . . . . . . . . . . . . . . . . . . . . . . . . . . . .385. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386HOUR 21: Connecting to Remote Systems Using SSH and SFTP .Stepping Beyond Your Own System. . . . . . . . . .403. . . . . . . . . . . . . . . . . . . . . . . . . . . .403HOUR 22: Searching for Information and Files .Finding What’s Where . . . . . . . . . . . . . . . . . . . . . . .415. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415HOUR 23: Perl Programming in Unix .Flexible and Powerful: Perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .428HOUR 24: GNOME and the GUI EnvironmentTweaking Your Inner GNOME. . . . . . . . . . . . . . . . . . . . . . . . .441. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .442Working with GNOME Applications . . . . . . . . . . . . . . . . . . . . . . . . . . .APPENDIX A: Common Unix Questions and Answers. . . . . . . . . . . . . . . . . . .How do I use find xargs with filenames that contain spaces? .How do I find large files on my system?455. . . . . . . . . . . . . . . . . . . . . . . . .456. . . . . . . . . . . . . . . . . . . . . . . .457. . . . . . . . . . . . . . . . . . . . . . . . . .458. . . . . . . . . . . . . . . .458. . . . . . . . . . . . . . . . . . . . . . . . . .458How do I list files that don’t match a given pattern?How do I view lines X–Y in a text file?. . . . . . . . . . . . . . . . . . . . . .459. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .459How do I add a new directory to my PATH? .How do I recover deleted files?455. . . . . . . .How do I run a program on a schedule? .How do I fix file permission problems?445. . . . . . .460. . . . . . . . . . . . . . . .460How can I set my shell to protect me from accidental deletions? .What do the shell errors arg list too long andbroken pipe mean? . . . . . . . . . . . . . . . . . . . . . .Why use ssh instead of telnet? Or sftp instead of ftp? . . . . . . . . . . .461Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463

About the AuthorDave Taylor is president of Intuitive Systems, LLC, a consulting firm focused on onlinecommunications and marketing strategies. Founder of four Internet startups, he has beeninvolved with Unix and the Internet since 1980, having created the popular Elm MailSystem and Embot mail autoresponder. A prolific author, he has been published more than1,000 times, and his most recent books include the best-selling Wicked Cool Shell Scripts andLearning Unix for Mac OS X.A popular columnist for Linux Journal, he also writes a tech Q&A column for the BoulderColorado Daily Camera newspaper. Previously, he was a research scientist at HP Palo AltoLaboratories. He has contributed software to the 4.4 release of Berkeley Unix (BSD), and hisprograms are found in all versions of Linux and other popular Unix variants.Dave has a bachelor’s degree in computer science (University of California at San Diego), amaster’s degree in educational computing (Purdue University), and an MBA (University ofBaltimore), and he is a top-rated public speaker who frequently offers workshops on onlinemarketing, blogging, and various technical topics. His official home page on the Web ishttp://www.DaveTaylorOnline.com, and his email address is d1taylor@gmail.com.Dave also maintains three weblogs online, Ask Dave Taylor (at www.askdavetaylor.com),where he fields questions from readers on a wide variety of topics; GoFatherhood (atwww.GoFatherhood.com), where he talks about the challenges and joys of parenting; andDave On Film (www.DaveOnFilm.com), where he shares his reviews of the latest movies.You’re invited to get involved at all three!

DedicationTo the lights of my life: Ashley, Gareth, and Kiana.AcknowledgmentsHowever you slice it, you can’t write a book locked in a cave (even if there’s a high-speedInternet connection and fancy computer therein), and this book has evolved over many,many years, starting its life as an Interactive Unix tutorial I was writing for Sun Microsystems.In the interim, a number of people have added their spices to the stew, most notably myco-author for the first and second editions of Teach Yourself Unix in 24 Hours, James C.Armstrong, Jr.In this new fifth edition, I’ve been delighted by the cooperative and talented team at SamsPublishing, again, and would like to specifically thank Mark Taber and Tonya Simpson,and my tech editors Brian Tiemann and Siddhartha Singh for all their ideas and commentary on how to make this book really superb. Any technical errors remaining are my ownresponsibility.Finally, I would like to acknowledge and thank my kids for letting me focus on updatingthis book, chapter by chapter, even when there were games and other activities that couldhave proven more fun. I wouldn’t trade them in, even for a 1THz PC! :-)

We Want to Hear from You!As the reader of this book, you are our most important critic and commentator. We valueyour opinion and want to know what we’re doing right, what we could do better, whatareas you’d like to see us publish in, and any other words of wisdom you’re willing to passour way.We welcome your comments. You can email or write to let us know what you did or didn’tlike about this book—as well as what we can do to make our books better.Please note that we cannot help you with technical problems related to the topic of this book.When you write, please be sure to include this book’s title and author as well as your nameand email address. We will carefully review your comments and share them with the authorand editors who worked on the book.Email:feedback@samspublishing.comMail:Sams Publishing800 East 96th StreetIndianapolis, IN 46240 USAReader ServicesVisit our website and register this book at informit.com/register for convenient access to anyupdates, downloads, or errata that might be available for this book.

This page intentionally left blank

IntroductionWelcome to the fifth edition of Sams Teach Yourself Unix in 24 Hours! This book has been designedto be helpful as a guide as well as a tutorial for both beginning users and those with previousUnix or Linux experience. The reader of this book is assumed to be intelligent, but no familiaritywith Unix is expected or required.Does Each Chapter Take an Hour?You can learn the concepts in each of the 24 lessons in one hour. If you want to experimentwith what you learn in each lesson, you might take longer than an hour. However, all theconcepts presented here are straightforward. If you are familiar with Windows applications orthe Macintosh, you will be able to progress more quickly through the lessons.What if I Take Longer Than 24 Hours?Since the publication of the first edition of this book, I’ve received a considerable amount ofpraise and positive feedback, but the one message that has always been a surprise is “I finishedyour book, but it took me a lot longer than 24 hours.” Now you can read here, directly fromthe author: That’s okay! Take your time and make sure you try everything as you go along.Learning and remembering are more important than speed. And if you do finish it all in24 hours, let me know!How to Use This BookThis book is designed to teach you topics in one-hour lessons. All the books in the Sams TeachYourself series enable you to start working and become productive with a topic as quickly aspossible. This book will do that for you!Each hour, or lesson, starts with an overview of the topic to inform you of what to expect inthat lesson. The overview helps you determine the nature of the lesson and whether the lessonis relevant to your needs.

2IntroductionMain SectionEach lesson has a main section that discusses the lesson topic in a clear, concise manner bybreaking the topic down into logical components and explaining each component clearly.Interspersed throughout each lesson are special elements, called tips, notes, and cautions, whichprovide additional information.NOTENotes are designed to clarify the concept that is being discussed or elaborate on the subject. If youare comfortable with your understanding of the subject, you can bypass them without danger.TIPTips inform you of tricks or elements that are easily missed by most computer users. You can skipthem, but often tips show you an easier way to do a task.CAUTIONA caution deserves at least as much attention as a tip because cautions point out problematicelements of the topic being discussed. Ignoring the information contained in a caution could haveadverse effects on the task at hand. These are the most important special elements in this book.TasksThis book offers another special element called tasks. These step-by-step exercises are designed towalk you quickly through the most important skills you can learn in Unix.WorkshopsThe Workshop section at the end of each lesson provides lists of key terms and exercises thatreinforce concepts you learned in the lesson and help you apply them in new situations. You canskip the Workshop section, but we recommend that you go through the exercises to see how theconcepts can be applied to other common tasks. The key terms also are compiled in one alphabetized list in the Glossary at the end of the book.

This page intentionally left blank

HOUR 2Getting onto the System andUsing the Command LineGoals for This HourIn this hour, you will learnXHow to log in to and log out of the systemXHow to change your password with the passwd commandXAbout choosing a memorable and secure passwordXHow to find out who the computer thinks you areXHow to find out who else is on the systemXHow to find out what everyone is doing on the systemXAbout checking the current date and timeIn this second Unix lesson, it’s time for you to log in to the system and try some commands. Thishour focuses on learning the basics of interacting with your Unix machine.This hour introduces many commands, so it’s very important that you have a Unix system available on which you can work through all the examples. Most examples have been taken froma PC running Solaris 11, a variant of Unix System V Release 4, and have been double-checkedon both a BSD-based system and a Mac OS X command line. Any variance between the threeis noted. If you have a Unix system available, odds are good that it’s based on either AT&TSystem V or Berkeley Unix.Beginning Your SessionBefore you can start interacting with the Unix command shell of your choice, you need to learnhow to log in to your account. The good news is that it’s easy! Let’s have a look.Task 2.1: Logging In to and Out of the SystemBecause Unix is a multiuser system, user authentication is always enforced: You always need toprovide credentials (generally a username and a password) to the system so that it knows whoyou are. Some modern user-friendly flavors of Unix (such as Mac OS X) allow you to bypass this

24HOUR 2: Getting onto the System and Using the Command Linerequirement by always booting into a single user’s desktop session, but this is just a conveniencefeature; under the hood, all Unix flavors are the same, and all require that you authenticateyourself at some stage of the process.Old-school hardware terminals do still exist, or you might choose to boot a Linux or FreeBSD boxdirectly to the textual console; but if you’re new to Unix, you’ll most likely need an applicationknown as a terminal to access the command line. Most graphical operating systems include one.I use the Terminal app included with Mac OS X (in the Utilities folder) whether I’m accessing mylocal system or just opening an environment in which to connect to a remote system via ssh.TIPMost Linux flavors have a prominently available terminal program for your use; on a Windows PC,your best bet is the freeware program PuTTY, available at http://www.putty.org.If you need to actually log in, the first thing you’ll see on the screen will look something like this:GNU/Linux ado.aplonis.net 5:38pm on Tue, 8 Jul 2014login:The first line of this challenge prompt indicates what variant of Unix the system is running(GNU/Linux in this case), the hostname of the computer system, and the current time and date.The second line asks for your login, also known as your username or account name.NOTEIf you connect to a Unix server via the network, using either telnet or ssh, you’ll see the samelogin prompt, though I strongly recommend that you always use ssh for security reasons. If you usea terminal program within a graphical environment, you won’t need to log in because you’ve alreadylogged in to your GUI session.1. Know your account name. It would be nice if computers could keep track of users by simply using full names so that I could enter Dave Taylor at the login prompt. Alas, likethe Internal Revenue Service, the Department of Motor Vehicles, and many other agencies,Unix does not use names but instead assigns each user a unique identifier. This identifier,called an account name, has eight characters or fewer and is usually based on the user’sfirst or last name, although it can be any combination of letters and numbers. I have twoaccount names, or logins, on the systems I use: taylor and, on another machine wheresomeone already had that account name, d1taylor.2. Know your password. Perhaps your account name is on a piece of paper with your initialpassword, both assigned by the Unix system administrator. If you do not have this information, you need to track it down before you can go further. Some accounts might nothave an initial password; in that case, you won’t have to enter one the first time you log in

Beginning Your Session25to the system. If that’s the case, create a password for your own security. In a few minutes,you will learn how you can give yourself the password of your choice by using the Unixcommand passwd.Note that a lot of systems are accessible only through the ssh function, and so a commonway to connect to a modern system is to open up a local terminal app on your Mac or PCand type in something like: ssh taylor@intuitive.comwhere taylor is the account name and intuitive.com is the name of the remote host.If that’s how you need to access your Unix system remotely, it’s actually easier than usingthe login/password sequence; you just need to make extra sure that you type in everythingexactly as prompted.3. At the login prompt, enter your account name if needed:login: taylorPassword:Be particularly careful to use exactly what your administrator tells you to use (for example, theaccounts taylor, Taylor, and TAYLOR are all different to Unix). After you’ve enteredyour account name, the system moves the cursor to the next line and prompts you for yourpassword. If you’re using the ssh sequence, then the prompt will include your accountname, as shown here:taylor@intuitive.com's password:Either way, when you enter your password, the system won’t echo it (that is, won’t displayit) on the screen. That’s okay. Lack of an echo doesn’t mean anything is broken; instead,this is a security measure to ensure that even if people are looking over your shoulder, theycan’t learn your secret password by watching your screen. Be certain to type your passwordcorrectly because you won’t see what you’ve typed and have a chance to correct it.NOTEIf you enter either your login or your password incorrectly, the system complains with an errormessage:login: taylorPassword:Login incorrectlogin:Most systems give you three or four attempts to get both your login and password correct, so tryagain. Don’t forget to enter your account name at the login prompt each time, as required. Be careful, though: Too many failed login attempts, and you might lock out your account and have to contactthe administrator for help.

26HOUR 2: Getting onto the System and Using the Command Line4. After you’ve successfully entered your account name and password, you are shown someinformation about the system, some news for users, perhaps a fortune, and an indicationof whether you have electronic mail. The specifics will vary, but here’s an example of whatI see when I log in to my account:login: taylorPassword:Last login: Thu Jul 7 17:00:23 on ttyAeYou have mail. NOTEThe dollar sign prompt is Unix’s way of telling you that it’s ready for you to enter some commands.It is the equivalent of a soldier saluting and saying, “Ready for duty!” or an employee saying, “Whatshall I do now, boss?”Your system might be configured so that you have a slightly different prompt here. Thepossibilities include a % for the C shell, your current location in the file system, the currenttime, the command-index number (which you’ll learn about when you learn how to teachthe Unix command-line interpreter to adapt to your work style rather than vice versa), andthe name of the computer system itself. Here are some examples:[/users/taylor] :(mentor) 33 :taylor@mentor %Your prompt might not look exactly like any of these, but you know you’re looking at aprompt because it’s at the beginning of the line on which your cursor sits, and it reappearseach time you’ve completed working with any Unix program. That’s how you know theprogram has completed its task.5. At this point, you’re ready to enter your first Unix command, exit, to sign off from thecomputer system. Try it. On my system, entering exit shuts down all my programs andquits the terminal app. On other systems, it returns you to the login prompt. Many Unixsystems offer a pithy quote as you leave, too.% exitHe who hesitates is lost.login:NOTEYou might be able to end your session by pressing Ctrl-D. Some shells will catch this and promptyou to determine whether you want to end your session; others will exit. Ctrl-D is actually an end-offile character; it may be different on your system.

Beginning Your Session276. If you have a direct connection to the computer because you’re using a shared system in acomputer center, library, or similar, odds are very good that logging out causes the systemto prompt for another account name, enabling the next person to use the system. If youmanually connected to the system via the Internet, you probably will see something morelike the following example. After being disconnected from the remote system, you’ll thenbe able to safely shut down your local computer:% exitDid you lose your keys again?Connection to 154.23.11.

Unix or Linux experience. The reader of this book is assumed to be intelligent, but no familiarity with Unix is expected or required. Does Each Chapter Take an Hour? You can learn the concepts in each of the 24 lessons in one hour. If you want to experiment with what you learn in each les