Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 1996 18:14:52 -0700 (PDT)
From:      Annelise Anderson <ANDRSN@HOOVER.STANFORD.EDU>
To:        freebsd-doc@freebsd.org
Cc:        freebsd-chat@freebsd.org
Subject:   Re: editors, vi, documentation for newusers
Message-ID:  <01I51YO5Y39U006OBL@HOOVER.STANFORD.EDU>

next in thread | raw e-mail | index | archive | help
Given the discussion that has been going on here about vi and making
things easier for new users, you might be interested in a guide I
wrote for people new to both freebsd *and* unix.  

John Fieber has been working on integrating this into the handbook
and I have asked him not include it in the sections on "unix basics"
because it is not that, nor do I have the capability to contribute
to that; it is rather a guide on a few essential tasks and some
suggestions on navigation and sources of information that will help
new users get acquainted with the system faster.  It is also not a
guide on how to configure the system in any way.

I have sent it to a few people who have indicated that they know
little unix and they seem to have found it helpful (including the
section on vi).  It also includes a simple description of getting
ports from the cdrom.  In all areas it could be expanded, but the
point is to give people enough to get along, not everything at once.

John and I agree that the section on the ls commands should use
standard unix commands and not the aliases, which is the only
major change I think we are contemplating.

My only qualification for writing this is the insight of a user
new to both freebsd and unix not very long ago, which is about all
I have to offer right now.

Here it is (18k).

Annelise

May 9, 1996

For People New to Both FreeBSD *and* Unix

Congratulations on installing FreeBSD!

This introduction is for people new to both FreeBSD *and* Un*x--so
it starts with basics.  It assumes you're using version 2.0.5 or later
of FreeBSD as distributed by Walnut Creek or FreeBSD.ORG, your system 
(for now) has a single user (you)--and you're probably pretty good with
DOS/Windows or OS/2.  

Topics Covered

	1) Logging in and Getting Out
	2) Adding a User with Root Privileges
	3) Looking Around
	4) Getting Help and Information
	5) Editing Text
	6) Printing Files from DOS
	7) Other Useful Commands
	8) Next Steps
	9) Other
	10) Comments Welcome

1) Logging in and Getting Out

Log in (when you see login:) as a user you created during
installation or as root.  (Your FreeBSD installation will already
have an account for root; root can go anywhere and do anything,
including deleting essential files, so be careful!)

To log out (and get a new login prompt) type

exit

as often as necessary.  Yes, press enter after commands, and remember
that Unix is case-sensitive--exit, not EXIT.

To shut down the machine (if you logged in as root) type

/sbin/shutdown -h now

Or to reboot type

/sbin/reboot

If you're not logged in as root, you can still reboot with
Ctrl-Alt-Delete.  Give it a little time to do its work.  This is
equivalent to /sbin/reboot in recent releases of FreeBSD, and is
much, much better than hitting the reset button.  You don't want to
have to reinstall this thing, do you?

2) Adding A User with Root Privileges

If you didn't create any users when you installed the system and
are thus logged in as root, you should probably create a user now with

adduser

Don't use the -verbose option; the defaults are what you want.  Suppose
you create a user jack with full name Jack Benimble.  Give jack a
password if security (even kids around who might pound on the keyboard)
is an issue.  When it asks you if you want to invite jack into 
other groups, type 

wheel

This will make it possible to log in as jack and use the su command to
become root.  Then you won't get scolded any more for logging in as
root, and as root you'll have the same environment as jack 
(this is good).

You can quit adduser any time by typing Ctrl-C, and at the end
you'll have a chance to approve your new user or simply type n for no.
You might want to create a second newuser (jill?) so that when you edit
jack's login files, you'll have a hot spare in case something goes wrong.

Once you've done this, use exit to get back to a login prompt and log
in as jack.  

If you already created a user and you want the user to be able to su
to root, you can log in as root and edit the file /etc/group, adding
jack to the first line (the group wheel).  But first you need to 
practice vi, the text editor. 

3) Looking Around

Logged in as an ordinary user, look around and try out some commands that
will access the sources of help and information within FreeBSD.

Here are some commands and what they do:

id        Tells you who you are!
pwd       Shows you where you are--the current working directory.
ls        Lists the files in the current directory.
lf        Lists the files in the current directory with a * after
		executables, a / after directories, and an @ after symbolic
		links.
ll        Lists the files in long format--size, date, permissions.
la        Lists hidden (unless you're root) "dot" files with the others.
cd        Changes directories.  cd .. backs up one level; note the
		space after cd.  cd /usr/local goes there.  cd~  goes to
		the home directory of the person logged in--e.g.,
		/usr/home/jack.  Try cd /cdrom, and then ls, to find out 
		if your cdrom is mounted and working.
view filename  
		Lets you look at a file (named "filename" without changing
		it.  Try view /etc/fstab.  :q to quit.
cat filename   
		Displays filename on screen.  If it's too long and you
		can see only the end of it, press ScrollLock and use
		the up-arrow to move backward; you can use ScrollLock with
		man pages too.  Press ScrollLock again to quit scrolling. 
		You might want to try cat on some of the dot files in your
		home directory--cat .cshrc, cat .login, cat .profile.

lf, ll, and la are aliases for longer forms of these commands, and won't
work with most versions of Un*x.  You can create other aliases in .cshrc.

4) Getting Help and Information

Here are some useful sources of help.  "text" stands for something of
your choice that you type in--usually a command or filename.

apropos text   Everything containing string "text" in the whatis database.
man text  The man page for "text."  The major source of documentation
		for Un*x systems.  man ls will tell you all the ways to
		use the ls command. Press Enter to move through text, Ctrl-b
		to go back a page, Ctrl-f to go forward, :q or Ctrl-c to quit.
which text     Tells you where in the user's path the command "text" is found.
locate text    All the paths where the string "text" is found. 
whatis text    Tells you what the command "text" does and its man page.
whereis text   Finds the file "text," giving its full path.

You might want to try using whatis on some common useful commands like
cat, more, grep, mv, find, tar, chmod, chown, date, and script.  more lets
you read a page at a time as it does in DOS, e.g., ll | more or more
filename.  The * works as a wildcard--e.g., ls w* will show you files 
beginning with w.  

Are some of these not working very well?  Both locate and whatis depend 
on a database that's rebuilt weekly.  If your machine isn't going to 
be left on over the weekend (and running FreeBSD), you might want to 
run the commands for daily, weekly, and monthly maintenance now and then.  
Run them as root and give each one time to finish before you start the 
next one, for now.

/etc/daily 
/etc/weekly 
/etc/monthly 

If you get tired waiting, press Alt-F2 to get another virtual console,
and log in again.  After all, it's a multi-user, multi-tasking system.
Nevertheless these commands will probably flash messages on your screen 
while they're running; you can type clear at the prompt to clear the 
screen.  Once they've run, you might want to look at /var/mail/root
and /var/log/messages.

Basically running such commands is part of system administration--and as
a single user of a Unix system, you're your own system administrator.
Virtually everything you need to be root to do is system administration.
Such responsibilities aren't covered very well even in those big fat books
on Unix, which seem to devote a lot of space to pulling down menus in
windows managers.  You might want to get one of the two leading books
on systems administration, either Evi Nemeth et.al.'s UNIX System 
Administration Handbook (Prentice-Hall, 1995, ISBN 0-13-15051-7)--the 
second edition with the red cover; or Aileen Frisch's Essential System
Administration (O'Reilly & Associates, 1993, ISBN 0-937175-80-3).  
I used Nemeth.

5) Editing Text

To configure your system, you need to edit text files.  Most of them
will be in the /etc directory; and you'll need to su to root to be able
to change them.  The text editor is vi.  Before you edit a file, you
should probably back it up.  Suppose you want to edit /etc/sysconfig.  You
could just use cd /etc to get to the /etc directory and do:

cp sysconfig sysconfig.orig

This would copy sysconfig to sysconfig.orig, and you could later copy
sysconfig.orig to sysconfig to recover the original.  But even better
would be moving (renaming) and then copying back:

mv sysconfig sysconfig.orig
cp sysconfig.orig sysconfig

because the mv command preserves the original date and owner of the file.
You can now edit sysconfig.  If you want the original back, you'd then 
mv sysconfig syconfig.myedit (assuming you want to preserve your edited
version) and then

mv sysconfig.orig sysconfig

to put things back the way they were.

To edit a file, type

vi filename

Move through the text with the arrow keys.
Esc (the escape key) puts vi in command mode.  Here are some commands:
	x    delete letter the cursor is on
	dd   delete the entire line (even if it wraps on the screen)
	i    insert text at the cursor
	a    insert text after the cursor

Once you type i or a, you can enter text.  Esc puts you back in command
mode where you can type

	:w   to write your changes to disk and continue editing
	:wq  to write and quit
	:q!  to quit without saving changes
	/text     to move the cursor to "text"; /Enter (the enter
			key) to find the next instance of "text".
	G    to go to the end of the file
	nG   to go to line n in the file, where n is a number
	Ctrl-L to redraw the screen
	Ctrl-b and Ctrl-f go back and forward a screen, as they
	do with more and view.

Practice with vi in your home directory by creating a new file with
vi filename and adding and deleting text, saving the file, and calling
it up again.  vi delivers some surprises because it's really quite
complex, and sometimes you'll inadvertently issue a command that will
do something you don't expect.  (Some people actually like vi--it's
more powerful than DOS EDIT--find out about the :r command.)  Use Esc 
one or more times to be sure you're in command mode and proceed from 
there when it gives you trouble, save often with :w, and use :q! to 
get out and start over (from your last :w) when you need to.

Now you can cd to /etc, su to root, use vi to edit the file /etc/group,
and add a user to wheel so the user has root privileges.  Just add a
comma and the user's login name to the end of the first line in the file,
press Esc, and use :wq to write the file to disk and quit.  Instantly
effective.  (You didn't put a space after the comma, did you?)

6) Printing Files from DOS

At this point you probably don't have the printer working, so here's a
way to create a file from a man page, move it to a floppy, and then
print it from DOS.  Suppose you want to read carefully about changing
permissions on files (pretty important).  You can use the command 
man chmod to read about it.  The command

man chmod > chmod.txt 

will send the man page to the chmod.txt file instead of showing it on
your screen.  Now put a dos-formatted diskette in your floppy drive a, 
su to root, and type

/sbin/mount -t msdos /dev/fd0 /mnt

to mount the floppy drive on /mnt.

Now (you no longer need to be root, and you can type su jack to get 
back to being user jack) you can go to the directory where you created
chmod.txt and copy the file to the floppy with:

cp chmod.txt /mnt

and use ls /mnt to get a directory listing of /mnt, which should show
the file chmod.txt.

You might especially want to make a file from /sbin/dmesg by typing

/sbin/dmesg > dmesg.txt

and copying dmesg.txt to the floppy.  /sbin/dmesg is the boot log record,
and it's useful to understand it because it shows what FreeBSD found
when it booted up.  If you ask questions on questions@freebsd.org or on
a USENET group--like "FreeBSD isn't finding my tape drive, what do I
do?"--people will want to know what dmesg has to say.

You can now dismount the floppy drive (as root) to get the disk out with

/sbin/umount /mnt

or reboot to go to DOS.  Copy these files to a DOS directory, call them
up with DOS EDIT, Windows Notepad, or a word processor, make a minor 
change so the file has to be saved, and print as you normally would 
from DOS or Windows. Hope it works!  man pages come out best if printed 
with the dos print command.  (Copying files from FreeBSD to a mounted dos partition is in some cases still a little risky.)

If you want to get the printer printing from FreeBSD, make sure there's
a subdirectory of /var/spool/output called lpd.  If there isn't, cd to
/var/spool/output and type

mkdir lpd

7) Other Useful Commands

df             shows file space and mounted systems.
ps aux         shows processes running. ps ax is a narrower form.
lsdev          lists configured devices      
devmenu        a menu of devices--in color!
rm filename    remove filename
rm -R dir      removes a directory dir and all subdirectories--careful!
ls -R          lists files in the current directory and all subdirectories;
		I used a variant, lf -R > where.txt, to get a list of all 
		the files in / and (separately) /usr before I found better 
		ways to find files.
passwd         to change user's password (or root's password)
man hier		man page on the Unix file system

Use find to locate filename in /usr or any of its subdirectories with

find /usr -name "filename"

You can use * as a wildcard in "filename" (which should be in quotes).
If you tell find to search in / instead of /usr it will look for 
the file(s) on all mounted file systems, including the cdrom and the
dos partition.

An excellent book that explains Unix commands and utilities is
Abrahams & Larson, Unix for the Impatient (2nd ed., Addison-Wesley,
1996).  There's also a lot of Unix information on the Internet.
Try http://www.eecs.nwu.edu/unix.html (Unix Reference Desk)

8) Next Steps

You should now have the tools you need to get around and edit files, so
you can get everything up and running.  There is a great deal of 
information in the FreeBSD handbook (which is probably on your hard drive)
and FreeBSD's web site, http://www.freebsd.org.  A wide variety of packages
and ports are on the Walnut Creek cdrom as well as the web site.  The 
handbook tells you more about how to use them (get the package if it exists, 
with pkg_add /cdrom/packages/All/packagename, where packagename is the 
filename of the package).  The cdrom has lists of the packages and ports 
with brief descriptions in cdrom/packages/index, cdrom/packages/index.txt, 
and cdrom/ports/index, with fuller descriptions in /cdrom/ports/*/*/pkg/DESCR,
where the *s represent subdirectories of kinds of programs and program
names respectively.

If you find the handbook too sophisticated (what with lndir and all) on
installing ports from the cdrom, here's what usually works:

Find the port you want, say kermit.  There will be a directory 
for it on the cdrom.  Copy the subdirectory to /usr/local (a good place 
for software you add that should be available to all users) with:

cp -R /cdrom/ports/comm/kermit /usr/local

This should result in a /usr/local/kermit subdirectory that has all the
files that the /kermit subdirectory on the cdrom has.  cd to the subdirectory
of /usr/local/kermit that has the file Makefile.  Type 

make all install

During this process the port will ftp to get any compressed files it needs.
It will put them in /usr/ports/distfiles.  If you don't have your network
running yet, you will have to get the distfile using another machine and
copy it to /usr/ports/distfiles from a floppy or your dos partition.  Read
Makefile (with cat or more or view) to find out where to go (the master
distribution site) to get the file and what its name is.  Its name will
be truncated when downloaded to DOS, and after you get it into
/usr/ports/distfiles you'll have to rename it (with the mv command) to its
original name so it can be found.  (Use binary file transfers!)

The other thing that happens when installing ports or packages is that
some other program is needed.  If the installation stops with a message
"can't find unzip" or whatever, you might need to install the package
or port for unzip before you continue.  

Once it's installed type rehash to make FreeBSD reread the files in the
path so it knows what's there.  (If you get a lot of "path not found"
messages when you use whereis or which, you might want to make additions
to the list of directories in the path statement in .cshrc in your
home directory.  The path statement in Unix does the same kind of work
it does in DOS, except the current directory is not (by default) in 
the path; if the command you want is in the directory you're in, you 
need to type ./ before the command to make it work; no space after the slash.)

You might want to get the most recent version of Netscape from their
ftp site, ftp.netscape.com.  (Netscape requires XWindows.) The version 
you want is the "unknown bsd" version.  Just use gunzip filename 
and tar xvf filename on it, move the binary to /usr/local/bin or some 
other place binaries are kept, rehash, and then do the following:

Make a symbolic link (similar to a shortcut in Windows 95 or a shadow in
OS/2) in the directory that has X11R6 (probably /usr) as follows:

ln -s X11R6 X11

and put the following lines in .cshrc in each user's home directory or
(easier) in /etc/csh.cshrc, the system-wide csh start-up file:

setenv XKEYSYMDB /usr/X11R6/lib/X11/XKeysymDB
setenv XNLSPATH /usr/X11R6/lib/X11/nls

This assumes that the file XKeysymDB and the directory nls are in
/usr/X11R6/lib/X11; if they're not, find them and put them there.

9) Other 

As root, you can dismount the cdrom with /sbin/umount /cdrom, take it
out of the drive, insert another one, and mount it with 
/sbin/mount_cd9660 /dev/cd0a /cdrom
assuming cd0a is the device name for your cdrom drive.

Using the live file system--the second of FreeBSD's cdrom disks--is
useful if you've got limited space.  You might try using emacs or
playing games from the cdrom.  This involves using lndir to tell the
program(s) where to find the necessary files, because they're in the
/cdrom file system instead of in /usr and its subdirectories, which 
is where they're expected to be.  Read man lndir.

You can delete a user (say, jack) by using the command vipw to bring 
up the master.passwd file; delete the line for jack and save the file.  
Then edit /etc/group, eliminating jack wherever it appears.  Finally, 
go to the /usr/home and use rm -R jack (to get rid of user jack's home
directory files).

10) Comments Welcome.  If you use this guide I'd be interested in 
knowing where it was unclear and what was left out that you think 
should be included, and if it was helpful.  My thanks to Eugene W. Stark,
professor of computer science at SUNY-Stony Brook, for helpful comments.

Annelise Anderson
mailto:andrsn@hoover.stanford.edu
_____________________________________________________________________

	"Man my only friend"

		--The computer Mike to Manuel Garcia O'Kelly in
		  Robert Heinlein's _The Moon Is A Harsh Mistress_
______________________________________________________________________




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01I51YO5Y39U006OBL>