--- unixref.mm	2001/12/22 07:56:23	4.1
+++ unixref.mm	2003/04/02 06:41:29
@@ -1,19 +1,22 @@
 .\" This file is in -*- nroff-fill -*- mode
-.\" STATUS: draft 4th edition
-.\" $Id: unixref.mm,v 4.1 2001/12/22 07:56:23 grog Exp $
+.\" STATUS: 4th edition
+.\" $Id: unixref.mm,v 4.16 2003/04/02 06:41:29 grog Exp $
 .\"
-.Chapter \*[nchunixref] "Making friends with FreeBSD"
+.Chapter \*[nchunixref] "The tools of the trade"
 So now you have installed FreeBSD, and it successfully boots from the hard disk.
-Your first encounter with FreeBSD can be rather puzzling.  Sure, you didn't
-expect to see the same things you know from Microsoft platforms, but you might
-not have expected what you see either:
+If you're new to FreeBSD, your first encounter with it can be rather puzzling.
+You probably didn't expect to see the same things you know from other platforms,
+but you might not have expected what you see either:
 .Pn login-prompt
 .Dx
    FreeBSD (freebie.example.org) (ttyv0)
 
 login:
 .De
-Where do you go from here?  This chapter tells you.
+If you have installed
+.Daemon xdm ,
+you'll at least get a graphical display, but it still asks you to log in and
+provide a password.  Where do you go from here?
 .P
 .X "Abrahams, Paul W."
 .X "Larson,  Bruce R."
@@ -24,98 +27,876 @@
 .X "Snyder, Garth"
 .X "Seebass, Scott"
 .X "Hein, Trent R."
-FreeBSD is a very powerful operating system, but power doesn't come without a
-certain complexity.  As a result, that some mundane operations can seem more
-difficult than they need be.  There isn't space in this book to explain
-everything there is about working with FreeBSD, but in the following few
-chapters I'd like to make the transition easier for people who have prior
-experience with Microsoft platforms or with other flavours of UNIX.  You can
-find a lot more information about these topics in \fIUNIX for the
-Impatient\fP\|, by Paul W. Abrahams and Bruce R. Larson, \fIUNIX Power Tools\fR,
-by Jerry Peek, Tim O'Reilly, and Mike Loukides, and \fIUNIX System
-Administration Handbook\fP, by Evi Nemeth, Garth Snyder, Scott Seebass, and
-Trent R. Hein.  See \*[biblio], for more information.
+There isn't space in this book to explain everything there is about working with
+FreeBSD, but in the following few chapters I'd like to make the transition
+easier for people who have prior experience with Microsoft platforms or with
+other flavours of UNIX.  You can find a lot more information about these topics
+in \fIUNIX for the Impatient\fP\/, by Paul W. Abrahams and Bruce R. Larson,
+\fIUNIX Power Tools\fR, by Jerry Peek, Tim O'Reilly, and Mike Loukides, and
+\fIUNIX System Administration Handbook\fP, by Evi Nemeth, Garth Snyder, Scott
+Seebass, and Trent R. Hein.  The third edition of this book also covers FreeBSD
+Release 3.2.  See
+.Sref "\*[biblio]" ,
+for more information.
 .P
 If you've come from Microsoft, you will notice a large number of differences
 between UNIX and Microsoft, but in fact the two systems have more in common than
 meets the eye.  Indeed, back in the mid-80s, one of the stated goals of MS-DOS
 2.0 was to make it more UNIX-like.  You be the judge of how successful that
-attempt was, but if you know the MS-DOS command line interface, you'll notice
+attempt was, but if you know the MS-DOS command-line interface, you'll notice
 some similarities in the following sections.
 .P
-In this chapter, we'll look at FreeBSD from the perspective of a newcomer with
-no UNIX background.  If you \fIdo\fP\| have a UNIX background, you may still
-find it interesting.  Specifically, we'll consider:
+In this chapter, we'll look at FreeBSD from the perspective of somebody with
+computer experience, but with no UNIX background.  If you \fIdo\fP\/ have a UNIX
+background, you may still find it interesting.
+.P
+If you're coming from a Microsoft platform, you'll be used to doing just about
+everything with a graphical interface.  In this book I recommend that you use X
+and possibly a desktop, but the way you use it is still very different.
+FreeBSD, like other UNIX-like systems, places much greater emphasis on the use
+of text.  This may seem primitive, but in fact the opposite is true.  It's
+easier to point and click than to type, but you can express yourself much more
+accurately and often more quickly with a text interface.
+.P
+As a result, the two most important tools you will use with FreeBSD are the
+\fIshell\fP\/ and the \fIeditor\fP.  Use the shell to issue direct commands to
+the system, and the editor to prepare texts.  We'll look at these issues in more
+detail in this chapter.  In
+.Sref "\*[chunixadmin]" ,
+we'll look at other aspects of the system.  First, though, we need to get access
+to the system.
+.H2 "Users and groups"
+.X "user"
+.X "user, groups"
+.Pn users-and-groups
+Probably the biggest difference between most PC operating systems and FreeBSD
+also takes the longest to get used to: FreeBSD is a multi-user, multi-tasking
+system.  This means that many people can use the system at once, and each can do
+several things at the same time.  You may think ``Why would I want to do
+that?.''  Once you've got used to this idea, though, you'll never want to do
+without it again.  If you use the X Window System, you'll find that all windows
+can be active at the same time\(emyou don't have to select them.  You can
+monitor some activity in the background in another window while writing a
+letter, testing a program, or playing a game.
+.P
+.X "user"
+Before you can access a FreeBSD system, you must be registered as a \fIuser\fP.
+The registration defines a number of parameters:
+.Ls B
+.LI
+.X "user, name"
+.X "user, ID"
+A \fIuser name\fP, also often called \fIuser ID\fP.  This is a name that you
+use to identify yourself to the system.
+.LI
+.Pn password
+.X "password"
+A \fIpassword\fP, a security device to ensure that other people don't abuse your
+user ID.  To log in, you need to specify both your user ID and the correct
+password.  When you type in the password, nothing appears on the screen, so that
+people looking over your shoulder can't read it.
+.P
+It might seem strange to go to such security measures on a system that you alone
+use.  The incidence of Internet-related security problems in the last few years
+has shown that it's not strange at all, it's just common sense.  Microsoft
+systems are still subject to a never-ending series of security exploits.
+FreeBSD systems are not.
+.LI
+.Pn shell
+.X "shell"
+A \fIshell\fP, a program that reads in your commands and executes them.  MS-DOS
+uses the program
+.Command COMMAND.COM
+to perform this function.  UNIX has a large choice of shells: the traditional
+UNIX shells are the Bourne shell
+.Command sh
+and the C shell
+.Command csh ,
+but FreeBSD also supplies
+.Command bash ,
+.Command tcsh ,
+.Command zsh
+and others.  I personally use the
+.Command bash
+shell, and the examples in this book are based on it.
+.LI
+.Pn home-directory
+.X "home directory"
+.X "directory, home"
+A \fIhome directory\fP.  The system can have multiple users, so each one needs a
+separate directory in which to store his private files.  Typically, users have a
+directory \fI/home/\f(BIusername\fR, where \f(BIusername\fP\/ is the name they
+use to log in.  When you log in to the system, the shell sets the current
+directory to your home directory.  In it, you can do what you want, and normally
+it is protected from access by other users.  Many shells, including the
+.Command bash
+shell used in these examples, use the special notation \fB~\fP\/ (tilde) to
+represent the name of the home directory.
+.LI
+.X "group"
+.Pn group
+A \fIgroup\fP\/ number.  UNIX collects users into \fIgroups\fP\/ who have
+specific common access permissions.  When you add a user, you need to make him a
+member of a specific group, which is entered in the password information.  Your
+group number indirectly helps determine what you are allowed to do in the
+system.  As we'll see on page
+.Sref \*[permissions] ,
+your user and group determine what access you have to the system.  You can
+belong to more than one group.
+.P
+Group numbers generally have names associated with them.  The group names and
+numbers are stored in the file
+.File /etc/group .
+In addition, this file may contain user IDs of users who belong to another
+group, but who are allowed to belong to this group as well.
+.P
+If you find the concept of groups confusing, don't worry about them.  You can
+get by quite happily without using them at all.  You'll just see references to
+them when we come to discuss file permissions.  For further information, look at
+the man page for \fIgroup(5)\fP.
+.Le
+By the time you get here, you should have defined a user name, as recommended on
+page
+.Sref \*[firstuser] .
+If you haven't, you'll have to log in as \f(CWroot\fP and create one as
+described there.
+.H2 "Gaining access"
+Once you have a user name, you can log in to the system.  Already you have a
+choice: FreeBSD offers both \fIvirtual terminals\fP\/ and the X Window System.
+The former displays plain text on the monitor, whereas the latter uses the
+system's graphics capabilities.  Once running, you can switch from one to the
+other, but you have the choice of which interface you use first.  If you don't
+do anything, you get a virtual terminal.  If you run
+.Daemon xdm ,
+you get X.
+.P
+It's still relatively uncommon to use
+.Daemon xdm ,
+and in many instances you may not want X at all, for example if you're running
+the system as a server.  As a result, we'll look at the ``conventional'' login
+first.
+.P
+If you're logging in on a virtual terminal, you'll see something like this:
+.Pn login
+.Dx
+login: \f(CBgrog\fP
+Password:                                 \fIpassword doesn't show on the screen\fP\/
+Last login: Fri Apr 11 16:30:04 from canberra
+Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
+        The Regents of the University of California.  All rights reserved.
+
+FreeBSD 5.0-RELEASE (FREEBIE) #0: Tue Dec 31 19:08:24 CST 2002
+
+Welcome to FreeBSD!
+
+You have mail.
+erase ^H, kill ^U, intr ^C, status ^T
+Niklaus Wirth has lamented that, whereas Europeans pronounce his name
+correctly (Ni-klows Virt), Americans invariably mangle it into
+(Nick-les Worth).  Which is to say that Europeans call him by name, but
+Americans call him by value.
+=== grog@freebie (/dev/ttyv0) ~ 1 ->
+.De
+There's a lot of stuff here.  It's worth looking at it in more detail\/:
+.Ls B
+.LI
+The program that asks you to log in on a terminal window is called
+.Command getty .
+It reads in your
+user ID and starts a program called
+.Command login
+and passes the user ID to it.
+.LI
+.Command login
+asks for the password and checks your user ID.
+.LI
+If the user ID and password are correct,
+.Command login
+starts your designated
+shell.
+.LI
+While starting up, the shell looks at a number of files.
+..if verylong
+We'll look at them in more detail further down, after we've seen what they need
+to do.
+..else
+See the man page for your particular shell for details of what they are for.
+..endif
+.X "message of the day"
+.Pn motd
+In this case, though, we can see the results: one file contains the time you
+last logged in, another one contains the \fIMessage of the day\fP\/
+.File ( /etc/motd ),
+and a third one informs you that you have mail.  The shell prints out the
+message of the day verbatim\(emin this case, it contains information about the
+name of the kernel and a welcome message.  The shell also prints information on
+last login time (in this case, from a remote system) and whether you have mail.
+.LI
+The line ``\f(CWerase ^H, kill ^U, intr ^C, status ^T\fP'' looks strange.  It's
+telling you the current editing control characters.  We'll look at these on page
+.Sref \*[control-chars] .
+.X "home directory"
+.X "directory, home"
+At this point, the shell changes the current directory to your \fIhome
+directory\fP.  There is no output on the screen to indicate this.
+.LI
+.X "Wirth, Niklaus"
+The shell runs the
+.Command fortune
+program, which prints out a random quotation from a database of ``fortune
+cookies.''  In this case, we get a message about Niklaus Wirth, the inventor of
+the Pascal programming language.
+.LI
+Finally, the last line is a prompt, the information that tells you that the
+shell is ready for input.
+.Le
+The prompt illustrates a number of things about the UNIX environment.  By
+default,
+.Command sh
+and friends prompt with a \f(CW$\fP, and
+.Command csh
+and friends prompt with a \f(CW%\fP.  You can change it to just about anything
+you want with the UNIX shells.  You don't have to like my particular version,
+but it's worth understanding what it's trying to say.
+.P
+.Pn shell-prompt
+The first part, \f(CW===\fP, is just to make it easier to find in a large list
+on an X display.  An
+.Command xterm
+window on a high resolution X display can contain up to 120 lines, and searching
+for command prompts can be non-trivial.
+.P
+Next, \f(CWgrog@freebie\fP is my user ID and the name of system on which I am
+working, in the RFC 2822 format used for mail IDs.  Multiple systems and
+multiple users can all be present on a single X display.  This way, I can figure
+out which user I am and what system I am running on.
+.P
+.Device ttyv0
+is the name of the terminal device.  This can sometimes be useful.
+.P
+\f(CW~\fP is the name of the home directory.  Most shells, but not all of them,
+support this symbolism.
+.P
+\f(CW1\fP is the prompt number.  Each time you enter a command, it is associated
+with this number, and the prompt number is incremented.  One way to re-execute
+the command is to enter \f(CW!!1\fP (two exclamation marks and the number of the
+command).  We'll look at more comfortable ones on page
+.Sref \*[control-chars] .
+.P
+To start X from a virtual terminal shell, use the
+.Command startx
+command:
+.Dx
+$ \f(CBstartx\fP
+.De
+If you use
+.Daemon xdm ,
+you bypass the virtual terminals and go straight into X.  Enter your user name
+and password to the login prompt or the
+.Daemon xdm
+login screen, and press \fBEnter\fP.  If you use the
+.Daemon xdm
+login, you'll go straight into X.
+.PIC images/kde-main-4.ps 5i
+.Figure-heading "KDE display"
+.Fn kde-main
+Either way, assuming that you've installed and configured
+.Command kde ,
+you'll get a display similar to that in Figure
+.Sref \*[kde-main] .
+This example includes four windows that are not present on startup.  On startup
+the central part of the screen is empty.  We'll look at the windows further
+below.
+.H2 "The KDE desktop"
+.Pn using-kde
+KDE is a complicated system, and good documentation is available at
+.URI http://www.kde.org/documentation/ .
+Once you have KDE running, you can access the same information via the help icon
+on the panel at the bottom (the life ring icon).  The following description
+gives a brief introduction.
+.P
+The KDE display contains a number of distinct areas.  At the top is an optional
+menu, at the bottom an almost optional \fIpanel\fP, and the middle of the screen
+is reserved for windows.
+.H3 "The Desktop Menu"
+The \fIDesktop Menu\fP\/ is at the very top of the screen.  It provides
+functionality that is not specific to a particular application.  Select the
+individual categories with the mouse.  For example, the \f(CWNew\fP menu looks
+like this:
+.PIC images/kde-new-menu.ps 3i
+.Figure-heading "KDE desktop menu"
+As the menu indicates, you can use these menus to create new files.
+.H4 "The Panel"
+At the bottom of the screen is the panel, which consists of a number of fields.
+The left-hand section is used for starting applications.
+.PIC images/kde-taskbar-left.ps 4i
+.P
+The stylized letter K at the extreme left is the \fIApplication Starter\fP.
+When you select it, a long vertical menu appears at the left of the screen and
+allows you to start programs (``applications'') or access just about any other
+function.
+.P
+Next comes an icon called ``show desktop.''  This is a convenient way to iconify
+all the windows currently on the desktop.
+.P
+The remaining icons on this part of the panel represent various applications.
+.Ls B
+.LI
+The
+.Command konsole
+terminal emulator.
+.LI
+The \fIcommand center\fP, which you use to configure KDE.
+.LI
+The help system.
+.LI
+Access to the home directory with the browser
+.Command konqueror .
+.LI
+Access to the Web, also with the browser
+.Command konqueror .
+.LI
+The
+.Command Kmail
+MUA.
+.LI
+The
+.Command KWord
+word processor, which can understand Microsoft Word documents.
+.LI
+The
+.Command Kspread
+spreadsheet.
+.LI
+The
+.Command Kpresenter
+presentation package.
+.LI
+The
+.Command Kate
+editor.
+.Le
+The next section of the panel contains some control buttons and information
+about the current desktop layout:
+.PIC images/kde-taskbar-middle.ps 4i
+The section at the left shows the current contents of four screens, numbered 1
+to 4.  Screen 1 is the currently displayed screen; you can select one of the
+others by moving the cursor in the corresponding direction, or by selecting the
+field with the mouse.
+.P
+To the right of that are icons for the currently active windows.  The size
+expands and contracts depending on the number of different kinds of window
+active.  If you select one of these icons with the left mouse button, it will
+iconify or deiconify (``minimize'' or ``maximize'') the window.
+If you have multiple
+.Command xterm s
+active, you will only have one icon.  In this case, if you select the icon, you
+will get another pop-up selection menu to allow you to choose the specific
+window.
+.P
+The right part of the panel contains a further three fields:
+.PIC images/kde-taskbar-right.ps 4i
+.Ls B
+.LI
+The first one
+shows a stylized padlock (for locking the session when you leave the machine;
+unlock by entering your password) and a stylized off switch, for logging out of
+the session.
+.LI
+The next section shows a stylized power connector, which displays the current
+power status of the machine, and a clipboard.
+.LI
+The right side shows a digital clock.
+.Le
+Probably the most useful part of this section of the panel is not very obvious:
+the right-pointing arrow allows you to remove the panel if you find it's in the
+way.  The entire panel is replaced by a single left-pointing arrow at the
+extreme right of the display.
+.H4 "Using the mouse"
+By default,
+.Command kde
+only uses the left and the right mouse buttons.  In general, the left button is
+used to select a particular button, and the right button is used for an
+auxiliary menu.
+.H4 "Manipulating windows"
+You'll notice that each window has a frame around it with a number of features.
+In X terminology, they're called \fIdecorations\fP.  Specifically:
+.Ls B
+.LI
+There's a \fItitle bar\fP\/ with the name of the program.  If you select the bar
+itself, you raise the window above all others.  If you hold down the button on
+the title bar, you can move the window.
+.LI
+At the left of the title bar there is an X logo.  If you select this logo, you
+get a menu of window operations.
+.LI
+At the right of the title bar, there are three buttons that you can select.  The
+left one iconifies the window, the middle one \fImaximizes\fP\/ the window,
+making it take up the entire screen, and the one on the right kills the
+application.  If the window is already maximized, the middle button restores it
+to its previous size.
+.LI
+You can select any corner of the window, or any of the other edges, to change
+the size of the window.
+.Le
+.SPUP
+.H2 "The fvwm2 window manager"
+.Pn fvwm2
+If you come from a conventional PC background, you shouldn't have much
+difficulty with KDE.  It's a relatively complete, integrated environment.  But
+it isn't really UNIX.  If you come from a UNIX environment, you may find it too
+all-encompassing.  You may also find that there are significant delays when you
+start new applications.
+.P
+UNIX has a very different approach to windows.  There is no desktop, just a
+window manager.  It takes up less disk space, less processor time, and less
+screen real estate.  By default, XFree86 comes with the
+.Command twm
+window manager, but that's really a little primitive.  With modern machines,
+there's no reason to choose such a basic window manager.  You may, however, find
+that
+.Command fvwm2
+is more your style than KDE.
+.H3 "Starting fvwm2"
+Like KDE, you install
+.Command fvwm2
+from the Ports Collection.  It's not designed to work completely correctly out
+of the box, though it does work.  As with KDE, the first thing you need to do is
+to create a
+.File .xsession
+or
+.File .xinitrc
+file, depending on whether you're running
+.Daemon xdm .
+It must contain at least the line:
+.Dx
+fvwm2
+.De
+Start X the same way you did for KDE.  This time you see, after starting the
+same applications as before:
+.PIC images/fvwm-main.ps 5i
+This picture shows both similarities with and differences from KDE.  The
+similarities include:
+.Ls B
+.LI
+Each window has a frame and a title.  The exact form of the decorations is
+different, but the purpose is the same.  There is no ``close application''
+button: for most UNIX applications, you should get the program to exit rather
+than killing it.
+.LI
+There is a task bar at the bottom right, taking up only half the width of the
+screen.  The currently active window (the
+.Command xterm
+at the left in this example) is highlighted.
+.LI
+The default
+.Command fvwm2
+display also has four screens, and the task bar shows the position of the
+windows on the task bar.
+.Le
+.ne 4v
+Still, there are a number of differences as well:
+.Ls B
+.LI
+Unless you have a top-end machine, it's \fImuch\fP\/ faster in what it does.
+.LI
+The background (the \fIroot window\fP\/) doesn't have any pattern; it's just a
+grey cross-hatch.
+.LI
+You can move from one screen to the other using the cursor, and windows can
+overlap.  In this example, the
+.Command galeon
+web browser window goes down to the screen below, and the Emacs window goes over
+all four screens, as the display on the task bar shows.  With KDE, the only way
+to display the rest of these windows is to move the window.
+.LI
+Paradoxically, you can do a lot more with the mouse.  On the root window, the
+left mouse button gives you a menu for starting various programs, both locally
+and remotely, and also various window utilities.  The middle button gives you
+direct access to the window manipulation utilities, and the right button gives a
+drop-down list to select any of the currently active windows:
+.XPSPIC -L -W 1i -0 images/fvwm-menu-2.ps
+.XPSPIC -I 2.3i -W 2.5i -0 images/fvwm-right-menu.ps
+.XPSPIC -I 1.3i -W .7i images/fvwm-middle-menu.ps
+.Le
+The menus above show one of the problems: look at those system names on the left
+submenu (\fIdopey\fP, \fIsnoopy\fP\/ and friends).  They don't exist on our
+sample network, and the chance of them existing on your network are pretty low
+as well.  They're hard-coded in the sample configuration file,
+.File /usr/X11R6/etc/system.fvwm2rc .
+To use
+.Command fvwm2
+effectively, you'll have to modify the configuration file.  The best thing to do
+is to make a copy of
+.File /usr/X11R6/etc/system.fvwm2rc
+in your own directory, as
+.File -n ~/.fvwm2/.fvwm2rc .
+Then you can have lots of fun tweaking the file to do exactly what you want it
+to do.  Clearly, KDE is easier to set up.
+.H2 "Changing the X display"
+.X "Ctrl-Alt-Keypad -, keystroke"
+.X "keystroke, Ctrl-Alt-Keypad -"
+.X "Ctrl-Alt-Keypad +, keystroke"
+.X "keystroke, Ctrl-Alt-Keypad +"
+.X "X, changing screen resolution"
+.X "screen resolution, changing under X"
+When you set up your
+.File XF86Config
+file, you may have specified more than one resolution.  For example, on page
+.Sref \*[screen-resolution] \&
+we selected the additional resolution 1024x768 pixels.  When you start X, it
+automatically selects the first resolution, in this case 640x480.  You can
+change to the previous resolution (the one to the left in the list) by pressing
+the \fBCtrl\fP-\fBAlt\fP-\fBKeypad -\fP key, and to the following resolution
+(the one to the right in the list) with \fBCtrl\fP-\fBAlt\fP-\fBKeypad +\fP.
+\fIKeypad +\fP\/ and \fIKeypad -\fP\/ refer to the \fB+\fP and \fB-\fP symbols
+on the numeric keypad at the right of the keyboard; you can't use the \fB+\fP
+and \fB-\fP symbols on the main keyboard for this purpose.  The lists wrap
+around: in our example, if your current resolution is 640x480, and you press
+\fBCtrl\fP-\fBAlt\fP-\fBKeypad -\fP, the display changes to 1024x768.  It's a
+very good idea to keep the default resolution at 640x480 until you have debugged
+your \fIXF86Config\fP\/ parameters: 640x480 almost always works, so if your
+display is messed up, you can just switch back to a known good display with a
+single keystroke.
+.H3 "Selecting pixel depth"
+You can configure most display boards to display a number of different pixel
+depths (a different number of bits per pixel, which translates to a different
+number of colours).  When you start X, however, it defaults to 8 bits per pixel
+(256 colours), which is a very poor rendition.  To start it with a different
+number, specify the number of planes.  For example, to start with 32 bits per
+pixel (4,294,967,296 colours), enter:
+.Dx
+$ \f(CBstartx -\^- -bpp 32\fP
+.De
+With older display boards, which had relatively limited display memory, there
+was a tradeoff between maximum resolution and maximum pixel depth.  Modern
+display cards no longer have this limitation.  We'll look at this issue in more
+detail on page
+.Sref \*[pixel-depth] .
+.H2 "Getting a shell"
+As we saw at the beginning of the chapter, your main tools are the shell and the
+editor, and that's what we saw on the sample screens.  But when you start X,
+they're not there: you need to start them.
+.P
+In KDE, you have two ways to start a terminal window:
+.Ls B
+.LI
+You can select the icon showing a monitor with a shell in front of it, third
+from the left at the bottom of the example above.  This starts the
+.Command konsole
+terminal emulator.
+.LI
+You can start an
+.Command xterm
+by pressing \fBAlt-F2\fP.  You see a window like the one in the centre left of
+Figure
+.Sref \*[kde-main] ,
+enter the text \f(CWxterm\fP (as shown) and press \f(CWRun\fP or the \fBEnter\fP
+key.
+.Le
+Obviously the first is the intended approach, and it's easier.  Nevertheless, I
+recommend using
+.Command xterm
+at least until you're sure you want to stick with
+.Command -n kde \/:
+there are some subtle differences, and
+.Command konsole
+is intended to work with
+.Command -n kde
+only.  If you do stick with KDE, you should change the configuration of the
+.Command konsole
+button to start
+.Command xterm
+instead; that's relatively straightforward.
+.P
+In
+.Command fvwm2 ,
+you start an
+.Command xterm
+from the left mouse menu, as shown above.
+.H3 "Shell basics"
+The most basic thing you can do with the shell is to start a program.  Consider
+program names to be commands: like you might ask somebody to ``wash the dishes''
+or ``mow the lawn,'' you can tell the shell to ``remove those files'':
+.Dx
+$ \f(CBrm file1 file2 file3\fP
+.De
+This starts a program called
+.Command rm
+(remove), and gives it a list of three file names to remove.
+.P
+If you're removing a whole lot of files, this could take a while.  Consider
+removing the entire directory hierarchy
+.File -n /usr/obj ,
+which is created when building a new version of the system (see page
+.Sref \*[buildworld] ).
+This directory hierarchy contains about 15,000 files and directories, and it'll
+take a while to remove it.  You can do this with the following command:
+.Dx
+# \f(CBrm -rf /usr/obj &\fP
+.De
+In this example, we have a couple of options led in by a hyphen (\f(CW-\fP) and
+also the character \f(CW&\fP at the end of the line.
 .Ls B
 .LI
-Your primary interface with FreeBSD is via the \fIshell\fP.  This looks rather
-like the command-line interface to Microsoft's MS-DOS, but there are a number of
-differences which aren't immediately obvious.  We'll look at them in the next
-section.
-.LI
-UNIX is a multi-user operating system.  This means that you have to tell the
-system who you are before you can access it.  On page \*[users-and-groups] we'll
-look at how to define users.
-.LI
-Once you have defined a user, you need to log in to the system and tell it what
-to do.  We'll look at that on page
-.Sref \*[logging-in] .
-.LI
-Not all users are created equal.  In particular, the system administration login
-\f(CWroot\fP has power over all other users.  We'll look at this topic on page
-.Sref \*[root] .
-.LI
-UNIX implements multi-tasking via a mechanism called \fIprocesses\fP.  We'll
-look at them on page \*[processes].
-.LI
-Timekeeping is extremely important in a networking system.  If your system has
-the wrong time, it can cause all sorts of strange effects.  On page
-\*[timekeeping] we'll look at how to ensure that your system is running the
-correct time.
-.LI
-Other aspects of FreeBSD are so extensive that we'll dedicate separate chapters
-to them.  We'll look at them in \*[chstarting], \*[chfilesys], \*[chdisks], XXX
-burncd and \*[chtapes].  In particular, on page \*[vt] we'll see how to access
-multiple ``terminals'' or windows.
-.LE
-.H2 "Differences from other environments"
-.X "Differences from other environments"
-At first sight, UNIX can look really arcane.  People often get really frustrated
-when working with the shell: it just doesn't seem to do what you want, and
-there's no good reason.
-.P
-Well, of course there's always a good reason, but they are often so non-obvious
-that even experienced programmers find it hard to believe.  Here are some of the
-most popular, seen from a Microsoft perspective:
-.H3 "Upper and lower case names"
-.X "File names"
-UNIX file names are \fIcase-sensitive\fP\|: the names \fIFOO\fP, \fIFoo\fP\| and
-\fIfoo\fP\| are three different names.  This may seem silly at first, but any
-alternative is going to make things slower (the system must internally upshift
-or downshift the names), and it means that the names must be associated with a
-specific character set.  How do you upshift the German name \fIBldsinn\fP?
-What if the same characters appear in a Chinese name?  Do they still shift the
-same?  In fact, all characters are legal in a UNIX file name, with one
-exception: \fI/\fP\| is a separator which indicates a directory, and you can't
-use it in a file name.  Still, there are some characters you should avoid:
-spaces are a pain, as we'll see below, and binary 0s (the ASCII \fINUL\fP\|
-character) can confuse a lot of programs.  It's almost impossible to get a
-binary 0 into a file name anyway, since the character is used to represent the
-end of a string in the C programming language.
-.P
-This isn't the problem it used to be: web browsers have made UNIX file names
-more popular with \fIUniform Resource Locators\fP\| or \fIURLs\fP.  We'll look
-at them on page \*[URL].
+The \f(CWr\fP option tells
+.Command rm
+to \fIrecursively\fP\/ descend into subdirectories.  If you didn't specify this,
+it would remove all files in the directory
+.Directory /usr/obj
+and then exit, complaining that it can't delete directories.
+.LI
+The \f(CWf\fP (\fIforce\fP\/) option tells
+.Command rm
+to continue on error; otherwise if anything goes wrong, it will stop.
+.LI
+The \f(CW&\fP character at the end of the line tells the shell (not
+.Command rm )
+to continue after starting the program.  It can run for some time, and there's
+no need to wait for it.
+.Le
+.SPUP
+.H3 "Options"
+In the previous example, we saw a couple of options.  By convention, they come
+between the command name and other parameters, and they're identified because
+they start with a hyphen character (\f(CW-\fP).  There's a lot of variation,
+though, depending on the individual program.
+.Ls B
+.LI
+Sometimes, as in the previous example, options consist of a single letter and
+can often be joined together.
+.LI
+Some programs, like
+.Command tar
+and
+.Command ps ,
+don't insist on the hyphen lead-in.  In Chapter
+.Sref "\*[nchunixadmin]" ,
+we'll see the command:
+.Dx
+# \f(CBps waux\fP
+.De
+.ne 5v
+This command could equally well be written:
+.Dx
+# \f(CBps -waux\fP
+.De
+You may also come across programs that refuse to accept the hyphen at all.
+.LI
+.ne 4v
+Sometimes options can have values.  For example, in Chapter
+.Sref "\*[nchnetdebug]" \&
+we'll see:
+.Dx
+# \f(CBtcpdump -i ppp0 host hub.freebsd.org\fP
+.De
+Here, \f(CWppp0\fP is an argument to the \f(CWi\fP option.  In some cases, it
+must be written with a space; in others, it must be written without a space; and
+in others again, it can be written either way.  Pay attention to this detail
+when reading man pages.
+.LI
+In other cases, they can be keywords, in which case they need to be written
+separately.  The GNU project is particularly fond of this kind of option.  For
+example, when building the system you may see compiler invocations like these:
+.Dx
+cc -O -pipe -Dinline=rpcgen_inline -Wall -Wno-format-y2k -Wno-uninitialized \e
+-D__FBSDID=__RCSID -c /usr/src/usr.bin/rpcgen/rpc_main.c
+.De
+With the exception of the last parameter, all of these texts are options, as the
+hyphen suggests.
+.LI
+Options are specific to particular commands, though often several commands
+attempt to use the same letters to mean the same sort of thing.  Typical ones
+are \f(CWv\fP for verbose output, \f(CWq\fP for quiet output (i.e. less than
+normal).
+.LI
+Sometimes you can run into problems when you supply a parameter that looks like
+an option.  For example, how do you remove a file called
+.File -n -rf ?
+There are a number of solutions for this problem.  In this example, you could
+write:
+.Dx
+$ \f(CBrm ./-rf\fP
+.De
+This is an alternative file naming convention that we'll look at again on page
+.Sref \*[relative-paths] .
+.Le
+.SPUP
+.H3 "Shell parameters"
+.X "shell, parameters"
+.X "parameters, shell"
+.X "parsing"
+.X "argument, shell"
+.X "white space"
+.X "space, white"
+When you invoke a program with the shell, it first \fIparses\fP\/ the input line
+before passing it to the program: it turns the line into a number of parameters
+(called \fIarguments\fP\/ in the C programming language).  Normally the
+parameters are separated by \fIwhite space\fP, either a space or a tab
+character.  For example, consider the previous example:
+.Dx
+$ \f(CBrm file1 file2 file3\fP
+.De
+the program receives four arguments, numbered 0 to 3:
+.br
+.ne 1i
+.Table-heading "Program arguments"
+.TS
+tab(#) ;
+rfCWp9 | lfCWw65 .
+\s10\fBArgument#\fBValue
+_
+0#rm
+1#file1
+2#file2
+3#file3
+.TE
+.sp 1.5v
+What happens if you want to pass a name with a space?  For example, you might
+want to look for the text ``\f(CWMail rejected\fP'' in a log file.  UNIX has a
+standard program for looking for text, called
+.Command grep .
+The syntax is:
+.Dx
+grep \f(CIexpression files
+.De
+Argument 1 is the expression; all additional arguments are the names of files to
+search.  We could write:
+.Dx
+$ \f(CBgrep Mail rejected /var/log/maillog\fP
+.De
+but that would try to look for the text \f(CWMail\fP in the files
+\fIrejected\fP\/ (probably causing an error message that the file did not exist)
+and
+.File /var/log/maillog
+(where just about every line contains the text \f(CWMail\fP).  That's not what
+we want.  Instead, we do pretty much what I wrote above:
+.Dx
+$ \f(CBgrep "Mail rejected" /var/log/maillog\fP
+.De
+In other words, if we put quote characters \f(CW""\fP around a group of words,
+the shell will interpret them as a single parameter.  The first parameter that
+is passed to
+.Command grep
+is \f(CWMail rejected\fP, not \f(CW"Mail rejected"\fP.
+.P
+This behaviour of the shell is a very good reason not to use file names with
+spaces in them.  It's perfectly legitimate to embed spaces into UNIX file names,
+but it's a pain to use.  If you want to create a file name that contains
+several words, for example \fIAll\ files\ updated\ since\ last\ week\fP,
+consider changing the spaces to underscores:
+\fIAll_files_updated_since_last_week\fP.
+.P
+It's even more interesting to see what happens when you pass a globbing
+character to a program, for example:
+.Dx
+$ \f(CBcc -o foo *.c\fP
+.De
+This invocation compiles all C source files (\fI*.c\fP\/) and creates a program
+.Command -n foo .
+If you do this with Microsoft, the C compiler gets four parameters, and it has
+to find the C source files itself.  In UNIX, the shell expands the text
+\fI*.c\fP\/ and replaces it with the names of the source files.  If there are
+thirty source files in the directory, it will pass a total of 33 parameters to
+the compiler.
+.H3 "Fields that can contain spaces"
+The solution to the ``Mail rejected'' problem isn't ideal, but it works well
+enough as long as you don't have to handle fields with blanks in them too often.
+In many cases, though, particularly in configuration files, fields with blanks
+are relatively common.  As a result, a number of system configuration files use
+a colon (\f(CW:\fP) as a delimiter.  This looks very confusing at first, but it
+turns out not to be as bad as the alternatives.  We'll see some examples in the
+\f(CWPATH\fP environment variable on page
+.Sref \*[PATH] ,
+in the password file on page
+.Sref \*[master-passwd] ,
+and in the login class file on page
+.Sref \*[login-class] .
+.H2 "Files and file names"
+.Pn file-names
+Both UNIX and Microsoft environments store disk data in \fIfiles\fP, which in
+turn are placed in \fIdirectories\fP.  A file may be a directory: that is, it
+may contain other files.
+.X "file names"
+.X "file name extension"
+The differences between UNIX and Microsoft start with \fIfile names\fP.
+Traditional Microsoft file names are rigid: a file name consists of eight
+characters, possibly followed by a period and another three characters (the
+so-called \fIfile name extension\fP\/).  There are significant restrictions on
+which characters may be used to form a file name, and upper and lower case
+letters have the same meaning (internally, Microsoft converts the names to UPPER
+CASE).  Directory members are selected with a backslash (\fB\e\fP), which
+conflicts with other meanings in the C programming language\(emsee page
+\*[slash] for more details.
+.P
+FreeBSD has a very flexible method of naming files.  File names can contain any
+character except \f(CW/\fP, and they can be up to 255 characters long.  They are
+\fIcase-sensitive\fP\/: the names \fIFOO\fP, \fIFoo\fP\/ and \fIfoo\fP\/ are
+three different names.  This may seem silly at first, but any alternative means
+that the names must be associated with a specific character set.  How do you
+upshift the German name \fIungleichmig\fP?  What if the same characters appear
+in a Russian name?  Do they still shift the same?  The exception is because the
+\f(CW/\fP\/ character represents directories.  For example, the name
+.File -n /home/fred/longtext-with-a-long-name
+represents:
+.Ls N
+.LI
+First character is a \f(CW/\fP, representing the \fIroot file system\fP.
+.LI
+\fIhome\fP\/ is the name of a directory in the root file system.
+.LI
+\fIfred\fP\/ is the name of a directory in
+.File -n /home .
+.LI
+The name suggests that
+.File -n longtext-with-a-long-name
+is probably a file, not a directory, though you can't tell from the name.
+.Le
+As a result, you can't use \f(CW/\fP in a file name. In addition, binary 0s (the
+ASCII \f(CWNUL\fP\/ character) can confuse a lot of programs.  It's almost
+impossible to get a binary 0 into a file name anyway: that character is used to
+represent the end of a string in the C programming language, and it's difficult
+to input it from the keyboard.
+.P
+Case sensitivity no longer seems as strange as it once did: web browsers have
+made UNIX file names more popular with \fIUniform Resource Indicators\fP\/ or
+\fIURIs\fP, which are derived from UNIX names.
 .H3 "File names and extensions"
-The Microsoft naming convention (name, period and extension) is similar to that
-of UNIX.  UNIX also uses extensions to represent specific kinds of files.  The
-difference is that these extensions (and their lengths) are implemented by
+The Microsoft naming convention (name, period and extension) seems similar to
+that of UNIX.  UNIX also uses extensions to represent specific kinds of files.
+The difference is that these extensions (and their lengths) are implemented by
 convention, not by the file system.  In Microsoft, the period between the name
-and the extension is a typographical feature which only exists at the display
+and the extension is a typographical feature that only exists at the display
 level: it's not part of the name.  In UNIX, the period is part of the name, and
-names like \fIfoo.bar.bazzot\fP\| are perfectly valid file names.  The system
+names like \fIfoo.bar.bazzot\fP\/ are perfectly valid file names.  The system
 doesn't assign any particular meaning to file name extensions; instead, it looks
 for \fImagic numbers\fP, specific values in specific places in the file.
+.H3 "Relative paths"
+.Pn relative-paths
+Every directory contains two directory entries,
+.Directory .
+and
+.Directory ..
+(one and two periods).  These are \fIrelative directory entries\fP\/:
+.Directory .
+is an alternative way to refer to the current directory, and
+.Directory ..
+refers to the parent directory.  For example, in
+.Directory /home/fred ,
+.Directory .
+refers to
+.Directory /home/fred ,
+and
+.Directory ..
+refers to
+.Directory /home .
+The root directory doesn't have a parent directory, so in this directory only,
+.Directory ..
+refers to the same directory.  We'll see a number of cases where this is
+useful.\*F
+.FS
+Interestingly, the Microsoft file systems also have this feature.
+.FE
 .H3 "Globbing characters"
 .X "globbing characters"
 .X "characters, globbing"
@@ -124,26 +905,30 @@
 common in UNIX are the characters \f(CW*\fP, \f(CW?\fP and the square brackets
 \f(CW[]\fP.  UNIX calls these characters \fIglobbing characters\fP.  The
 Microsoft usage comes from UNIX, but the underlying file name representation
-makes for big differences.  Table \*[globbing-example] gives some examples.
+makes for big differences.  Table
+.Sref \*[globbing-example] \&
+gives some examples.
 .br
-.ne 1i
+.Table-heading "Globbing examples"
 .TS
-box,center,tab(#) ;
-lfCWp9 | lw32 | lw32 .
-Name#Microsoft meaning#UNIX meaning
-=
+tab(#) ;
+lfCWp9 | lw28 | lw28 .
+\fBName#\fBMicrosoft meaning#\fBUNIX meaning
+_
 CONFIG.*#T{
 All files with the name \fICONFIG\fP, no matter what their extension.
 T}#T{
 All files whose name starts with \fICONFIG.\fP, no matter what the rest is.
-Note that the name includes a period at the end.
+Note that the name contains a period.
 T}
 .sp .4v
 CONFIG.BA?#T{
-All files with the name \fICONFIG\fP and an extension which starts with
+.nh
+All files with the name \fICONFIG\fP\/ and an extension that starts with
 \fIBA\fP, no matter what the last character.
+.hy
 T}#T{
-All files which start with \fICONFIG.BA\fP\| and have one more character in their
+All files that start with \fICONFIG.BA\fP\/ and have one more character in their
 name.
 T}
 .sp .4v
@@ -157,817 +942,355 @@
 *.*#T{
 All files with an extension.
 T}#T{
-All files which have a period after the beginning of their name.
+All files that have a period in the middle of their name.
 T}
 .sp .4v
 foo[127]#T{
 In older versions, invalid.  In newer versions with long file name support, the
 file with the name \fIfoo[127]\fP.
 T}#T{
-The three files \fIfoo1\fP, \fIfoo2\fP\| and \fIfoo7\fP.
+The three files \fIfoo1\fP, \fIfoo2\fP\/ and \fIfoo7\fP.
 T}
 .TE
 .sp 1.5v
-.Figure-heading "Globbing examples"
 .Tn globbing-example
-.H3 "Shell parameters"
-.X "Shell parameters"
-.X "parameters, shell"
-.X "parsing"
-.X "argument, shell"
-.X "white space"
-.X "space, white"
-When you invoke a program with the shell, it first \fIparses\fP\| the input line
-before passing it to the program: it turns the line into a number of parameters
-(called \fIarguments\fP\| in the C programming language).  Normally the
-parameters are separated by \fIwhite space\fP, either a space or a tab
-character.  If you write a program or script \fIfoo\fP, and invoke it like this:
-.Dx
-$ \f(CBfoo and a lot more\fP
-.De
-the program will receive five arguments, numbered 0 to 4:
-.br
-.ne 1i
-.TS
-box,center,tab(#) ;
-rfCWp9 | lw65 .
-\s10\fRArgument#Value
-=
-0#foo
-1#and
-2#a
-3#lot
-4#more
-.TE
-.sp 1.5v
-What happens if you want to pass a name with a space?  For example, you might
-want to look for the text ``\f(CWMail rejected\fP'' in a log file.  We have a
-program for looking for text, called \fIgrep\fP.  The syntax is:
-.Dx
-grep \fIexpression\fP\| \fIfiles\fP\|
-.De
-Argument 1 is the expression; all additional arguments are the names of files to
-search.  We could write
-.Dx
-$ \f(CBgrep Mail rejected /var/log/maillog\fP
-.De
-but that would try to look for the text \f(CWMail\fP in the files
-\fIrejected\fP\| (probably causing an error message that the file did not exist)
-and \fI/var/log/maillog\fP\| (where just about every line contains the text
-\f(CWMail\fP).  That's  not what we want.  Instead, we do pretty much what I
-wrote above:
-.Dx
-$ \f(CBgrep "Mail rejected" /var/log/maillog\fP
-.De
-In other words, if we put quote characters \f(CB""\fP around a group of words,
-the shell will interpret them as a single parameter.  The parameter that is
-passed to \fIgrep\fP\| is \f(CWMail rejected\fP, not \f(CW"Mail rejected"\fP.
-.P
-This behaviour of the shell is a very good reason not to use file names with
-spaces in them.  It's perfectly legitimate to embed spaces into UNIX file names,
-but it's a pain to use.
-.P
-It's even more interesting to see what happens when you pass a globbing
-character to a program, for example:
-.Dx
-$ \f(CBcc -o foo *.c\fP
-.De
-This invocation compiles all C source files (\fI*.c\fP\|) and creates a program
-\fIfoo\fP.  If you do this with Microsoft, the C compiler gets four parameters,
-and it has to find the C source files itself.  In UNIX, the shell expands the
-text \fI*.c\fP\| and replaces it with the names of the source files.  If there
-are thirty source files in the directory, it will pass a total of 33 parameters
-to the compiler.
-.H3 "Fields which can contain spaces"
-The solution to the ``Mail rejected'' problem isn't ideal, but it works well
-enough as long as you don't have to do it all the time.  In many cases, though,
-particularly in configuration files, you do have to do it relatively often.  As
-a result, a number of system configuration files use a colon (\f(CW:\fP) as a
-delimiter.  This looks very confusing at first, but it turns out not to be as
-bad as the alternatives.  We'll see some examples in the password file on page
-\*[master-passwd], in the login class file on page \*[login-class], and in the
-\f(CWPATH\fP environment variable on page \*[PATH].
-.H3 "Slashes: backward and forward"
-.X "root directory"
-.X "slash character"
-.X "escape character"
-.X "character, slash"
-.X "character, escape"
-.Pn slash
-Some of the most confusing characters in computers are \f(CW/\fP (``slash'') and
-\f(CW\e\fP (``backslash'').  UNIX uses \f(CW/\fP to delimit directories: for
-example, \fI/etc/fstab\fP\| starts from the \fIroot directory\fP\| (\fI/\fP\|),
-and represents the directory \fIetc\fP\| inside this directory, and the file
-\fIfstab\fP\| within that directory.  The backslash \f(CW\e\fP is called an
-\fIescape character\fP\| it has a number of different purposes:
-.Ls B
-.LI
-You can put it in front of another special character to say ``don't interpret
-this character in any special way''.  For example, we've seen that the shell
-interprets a space character as the end of a parameter.  In the previous example
-we changed \f(CWMail rejected\fP to \f(CW"Mail rejected"\fP to stop the shell
-from interpreting it.  We could also have written it like this: 
-\f(CWMail\e\ rejected\fP.
-.P
-.X "quoting"
-A more common use for this \fIquoting\fP\| is to tell the shell to ignore the
-end of a line.  If a command line in a shell script gets too long, you might
-like to split it up into several lines; but the shell sees the end of a line as
-a go-ahead to perform the command.  You can stop it from doing so by putting a
-backslash \fIimmediately\fP\| before the end of the line:
-.Dx
-$ \f(CBgrep \e
-  "Mail rejected" \e
-   /var/log/maillog\fP
-.De
-Don't put any spaces between the \f(CW\e\fP and the end of the line; otherwise
-the shell will interpret the first space as a parameter by itself, and then it
-will interpret the end of line as the end of the command.
-.LI
-.X "control characters"
-.X "character, control"
-In the C programming language, the backslash is used to represent several
-\fIcontrol characters\fP.  For example, \f(CW\en\fP means ``new line''.  This
-usage appears in many other places as well.
-.LI
-Using \f(CW\e\fP as an escape character causes problems: how do we put a
-\f(CW\e\fP character on a line?  The answer: quote it.  Write \f(CW\e\e\fP when
-you mean \f(CW\e\fP.  This causes particular problems when interfacing with
-Microsoft\(emsee page \*[multibackslash] for an example.
-.Le
-There are many more such surprises in store; take a look at \fIUNIX Power
-Tools\fP\| for a good overview.
-.H3 "Tab characters"
-.X "Tab characters"
-.X "character, tab"
-.X "make, command"
-.X "command, make"
-.X "sendmail, command"
-.X "command, sendmail"
-.X "syslogd, command"
-.X "command, syslogd"
-We've seen that the shell treats white space, either spaces or tab characters,
-as the same.  Unfortunately, some other programs do not.  \fImake\fP,
-\fIsendmail\fP\| and \fIsyslogd\fP\| make a distinction between the two kinds of
-characters, and they all require tabs (not spaces) in certain places.  This is a
-\fIreal\fP\| nuisance, since hardly any editor makes a distinction between them.
-.H3 "Carriage control characters"
-.X "Carriage Return character"
-.X "Line Feed character"
-.X "character, carriage return"
-.X "character, line feed"
-In the olden days, the standard computer terminal was a Teletype, a kind of
-computer-controlled electric typewriter.  When it got to the end of a line, it
-required two mechanical operations to move to the beginning of the next line: the
-\fICarriage Return\fP\| control character told it to move the carriage back to
-the beginning of the line, and the \fILine Feed\fP\| character told it to move
-to the next line.
-.P
-.X "Newline, character"
-.X "character, newline"
-Generations of computer systems emulated this behaviour by putting both
-characters at the end of each text line.  This makes it more difficult to
-recognize the end of line, it uses up more storage space, and normally it
-doesn't buy you much.  The implementors of UNIX decided instead to use a single
-character, which it calls the \fINewline\fP\| character.  For some reason, they
-chose the line feed to represent newline, though the character generated by
-\fBEnter\fP is a carriage return.  As we saw above, the C programming language
-represents it as \f(CW\en\fP.
-.P
-This causes problems transferring data between FreeBSD and Microsoft, and also
-when printing to printers which still expect both characters.  We'll look at the
-file transfer issues on page \*[Microsoft-staircase], and the printer issues on
-page \*[staircase].
-.H2 "Users and groups"
-.X "users and groups"
-.Pn users-and-groups
-Probably the biggest difference between traditional Microsoft platforms and
-FreeBSD also takes the longest to appreciate: FreeBSD is a multi-user,
-multi-tasking system.  This means that many people can use the system at once,
-and each of them can do several things at the same time.  You may think ``why
-would I want to do that?''.  Once you've got used to this idea, though, you'll
-never be satisfied with Microsoft again (assuming you were in the first place).
-If you use the X window system, you'll find that all windows can be active at
-the same time\(emyou don't have to select them.  You can monitor some activity
-in the background in another window while writing a letter, testing a program,
-or playing a game.
-.P
-.X "user"
-In order to access a FreeBSD system, you must be registered as a \fIuser\fP.
-The registration defines a number of parameters:
-.Ls B
-.LI
-.X "user name"
-.X "user ID"
-A \fIuser name\fP, also often called \fIuser ID\fP.  This is a name which you
-use to identify yourself to the system.
-.LI
-.Pn password
-.X "password"
-A \fIpassword\fP, a security device to ensure that other people don't abuse your
-user ID.  In order to log in, you need to specify both your user ID and the
-correct password.  When you type in the password, nothing appears on the screen,
-so that people looking over your shoulder can't read it.
-.P
-It may seem strange to go to such security measures on a system which you alone
-use, but if you connect to the Internet, even via PPP or SLIP, other people can
-at least theoretically access your system while you are connected.  If you don't
-connect to the Internet, you can get away without a password, though it's not
-recommended.  You can't get away without a user ID.
-.LI
-.Pn shell
-.X "shell"
-.X "COMMAND.COM"
-.X "sh, command"
-.X "command, sh"
-.X "csh, command"
-.X "command, csh"
-.X "bash, command"
-.X "command, bash"
-.X "tcsh, command"
-.X "command, tcsh"
-.X "zsh, command"
-.X "command, zsh"
-.X "COMMAND.COM"
-A \fIshell\fP, a program which reads in your commands and executes them.  MS-DOS
-uses the program \fICOMMAND.COM\fP\| to perform this function.  UNIX has a large
-choice of shells: the traditional UNIX shells are the Bourne shell \fIsh\fP\|
-and the C shell \fIcsh\fP, but FreeBSD also supplies \fIbash\fP, \fItcsh\fP,
-\fIzsh\fP\| and others.  The UNIX shells are orders of magnitude more powerful
-than \fICOMMAND.COM\fP\(emsee \fIUNIX Power Tools\fP\| for a good discussion.  I
-personally use the \fIbash\fP\| shell, and this book assumes you're using it.
-.LI
-.Pn home-directory
-.X "home directory"
-.X "directory, home"
-A \fIhome directory\fP.  Since the system can have multiple users, each one
-needs a separate directory in which to store his private files.  Typically,
-users have a directory \fI/home/\f(BIusername\fR, where \f(BIusername\fP\| is
-the name they use to log in.  When you log in to the system, the shell sets the
-current directory to your home directory.  In it, you can do what you want, and
-normally it is protected from access by other users.  Many shells, including the
-\fIbash\fP\| used in these examples, use the special notation \f(CW~\fP (tilde)
-to represent the name of the home directory.
-.LI
-.X "group"
-.Pn group
-A \fIgroup\fP\| number.  UNIX collects users into \fIgroups\fP\| who have
-specific access permissions.  When you add a user, you need to make him a member
-of a specific group, which is entered in the password information.  Your group
-number indirectly helps determine what you are allowed to do in the system.  As
-we'll see on page \*[permissions], your user and group determine what access you
-have to the system.  You can belong to more than one group.
-.P
-.X "/etc/group"
-Group numbers generally have names associated with them.  The group names and
-numbers are stored in the file \fI/etc/group\fP.  In addition, this file may
-contain userids of users who belong to another group, but who are allowed to
-belong to this group as well.
-.P
-If you find the concept of groups confusing, don't worry about them.  You can
-get by quite happily without using them at all.  You'll just see references to
-them when we come to discuss file permissions.  For further information, look at
-the man page for \fIgroup(5)\fP.
-.Le
-.P
-In addition to ``real'' users, who represent people, the system has a number of
-pseudo-users who represent tasks performed by the system.  Don't remove them, or
-you could run into problems.
-.P
-.X "/etc/passwd"
-.X "/etc/master.passwd"
-.X "/etc/pwd.db"
-.X "/etc/spwd.db"
-.Pn master-passwd
-The list of users is kept in the file \fI/etc/passwd\fP.  In older UNIX systems,
-this was the only file used to store user information, and the passwords were
-also stored here in encrypted form.  Nowadays processors are much faster, and
-it's too easy to crack a password.  As a result, FreeBSD keeps the real
-information in a file called \fI/etc/master.passwd\fP, and for performance
-reasons it also makes it available in database form in \fI/etc/pwd.db\fP\| and
-\fI/etc/spwd.db\fP.  \fI/etc/passwd\fP\| remains for compatibility reasons: some
-programs access it directly to get information about the environment in which
-they are running.
-.P
-By default, there are no real users on a freshly installed system.  Optionally,
-\fIsysinstall\fP\| will do it for you, but there's no particular reason to do it
-during system installation.  In the next section, we'll look at two ways to add
-and modify users.
-.H3 "Choosing a user name"
-.X "user name, choosing"
-.X "choosing a user name"
-.Pn logging-in
-.X "logging in"
-So what user name do you choose?  User names are usually related to your real
-name and can be up to 8 characters long.  By convention, they are in all lower
-case, even when they represent real names.  Typical ways to form a user name
-are:
+.H3 "Input and output"
+.Pn stdout
+Most programs either read input data or write output data.  To make it easier,
+the shell usually starts programs with at least three open files:
 .Ls B
 .LI
-First name.  In my personal case, this would be \f(CWgreg\fP.
-.LI
-Last name (\f(CWlehey\fP).
-.LI
-First name and initial of last name (\f(CWgregl\fP).
+\fIStandard input\fP, often abbreviated to \fIstdin\fP, is the file that most
+programs read to get input data.
 .LI
-Initial of first name, and last name (\f(CWglehey\fP).
+\fIStandard output\fP, or \fIstdout\fP, is the normal place for programs to
+write output data.
 .LI
-Initials (\f(CWgfl\fP).
-.LI
-Nickname (for example, \f(CWgrog\fP).
+\fIStandard error output\fP, or \fIstderr\fP, is a separate file for programs to
+write error messages.
 .Le
-I choose the last possibility, as we will see in the following discussion.
-.H3 "Adding users"
-.X "adding users"
-.X "users, adding"
-.Pn adding-user
-.X "sysinstall command"
-.X "command, sysinstall"
-.X "adduser command"
-.X "command, adduser"
-.X "Schneider, Wolfram"
-.X "Lehey, Yana"
-There are two ways to add users.  One is the program \fIadduser\fP\|:
-.Dx
-# \f(CBadduser\fP
-Use option ``-verbose'' if you want see more warnings & questions
-or try to repair bugs.
-
-Enter username [a-z0-9]: \f(CByana\fP
-Enter full name []: \f(CBYana Lehey\fP
-Enter shell bash csh date no sh [bash]:	\fIaccept the default\fP\|
-Uid [1000]:						\fIaccept the default\fP\|
-Enter login class: default []:			\fIaccept the default\fP\|
-Login group yana [yana]: \f(CBhome\fP
-Login group is ``home''. Invite yana into other groups: \f(CBno\fP
-[no]: \f(CBwheel\fP						\fIin order to use su\fP\|
-Enter password []:					\fIno echo\fP\|
-Enter password again []:				\fIno echo\fP\|
-
-Name:	  yana
-Password: ****
-Fullname: Yana Lehey
-Uid:	  1000
-Gid:	  1001 (home)
-Class:    
-Groups:	  home wheel
-HOME:	  /home/yana
-Shell:	  /bin/bash
-OK? (y/n) [y]:						\fIaccept the default\fP\|
-Added user ``yana''
-Add another user? (y/n) [y]: \f(CBn\fP
-.De
-.X "vipw command"
-.X "command, vipw"
-.X "Lehey, Norman"
-.Pn vipw
-.P
-.X "/etc/master.passwd"
-An alternative way of adding or removing users is with the \fIvipw\fP\| program.
-This is a more typical UNIX-hackish approach: \fIvipw\fP\| starts your favourite
-editor and allows you to edit the contents of the file \fI/etc/master.passwd\fP.
-After you have finished, it checks the contents and rebuilds the password
-database.  Figure \*[vipw-screen] shows an example.
-.X "/etc/master.passwd"
-.Df
-.PIC "images/vipw.ps" 4i
-.Figure-heading "\fIvipw\fP\| display"
-.Tn vipw-screen
-.DE
-.Df
-.ne 2i
-.Pn user-class
-.TB "\fI/etc/master.passwd\fP\| format"
-.TS
-box,center,tab(#) ;
-lfCWp9w15 | lw60  .
-\s10\fRField#Meaning
-=
-yvonne#T{
-User name
+With an interactive shell (one that works on a terminal screen, like we're
+seeing here), all three files are the same device, in this case the terminal
+you're working on.
+.P
+Why two output files?  Well, you may be collecting something important, like a
+backup of all the files on your system.  If something goes wrong, you want to
+know about it, but you don't want to mess up the backup with the message.
+.H4 "Redirecting input and output"
+But of course, even if you're running an interactive shell, you don't want to
+back up your system to the screen.  You need to change \fIstdout\fP\/ to be a
+file.  Many programs can do this themselves; for example, you might make a
+backup of your home directory like this:
+.Dx
+$ \f(CBtar -cf /var/tmp/backup ~\fP
+.De
+This creates (option \f(CWc\fP) a file (option \f(CWf\fP) called
+.File -n /var/tmp/backup ,
+and includes all the files in your home directory
+.Directory ( ~ ).
+Any error messages still appear on the terminal, as \fIstderr\fP\/ hasn't been
+changed.
+.P
+This syntax is specific to
+.Command tar .
+The shell provides a more general syntax for redirecting input and output
+streams.  For example, if you want to create a list of the files in your current
+directory, you might enter:
+.Dx
+$ \f(CBls -l\fP
+  drwxr-xr-x   2 root  wheel    512 Dec 20 14:36 CVS
+  -rw-r--r--   1 root  wheel   7928 Oct 23 12:01 Makefile
+  -rw-r--r--   5 root  wheel    209 Jul 26 07:11 amd.map
+  -rw-r--r--   5 root  wheel   1163 Jan 31  2002 apmd.conf
+  -rw-r--r--   5 root  wheel    271 Jan 31  2002 auth.conf
+  -rw-r--r--   1 root  wheel    741 Feb 19  2001 crontab
+  -rw-r--r--   5 root  wheel    108 Jan 31  2002 csh.cshrc
+  -rw-r--r--   5 root  wheel    482 Jan 31  2002 csh.login
+\fI(etc)\fP\/
+.De
+You can redirect this output to a file with the command:
+.Dx
+$ \f(CBls -l > /var/tmp/etclist\fP
+.De
+This puts the list in the file
+.File -n /var/tmp/etclist .
+The symbol \f(CW>\fP tells the shell to redirect \fIstdout\fP\/ to the file
+whose name follows.  Similarly, you could use the \f(CW<\fP to redirect
+\fIstdin\fP\/ to that file, for example when using
+.Command grep
+to look for specific texts in the file:
+.Dx
+$ \f(CBgrep csh < /var/tmp/etclist\fP
+  -rw-r--r--   5 root  wheel    108 Jan 31  2002 csh.cshrc
+  -rw-r--r--   5 root  wheel    482 Jan 31  2002 csh.login
+  -rw-r--r--   5 grog  lemis    110 Jan 31  2002 csh.logout
+.De
+In fact, though, there's a better way to do that: what we're doing here is
+feeding the output of a program into the input of another program.  That happens
+so often that there's a special method of doing it, called \fIpipes\fP\/:
+.Dx
+$ \f(CBls -l | grep csh\fP
+  -rw-r--r--   5 root  wheel    108 Jan 31  2002 csh.cshrc
+  -rw-r--r--   5 root  wheel    482 Jan 31  2002 csh.login
+  -rw-r--r--   5 grog  lemis    110 Jan 31  2002 csh.logout
+.De
+The \f(CW|\fP symbol causes the shell to start two programs.  The first has a
+special file, a \fIpipe\fP, as the output, and the second has the same pipe as
+input.  Nothing gets written to disk, and the result is much faster.
+.P
+A typical use of pipes are to handle quantities of output data in excess of a
+screenful.  You can pipe to the
+.Command less \*F
+.FS
+Why
+.Command less ?
+Originally there was a program called
+.Command more ,
+but it isn't as powerful.
+.Command less
+is a new program with additional features, which proves beyond doubt that
+.Command less
+is
+.Command more .
+.FE
+program, which enables you to page backward and forward:
+.Dx
+$ \f(CBls -l | less\fP
+.De
+Another use is to sort arbitrary data:
+.Dx
+$ \f(CBps aux | sort -n +1\fP
+.De
+This command takes the output of the
+.Command ps
+command and sorts it by the numerical (\f(CW-n\fP) value of its \fIsecond\fP\/
+column (\f(CW+1\fP).  The first column is numbered 0.  We'll look at
+.Command ps
+on page
+.Sref \*[ps-command] .
+.H3 "Environment variables"
+.X "environment variables"
+.X "variables, environment"
+.Pn environment-variables
+.X "environment variables"
+The UNIX programming model includes a concept called \fIenvironment
+variables\fP.  This rather unusual sounding name is simply a handy method of
+passing relatively long-lived information of a general nature from one program
+to another.  It's easier to demonstrate the use than to describe.  Table
+.Sref \*[environment-variable-table] \&
+takes a look at some typical environment variables.  To set environment
+variables from Bourne-style shells, enter:
+.Dx
+$ \f(CBexport TERM=xterm\fP
+.De
+This sets the value of the \f(CWTERM\fP variable to \f(CWxterm\fP.  The word
+\f(CWexport\fP tells the shell to pass this information to any program it
+starts.  Once it's exported, it stays exported.  If the variable isn't exported,
+only the shell can use it.
+.P
+.ne 5v
+Alternatively, if you want to set the variable only once when running a program,
+and then forget it, you can set it at the beginning of a command line:
+.Dx
+$ \f(CBTERM=xterm-color mutt\fP
+.De
+This starts the
+.Command mutt
+mail reader (see page
+.Sref \*[mutt] )
+with
+.Command xterm 's
+colour features enabled.
+.P
+For
+.Command csh
+and
+.Command tcsh ,
+set environment variables with:
+.Dx
+% \f(CBsetenv TERM xterm\fP
+.De
+To start a process with these variables, enter:
+.Dx
+% \f(CBenv xterm-color mutt\fP
+.De
+.br
+.Table-heading "Common environment variables"
+.TS H
+tab(#) ;
+lfCWp9 | lw60 .
+\fB\s10Name#\fBPurpose
+_
+.TH N
+BLOCKSIZE#T{
+The size of blocks that programs like
+.Command df
+count.  The default is 512 bytes, but it's often more convenient to use 1024 or
+even 1048576 (1 MB).
+T}
+.sp .3v
+DISPLAY#T{
+When running X, the name of the X server.  For a local system, this is typically
+\f(CWunix:0\fP.  For remote systems, it's in the form
+.br
+\f(CIsystem-name\fP\/:\f(CIserver-number\fP\/.\f(CIscreen-number\fP.  For the
+system \fIbumble.example.org\fP, you would probably write \f(CWbumble.example.org:0\fP.
+T}
+.sp .3v
+EDITOR#T{
+The name of your favourite editor.  Various programs that start editors
+look at this variable to know which editor to start.
 T}
 .sp .3v
-(gibberish)#T{
-Encrypted password.  When adding a new user, leave this field empty and add it
-later with the \fIpasswd\fP\| program.
+HOME#T{
+The name of your home directory.
 T}
 .sp .3v
-1005#T{
-User number
+.X "locale"
+LANG#T{
+The \fIlocale\fP\/
+that you use.  This should be the name of a directory in
+.Directory /usr/share/locale .
 T}
 .sp .3v
-1000#T{
-Group number
+MAIL#T{
+Some programs use this variable to find your incoming mail file.
 T}
 .sp .3v
-.X "/etc/passwd"
-(empty)#T{
-Login class.  We'll look at this below.  This field is not included in
-\fI/etc/passwd\fP.
+MANPATH#T{
+A list of path names, separated by colons (\f(CW:\fP), that specifies where the
+.Command man
+program should look for man pages.  A typical string might be
+\f(CW/usr/share/man:/usr/local/man\fP, and specifies that there are man pages in
+each of the directories
+.Directory /usr/share/man
+and
+.Directory /usr/local/man .
 T}
 .sp .3v
-0#T{
-Password change time.  If non-0, it is the time in seconds after which the
-password must be changed.  This field is not included in \fI/etc/passwd\fP.
+NTAPE#T{
+The name of the non-rewinding tape device.  See page
+.Sref \*[tape-devices] \&
+for more details.
 T}
 .sp .3v
-0#T{
-Account expiration time.  If non-0, it is the time in seconds after which the
-user expires.  This field is not included in \fI/etc/passwd\fP.
+PATH#T{
+A list of path names, separated by colons (\f(CW:\fP), that specifies where the
+shell should look for executable programs if you specify just the program name.
 T}
 .sp .3v
-.X "Lehey, Yvonne"
-.X "gecos"
-T{
-Yvonne Lehey, Echunga, +61-8-8388-8250
-T}#T{
-The so-called \fIgecos\fP\|
-field, which describes the user.  This field is used
-by a number of programs, in particular mail readers, to extract the real name of
-the user.
+PS1#T{
+In Bourne-style shells, this is the prompt string.  It's usually set to
+\f(CB$\fP, but can be changed.  See page
+.Sref \*[shell-prompt] \&
+for a discussion of a possible prompt for
+.Command bash .
+T}
+.sp .3v
+PS2#T{
+In Bourne-style shells, this is the prompt string for continuation lines.  It's
+usually set to \f(CB>\fP.
+T}
+.sp .3v
+SHELL#T{
+The name of the shell.  Some programs use this for starting a shell.
 T}
 .sp .3v
-/home/yvonne#T{
-The name of the home directory.
+TAPE#T{
+The name of the rewinding tape device.  See page
+.Sref \*[tape-devices] \&
+for more details.
 T}
 .sp .3v
-/bin/bash#T{
-The shell to be started when the user logs in.
+TERM#T{
+The type of terminal emulation you are using.  This is very important: there is
+no other way for an application to know what the terminal is, and if you set it
+to the wrong value, full-screen programs will behave incorrectly.
+T}
+TZ#T{
+Time zone.  This is the name of a file in
+.Directory /usr/share/zoneinfo
+that describes the local time zone.  See the section on timekeeping on page
+.Sref \*[timekeeping] \&
+for more details.
 T}
+.Tn environment-variable-table
 .TE
-.Tn master.passwd-format
 .sp 1.5v
-.DE
+.Pn PATH
+Note particularly the \f(CWPATH\fP variable.  One of the most popular questions
+in the \f(CWFreeBSD-questions\fP mailing list is ``I have compiled a program,
+and I can see it in my directory, but when I try to run it, I get the message
+``\f(CWcommand not found\fP.''  This is usually because \f(CWPATH\fP does not
+include the current directory.
+.Aside
+It's good practice \fInot\fP\/ to have your current directory or your home
+directory in the \f(CWPATH\fP: if you do, you can be subject to security
+compromises.  For example, somebody could install a program called
+.Command -n ps
+in the directory
+.Directory -n /var/tmp .
+Despite the name, the program might do something else, for example remove all
+files in your home directory.  If you change directory to
+.Directory -n /var/tmp
+and run
+.Command -n ps ,
+you will remove all files in your home directory.  Obviously much more subtle
+compromises are possible.
 .P
-You're probably wondering why would you ever want to do things this way, and you
-might find it funny that most experienced UNIX administrators prefer it.  The
-reason is that you get more of an overview than with a peephole approach that
-graphical environments give you, but of course you need to understand the format
-better.  It's less confusing once you know that each line represents a single
-user, that the lines are divided into \fIfields\fP\| (which may be empty), and
-that each field is separated from the next by a colon (\f(CW:\fP).  Table
-\*[master.passwd-format] describes the fields you see on the line on which the
-cursor is positioned.  You can read more about the format of
-\fI/etc/master.passwd\fP\| in the man page for \fIpasswd\fP\| for further
-details.
-.P
-We'll see a valid use of this approach on page \*[add-SLIP-user]: if you want to
-make a second user almost the same as the first, it's easier to use an editor
-than type in all the parameters again.
-.\"XXX
-.bp
-.H3 "The super user"
-.X "super user"
-.Pn root
-.X "su command"
-.X "command, su"
-FreeBSD has a number of privileged users for various administration functions.
-Some are just present to be the owners of particular files, while others, such
-as \f(CWdaemon\fP and \f(CWuucp\fP, exist to run particular programs.  One user
-stands above all others, however: \f(CWroot\fP may do just about anything.  The
-kernel gives \f(CWroot\fP special privileges, and you need to become
-\f(CWroot\fP in order to perform a number of functions, including adding other
-users.  Make sure \f(CWroot\fP has a password if there is any chance that other
-people can access your system (this is a must if you have any kind of dialup
-access).  Apart from that, \f(CWroot\fP is a user like any other, but to quote
-the man page \fIsu(1)\fP,
-.br
-.ne 1i
-.Quote
-\fIBy default (unless the prompt is reset by a startup file) the super-user
-prompt is set to \f(CW#\fP to remind one of its awesome power.
-.End-quote
-.H4 "Becoming super user"
-.X "becoming super user"
-.X "super user, becoming"
-Frequently when you're logged in normally, you want to do something which
-requires you to be \f(CWroot\fP.  You can log out and log in again as
-\f(CWroot\fP, of course, but there's an easier way:
-.Dx
-$ \f(CBsu\fP							\fIbecome super user\fP\|
-Password:						\fIas usual, it doesn't echo\fP\|
-#							\fIroot prompt\fP\|
-.De
-.X "/etc/group"
-In order to be able to use \fIsu\fP, you must be a member of the group
-\f(CWwheel\fP.  Normally you do this when you add the user, but otherwise just
-put the name of the user at the end of the line in \fI/etc/group\fP\|:
+Instead, run the program like this:
 .Dx
-wheel:*:0:root\f(CB,grog\fP				\fIadd the text in bold face\fP\|
+$ \f(CB./program\fP
 .De
-.Aside
-BSD treats \fIsu\fP\| somewhat differently from System V.  First, you need to be
-a member of the group \f(CWwheel\fP, and secondly BSD gives you more of the
-super-user environment than System V.  See the man page
-..if review
-| (bmc)
-|
-| Personally, I prefer using the `sudo' port.  It's arguably safer, since I
-| run only one command at a time as `root', and I'm never sitting in a `root'
-| shell, where I might inadvertently type a Bad Command, forgetting I'm in
-| a `root' shell.
-..endif
-for further information.
 .End-aside
-.H3 "Adding or changing passwords"
-.X "adding passwords"
-.X "changing passwords"
-.X "passwords, adding"
-.X "passwords, changing"
-.X "passwd command"
-.X "command, passwd"
-If your system has any connection with the outside world, it's a good idea to
-change your password from time to time.  Do this with the \fIpasswd\fP\|
-program.  The input doesn't look very interesting:
-.Dx
-$ \f(CBpasswd\fP
-Changing local password for yana.
-Old password:				\fIdoesn't echo\fP\|
-New password:				\fIdoesn't echo\fP\|
-Retype new password:			\fIdoesn't echo\fP\|
-passwd: rebuilding the database...
-passwd: done
-.De
-You have to enter the old password to make sure that some passer-by doesn't
-change it for you while you're away from your monitor, and you have to enter the
-new password twice to make sure that you don't mistype and lock yourself out of
-your account.  If this does happen anyway, you can log in as \f(CWroot\fP and
-change the password: \f(CWroot\fP doesn't have to enter the old password, and it
-can change anybody's password.  For example:
-.Dx
-# \f(CBpasswd\fP
-Changing local password for yana.
-New password:				\fIdoesn't echo\fP\|
-Retype new password:			\fIdoesn't echo\fP\|
-passwd: rebuilding the database...
-passwd: done
-.De
-In this case, you specify the name of the user for whom you change the password.
-.P
-.X "root"
-.X "su, command"
-.X "command, su"
-If you are changing the \fIroot\fP\| password, be careful: it's easy enough to
-lock yourself out of the system if you mess things up, which could happen if,
-for example, you mistyped the password twice in the same way (don't laugh, it
-happens).  If you're running X, open another window and use \fIsu\fP\| to become
-\fIroot\fP.  If you're running in character mode, select another virtual
-terminal and log in as \fIroot\fP\| there.  Only when you're sure you can still
-access \fIroot\fP\| should you log out.
-.P
-If you \fIdo\fP\| manage to lose the \f(CWroot\fP password, all may not be lost.
-Reboot the machine to single user mode (see page \*[single-user]), and enter:
-.Dx
-# \f(CBmount -u /\fP				\fImount root file system read/write\fP\|
-# \f(CBmount /usr /\fP				\fImount /usr file system (if separate)\fP\|
-# \f(CBpasswd root\fP				\fIchange the password for \f(CWroot\f(CW
-Enter new password:
-Enter password again:
-# \f(CB^D\fP						\fIenter ctrl-D to continue with startup
-.De
-If you have a separate \fI/usr\fP\| file system (the normal case), you need to
-mount it as well, since the \fIpasswd\fP\| program is in the directory
-\fI/usr/bin\fP.  Note that you should explicitly state the name \f(CWroot\fP: in
-single user mode, the system doesn't have the concept of user IDs.
-.H3 "Login classes"
-.X "login classes"
-.Pn login-class
-.X "/etc/login.conf"
-In UNIX tradition, \f(CWroot\fP has been the owner of the universe.  In a large
-installation, this is rather primitive, and the 4.3BSD Net/2 relase introduced a
-new concept, \fIlogin classes\fP, which determine session accounting, resource
-limits and user environment settings.  Various programs in the system use the
-database described in \fI/etc/login.conf\fP\| to set up a user's login
-environment and to enforce policy, accounting and administrative restrictions.
-The login class database also provides the means by which users are able to be
-authenticated to the system and the types of authentication available.
-.P
-When creating a user, you may optionally enter a class name, which should match
-an entry in \fI/etc/login.conf\fP\(emsee page \*[user-class] for more details.
-If you don't, the system uses the entry \f(CWdefault\fP for a non-root user.
-For the root user, the system uses the entry \f(CWroot\fP if it is present, and
-\f(CWdefault\fP otherwise.
-.P
-The structure of the login configuration database is relatively extensive.  It
-describes a number of parameters, many of which can have two values: a
-\fIcurrent\fP\| value and a \fImaximum\fP\| value.  On login, the system sets
-the values to the \f(CW-cur\fP (current) value, but the user may, at his option,
-increase the value to the \f(CW-max\fP (maximum) value.  We'll look at the
-\f(CWdefault\fP entry for an example.
-.Dx
-# Example defaults
-# These settings are used by login(1) by default for classless users
-# Note that entries like "cputime" set both "cputime-cur" and "cputime-max"
-
-default:\e
-	:cputime=infinity:\e
-	:datasize-cur=64M:\e
-	:stacksize-cur=64M:\e
-	:memorylocked-cur=10M:\e
-	:memoryuse-cur=100M:\e
-	:filesize=infinity:\e
-	:coredumpsize=infinity:\e
-	:maxproc-cur=64:\e
-	:openfiles-cur=64:\e
-	:priority=0:\e
-	:requirehome@:\e
-	:umask=022:\e
-	:tc=auth-defaults:
-.De
-.X backslash
-As in the password file, the fields are delimited by colons (\f(CW:\fP).  In
-this example, though, lines are \fIcontinued\fP\| by placing a backslash
-(\f(CW\e\fP) at the end of each line except the last.  This usage is common in
-UNIX.  Unlike Microsoft usage, a backslash is never used to represent a
-directory.
-.P
-This entry defines the following parameters:
-.Ls B
-.LI
-Processes may use as much CPU time as they want.  If you change this, you can
-stop processes which use more than a specific amount of CPU time.
-.LI
-The current maximum sizes of the user data segment and the stack are set to 64
-MB.  The entry doesn't define maximum values for these parameters.
-.LI
-The user may lock a maximum of 10 MB of memory per process.
-.LI
-The total memory use per process may not exceed 100 MB.
-.LI
-There is no limit on the size of data files or core dump files that the user may
-create.
-.LI
-The user may have up to 64 processes.
-.LI
-Each process may have up to 64 open files.  For some programs, this could be a
-limitation.
-.LI
-The user \fIneed not\fP\| have a home directory in order to log in.  The
-\f(CW@\fP symbol specifies that the preceding symbol (\f(CWrequirehome\fP)
-should be undefined.  As a result, the system does not require the home
-directory.
-.LI
-.X "umask"
-By default, the \fIumask\fP\| is set to \f(CW022\fP.  See page \*[umask] for
-more details of \fIumask\fP.
-.LI
-The system uses the default authentication scheme for this user.
-.Le
-See the man page \fIlogin.conf(5)\fP\| for further details.
-.H3 "Referring to other classes"
-If you want to create a new class, you don't have to start from scratch.  You
-can derive the defaults from a different class.  For example, if you have one
-user on the system who uses a lot of memory, you might create a class like this:
-.Dx
-glutton:\e
-	:tc=default:\e
-	:memoryuse-cur=infinity:
-.De
-The property \f(CWtc\fP refers to the \f(CWdefault\fP class.  A good example of
-this is the \f(CWxuser\fP class, designed for the needs of X11 users:
-.Dx
-xuser:\e
-	:manpath=/usr/share/man /usr/X11R6/man /usr/local/man:\e
-	:cputime=4h:\e
-	:datasize=12M:\e
-	:stacksize=4M:\e
-	:filesize=8M:\e
-	:memoryuse=16M:\e
-	:openfiles=32:\e
-	:maxproc=48:\e
-	:tc=standard:
-.De
-In this example, you'll notice also that the class definition defines a default
-for the environment variable \f(CWMANPATH\fP.
-.H3 "Using login classes"
-Login classes are a relatively recent addition to FreeBSD.  There are a couple
-of things to note about their use:
-.Ls B
-.LI
-At the time of writing, not all parameters are implemented.
-.LI
-.X "/etc/login.conf"
-The data is stored in the file database format for faster access.  After
-modifying the file \fI/etc/login.conf\fP, be sure to run the following command
-to update the database:
+.sp -1v
+.Pn profile
+You should set your \f(CWPATH\fP variable to point to the most common executable
+directories.  Add something like this to your
+.File .profile
+file (for
+Bourne-style shells):
 .Dx
-# \f(CBcap_mkdb /etc/login.conf\fP
+PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
+export PATH
 .De
-.Le
-.sp -2v
-.H2 "Using the shell"
-.X "using the shell"
-.X "shell, using"
-So now we have a user ID, and we can get beyond the prompt on page
-\&\*[login-prompt].  When you log in, you start your \fIshell\fP.  As we saw on
-page \*[shell], the shell takes your input as commands and ensures that they are
-executed.  To log in, you type in your user ID, and when asked, your password:
-.Dx
-login: \f(CBgrog\fP
-Password:					\fIpassword doesn't show on the screen\fP\|
-Last login: Sun Dec 21 18:56:11 on ttyv0
-Copyright (c) 1980, 1983, 1986, 1988, 1989, 1991, 1993, 1994
-	The Regents of the University of California.  All rights reserved.
-
-FreeBSD 2.2.5 (FREEBIE) #14: Tue Jan  2 06:56:46 MET 1998
-
-Welcome to FreeBSD!
-
-You have mail.
-erase ^H, kill ^U, intr ^C, status ^T
-Niklaus Wirth has lamented that, whereas Europeans pronounce his name
-correctly (Ni-klows Virt), Americans invariably mangle it into
-(Nick-les Worth).  Which is to say that Europeans call him by name, but
-Americans call him by value.
-=== grog@freebie(/dev/ttyv0) ~ 1 ->
+This variable is of great importance: one of the leading problems that beginners
+have is to have an incorrect \f(CWPATH\fP variable.
+.H4 "Printing out environment variables"
+So you can't start a program, and you're wondering whether your \f(CWPATH\fP
+environment variable is set correctly.  You can find out with the
+.Command echo
+command:
+.Dx
+$ \f(CBecho $PATH\fP
+/bin:/usr/bin
+.De
+The \f(CW$\fP at the beginning of \f(CW$PATH\fP tells the shell to substitute
+the value of the environment variable for its name.  Without this, the shell has
+no way of knowing that it's an environment variable, so it passes the text
+\f(CWPATH\fP to
+.Command echo ,
+which just prints it out.
+.P
+If you want to print out all the environment variables, use the
+.Command printenv
+command:
+.Dx
+$ \f(CBprintenv | sort\fP
+BLOCKSIZE=1048576
+CLASSPATH=/usr/local/java/lib:/usr/local/java/lib/classes.zip:/home/grog/netscape/
+CVSROOT=/home/ncvs
+DISPLAY=freebie:0
+EDITOR=emacs
+HOME=/home/grog
+PAGER=less
+PATH=.:/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin
+XAUTHORITY=/home/grog/.Xauthority
 .De
-There's a lot of stuff here, and it's worth looking at it in more detail:
-.Ls B
-.LI
-.X "getty, command"
-.X "command, getty"
-.X "login, command"
-.X "command, login"
-The program that asks you to log in is called \fIgetty\fP.  It reads in your
-user ID and starts a program called \fIlogin\fP and passes the user ID to it.
-.LI
-\fIlogin\fP\| asks for the password and checks your user ID.
-.LI
-If the user ID and password are correct, \fIlogin\fP\| starts your designated
-shell.
-.LI
-While starting up, the shell looks at a number of files.
-..if verylong
-We'll look at them in more detail further down, after we've seen what they need
-to do.
-..else
-See the man page for your particular shell for details of what they are for.
-..endif
-.X "Message of the day"
-.X "/etc/motd"
-.Pn motd
-In this case, though, we can see the results: one file contains the time you
-last logged in, another one contains the \fIMessage of the day\fP\|
-(\fI/etc/motd\fP\|), and a third one contains your mail.  The shell prints out
-the message of the day unaltered\(emin this case, it contains information about
-the name of the kernel and a welcome message.  The shell also prints information
-on last login time and whether you have mail.
-.LI
-The line ``\f(CWerase ^H, kill ^U, intr ^C, status ^T\fP'' looks strange.  It's
-telling you the current editing control characters.  We'll look at these on page
-\*[control-chars].
-.LI
-.X "home directory"
-.X "directory, home"
-It changes the current directory to your \fIhome directory\fP.
-.LI
-.X "Wirth, Niklaus"
-.X "fortune, command"
-.X "command, fortune"
-Then it runs the \fIfortune\fP\| program, which prints out a random quotation
-from a database of ``fortune cookies''.  In this case, we get a message about
-Niklaus Wirth, the inventor of the Pascal programming language.
-.LI
-Finally, the last line is a prompt, the information that tells you that the
-shell is ready for input.
-.Le
-.X "sh, command"
-.X "command, sh"
-.X "csh, command"
-.X "command, csh"
-It's worth looking at the prompt in more detail, since it illustrates a number
-of things about the UNIX environment.  By default, \fIsh\fP\| and friends prompt
-with a \f(CW$\fP, and \fIcsh\fP\| and friends prompt with a \f(CW%\fP.  In the
-same way that you can change the MS-DOS command prompt away from \f(CWC:\e> \fP
-to, say, show the current directory, you can change it to just about anything
-you want with the UNIX shells.  You don't have to like my particular version,
-but it's worth understanding what it's trying to say.
-.P
-.X "xterm, command"
-.Pn shell-prompt
-The first part, \f(CW===\fP, is just to make it easier to find in a large list
-on an X display.  An \fIxterm\fP\| window (a terminal emulator which runs under
-X11) on a high resolution X display can contain up to 90 lines, and searching
-for command prompts can be non-trivial.
-.P
-Next, \f(CWgrog@freebie\fP is my user ID and the name of system on which I am
-working, in the RFC 822 format used for mail IDs.  Multiple systems and multiple
-users can all be present on a single X display.  This way, I can figure out
-which user I am and what system I am running on.
-.P
-.X "/dev/ttyv0"
-\fI/dev/ttyv0\fP\| is the name of the current controlling terminal.  This can
-sometimes be useful.
-.P
-\f(CW~\fP is the name of the home directory.  Most shells, but not all of them,
-support this symbolism.
-.P
-\f(CW1\fP is the prompt number.  Each time you enter a command, it is associated
-with this number, and the prompt number is incremented.  One way to re-execute
-the command is to enter \f(CW!!1\fP (two exclamation marks and the number of the
-command).  We'll look at more comfortable ones in the next section.
+This example sorts the variables to make it easier to find them.  In all
+probability, you'll find many more variables.
 .H3 "Command line editing"
-.X "Command line editing"
+.X "command line editing"
 .Pn control-chars
 Typing is a pain.  If you're anything like me, you're continually making
 mistakes, and you may spend more time correcting typing errors than doing the
@@ -977,15 +1300,13 @@
 $ \f(CBgroff -rex=7.5 -r$$ -rL -rW -rN2 -mpic tmac.M unixerf.mm\f(CW
 troff: fatal error: can't open `unixerf.mm': No such file or directory
 .De
-This command \fIshould\fP\| create the PostScript version of this chapter, but
+This command \fIshould\fP\/ create the PostScript version of this chapter, but
 unfortunately I messed up the name of the chapter: it should have been
 \fIunixref.mm\fP, and I typed \fIunixerf.mm\fP.
 .Aside
-Yes, I know this looks terrible.  UNIX isn't all like this, but sometimes this
-kind of notation has its advantages: it offers a flexibility that you can't get
-any other way.  In addition, it's relatively easy to generate this kind of
-command line automatically: the command I really use to format this chapter is
-\f(CWmake unixref\fP.
+Yes, I know this looks terrible.  In fact, UNIX has ways to ensure you almost
+never need to write commands like this.  The command I really use to format this
+chapter is ``\f(CWmake unixref\fP''.
 .End-aside
 It would be particularly frustrating if I had to type the whole command in
 again.  UNIX offers a number of ways to make life easier.  The most obvious one
@@ -999,35 +1320,36 @@
 .Dx
  erase ^H, kill ^U, intr ^C, status ^T
 .De
-in the example above.  \fB^H\fP (\fBCTRL-H\fP) is an alternative representation
-for \fBBackspace\fP.
+in the example on page
+.Sref \*[login] .
+\fB^H\fP (\fBCtrl-H\fP) is an alternative representation for \fBBackspace\fP.
 .P
 The three other functions \f(CWkill\fP, \f(CWintr\fP, and \f(CWstatus\fP perform
 similar editing functions.  \f(CWkill\fP erases the whole line, and \f(CWintr\fP
 stops a running program.
 .Aside
 .X "signal"
-More correctly, \f(CWintr\fP sends a \fIsignal\fP\| called \f(CWSIGINTR\fP to
+More correctly, \f(CWintr\fP sends a \fIsignal\fP\/ called \f(CWSIGINT\fP to
 the process.  This normally causes a program to stop.
 .End-aside
-.X "bash, command"
-.X "command, bash"
 You'll notice that it is set to \fBCtrl-C\fP, so its function is very similar to
 that of the MS-DOS \fBBreak\fP key.  \f(CWstatus\fP is an oddball function: it
-doesn't change the input, it just displays a statistics message.  \fIbash\fP\|
+doesn't change the input, it just displays a statistics message.
+.Command bash
 doesn't in fact use it: it has a better use for \fBCtrl-T\fP.
 .P
 In fact, these control characters are just a few of a large number of control
-characters that you can set.  Table \*[terminal-control-chars] gives an
-overview.
+characters that you can set.  Table
+.Sref \*[terminal-control-chars] \&
+gives an overview of the more common control characters.  For a complete list,
+see the man page \fIstty(1)\fP.
 .br
-.ne 1i
-.TB "Terminal control characters"
+.Table-heading "Terminal control characters"
 .TS H
-box, center,tab(%) ;
- lfCWp9 | lfCWp9 | lf(R)w59  .
-\s10\fRName%Default%Function
-=
+tab(%) ;
+ lfCWp9 | lfCWp9 | lf(R)w54  .
+\s10\fBName%\fBDefault%\fBFunction
+_
 .TH N
 CR%\er%T{
 Go to beginning of line.  Normally, this also terminates input (in other words,
@@ -1038,403 +1360,323 @@
 End line.  Normally, this also terminates input.
 T}
 .sp .4v
-INTR%CTRL-C%T{
-Generate an \s10\f(CWSIGINT\fR\s0 signal.  This normally causes the process
+INTR%Ctrl-C%T{
+Generate a \s10\f(CWSIGINT\fR\s0 signal.  This normally causes the process
 to terminate.
 T}
 .sp .4v
-QUIT%CTRL-|%T{
+QUIT%Ctrl-|%T{
 Generate a \s10\f(CWSIGQUIT\fR\s0 signal.  This normally causes the process
-to terminate.
+to terminate and \fIcore dump\fP, to save a copy of its memory to disk for later
+analysis.
 T}
 .sp .4v
 ERASE%DEL%T{
 Erase last character.  FreeBSD sets this to \fBBackspace\fP on login, but
-under some unusual circumstances you will find it still set to \fBDEL\fP.
+under some unusual circumstances you might find it still set to \fBDEL\fP.
 T}
 .sp .4v
-KILL%CTRL-U%T{
+KILL%Ctrl-U%T{
 Erase current input line.
 T}
 .sp .4v
-EOF%CTRL-D%T{
+EOF%Ctrl-D%T{
 Return end-of-file indication.  Most programs stop when they receive an EOF.
 T}
 .sp .4v
-EOL%%T{
-Alternate end-of-line character.  This is not normally used, and by default it
-is disabled.
-T}
-.sp .4v
-EOL2%%T{
-Alternate end-of-line character.  Also seldom used.
-T}
-.sp .4v
-START%CTRL-Q%T{
-Resume output after stop.  See the next entry.
+STOP%Ctrl-S%T{
+Stop output.  Use this to examine text that is scrolling faster than you can
+read.
 T}
 .sp .4v
-STOP%CTRL-S%T{
-Stop output.  Use this to examine text which is scrolling faster than you can
-read.
+START%Ctrl-Q%T{
+Resume output after stop.
 T}
 .sp .4v
-.X "fg, command"
-.X "command, fg"
-SUSP%CTRL-Z%T{
+SUSP%Ctrl-Z%T{
 Suspend process.  This key generates a \s10\f(CWSIGTSTP\fR\s0 signal when typed.
-This normally causes a program to be suspended.  To restart, use the \fIfg\fP\|
+This normally causes a program to be suspended.  To restart, use the
+.Command fg
 command.
 T}
 .sp .4v
-DSUSP%CTRL-Y%T{
+DSUSP%Ctrl-Y%T{
 Delayed suspend.
 Generate a \s10\f(CWSIGTSTP\fR\s0 signal when the character is read.  Otherwise,
 this is the same as \f(CWSUSP\fP.
 T}
 .sp .4v
-REPRINT%CTRL-R%T{
+REPRINT%Ctrl-R%T{
 Redisplay all characters in the input queue (in other words, characters that
 have been input but not yet read by any process).  The term "print" recalls the
 days of harcopy terminals.  Many shells disable this function.
 T}
 .sp .4v
-DISCARD%CTRL-O%T{
+DISCARD%Ctrl-O%T{
 Discard all terminal output until another \s10\f(CWDISCARD\fR\s0
 character arrives, more input is typed or the program clears the
 condition.
 T}
-.sp .4v
-WERASE%CTRL-W%Erase the preceding word.
-.sp .4v
-LNEXT%CTRL-V%T{
-Interpret next character literally.  Many shells disable this function.
-T}
-.sp .4v
-STATUS%\\377%T{
-Send a \f(CWSIGINFO\fR signal to the foreground process group.  If
-\f(CWNOKERNINFO\fR is not set, the kernel also prints a status message on
-the terminal.
-T}
 .TE
 .Tn terminal-control-chars
 .sp 1.5v
-.X "stty, command"
-.X "command, stty"
-To set these characters, use the \fIstty\fP\| program.  For example, if you're
-used to erasing the complete input line with \fBCtrl-X\fP, and specifying an
-end-of-file condition with \fBCtrl-Z\fP, you could enter:
+.ne 4v
+To set these characters, use the
+.Command stty
+program.  For example, if you're used to erasing the complete input line with
+\fBCtrl-X\fP, and specifying an end-of-file condition with \fBCtrl-Z\fP, you
+could enter:
 .Dx
 $ \f(CBstty susp \e377 kill ^X eof ^Z\fP
 .De
 You need to set \f(CWSUSP\fP to something else first, because by default it is
 \f(CWCtrl-Z\fP, so the system wouldn't know which function to perform if you
-press \f(CW^Z\fP
+press \f(CW^Z\fP.
 .Aside
-The combination \f(CW\e377\fP is the character octal 377 (this notation comes
-from the C language, and its origin is lost in the mists of time, back in the
-days when UNIX ran on PDP-11s).  This character is the ``null'' character which
-turns off the corresponding function.  System V uses the character \f(CW\e0\fP
-for the same purpose.
+The combination \f(CW\e377\fP represents the character octal 377 (this notation
+comes from the C programming language, and its origin is lost in the mists of
+time, back in the days when UNIX ran on PDP-11s).  This character is the
+``null'' character that turns off the corresponding function.  System V uses
+the character \f(CW\e0\fP for the same purpose.
 .End-aside
-In this particular case, \f(CW^X\fP really does mean the letter \f(CW^\fP
-followed by the letter \f(CWX\fP, and not \fBCTRL-X\fP, the single character
+In this particular case, \f(CW^X\fP really does mean the character \f(CW^\fP
+followed by the letter \f(CWX\fP, and not \fBCtrl-X\fP, the single character
 created by holding down the \fBControl\fP character and pressing \fBX\fP at the
 same time.
 .H3 "Command history and other editing functions"
-.X "Command history"
+.X "command history"
 .Pn command-history
-The editing characters we looked at above are provided by the terminal driver,
-which is part of the kernel, so they are available to all processes.  They all
-have the limitation that they only work on the line you're currently typing.
-Once you've pressed \fBEnter\fP, there's nothing they can do any more.
-.P
-Nowadays, most shells supply a \fIcommand history\fP\| function and additional
+Nowadays, most shells supply a \fIcommand history\fP\/ function and additional
 functionality for editing it.  We'll take a brief look at these features
 here\(emfor more details, see the man pages for your shell.
+.P
+Shell command line editing has been through a number of evolutionary phases.
+The original Bourne shell supplied no command line editing at all, though the
+version supplied with FreeBSD gives you many of the editing features of more
+modern shells.  Still, it's unlikely that you'll want to use the Bourne shell as
+your shell:
+.Command bash ,
+.Command ksh ,
+and
+.Command zsh
+are all compatible with the Bourne shell, but they also supply better command
+line editing.
+.P
+The next phase of command line editing was introduced with the C shell,
+.Command csh .
+By modern standards, it's also rather pitiful.  It's described in the
+.Command csh
+man page if you really want to know.  About the only part that is still useful
+is the ability to repeat a previous command with the \f(CW!!\fP construct.
+.Pn set-cle
+Modern shells supply command line editing that resembles the editors
+.Command vi
+or \fIEmacs\fP.  In
+.Command bash ,
+.Command sh ,
+.Command ksh ,
+and
+.Command zsh
+you can
+make the choice by entering:
+.Dx
+$ \f(CBset -o emacs\fP                          \fIfor Emacs-style editing\fP\/
+$ \f(CBset -o vi\fP                             \fIfor vi-style editing\fP\/
+.De
+In
+.Command tcsh ,
+the corresponding commands are:
+.Dx
+% \f(CBbind emacs\fP
+% \f(CBbind vi\fP
+.De
+Normally you put one of these commands in your startup file.
+.P
+In \fIEmacs\fP\/ mode, you enter the commands simply by typing them in.  In
+\fIvi\fP\/ mode, you have to press \fBESC\fP first.  Table
+.Sref \*[bash-cli-edit] \&
+shows an overview of the more typical Emacs-style commands in
+.Command bash .
+Many other shells supply similar editing support.
+.P
+As the name suggests, the
+.X "emacs, command"
+.X "command, emacs"
+.Command -n Emacs
+editor understands the same editing characters.  It also understands many more
+commands than are shown here.  In addition, many X-based commands, including web
+browsers, understand some of these characters.
 .\"XXX
 .br
-.DF
-.X "emacs command"
-.X "command, emacs"
-.TB "Command line editing\(em\fIEmacs\fP\| mode"
+.Table-heading "Emacs editing characters"
 .TS H
-box, center,tab(#) ;
-lf(B)w11 | lw67	 .
-Key#Function
-=
+tab(#) ;
+lf(B)w12 | lw57  .
+Key#\fBFunction
+_
 .TH N
 T{
 Ctrl-A
 T}#T{
-Move to the beginning of the line
+Move to the beginning of the line.
 T}
 T{
 LeftArrow
 T}#T{
-Move to previous character on line
+Move to previous character on line.
 T}
 T{
 Ctrl-B
 T}#T{
-Move to previous character on line (alternative)
+Move to previous character on line (alternative).
 T}
 T{
 Ctrl-D
 T}#T{
 Delete the character under the cursor.  Be careful with this character: it's
-also the End-of-file character, so if you enter it on an empty line, it
+also the shell's end-of-file character, so if you enter it on an empty line, it
 stops your shell and logs you out.
 T}
 T{
 Ctrl-E
 T}#T{
-Move to the end of the line
+Move to the end of the line.
 T}
 T{
 RightArrow
 T}#T{
-Move to next character on line
+Move to next character on line.
 T}
 T{
 Ctrl-F
 T}#T{
-Move to next character on line (alternative)
+Move to next character on line (alternative).
 T}
 T{
 Ctrl-K
 T}#T{
-Erase the rest of the line
+Erase the rest of the line.  The contents are saved to a \fIring buffer\fP\/ of
+erased text and can be restored, possibly elsewhere, with \fBCtrl-Y\fP.
 T}
 T{
 Ctrl-L
-T}#T{
-Erase screen contents
-T}
-T{
-DownArrow
-T}#T{
-Move to next input line
-T}
-T{
-Ctrl-N
-T}#T{
-Move to next input line (alternative)
-T}
-T{
-UpArrow
-T}#T{
-Move to previous input line
-T}
-T{
-Ctrl-P
-T}#T{
-Move to previous input line (alternative)
-T}
-T{
-Ctrl-R
-T}#T{
-Incremental search backward for text
-T}
-T{
-Ctrl-S
-T}#T{
-Incremental search for text forward
-T}
-T{
-Ctrl-T
-T}#T{
-Transpose the character under the cursor with the character before the cursor
-T}
-T{
-Ctrl-U
-T}#T{
-Erase the current line
-T}
-T{
-Ctrl-Y
-T}#T{
-Insert previously erased with \fBCtrl-K\fP or \fBAlt-D\fP
-T}
-T{
-Ctrl-_
-T}#T{
-Undo the last command
-T}
-T{
-Alt-C
-T}#T{
-Capitalize the following word
-T}
-T{
-Alt-D
-T}#T{
-Delete the following word
-T}
-T{
-Alt-F
-T}#T{
-Move forward one word
-T}
-T{
-Alt-L
-T}#T{
-Convert the following word to lower case
-T}
-T{
-Alt-T
-T}#T{
-Transpose the word before the cursor with the one after it
-T}
-T{
-Alt-U
-T}#T{
-Convert the following word to upper case
-T}
-.TE
-.Tn bash-cli-edit
-.sp 1.5v
-.DE
-.P
-.X "bash, command"
-.X "command, bash"
-.X "ksh, command"
-.X "command, ksh"
-.X "zsh, command"
-.X "command, zsh"
-Shell command line editing has been through a number of evolutionary phases.
-The original Bourne shell supplied no command line editing at all, though the
-version supplied with FreeBSD gives you many of the editing features of more
-modern shells.  Still, it's unlikely that you'll want to use the Bourne shell as
-your shell: \fIbash\fP, \fIksh\fP, and \fIzsh\fP\| are all compatible with the
-Bourne shell, but they also supply better command line editing.
-.P
-.X "csh, command"
-.X "command, csh"
-.X "vi command"
-.X "command, vi"
-The next phase of command line editing was introduced with the C shell,
-\fIcsh\fP.  By modern standards, it's also rather pitiful.  It's described in
-the \fIcsh\fP\| man page if you really want to know.  About the only part that
-is still useful is the ability to repeat a previous command with the \f(CW!!\fP
-construct.
-.Pn set-cle
-Modern shells supply command line editing which resembles the editors \fIvi\fP\|
-or \fIEmacs\fP.  In \fIbash\fP, \fIsh\fP, \fIksh\fP, and \fIzsh\fP\| you can
-make the choice by entering
-.Dx
-$ \f(CBset -o emacs\fP				\fIfor Emacs-style editing\fP\|
-$ \f(CBset -o vi\fP				\fIfor vi-style editing\fP\|
-.De
-.X "tcsh command"
-.X "command, tcsh"
-In \fItcsh\fP, the corresponding commands are:
-.Dx
-% \f(CBbind emacs\fP
-% \f(CBbind vi\fP
-.De
-Normally you put one of these commands in your startup file.
-.ne 2i
-.TB "Command line editing\(em\fIvi\fP\| mode"
-.TS H
-box,center, tab(#) ;
-| lf(B)w11 | lw58 | .
-Key#Function
-=
-.TH N
+T}#T{
+Erase screen contents (shell) or redraw window (\fIEmacs\fP\/).
+T}
+T{
+DownArrow
+T}#T{
+Move to next input line.
+T}
 T{
-^
+Ctrl-N
 T}#T{
-Move to the beginning of the line
+Move to next input line (alternative).
 T}
 T{
-h
+UpArrow
 T}#T{
-Move to previous character on line
+Move to previous input line.
 T}
 T{
-x
+Ctrl-P
 T}#T{
-Delete the character under the cursor
+Move to previous input line (alternative).
 T}
 T{
-$
+Ctrl-R
 T}#T{
-Move to the end of the line
+Incremental search backward for text.
 T}
 T{
-l
+Ctrl-S
 T}#T{
-Move to next character on line
+Incremental search forward for text.
 T}
 T{
-D
+Ctrl-T
 T}#T{
-Erase the rest of the line
+Transpose the character under the cursor with the character before the cursor.
 T}
 T{
-Ctrl-L
+Ctrl-Y
+T}#T{
+Insert previously erased with \fBCtrl-K\fP or \fBAlt-D\fP.
+T}
+T{
+Ctrl-_
+T}#T{
+Undo the last command.
+T}
+T{
+Alt-C
 T}#T{
-Erase screen contents
+Capitalize the following word.
 T}
 T{
-j
+Alt-D
 T}#T{
-Move to next input line
+Delete the following word.
 T}
 T{
-k
+Alt-F
 T}#T{
-Move to previous input line
+Move forward one word.
 T}
 T{
-K
+Alt-L
 T}#T{
-Search for text backward
+Convert the following word to lower case.
 T}
 T{
-J
+Alt-T
 T}#T{
-Search for text forward
+Transpose the word before the cursor with the one after it.
 T}
 T{
-u
+Alt-U
 T}#T{
-Undo the last command
+Convert the following word to upper case.
 T}
 T{
-w
+Ctrl-X Ctrl-S
 T}#T{
-Move forward one word
+Save file
+.X "command, emacs"
+.X "emacs, command"
+.Command -n ( Emacs \&
+only).
 T}
-i#T{
-Change to insert mode
+T{
+Ctrl-X Ctrl-C
+T}#T{
+Exit the
+.Command -n Emacs
+editor.
 T}
 .TE
-.Tn tcsh-cli-edit
+.Tn bash-cli-edit
 .sp 1.5v
-.X "tcsh command"
-.X "command, tcsh"
-.X "vi command"
-.X "command, vi"
-In \fIEmacs\fP\| mode, you enter the commands simply by typing them in.  In
-\fIvi\fP\| mode, you have to press \fBESC\fP first.  Table \*[bash-cli-edit]
-shows an overview of the more typical Emacs-style commands in \fIbash\fP, and
-Table \*[tcsh-cli-edit] shows the commands for \fItcsh\fP\| in \fIvi\fP\| mode.
-Many other shells supply similar functionality.
+You'll note a number of alternatives to the cursor keys.  There are two reasons
+for them: firstly, the shell and \fIEmacs\fP\/ must work on systems without
+arrow keys on the keyboard.  The second reason is not immediately obvious: if
+you're a touch-typer, it's easier to type \fBCtrl-P\fP than take your hands away
+from the main keyboard and look for the arrow key.  The arrows are good for
+beginners, but if you get used to the control keys, you'll never miss the arrow
+keys.
 .H4 "File name completion"
 .X "file name completion"
-.X "emacs command"
-.X "command, emacs"
 As we have seen, UNIX file names can be much longer than traditional Microsoft
 names, and it becomes a problem to type them correctly.  To address this
-problem, newer shells provide \fIfile name completion\fP.  In \fIEmacs\fP\|
+problem, newer shells provide \fIfile name completion\fP.  In \fIEmacs\fP\/
 mode, you typically type in part of the name, then press the \fBTab\fP key.  The
 shell checks which file names begin with the characters you typed.  If there is
 only one, it puts in the missing characters for you.  If there are none, it
 beeps (rings the ``terminal bell'').  If there are more than one, it puts in as
 many letters as are common to all the file names, and then beeps.  For example,
-if I have a directory \fIdocumentation\fP\| in my home directory, I might enter:
+if I have a directory
+.Directory docco
+in my home directory, I might enter:
 ..if review
 | (bmc) Except in `ksh'.  In most versions of `ksh', including the `pdksh'
 | that's available for FreeBSD, file name completion is done via "ESC ESC"
@@ -1445,285 +1687,127 @@
 |	bind '^I'=complete-file
 ..endif
 .Dx
-=== grog@freebie (/dev/ttyp4) ~ 14 -> cd \f(CBdoc\f(CWumentation/
-=== grog@freebie (/dev/ttyp4) ~/documentation 15 -> \f(CBls\f(CW
+=== grog@freebie (/dev/ttyp4) ~ 14 -> cd \f(CBdoc\f(CWco/
+=== grog@freebie (/dev/ttyp4) ~/docco 15 -> \f(CBls\f(CW
 freebsd.faq  freebsd.fbc  freeware
-=== grog@freebie (/dev/ttyp4) ~/documentation 16 -> \f(CBemacs f\fPree\fIbeep\f(CBb\f(CWsd.f\fIbeep\f(CBaq
+=== grog@freebie (/dev/ttyp4) ~/docco 16 -> \f(CBemacs f\fPree\fIbeep\f(CBb\f(CWsd.f\fIbeep\f(CBaq
 .De
-Remember that my input is in \s\n[cwfontsize]\f(CBfixed bold\fP\s0 font, and the
-shell's output is in \s\n[cwfontsize]\f(CWfixed\fP\s0 font.  On the first line,
-I entered the characters \f(CWcd doc\fP followed by a \fBTab\fP character, and
-the shell completed with the text \f(CWumentation/\fP.  On the last line, I
-entered the characters \f(CWemacs f\fP and a \fBTab\fP.  In this case, the shell
-determined that there was more than one file which started like this, so it
-added the letters \f(CWree\fP and rang the bell.  I entered the letter \f(CWb\fP
-and pressed \fBTab\fP again, and the shell added the letters \f(CWsd.f\fP and
-beeped again.  Finally, I added the letters \f(CWaq\fP to complete the file name
+Remember that my input is in \f(CBconstant width bold\fP font, and the shell's
+output is in \f(CWconstant width\fP font.  On the first line, I entered the
+characters \f(CWcd doc\fP followed by a \fBTab\fP character, and the shell
+completed with the text \f(CWco/\fP.  On the last line, I entered the characters
+\f(CWemacs f\fP and a \fBTab\fP.  In this case, the shell determined that there
+was more than one file name that started like this, so it added the letters
+\f(CWree\fP and rang the bell.  I entered the letter \f(CWb\fP and pressed
+\fBTab\fP again, and the shell added the letters \f(CWsd.f\fP and beeped again.
+Finally, I added the letters \f(CWaq\fP to complete the file name
 \fIfreebsd.faq\fP.
 .P
-.X "vi command"
-.X "command, vi"
-Command line completion in \fIvi\fP\| mode is similar: instead of pressing
+Command line completion in \fIvi\fP\/ mode is similar: instead of pressing
 \fBTab\fP, you press \fBESC\fP twice.
-.H3 "Environment variables"
-.X "environment variables"
-.X "variables, environment"
-.Pn environment-variables
-.X "environment variables"
-The UNIX programming model includes a concept called \fIenvironment
-variables\fP.  This rather unusual sounding name is simply a handy method of
-passing relatively long-lived information of a general nature from one program
-to another.  It's easier to demonstrate the use than to describe.  Table
-\*[environment-variable-table] takes a look at some typical environment
-variables.  To set environment variables from Bourne-style shells, enter
-.Dx
-$ \f(CBTERM=xterm export TERM\fP
-.De
-This sets the value of the \f(CWTERM\fP variable to \f(CWxterm\fP.  If you
-want, you can also set it at the beginning of a command line:
-.Dx
-$ \f(CBTERM=xterm-color mutt\fP
-.De
-.X "mutt, command"
-.X "command, mutt"
-This starts the \fImutt\fP\| mail reader (see page \*[mutt]) with
-\fIxterm\fP\|'s colour features enabled.
-.P
-For \fIcsh\fP\| and \fItcsh\fP, set environment variables with:
-.Dx
-% \f(CBsetenv TERM xterm\fP
-.De
-To start a process with these variables, enter:
-.Dx
-% \f(CBenv xterm-color mutt\fP
-.De
-.TB "Common environment variables"
-.TS H
-box,center,tab(#) ;
-| lfCWp9 | lw68 | .
-\fR\s10Name#Purpose
-=
-.TH N
-.X "df"
-BLOCKSIZE#T{
-The size of blocks which programs like \fIdf\fP\|
-count.  The default is 512
-bytes, but it's often more convenient to use 1024.
-T}
-.sp .3v
-.X "termcap"
-COLUMNS#T{
-The number of columns on the current display.  This variable should not be used,
-since the number of columns is defined in the \fItermcap\fP\|
-description for
-terminals with a fixed display size, and the software should be able to ask the
-others, such as \fIxterm\fP, for their size.  Unfortunately, other systems
-frequently have difficulties in this area, and \f(CWCOLUMNS\fP can help.
-T}
-.sp .3v
-DISPLAY#T{
-When running X, the name of the X server.  For a local system, this is typically
-\f(CWunix:0\fP.  For remote systems, it's in the form
-.br
-\f(BIsystem-name\fP\|:\f(BIserver-number\fP\|.\f(BIscreen-number\fP.  For the
-system \fIbumble.example.org\fP, you would probably write \f(CWbumble.example.org:0\fP.
-T}
-.sp .3v
-EDITOR#T{
-The name of your favourite editor.  Various programs that start editors
-look at this variable to know which editor to start.
-T}
-.sp .3v
-HOME#T{
-The name of your home directory.
-T}
-.sp .3v
-.X "locale"
-LANG#T{
-The \fIlocale\fP\|
-which you use.  This should be the name of a directory in
-\fI/usr/share/locale\fP.
-T}
-.sp .3v
-LINES#T{
-See \f(CWCOLUMNS\fP above.  This second variable defines the number
-of lines on the screen.
-T}
-.sp .3v
-MAIL#T{
-Some programs use this variable to find your incoming mail file.
-T}
-.sp .3v
-.X "/usr/share/man"
-.X "/usr/local/man"
-MANPATH#T{
-A list of path names, separated by colons (\f(CW:\fP), which specifies where the
-\fIman\fP\| program should look for man pages.  A typical string might be
-\f(CW/usr/share/man:/usr/local/man\fP, and specifies that there are man pages in
-each of the directories \fI/usr/share/man\fP\|
-and \fI/usr/local/man\fP.
-T}
-.sp .3v
-NTAPE#T{
-The name of the non-rewinding tape device.  See page \*[tape-devices] for more
-details.
-T}
-.sp .3v
-PATH#T{
-A list of path names, separated by colons (\f(CW:\fP), which specifies where the
-shell should look for executable programs if you specify just the program name.
-T}
-.sp .3v
-PS1#T{
-In Bourne-style shells, this is the prompt string.  It's usually set to
-\f(CB$\fP, but can be changed.  See page \*[shell-prompt] for a discussion of
-a possible prompt for \fIbash\fP.
-T}
-.sp .3v
-PS2#T{
-In Bourne-style shells, this is the prompt string for continuation lines.  It's
-usually set to \f(CB>\fP.
-T}
-.sp .3v
-SHELL#T{
-The name of the shell.  You can use this for starting a new copy.
-T}
-.sp .3v
-TAPE#T{
-The name of the rewinding tape device.  See page \*[tape-devices] for more
-details.
-T}
-.sp .3v
-.X "/usr/share/zoneinfo"
-TERM#T{
-The type of terminal emulation you are using.  This is very important: there is
-no other way for an application to know what the terminal is, and if you set it
-to the wrong value, full-screen programs will behave incorrectly.
-T}
-TZ#T{
-Time zone.  This is the name of a file in \fI/usr/share/zoneinfo\fP\|
-which
-describes the local time zone.  See the section on timekeeping on page
-\*[timekeeping] for more details.
-T}
-.Tn environment-variable-table
-.TE
-.sp 1.5v
-.Pn PATH
-Note particularly the \f(CWPATH\fP variable.  One of the most popular questions
-in the \f(CWFreeBSD-questions\fP mailing list is ``I have compiled a program,
-and I can see it in my directory, but when I try to run it, I get the message
-\f(CWcommand not found\fP''.  This is usually because the current directory is
-not in the \f(CWPATH\fP.
-.Aside
-It's good practice \fInot\fP\| to have your current directory or your home
-directory in the \f(CWPATH\fP: if you do, you can be subject to security
-attacks.
-.End-aside
-.X ".profile"
-.Pn profile
-You should set your \f(CWPATH\fP variable to point to the most common executable
-directories.  Add something like this to your \fI.profile\fP\| file (for
-Bourne-style shells):
-.Dx
-PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
-export PATH
-.De
-.X ".cshrc"
-Alternatively, for \fIcsh\fP-style shells, put this in your \fI.cshrc\fP\|:
-.Dx
-set path = (/usr/bin /usr/local/bin /usr/sbin /bin /sbin /usr/X11R6/bin)
-.De
-This specifies to look for executable programs in the sequence \fI/usr/bin\fP,
-\fI/usr/local/bin\fP, \fI/usr/sbin\fP, \fI/bin\fP, \fI/sbin\fP and
-\fI/usr/X11R6/bin\fP.  This variable is of great importance: one of the leading
-problems that beginners have is to have an incorrect \f(CWPATH\fP variable.
-.P
 .H3 "Shell startup files"
-.X "Shell startup files"
+.X "shell, startup files"
 .Pn bashrc
 As we saw above, there are a lot of ways to customize your shell.  It would be
 inconvenient to have to set them every time, so all shells provide a means to
 set them automatically when you log in.  Nearly every shell has its own startup
-file.  Table \*[.rcnames] gives an overview.
-.P
-The format of these files is like a shell script\(emin other words, straight
-shell commands.  Figure \*[.bashrc] shows a typical \fI.bashrc\fP\| file to set
-the environment variables we discussed.
+file.  Table
+.Sref \*[.rcnames] \&
+gives an overview.
 .P
 .br
-.ne 1i
-.TB "Shell startup files"
+.Table-heading "Shell startup files"
 .TS H
-box,center,tab(#) ;
-l | lI .
-Shell#startup file
-=
+tab(#) ;
+lI | lI .
+\fBShell#\fBstartup file
+_
 .TH
 bash#.profile\fR, then\fP .bashrc
 csh#.login\fP on login, always\fP .cshrc
 sh#.profile
-tcsh#.login\fP on login, always\fP .tcshc, .cshrc if .tcshrc not found
-.Tn .rcnames
+tcsh#.login\fP on login, always\fI .tcshc\/\fR,\fI .cshrc \fRif\fI .tcshrc\fR not found
 .TE
+.Tn .rcnames
 .sp 1.5v
+.P
+.ne 6v
+These files are shell scripts\(emin other words, straight shell commands.
+Figure
+.Sref \*[.bashrc] \&
+shows a typical
+.File .bashrc
+file to set the environment variables we discussed.
 .Dx
 umask 022
-BLOCKSIZE=1024	# for df
-CVSROOT=/src/ncvs
-EDITOR=/opt/bin/emacs;export EDITOR
-LANG=en_AU.ISO8859-1 export LANG
-MANPATH=/usr/share/man:/usr/local/man
-MOZILLA_HOME=/usr/local/netscape export MOZILLA_HOME
-PAGER=less export PAGER
-PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
+export BLOCKSIZE=1024   # for df
+export CVSROOT=/src/ncvs
+export EDITOR=/opt/bin/emacs
+export MANPATH=/usr/share/man:/usr/local/man
+export MOZILLA_HOME=/usr/local/netscape
+export PAGER=less
+export PATH=/usr/bin:/usr/local/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin
 PS1="=== \eu@\eh (`tty`) \ew \e# -> "
 PS2="\eu@\eh \ew \e! ++ "
-SHELL=/bin/bash export SHELL
-TAPE=/dev/nrst0 export TAPE	# note non-rewinding as standard
+export SHELL=/usr/local/bin/bash
+export TAPE=/dev/nsa0   # note non-rewinding as standard
 if [ "$TERM" = "" ]; then
-  TERM=xterm
+  export TERM=xterm
 fi
 if [ "$DISPLAY" = "" ]; then
-  DISPLAY=unix:0;export DISPLAY
+  export DISPLAY=:0
 fi
 /usr/games/fortune		# print a fortune cookie
 .De
-.X ".bashrc"
-.Figure-heading "Minimal \fI.bashrc\fP\| file"
-.ft R
-.Tn .bashrc
+.Figure-heading "Minimal .bashrc file"
+.Fn .bashrc
 It would be tedious for every user to put settings in their private
 initialization files, so the shells also read a system-wide default file.  For
-the Bourne shell family, it is \fI/etc/profile\fP, while the C shell family has
-three files: \fI/etc/csh.login\fP to be executed on login, \fI/etc/csh.cshrc\fP
+the Bourne shell family, it is
+.File /etc/profile ,
+while the C shell family has
+three files:
+.File /etc/csh.login
+to be executed on login,
+.File /etc/csh.cshrc
 to be executed when a new shell is started after you log in, and
-\fI/etc/csh.logout\fP to be executed when you stop a shell.  The start files are
-executed before the corresponding individual files.
-.P
-In addition, login classes (page \*[login-class]) offer another method of
-setting environment variables at a global level.
+.File /etc/csh.logout
+to be executed when you stop a shell.  The start files are executed before the
+corresponding individual files.
+.P
+In addition, login classes (page
+.Sref \*[login-class] )
+offer another method of setting environment variables at a global level.
 .H3 "Changing your shell"
 .Pn chsh
-.X "command, chsh"
-.X "chsh, command"
-The FreeBSD installation gives \f(CWroot\fP a C shell, \fIcsh\fP.  This is the
-traditional Berkeley shell, but it has a number of disadvantages: command line
-editing is very primitive, and the script language is significantly different
-from that of the Bourne shell, which is the \fIde facto\fP\| standard for shell
-scripts: if you stay with the C shell, you may still need to understand the
-Bourne shell.  The latest version of the Bourne shell \fIsh\fP\| also includes
-some command line editing.  See page \*[set-cle] for details of how to enable
-it.
-.P
-You can get better command line editing with \fItcsh\fP, in the Ports
-Collection.  You can get both better command line editing and Bourne shell
-syntax with \fIbash\fP, also in the Ports Collection.
-.P
-If you have \f(CWroot\fP access, you can use \fIvipw\fP\| to change your shell,
-but there's a more general way: use \fIchsh\fP\| (\fIChange Shell\fP\|).  Simply
-run the program.  It starts your favourite editor (as defined by the
-\f(CWEDITOR\fP environment variable).  Here's an example before:
+The FreeBSD installation gives \f(CWroot\fP a C shell,
+.Command csh .
+This is the traditional BSD shell, but it has a number of disadvantages: command
+line editing is very primitive, and the script language is significantly
+different from that of the Bourne shell, which is the \fIde facto\fP\/ standard
+for shell scripts: if you stay with the C shell, you may still need to
+understand the Bourne shell.  The latest version of the Bourne shell
+.Command sh
+also includes some command line editing.  See page
+.Sref \*[set-cle] \&
+for details of how to enable it.
+.P
+If you want to stay with a
+.Command csh -like
+shell, you can get better command line editing with
+.Command tcsh ,
+which is also in the base system.  You can get both better command line editing
+and Bourne shell syntax with
+.Command bash ,
+in the Ports Collection.
+.P
+If you have \f(CWroot\fP access, you can use
+.Command vipw
+to change your shell, but there's a more general way: use
+.Command chsh
+(\fIChange Shell\fP\/).  Simply run the program.  It starts your favourite
+editor (as defined by the \f(CWEDITOR\fP environment variable).  Here's an
+example before:
 .Dx
 .X "Velte, Jack"
 #Changing user database information for velte.
@@ -1743,585 +1827,224 @@
 Office Phone: \f(CB+1-408-555-1999\fP
 Home Phone: 
 .De
-\fIchsh\fP\| checks and updates the password files when you save the
-modifications and exit the editor.  The next time you log in, you get the new
-shell.  \fIchsh\fP\| tries to ensure you don't make any mistakes\(emfor example,
-it won't let you enter the name of a shell which isn't mentioned in the file
-\fI/etc/shells\fP\(embut it's a \fIvery\fP\| good idea to check the shell before
-logging out.  You can try this with \fIsu\fP, which you normally use to become
-super user:
+.Command chsh
+checks and updates the password files when you save the modifications and exit
+the editor.  The next time you log in, you get the new shell.
+.Command chsh
+tries to ensure you don't make any mistakes\(emfor example, it won't let you
+enter the name of a shell that isn't mentioned in the file
+.File /etc/shells \(embut
+it's a \fIvery\fP\/ good idea to check the shell before logging out.  You can
+try this with
+.Command su ,
+which you normally use to become super user:
 .Dx
 bumble# \f(CBsu velte\fP
 Password:
-su-2.00$				\fInote the new prompt\fP\|
+su-2.00$                                \fInote the new prompt\fP\/
 .De
-There are a couple of problems in using \fItcsh\fP\| or \fIbash\fP\| as a root
-shell:
-.Ls B
-.LI
-The shell for \f(CWroot\fP \fImust\fP\| be on the root file system, otherwise
-will not work in single user mode.  Unfortunately, most ports of shells put the
-shell in the directory \fI/usr/local/bin\fP, which is almost never on the root
-file system.
-.LI
-Most shells are \fIdynamically linked\fP\|: they rely on library routines in
-files such as \fI/usr/lib/libc.a\fP.  These files are not available in single
-user mode, so the shells won't work.  You can solve this problem by creating
-\fIstatically linked\fP\| versions of the shell, but this requires programming
-experience beyond the scope of this book.
-.Le
-If you can get hold of a statically linked version, perform the following steps
-to install it:
+You might hear objections to using
+.Command bash
+as a root shell.  The argument goes something like this:
+.Command bash
+is installed in
+.Directory /usr/local/bin ,
+so it's not available if you boot into single-user mode, where only the root
+file system is available.  Even if you copy it to, say,
+.Directory /bin ,
+you can't run it in single-user mode because it needs libraries in
+.Directory /usr/lib .
+.P
+In fact, this isn't a problem.  If you install the system the way I recommend in
+Chapter
+.Sref \*[nchinstall] ,
+.Directory /usr
+\fIis\fP\/ on the root file system.  Even if it isn't, though, you don't have to
+use
+.Command bash
+in single-user mode.  When you boot to single-user mode, you get a prompt asking
+you which shell to start, and suggesting
+.Command -n /bin/sh .
+.br
+.ne 14v
+.H2 "Differences from Microsoft"
+If you're coming from a Microsoft background, there are a few gotchas that you
+might trip over.
+.H3 "Slashes: backward and forward"
+.X "root, directory"
+.X "slash, character"
+.X "escape, character"
+.X "character, slash"
+.X "character, escape"
+.Pn slash
+\f(CW/\fP (slash) and \f(CW\e\fP (backslash) are confusing.  As we've seen, UNIX
+uses \f(CW/\fP to delimit directories.  The backslash \f(CW\e\fP is called an
+\fIescape character\fP.  It has several purposes:
 .Ls B
 .LI
-Copy the shell to \fI/bin\fP, for example:
-.Dx
-# \f(CBcp /usr/local/bin/bash /bin\fP
-.De
-.sp -1v
-.LI
-Add the name of the shell to \fI/etc/shells\fP,  in this example the line in
-\fBbold print\fP:
+You can put it in front of another special character to say ``don't interpret
+this character in any special way.''  We've seen that the shell interprets a
+space character as the end of a parameter.  In the previous example we changed
+\f(CWMail rejected\fP to \f(CW"Mail rejected"\fP to stop the shell from
+interpreting it.  We could also have written: \f(CWMail\e\ rejected\fP.
+.P
+.X "quoting"
+A more common use for this \fIquoting\fP\/ is to tell the shell to ignore the
+end of a line.  If a command line in a shell script gets too long, you might
+like to split it up into several lines; but the shell sees the end of a line as
+a go-ahead to perform the command.  Stop it from doing so by putting a backslash
+\fIimmediately\fP\/ before the end of the line:
 .Dx
-# List of acceptable shells for chpass(1).
-# Ftpd will not allow users to connect who are not using
-# one of these shells.
-/bin/sh
-/bin/csh
-\f(CB/bin/bash\fP
-.De
-.Le
-.sp -2v
-.H2 "Processes"
-.X "process, defined"
-.Pn processes
-.Pn ps-command
-.X "process ID"
-.X "PID"
-As we have seen, UNIX is a multi-user, multi-tasking operating system.  In
-particular, you can run a specific program more than once.  We use the term
-\fIprocess\fP\| to refer to a particular instance of a running program.  Each
-process is given a \fIprocess ID\fP, more frequently referred to as \fIPID\fP, a
-number between 0 and 29999 which uniquely identifies it.  There are many things
-that you might like to know about the processes which are currently running,
-such as:
-.Ls B
-.LI
-How many processes are running?
-.LI
-Who is running the processes?
-.LI
-Why is the system so slow?
-.LI
-Which process is blocking my access to the modem?
-.Le
-.X "ps command"
-.X "command, ps"
-.X "process status"
-Your primary tool for investigating process behaviour is the \fIps\fP\|
-(\fIprocess status\fP\|) command.  It has a large number of command options, and
-it can tell you a whole lot of things which you will only understand when you
-have investigated how the kernel works, but it can be very useful for a number
-of things.  Here are some typical uses:
-.H3 "What processes do I have running?"
-After starting a large number of processes in a number of windows under X, you
-probably can't remember what is still running.  Maybe processes that you thought
-had stopped are still running.  To display a brief summary of the processes you
-have running, use the \fIps\fP\| command with no options:
-.Dx
-$ \f(CBps\fP
-  PID  TT  STAT      TIME COMMAND
-  187  p0  Is+    0:01.02 -bash (bash)
-  188  p1  Ss     0:00.62 -bash (bash)
-  453  p1  R+     0:00.03 ps
-.De
-This display shows the following information:
-.Ls B
-.LI
-The \f(BIPID\fP\| of the process.
-.LI
-.X "controlling terminal"
-.X "/dev/ttyp0"
-.X "teletype"
-\f(BITT\fP\| is short for \fIteletype\fP, and shows the last few letters of the
-name of the \fIcontrolling terminal\fP, the terminal on which the process is
-running.  In this example, the terminals are \fI/dev/ttyp0\fP\| and
-\fI/dev/ttyp1\fP.
-.LI
-\fISTAT\fP\| shows the current process status.  It's involved and requires a
-certain amount of understanding of how the kernel runs in order to interpret
-it\(emsee the man page for \fIps\fP\| for more details.
-.LI
-\fITIME\fP\| is the CPU time that the process has used in minutes, seconds and
-hundredths of a second.  Note that many other UNIX systems, particularly System
-V, only show this field to the nearest second.
-.LI
-.X "ps command"
-.X "command, ps"
-\fICOMMAND\fP\| is normally the command you entered, but don't rely on this.  In
-the next section, you'll see that \fIsendmail\fP\| has changed its
-\fICOMMAND\fP\| field to tell you what it is doing.  You'll notice that the
-command on the last line is the \fIps\fP\| which performs the listing.  Due to
-some complicated timing problems in the kernel, this process may or may not
-appear in the listing.
-.LE
-.H3 "What processes are running?"
-There are many more processes in the system than the list above shows.  To show
-them all, use the \f(CWa\fP option to \fIps\fP.  To show dmons as well
-(see the next section for a definition of \fIdmon\fP\|), use the \f(CWx\fP
-option.  To show much more detail, use the \f(CWu\fP or \f(CWl\fP options.  For
-example,
-.Dx
-$ \f(CBps waux\fP
-.\" This doesn't fit on the page in the standard point size.  Reduce.
-.\" Should do now. .ps 6000u
-USER    PID %CPU %MEM  VSZ  RSS  TT  STAT STARTED    TIME COMMAND
-grog    510  0.0  0.9  448  272  p1  R+    2:49PM 0:00.02 ps -waux
-root      1  0.0  0.6  324  180  ??  Is   10:10AM 0:00.15 /sbin/init --
-root      2  0.0  0.1    0   12  ??  DL   10:10AM 0:00.00  (pagedaemon)
-root      3  0.0  0.1    0   12  ??  DL   10:10AM 0:00.00  (vmdaemon)
-root      4  0.0  0.1    0   12  ??  DL   10:10AM 0:08.61  (update)
-root     23  0.0  0.3  196   72  ??  Is   10:10AM 0:00.02 adjkerntz -i
-root     49  0.0  0.4  220  116  ??- I     9:11AM 0:00.10 mount -a -t nfs
-root     71  0.0  1.1  188  340  ??  Ss    9:11AM 0:00.78 syslogd
-daemon   76  0.0  0.9  176  272  ??  Is    9:11AM 0:00.03 portmap
-root     81  0.0  0.9  160  280  ??  Is    9:11AM 0:00.84 rwhod
-root     85  0.0  0.6  408  176  ??  Is    9:11AM 0:00.03 mountd
-root     87  0.0  0.4  232  104  ??  Is    9:11AM 0:00.03 nfsd: master (nfsd)
-root     90  0.0  0.2  224   56  ??  I     9:11AM 0:00.02 nfsd: server (nfsd)
-root     91  0.0  0.2  224   56  ??  I     9:11AM 0:00.00 nfsd: server (nfsd)
-root     92  0.0  0.2  224   56  ??  I     9:11AM 0:00.00 nfsd: server (nfsd)
-root     93  0.0  0.2  224   56  ??  I     9:11AM 0:00.00 nfsd: server (nfsd)
-root     98  0.0  1.0  192  300  ??  Is    9:11AM 0:00.54 inetd
-root    105  0.0  1.1  236  340  ??  Is    9:11AM 0:01.19 cron
-root    107  0.0  1.1  192  320  ??  Is    9:11AM 0:00.07 lpd
-root    110  0.0  1.3  484  376  ??  Is    9:11AM 0:00.16 sendmail: accepting connecti
-root    150  0.0  1.8  156  536  v0  Is+   9:11AM 0:00.06 /usr/libexec/getty Pc ttyv0
-root    151  0.0  1.8  156  536  v1  Is+   9:11AM 0:00.06 /usr/libexec/getty Pc ttyv1
-root    152  0.0  1.8  156  536  v2  Is+   9:11AM 0:00.06 /usr/libexec/getty Pc ttyv2
-root    153  0.0  1.8  156  536  v3  Is+   9:11AM 0:00.05 /usr/libexec/getty Pc ttyv3
-root    154  0.0  1.8  156  536  v4  Is+   9:11AM 0:00.07 /usr/libexec/getty Pc ttyv4
-root    155  0.0  1.8  156  536  v5  Is+   9:11AM 0:00.06 /usr/libexec/getty Pc ttyv5
-root    156  0.0  1.8  156  536  v6  Is+   9:11AM 0:00.05 /usr/libexec/getty Pc ttyv6
-root    160  0.0  1.8  176  556  ??  I     9:11AM 0:00.08 /usr/libexec/yagetty 38400
-root    163  0.0  0.6  284  168  ??  I     9:12AM 0:01.55 nfs radio.example.org /C
-root    173  0.0  1.8  168  540  ??  Is    9:29AM 0:00.11 rshd
-root    174  0.0  5.7  540 1728  ??  I     9:29AM 0:03.04 xterm
-root    180  0.0  1.8  168  544  ??  Is    9:29AM 0:00.21 rshd
-root    181  0.1  6.0  540 1820  ??  S     9:29AM 0:06.12 xterm
-grog    187  0.0  1.7  808  520  p0  Is    9:30AM 0:01.10 -bash (bash)
-grog    188  0.0  1.9  768  568  p1  Ss    9:30AM 0:00.75 -bash (bash)
-root    462  0.0  2.0  752  600  p0  I+    2:35PM 0:00.78 su (bash)
-root      0  0.0  0.0    0    0  ??  DLs  -       0:00.00  (swapper)
-.De
-We've seen a number of these fields already.  The others are:
-.Ls B
-.LI
-.X "real user ID"
-\fIUSER\fP\| is the \fIreal user ID\fP\| of the process, the user ID of the
-person who started it.
-.LI
-\f(BI%CPU\fP\| is an approximate count of the proportion of CPU time that the
-process has been using in the last few seconds.  This is the column to examine
-if things suddenly get slow.
-.LI
-\fI%MEM\fP\| is an approximate indication of the amount of physical memory that
-the process is using.
-.LI
-\fIVSZ\fP\| (\fIvirtual size\fP\|) is the number of 4096 byte pages of virtual
-memory that the process is using.
-.LI
-\fIRSS\fP\| (\fIresident segment size\fP\|) is the number of 4096 byte pages of
-physical memory currently in use.
-.LI
-\fISTARTED\fP\| is the time or date when the process was started.
-.Le
-In addition, a surprising number of processes don't have a controlling
-terminal.  They are \fIdmons\fP, and we'll look at them in the next
-section.
-.H3 "\fItop\fP\|"
-.X "top"
-Another tool for investigating system performance is \fItop\fP, which shows a
-number of performance criteria, including the status of the processes which are
-using the most resources.  Start it with the number of processes you want
-displayed, for example:
-.Dx
-$ \f(CBtop 4\fP
-last pid: 10887;  load averages:  0.27,  0.43,  0.32                  14:18:05
-109 processes: 6 running, 96 sleeping, 7 zombie
-CPU states:  3.5% user,  0.0% nice,  5.0% system,  0.0% interrupt, 91.5% idle
-Mem: 6456K Active, 53M Inact, 21M Wired, 11M Cache, 8341K Buf, 588K Free
-Swap: 314M Total, 97M Used, 218M Free, 31% Inuse
-
-  PID USERNAME PRI NICE  SIZE    RES STATE    TIME   WCPU    CPU COMMAND
-15027 grog       2   0 38788K 16000K select  52:34  2.02%  2.02% X
-22478 grog       2   0  6232K  3160K select   3:44  0.72%  0.72% emacs
-10887 grog      28   0   920K   692K RUN      0:00  0.70%  0.65% top
-15058 grog       2   0   484K   456K select   0:09  0.11%  0.11% fvwm2
-.De
-See the man page \fItop(1)\fP\| for more details.
-.H3 "Dmons"
-.Pn daemon
-.X dmon
-.X daemon
-.X "sendmail dmon"
-.X "inetd dmon"
-.X "cron dmon"
-A significant part of the work in a FreeBSD system is performed by
-\fIdmon\fP\|s.  A dmon is not just the friendly little guy on the cover of
-this book\(emit's a process which goes around in the background and does routine
-work such as sending mail (\fIsendmail\fP\|), accepting or denying Internet
-access (\fIinetd)\fP, or starting jobs at particular times (\fIcron\fP\|).
-.Aside
-To quote the \fIShorter Oxford English Dictionary\fP\|: \fBDemon\fP Also
-\fBdmon\fP. ME [In form, and in sense I, a. L. \fIdmon\fP
-(med. L. \fIdemon\fP\|)...] 1. Gr. Myth. (=
-\fI\(*d\(*a\h'.05m'\(*i\(*m\(*w\(*n\fP\|): A being of a nature intermediate
-between that of gods and men; an inferior divinity, spirit (including the souls
-of deceased persons).  Often written \fIdmon\fP\| for distinction.  1569.
-.End-aside
-You can recognize dmons in a \fIps waux\fP\| listing by the fact that they don't
-have a controlling terminal.  Each dmon has a man page which describes what it
-does.
-.P
-.X "init dmon"
-.X "dmon, init"
-Normally, dmons are started when the system is booted and run until the system
-is stopped.  If you stop one by accident, you could be in trouble.  For example,
-\fIinit\fP\| is responsible for starting other processes.  If you kill it, you
-effectively kill the system, so, unlike traditional UNIX systems, FreeBSD does
-not allow \fIinit\fP\| to be killed.
-.H3 "\fIcron\fP\|"
-.X "cron"
-.Pn cron
-.X "/etc/daily"
-.X "/etc/weekly"
-.X "/etc/monthly"
-One of the more useful dmons is \fIcron\fP, named after Father Time.
-\fIcron\fP\| performs functions at specific times.  For example, by default the
-system runs the script \fI/etc/daily\fP\| every day at 2:00 am, the script
-\fI/etc/weekly\fP\| every Saturday at 3:30 am, and the script
-\fI/etc/monthly\fP\| on the first day of every month at 5:30 am.
-.P
-.X "crontab"
-To tell \fIcron\fP\| to perform a function at a particular time, you need a file
-called a \fIcrontab\fP.  The system keeps the real \fIcrontab\fP\| where you
-can't get at it, but you can keep a copy.  It's a good idea to call it
-\fIcrontab\fP\| as well.
-.P
-Let's look at the format of the default system \fIcrontab\fP, located in
-\fI/etc/crontab\fP\|:
-.Dx
-# /etc/crontab - root's crontab for FreeBSD
-#
-# $I\&d: crontab,v 1.10 1995/05/27 01:55:21 ache Exp $
-# From: I\&d: crontab,v 1.6 1993/05/31 02:03:57 cgd Exp
-#
-SHELL=/bin/sh
-PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
-HOME=/var/log
-#
-#minute hour	mday	month	wday	who	command
-#
-*/5	*	*	*	*	root	/usr/libexec/atrun
-#
-# rotate log files every hour, if necessary
-#0	*	*	*	*	root	/usr/bin/newsyslog
-#
-# do daily/weekly/monthly maintenance
-0	2	*	*	*	root	/etc/daily 2>&1 | sendmail root
-30	3	*	*	6	root	/etc/weekly 2>&1 | sendmail root
-30	5	1	*	*	root	/etc/monthly 2>&1 | sendmail root
-#
-# time zone change adjustment for wall cmos clock,
-# does nothing, if you have UTC cmos clock.
-# See adjkerntz(8) for details.
-1,31	0-4	*	*	*	root	/sbin/adjkerntz -a
-.De
-As usual, lines starting with \f(CW#\fP are comments.  The others have seven
-fields.  The first five fields specify the minute, the hour, the day of the
-month, the month, and the day of the week on which an action should be
-performed.  The character \f(CB*\fP means ``every''.  Thus, \f(CW0 2 * * *\fP
-(for \fI/etc/daily\fP\|) means ``0 minutes, 2 o'clock (on the 24 hour clock),
-every day of the month, every month, every weekday''.
-.P
-.X "/etc/crontab"
-Field number six is special: it only exists in \fI/etc/crontab\fP, and it
-specifies the user as which the operation should be performed.  When you write
-your own \fIcrontab\fP\| file, don't use this field.
-.P
-The remaining fields define the operation to be performed.  \fIcron\fP\| doesn't
-read your shell initialization files.  In particular, this can mean that it
-won't find programs you expect it to find.  It's a good idea to put in explicit
-\f(CWPATH\fP definitions, or specify an absolute pathname for the program, as is
-done in this example.  \fIcron\fP\| mails the output to you, so you should check
-\f(CWroot\fP's mail from time to time.
-.P
-.X "crontab, command"
-.X "command, crontab"
-To install or list a \fIcrontab\fP, use the \fIcrontab\fP\| program:
-.Dx
-$ \f(CBcrontab crontab\fP				\fIinstall a crontab\fP\|
-$ \f(CBcrontab -l\fP					\fIlist the contents of an installed crontab\fP\|
-# DO NOT EDIT THIS FILE - edit the master and reinstall.
-# (crontab installed on Wed Jan  1 15:15:10 1997)
-# (Cron version -- $\&Id: crontab.c,v 1.7 1996/12/17 00:55:12 pst Exp $)
-0 0 * * * /home/grog/Scripts/rotate-log
+$ \f(CBgrep \e
+  "Mail rejected" \e
+   /var/log/maillog\fP
 .De
-.sp -1v
-.H3 "Stopping processes"
-.X "stopping processes"
-.X "processes, stopping"
-.Pn stopping-processes
-Sometimes you may find that you want to stop a currently running process.  There
-are a number of ways to do this, but the easiest are:
-.Ls B
-.LI
-If the process is running on a terminal, and it's accepting input, hitting the
-\fIEOF\fP\| key (usually \fBCTRL-D\fP) will often do it.
+Don't put any spaces between the \f(CW\e\fP and the end of the line; otherwise
+the shell will interpret the first space as a parameter by itself, and then it
+will interpret the end of line as the end of the command.
 .LI
-If \fIEOF\fP\| doesn't do it, try the \fIINTR\fP\| key (usually \fBCtrl-C\fP).
+.X "control characters"
+.X "character, control"
+In the C programming language, the backslash is used to represent several
+\fIcontrol characters\fP.  For example, \f(CW\en\fP means ``new line.''  This
+usage appears in many other places as well.
 .LI
-.X "kill command"
-.X "command, kill"
-If the process is ignoring \fIINTR\fP, or if it is not associated with a
-terminal, use the \fIkill\fP\| command.  For example, to find who is using all
-the CPU time, use \fIps\fP\| and look at the \f(CW%CPU\fP field:
-.Dx
-# \f(CBps waux \fP
-USER   PID %CPU %MEM   VSZ  RSS  TT  STAT STARTED      TIME COMMAND
-root   105  97.3  1.1  236  340  ??  Is    9:11AM 137:14.29 cron
-\fI\&(other processes omitted)\fP\|
-.De
-Here, \fIcron\fP\| is using 97% of the CPU time, and has accumulated over 2
-hours of CPU time since this morning.  It's obviously sick, and we should put it
-out of its misery.  To stop it, enter:
-.Dx
-# \f(CBkill 105\fP
-.De
-This command sends a signal called \f(CWSIGTERM\fP (terminate) to the process.
-This signal gives the process time to tidy up before exiting, so you should
-always try to use it first.  The 105 is \fIcron\fP\|'s PID, which we got from
-the \fIps\fP\| command.
-.P
-If the process doesn't go away within a few seconds, it's probably ignoring
-\f(CWSIGTERM\fP.  In this case, you can use the ultimate weapon:
-.Dx
-# \f(CBkill -9 105\fP
-.De
-The \f(CW-9\fP is the number of \f(CWSIGKILL\fP, a signal that cannot be caught
-or ignored.  You can find a list of the signals and their numeric values in
-\fI/usr/include/sys/signal.h\fP, which is part of the software development
-package.
+Using \f(CW\e\fP as an escape character causes problems: how do we put a
+\f(CW\e\fP character on a line?  The answer: quote it.  Write \f(CW\e\e\fP when
+you mean \f(CW\e\fP.  This causes particular problems when interfacing with
+..if Samba
+Microsoft\(emsee page
+.Sref \*[multibackslash] \&
+for an example.
+..else
+Microsoft: if you give a Microsoft path name to a shell, it needs the doubled
+backslashes: \fIC:\e\eWINDOWS\fP.
+..endif
 .Le
-.sp -1v
-.H2 "Timekeeping"
-.X "timekeeping"
-.Pn timekeeping
-FreeBSD is a networking system, so keeping the correct time is more important
-than on a standalone system.  Apart from the obvious problem of keeping the same
-time as other local systems, it's also important to keep time with systems in
-other time zones.
-.P
-.X "Time Zones"
-.X "tzsetup, command"
-.X "command, tzsetup"
-.X "epoch"
-.X "UTC"
-.X "Universal Coordinated Time"
-.X "Time Zones"
-.X "PST"
-.X "Pacific Standard Time"
-.X "PDT"
-.X "Pacific Daylight Time"
-.X "/etc/localtime"
-.X "tzsetup, command"
-.X "command, tzsetup"
-Internally, FreeBSD keeps the time as the number of seconds since the
-\fIepoch\fP, the beginning of recorded history: 00:00:00 UTC, 1 January 1970.
-\fIUTC\fP is the international base time zone, and means \fIUniversal
-Coordinated Time\fP, despite the initials.  It corresponds very closely, but not
-exactly, to Greenwich Mean Time (GMT), the local time in England in the winter.
-It would be inconvenient to keep all dates in UTC, so the system understands the
-concept of \fITime Zones\fP.  For example, in Walnut Creek, CA, the time zone in
-the winter is called \fIPST\fP\| (\fIPacific Standard Time\fP\|), and in the
-summer it is \fIPDT\fP\| (\fIPacific Daylight Time\fP\|).  FreeBSD stores
-information about the local time zone in a file called \fI/etc/localtime\fP.
-Normally, \fIsysinstall\fP installs the correct data in this file, but if you
-got it wrong, or if you move time zones, you can do it yourself easily enough by
-running the \fItzsetup\fP\| program.
-.H3 "The \f(CWTZ\fP environment variable"
-.X "/usr/share/zoneinfo"
-An alternate means of describing the time zone is to set the environment
-variable \f(CWTZ\fP, which we looked at on page \*[environment-variables].  This
-looks like the way that System V does it, but that's not quite accurate.  System
-V doesn't have the time zone definition files in \fI/usr/share/zoneinfo\fP, so
-the \f(CWTZ\fP variable tells it information about the time zone.  For example,
-the value of \f(CWTZ\fP for Berlin, Germany is \f(CWMEZ1MSZ2\fP in System V, but
-\f(CWGermany/Berlin\fP in FreeBSD.
-.H3 "Keeping the correct time"
-.X "ntp"
-.Pn ntp
-If you're connected to the Internet on a reasonably regular basis, there are a
-number of programs which can help you synchronize your time via the \fIntp\fP\|
-service.
-.P
-A number of systems around the world supply time information via the \f(CWntp\fP
-service.  The first thing you need to do is to find one near you.  One place to
-look is at
-.br
-\fIhttp://www.eecis.udel.edu/~mills/ntp/servers.html\fP.
+.H3 "Tab characters"
+.X "Tab characters"
+.X "character, tab"
+We've seen that the shell treats ``white space,'' either spaces or tab
+characters, as the same.  Unfortunately, some other programs do not.
+.Command make ,
+.Daemon sendmail
+and
+.Daemon syslogd
+make a distinction between the two kinds of characters, and they all require
+tabs (not spaces) in certain places.  This is a \fIreal\fP\/ nuisance, because
+hardly any editor makes a distinction between them.
+.H3 "Carriage control characters"
+.X "carriage return, character"
+.X "line feed, character"
+.X "character, carriage return"
+.X "character, line feed"
+In the olden days, the standard computer terminal was a Teletype, a kind of
+computer-controlled electric typewriter.  When the carriage, which contained the
+print head, got to the end of a line, it required two mechanical operations to
+move to the beginning of the next line: the \fIcarriage return\fP\/ control
+character told it to move the carriage back to the beginning of the line, and
+the \fIline feed\fP\/ character told it turn the platen to the next line.
 .P
-.X "ntpd, command"
-.X "command, ntpd"
-.X "ntpdate, command"
-.X "command, ntpdate"
-Your choice of program depends on the nature of your connection to the Internet.
-If you're connected full time, you'll probably prefer \fIntpd\fP, which keeps
-the system synchronized.  Otherwise you can use \fIntpdate\fP, which you can run
-as you feel like it.
-..if review
-| (bmc) Or when you bring up your PPP link.
-..endif
-.H4 "ntpd"
-\fIntpd\fP\| performs periodic queries to keep the system synchronized with a
-time server.  There are many ways to run it\(emsee the man page \fIntpd(8)\fP.
-In most cases, you can set up one system on the network to connect to an
-external time reference, and the other systems on the same Ethernet can get the
-time information from the first system.
-.P
-To get the time from an external source and broadcast it to the other systems on
-the network, create a file \fI/etc/ntp.conf\fP\| with a content like this:
-.Dx
-server	203.21.37.18	# ns.saard.net
-driftfile	/etc/ntp.drift
-broadcast 223.147.37.255
-.De
-.X "/etc/ntp.drift"
-The first line defines the server.  It's important to get one near you: network
-delays can significantly impair the accuracy of the results.  \fIntpd\fP\| uses
-the file \fI/etc/ntp.drift\fP\| to record information about the (in)accuracy of
-the local system's clock.  You only need the final line if you have other
-systems on the network which wait for a broadcast message.  It specifies the
-broadcast address for the network and also tells \fIntpd\fP\| to broadcast on
-this address
-.P
-After setting up this file, you just need to start \fIntpd\fP\|:
-.Dx
-# \f(CBntpd\fP
-.De
-.X "/etc/rc.conf"
-To ensure that \fIntpd\fP\| gets started every time you reboot, ensure that you
-have the the following lines in \fI/etc/rc.conf\fP\|:
-.Dx
-xntpd_enable="\f(CBYES\fP"		# Run ntpd Network Time Protocol (or NO).
-xntpd_flags=""			# Flags to ntpd (if enabled).
-.De
-If \fI/etc/rc.conf\fP\| doesn't exist, create it.
-.P
-The comment on the first line is misleading: the value of \f(CWntpd_enable\fP
-must be \f(CWYES\fP.  You don't need any flags.  You put exactly the same text
-in the \fI/etc/rc.conf\fP\| on the other machines, and simply omit the file
-\fI/etc/ntp.conf\fP.  This causes \fIxntpd\fP\| on these machines to monitor
-broadcast messages.
-.P
-Why are these variables called \f(CWxntpd_enable\fP and \f(CWxntpd_flags\fP if
-the daemon is called \fIntpd\fP\|?  In previous versions of FreeBSD it was
-called \fIxntpd\fP, but the name has changed.  In order not to break existing
-configurations, the FreeBSD team decided not to change the name of the
-variables.
-.H4 "ntpdate"
-.X "ntpdate, command"
-.X "command, ntpdate"
-If you only infrequently connect to the Internet, \fIxntpd\fP\| may become
-discouraged and not keep good time.  In this case, it's better to use
-\fIntpdate\fP.  Simply run it when you want to set the time:
-.Dx
-# \f(CBntpdate \f(BIserver
-.De
-You can't use both \fIntpdate\fP\| and \fIxntpd\fP\|: they both use the same
-port.
-..if XXX
-From grog@freebie.lemis.com Wed Feb 11 09:17:19 1998
-*sigh*  I knew I would have to expound on this subject.                                                        
-
-  find searches directories hierarchically.  By default, it lists
-  everything it finds, which can be a lot.  You can tell it to
-  restrict the listing to entries which fulfil particular criteria, or  
-  to do things other than listing.
-
-  One thing you *must* tell find is the name of at least one directory
-  hierarchy.  For example,                                                        
-
-    find .                                                                  
-    find . /usr/bin
-
-  There are a lot of restrictions you can specify.  The more useful            
-  ones are:                                                                 
-
-    - by name:   -name "foo*.conf"    (only file names which match)       
-    - by type:   -type f              (only files)                       
-                 -type d              (only directories)                         
-                 -type l              (only symbolic links)                       
-    - by timestamps:                                                            
-                 -atime -10           (accessed within the last 10 days)       
-                 -ctime +30           (created more than 30 days ago)         
-                 -mtime 5             (modified 5 days ago exactly)               
-                 -mmin -10            (modified within the last 10 minutes)
-                 -newer foo           (newer than file "foo")                    
-    - by size:   -size +50            (larger than 50 blocks/25K)           
-                 -size -10000n        (smaller than 10000 bytes)            
-    - by file system:                                                     
-                 -xdev                (just this file system)              
-                 -fstype ufs          (just UFS file systems)
-
-BTW (are you listening, Mike?), xdev is no longer documented.  It               
-still works, and it's a *very* useful restriction, especially when      
-you're searching the root file system.                                  
-
-
-  You can specify various things to do with the list of files.  The     
-  default is to print it (BTW, in Missed'em V systems, there *is* no
-  default, and you need to add -print).  You can also do things like        
-  execute a program on them or list them, but it's better to pipe the        
-  output into xargs and get it to do it for you, so I won't elaborate.
-
-  Finally, you can combine expressions with -and, and -or and !        
-  (not).  Since most shells interpret !, you need a \ in front of it.
-  For some reason, nobody has implemented a keyword -not.  You can
-  also put parentheses (again with \) around expressions.
-
-  Here are some examples:
-
-  1.  Find all files in the current directory ending in "rc" or
-      ".conf" and list them by modification date:
-
-      find . -type f -name "*rc" -or -name "*.conf" | xargs ls -lrt | less
-
-  2.  Find all files in the root file system which are larger than
-      500K:              
-
-      find / -xdev -size +1000 | xargs ls -l                              
-
-Any questions?
-
-
-xargs is pretty straightforward: it takes a lot of input and makes it
-into lines as long as the system will accept on exec.  If you supply
-xargs anything on the invocation line, it puts them in front.  For
-example,                                                        
-
-  echo foo bar baz zot | xargs ls                                       
-
-will produce and execute                                                   
-
-  ls foo bar baz zot                                               
-
-Also,
-
-  find / | xargs ls                                                               
-
-will produce and execute as many lines as it takes to list all the              
-files you find.                                                              
-
-..endif
+.X "new line, character"
+.X "character, new line"
+Generations of computer systems emulated this behaviour by putting both
+characters at the end of each text line.  This makes it more difficult to
+recognize the end of line, it uses up more storage space, and normally it
+doesn't buy you much.  The implementors of UNIX decided instead to use a single
+character, which it calls the \fInew line\fP\/ character.  For some reason, they
+chose the line feed to represent new line, though the character generated by
+\fBEnter\fP is a carriage return.  As we saw above, the C programming language
+represents it as \f(CW\en\fP.
+.P
+This causes problems transferring data between FreeBSD and Microsoft, and also
+when printing to printers that still expect both characters.  We'll look at the
+file transfer issues on page
+.Sref \*[Microsoft-staircase] \&
+and the printer issues on page
+.Sref \*[staircase] .
+.H2 "The Emacs editor"
+.Pn Emacs
+Apart from the shell, your second most important tool is the \fIeditor\fP, a
+program that creates and changes texts.  Another divergence of concept between
+UNIX and Microsoft environments is that UNIX gives you a choice of editors in
+just about anything you do.  Microsoft products frequently try to redefine the
+whole environment, so if you change mailers, you may also have to change the
+editor you use to write mail.  This has a profound effect on the way you work.
+In particular, the Microsoft way makes it uninteresting to write a really good
+editor, because you can't use it all the time.
+.P
+The standard BSD editor is
+.Command vi ,
+about which people speak with a mixture of admiration, awe and horror.
+.Command vi
+is one of the oldest parts of BSD.  It is a very powerful editor, but nobody
+would say that it is easy to learn.  There are two reasons to use
+.Command vi \/:
+.Ls N
+.LI
+If you're already an experienced \fIvi\fP\/ hacker, you probably won't want to
+change.
+.LI
+If you do a lot of work on different UNIX systems, you can rely on
+.Command vi
+being there.  It's about the only one on which you can rely.
+.Le
+If, on the other hand, you don't know
+.Command vi ,
+and you only work on systems whose software you can control, you probably
+shouldn't use
+.Command vi .
+\fIEmacs\fP\/ is much easier to learn, and it is more powerful than
+.Command vi .
+.PIC "images/emacs.init.ps" 4i
+.sp 1.5v
+.Figure-heading "Emacs main menu"
+.Fn emacs-init
+When running under X, \fIEmacs\fP\/ displays its own window
+.Command ( vi \&
+uses an
+.Command xterm
+under these circumstances).  As a result, if you start \fIEmacs\fP\/ from an
+.Command xterm ,
+you should use the \f(CW&\fP character to start it in the background:
+.Dx
+$ \f(CBemacs &\fP
+.De
+Figure
+.Sref \*[emacs-init] \&
+shows the resulting display.  As you can see, the first thing that \fIEmacs\fP\/
+offers you is a tutorial.  You should take it.  You'll also notice the menu bars
+at the top.  Although they look primitive compared to graphics toolbars, they
+offer all the functionality of graphics-oriented menus.  In addition, they will
+tell you the keystrokes that you can use to invoke the same functions.  Figure
+.Sref \*[emacs-files-menu] \&
+gives an example of the \fIFiles\fP\/ menu.
+.P
+There is a lot of documentation for \fIEmacs\fP, much of it on line.  The
+complete \fIEmacs\fP\/ handbook is available via the \fIinfo\fP\/ mode of
+\fIEmacs\fP, which is described in the tutorial.  If that's not enough, read
+\fILearning GNU Emacs\fP, by Debra Cameron, Bill Rosenblatt and Eric Raymond.
+.PIC "images/emacs.menu.ps" 4i
+.Figure-heading "Emacs files menu"
+.Fn emacs-files-menu
+.X "Files, menu"
+.H2 "Stopping the system"
+To stop X, press the key combination \fBCtrl\fP-\fBAlt\fP-\fBBackspace\fP, which
+is deliberately chosen to resemble the key combination
+\fBCtrl\fP-\fBAlt\fP-\fBDelete\fP used to reboot the machine.
+\fBCtrl\fP-\fBAlt\fP-\fBBackspace\fP stops X and returns you to the virtual
+terminal in which you started it.  If you run from
+.Daemon xdm ,
+it redisplays a login screen.
+.P
+To stop the system, use the
+.Command shutdown
+program.  To do so, you need to be a member of group \f(CWoperator\fP.
+.P
+By default, KDE uses the
+.Command halt
+program.  Only \f(CWroot\fP can use this program, so you should reconfigure KDE
+to use
+.Command shutdown .
+After this, you can shut down from KDE with the keystroke combination
+\fBCtrl-Alt-PageDown\fP.
