Main index

Introducing UNIX and Linux


Getting started

Overview
Using UNIX
      Usernames
      Logging in
Logging out
Commands
      Typing in commands
      Commands and options
Communication with other users
      Email
      Other communication facilities
Files
      The editor Vi
            Vi commands (command mode)
            Vi commands (colon mode)
      Other editors
Input and output
      Scripts
      Here-documents
      Pipes
      Making copies of input and output
      Pagers
Emergencies
Getting help
Summary
Exercises

Emergencies

What happens if you type in a command you realise you shouldn't have? It may be that UNIX will provide you with an error message indicating this; if, however, your command was a valid UNIX command that simply does something that is not what you intended, then the situation becomes more complex.

The worst-case scenario arises if your command runs and causes damage, such as deleting a file you did not wish to delete. In this case, you probably cannot recover from the error, and you quickly learn to be more careful in future! Fortunately, such mistakes are infrequent, as there are few commands that will destroy data. More common is the following: you write a program, try to run it, and find that either it hangs (it sits there apparently doing nothing) or begins to generate incorrect results. You know something has gone wrong. The remedy is to interrupt the command, which can be done by typing ctrl-C, and will cause the command to terminate immediately. This is not the same as ctrl-D, which simply indicates to the system that the standard input stream has been closed. Try this out - there should be a file called /usr/dict/words on your machine; try to display it on your screen using cat. It's a very big file, and will take perhaps a minute to fully appear, so you will have ample time to press ctrl-C.

The file /usr/dict/words simply contains a list of English words and abbreviations, one on each line. If your system does not have such a file, create a similar file yourself using Vi, since /usr/dict/words is used for several examples later on. If you name this new file mydictionary, then you should substitute mydictionary whenever /usr/dict/words is mentioned in subsequent chapters. To indicate the words that might occur in the file, the following is a typical section of /usr/dict/words:

O'Donnell
odorous
O'Dwyer
Odysseus
Odyssey
o'er
oersted
of
off
offal

Note, however, that neither ctrl-C nor ctrl-D will get you out of Vi.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck