1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V5.0-Based Extension//EN"
"http://www.FreeBSD.org/XML/share/xml/freebsd50.dtd">
<!-- $FreeBSD$ -->
<!-- The FreeBSD Documentation Project -->
<article xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:lang="en">
<info>
<title>For People New to Both FreeBSD and &unix;</title>
<authorgroup>
<author>
<personname>
<firstname>Annelise</firstname>
<surname>Anderson</surname>
</personname>
<affiliation>
<address><email>andrsn@andrsn.stanford.edu</email></address>
</affiliation>
</author>
</authorgroup>
<pubdate>1997-08-15</pubdate>
<legalnotice xml:id="trademarks" role="trademarks">
&tm-attrib.freebsd;
&tm-attrib.ibm;
&tm-attrib.microsoft;
&tm-attrib.opengroup;
&tm-attrib.general;
</legalnotice>
<releaseinfo>$FreeBSD$</releaseinfo>
<abstract>
<para>Congratulations on installing FreeBSD! This introduction
is for people new to both FreeBSD <emphasis>and</emphasis>
&unix;—so it starts with basics.</para>
</abstract>
</info>
<sect1 xml:id="in-and-out">
<title>Logging in and Getting Out</title>
<para>Log in (when you see <prompt>login:</prompt>) as a user you
created during installation or as <systemitem
class="username">root</systemitem>. (Your FreeBSD
installation will already have an account for <systemitem
class="username">root</systemitem>; who can go anywhere and do
anything, including deleting essential files, so be careful!)
The symbols &prompt.user; and &prompt.root; in the following
stand for the prompt (yours may be different), with
&prompt.user; indicating an ordinary user and &prompt.root;
indicating <systemitem
class="username">root</systemitem>.</para>
<para>To log out (and get a new <prompt>login:</prompt> prompt)
type</para>
<informalexample>
<screen>&prompt.root; <userinput>exit</userinput></screen>
</informalexample>
<para>as often as necessary. Yes, press <keysym>enter</keysym>
after commands, and remember that &unix; is
case-sensitive—<command>exit</command>, not
<command>EXIT</command>.</para>
<para>To shut down the machine type</para>
<informalexample>
<screen>&prompt.root; <userinput>/sbin/shutdown -h now</userinput></screen>
</informalexample>
<para>Or to reboot type</para>
<informalexample>
<screen>&prompt.root; <userinput>/sbin/shutdown -r now</userinput></screen>
</informalexample>
<para>or</para>
<informalexample>
<screen>&prompt.root; <userinput>/sbin/reboot</userinput></screen>
</informalexample>
<para>You can also reboot with
<keycombo><keycap>Ctrl</keycap><keycap>Alt</keycap><keycap>Delete</keycap></keycombo>.
Give it a little time to do its work. This is equivalent to
<command>/sbin/reboot</command> in recent releases of FreeBSD
and is much, much better than hitting the reset button. You
do not want to have to reinstall this thing, do you?</para>
</sect1>
<sect1 xml:id="adding-a-user">
<title>Adding a User with Root Privileges</title>
<para>If you did not create any users when you installed the
system and are thus logged in as <systemitem
class="username">root</systemitem>, you should probably create
a user now with</para>
<informalexample>
<screen>&prompt.root; <userinput>adduser</userinput></screen>
</informalexample>
<para>The first time you use <command>adduser</command>, it might
ask for some defaults to save. You might want to make the
default shell &man.csh.1; instead of &man.sh.1;, if it suggests
<command>sh</command> as the default. Otherwise just press
enter to accept each default. These defaults are saved in
<filename>/etc/adduser.conf</filename>, an editable file.</para>
<para>Suppose you create a user <systemitem
class="username">jack</systemitem> with full name
<emphasis>Jack Benimble</emphasis>. Give <systemitem
class="username">jack</systemitem> 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 <systemitem
class="username">jack</systemitem> into other groups, type
<systemitem class="groupname">wheel</systemitem></para>
<informalexample>
<screen>Login group is ``jack''. Invite jack into other groups: <userinput>wheel</userinput></screen>
</informalexample>
<para>This will make it possible to log in as <systemitem
class="username">jack</systemitem> and use the &man.su.1;
command to become <systemitem
class="username">root</systemitem>. Then you will not get
scolded any more for logging in as <systemitem
class="username">root</systemitem>.</para>
<para>You can quit <command>adduser</command> any time by typing
<keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo>,
and at the end you will have a chance to approve your new user
or simply type <keycap>n</keycap> for no. You might want to
create a second new user so that when you edit <systemitem
class="username">jack</systemitem>'s login files, you will
have a hot spare in case something goes wrong.</para>
<para>Once you have done this, use <command>exit</command> to get
back to a login prompt and log in as <systemitem
class="username">jack</systemitem>. In general, it is a good
idea to do as much work as possible as an ordinary user who does
not have the power—and risk—of <systemitem
class="username">root</systemitem>.</para>
<para>If you already created a user and you want the user to be
able to <command>su</command> to <systemitem
class="username">root</systemitem>, you can log in as
<systemitem class="username">root</systemitem> and edit the file
<filename>/etc/group</filename>, adding <systemitem
class="username">jack</systemitem> to the first line (the
group <systemitem class="groupname">wheel</systemitem>). But
first you need to practice &man.vi.1;, the text editor—or
use the simpler text editor, &man.ee.1;, installed on recent
versions of FreeBSD.</para>
<para>To delete a user, use <command>rmuser</command>.</para>
</sect1>
<sect1 xml:id="looking-around">
<title>Looking Around</title>
<para>Logged in as an ordinary user, look around and try out some
commands that will access the sources of help and information
within FreeBSD.</para>
<para>Here are some commands and what they do:</para>
<variablelist>
<varlistentry>
<term><command>id</command></term>
<listitem>
<para>Tells you who you are!</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>pwd</command></term>
<listitem>
<para>Shows you where you are—the current working
directory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ls</command></term>
<listitem>
<para>Lists the files in the current directory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ls -F</command></term>
<listitem>
<para>Lists the files in the current directory with a
<literal>*</literal> after executables, a
<literal>/</literal> after directories, and an
<literal>@</literal> after symbolic links.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ls -l</command></term>
<listitem>
<para>Lists the files in long format—size, date,
permissions.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ls -a</command></term>
<listitem>
<para>Lists hidden <quote>dot</quote> files with the others.
If you are <systemitem class="username">root</systemitem>,
the <quote>dot</quote> files show up without the
<option>-a</option> switch.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>cd</command></term>
<listitem>
<para>Changes directories. <command>cd ..</command> backs
up one level; note the space after <command>cd</command>.
<command>cd /usr/local</command> goes there. <command>cd
~</command> goes to the home directory of the person
logged in—e.g., <filename>/usr/home/jack</filename>.
Try <command>cd /cdrom</command>, and then
<command>ls</command>, to find out if your CDROM is
mounted and working.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>less
<replaceable>filename</replaceable></command></term>
<listitem>
<para>Lets you look at a file (named
<replaceable>filename</replaceable>) without changing it.
Try <command>less /etc/fstab</command>.
Type <command>q</command> to quit.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>cat
<replaceable>filename</replaceable></command></term>
<listitem>
<para>Displays <replaceable>filename</replaceable> on
screen. If it is too long and you can see only the end of
it, press <keycap>ScrollLock</keycap> and use the
<keycap>up-arrow</keycap> to move backward; you can use
<keycap>ScrollLock</keycap> with manual pages too. Press
<keycap>ScrollLock</keycap> again to quit scrolling. You
might want to try <command>cat</command> on some of the
dot files in your home directory—<command>cat
.cshrc</command>, <command>cat
.login</command>, <command>cat
.profile</command>.</para>
</listitem>
</varlistentry>
</variablelist>
<para>You will notice aliases in <filename>.cshrc</filename> for
some of the <command>ls</command> commands (they are very
convenient). You can create other aliases by editing
<filename>.cshrc</filename>. You can make these aliases
available to all users on the system by putting them in the
system-wide <command>csh</command> configuration file,
<filename>/etc/csh.cshrc</filename>.</para>
</sect1>
<sect1 xml:id="getting-help">
<title>Getting Help and Information</title>
<para>Here are some useful sources of help.
<replaceable>Text</replaceable> stands for something of your
choice that you type in—usually a command or
filename.</para>
<variablelist>
<varlistentry>
<term><command>apropos
<replaceable>text</replaceable></command></term>
<listitem>
<para>Everything containing string
<replaceable>text</replaceable> in the <database>whatis
database</database>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>man
<replaceable>text</replaceable></command></term>
<listitem>
<para>The manual page for <replaceable>text</replaceable>.
The major source of documentation for &unix; systems.
<command>man ls</command> will tell you all the ways to
use <command>ls</command>. Press <keycap>Enter</keycap>
to move through text,
<keycombo><keycap>Ctrl</keycap><keycap>B</keycap></keycombo>
to go back a page,
<keycombo><keycap>Ctrl</keycap><keycap>F</keycap></keycombo>
to go forward, <keycap>q</keycap> or
<keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo>
to quit.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>which
<replaceable>text</replaceable></command></term>
<listitem>
<para>Tells you where in the user's path the command
<replaceable>text</replaceable> is found.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>locate
<replaceable>text</replaceable></command></term>
<listitem>
<para>All the paths where the string
<replaceable>text</replaceable> is found.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>whatis
<replaceable>text</replaceable></command></term>
<listitem>
<para>Tells you what the command
<replaceable>text</replaceable> does and its manual page.
Typing <command>whatis *</command> will tell you about all
the binaries in the current directory.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>whereis
<replaceable>text</replaceable></command></term>
<listitem>
<para>Finds the file <replaceable>text</replaceable>, giving
its full path.</para>
</listitem>
</varlistentry>
</variablelist>
<para>You might want to try using <command>whatis</command> on
some common useful commands like <command>cat</command>,
<command>more</command>, <command>grep</command>,
<command>mv</command>, <command>find</command>,
<command>tar</command>, <command>chmod</command>,
<command>chown</command>, <command>date</command>, and
<command>script</command>. <command>more</command> lets you
read a page at a time as it does in DOS, e.g., <command>ls -l |
more</command> or <command>more
<replaceable>filename</replaceable></command>. The
<literal>*</literal> works as a wildcard—e.g., <command>ls
w*</command> will show you files beginning with
<literal>w</literal>.</para>
<para>Are some of these not working very well? Both
&man.locate.1; and &man.whatis.1; depend on a database that is
rebuilt weekly. If your machine is not 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 <systemitem
class="username">root</systemitem> and, for now, give each one
time to finish before you start the next one.</para>
<informalexample>
<screen>&prompt.root; <userinput>periodic daily</userinput>
<lineannotation>output omitted</lineannotation>
&prompt.root; <userinput>periodic weekly</userinput>
<lineannotation>output omitted</lineannotation>
&prompt.root; <userinput>periodic monthly</userinput>
<lineannotation>output omitted</lineannotation></screen>
</informalexample>
<para>If you get tired of waiting, press
<keycombo><keycap>Alt</keycap><keycap>F2</keycap></keycombo> to
get another <firstterm>virtual console</firstterm>, and log in
again. After all, it is a multi-user, multi-tasking system.
Nevertheless these commands will probably flash messages on your
screen while they are running; you can type
<command>clear</command> at the prompt to clear the screen.
Once they have run, you might want to look at
<filename>/var/mail/root</filename> and
<filename>/var/log/messages</filename>.</para>
<para>Running such commands is part of system
administration—and as a single user of a &unix; system,
you are your own system administrator. Virtually everything you
need to be <systemitem class="username">root</systemitem> to do
is system administration. Such responsibilities are not 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 <citetitle>UNIX
System Administration Handbook</citetitle> (Prentice-Hall,
1995, ISBN 0-13-15051-7)—the second edition with the red
cover; or Æleen Frisch's <citetitle>Essential System
Administration</citetitle> (O'Reilly & Associates, 2002,
ISBN 0-596-00343-9). I used Nemeth.</para>
</sect1>
<sect1 xml:id="editing-text">
<title>Editing Text</title>
<para>To configure your system, you need to edit text files. Most
of them will be in the <filename>/etc</filename> directory; and
you will need to <command>su</command> to <systemitem
class="username">root</systemitem> to be able to change them.
You can use the easy <command>ee</command>, but in the long run
the text editor <command>vi</command> is worth learning. There
is an excellent tutorial on vi in
<filename>/usr/src/contrib/nvi/docs/tutorial</filename>, if you
have the system sources installed.</para>
<para>Before you edit a file, you should probably back it up.
Suppose you want to edit <filename>/etc/rc.conf</filename>. You
could just use <command>cd /etc</command> to get to the
<filename>/etc</filename> directory and do:</para>
<informalexample>
<screen>&prompt.root; <userinput>cp rc.conf rc.conf.orig</userinput></screen>
</informalexample>
<para>This would copy <filename>rc.conf</filename> to
<filename>rc.conf.orig</filename>, and you could later copy
<filename>rc.conf.orig</filename> to
<filename>rc.conf</filename> to recover the original. But even
better would be moving (renaming) and then copying back:</para>
<informalexample>
<screen>&prompt.root; <userinput>mv rc.conf rc.conf.orig</userinput>
&prompt.root; <userinput>cp rc.conf.orig rc.conf</userinput></screen>
</informalexample>
<para>because <command>mv</command> preserves the original date
and owner of the file. You can now edit
<filename>rc.conf</filename>. If you want the original back,
you would then <userinput>mv rc.conf rc.conf.myedit</userinput>
(assuming you want to preserve your edited version) and
then</para>
<informalexample>
<screen>&prompt.root; <userinput>mv rc.conf.orig rc.conf</userinput></screen>
</informalexample>
<para>to put things back the way they were.</para>
<para>To edit a file, type</para>
<informalexample>
<screen>&prompt.root; <userinput>vi <replaceable>filename</replaceable></userinput></screen>
</informalexample>
<para>Move through the text with the arrow keys.
<keycap>Esc</keycap> (the escape key) puts <command>vi</command>
in command mode. Here are some commands:</para>
<variablelist>
<varlistentry>
<term><command>x</command></term>
<listitem>
<para>delete letter the cursor is on</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>dd</command></term>
<listitem>
<para>delete the entire line (even if it wraps on the
screen)</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>i</command></term>
<listitem>
<para>insert text at the cursor</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>a</command></term>
<listitem>
<para>insert text after the cursor</para>
</listitem>
</varlistentry>
</variablelist>
<para>Once you type <command>i</command> or <command>a</command>,
you can enter text. <command>Esc</command> puts you back in
command mode where you can type</para>
<variablelist>
<varlistentry>
<term><command>:w</command></term>
<listitem>
<para>to write your changes to disk and continue
editing</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>:wq</command></term>
<listitem>
<para>to write and quit</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>:q!</command></term>
<listitem>
<para>to quit without saving changes</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>/<replaceable>text</replaceable></command></term>
<listitem>
<para>to move the cursor to <replaceable>text</replaceable>;
<command>/</command><keycap>Enter</keycap> (the enter key)
to find the next instance of
<replaceable>text</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>G</command></term>
<listitem>
<para>to go to the end of the file</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command><replaceable>n</replaceable>G</command></term>
<listitem>
<para>to go to line <replaceable>n</replaceable> in the
file, where <replaceable>n</replaceable> is a
number</para>
</listitem>
</varlistentry>
<varlistentry>
<term><keycombo><keycap>Ctrl</keycap><keycap>L</keycap></keycombo></term>
<listitem>
<para>to redraw the screen</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<keycombo>
<keycap>Ctrl</keycap>
<keycap>b</keycap>
</keycombo>
and
<keycombo>
<keycap>Ctrl</keycap>
<keycap>f</keycap>
</keycombo>
</term>
<listitem>
<para>go back and forward a screen, as they do with
<command>more</command> and
<command>view</command>.</para>
</listitem>
</varlistentry>
</variablelist>
<para>Practice with <command>vi</command> in your home directory
by creating a new file with <command>vi
<replaceable>filename</replaceable></command> and adding and
deleting text, saving the file, and calling it up again.
<command>vi</command> delivers some surprises because it is
really quite complex, and sometimes you will inadvertently issue
a command that will do something you do not expect. (Some
people actually like <command>vi</command>—it is more
powerful than DOS EDIT—find out about
<command>:r</command>.) Use <keycap>Esc</keycap> one or more
times to be sure you are in command mode and proceed from there
when it gives you trouble, save often with
<command>:w</command>, and use <command>:q!</command> to get out
and start over (from your last <command>:w</command>) when you
need to.</para>
<para>Now you can <command>cd</command> to
<filename>/etc</filename>, <command>su</command> to <systemitem
class="username">root</systemitem>, use <command>vi</command>
to edit the file <filename>/etc/group</filename>, and add a user
to <systemitem class="groupname">wheel</systemitem> 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
<keycap>Esc</keycap>, and use <command>:wq</command> to write
the file to disk and quit. Instantly effective. (You did not
put a space after the comma, did you?)</para>
</sect1>
<sect1 xml:id="other-useful-commands">
<title>Other Useful Commands</title>
<variablelist>
<varlistentry>
<term><command>df</command></term>
<listitem>
<para>shows file space and mounted systems.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ps aux</command></term>
<listitem>
<para>shows processes running. <command>ps ax</command> is
a narrower form.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<command>rm
<replaceable>filename</replaceable>
</command>
</term>
<listitem>
<para>remove <replaceable>filename</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<command>rm -R
<replaceable>dir</replaceable>
</command>
</term>
<listitem>
<para>removes a directory <replaceable>dir</replaceable> and
all subdirectories—careful!</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>ls -R</command></term>
<listitem>
<para>lists files in the current directory and all
subdirectories; I used a variant, <command>ls -AFR >
where.txt</command>, to get a list of all the files in
<filename>/</filename> and (separately)
<filename>/usr</filename> before I found better ways to
find files.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>passwd</command></term>
<listitem>
<para>to change user's password (or <systemitem
class="username">root</systemitem>'s password)</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>man hier</command></term>
<listitem>
<para>manual page on the &unix; filesystem</para>
</listitem>
</varlistentry>
</variablelist>
<para>Use <command>find</command> to locate
<filename>filename</filename> in <filename>/usr</filename> or
any of its subdirectories with</para>
<informalexample>
<screen>&prompt.user; <userinput>find /usr -name "<replaceable>filename</replaceable>"</userinput></screen>
</informalexample>
<para>You can use <literal>*</literal> as a wildcard in
<parameter>"<replaceable>filename</replaceable>"</parameter>
(which should be in quotes). If you tell
<command>find</command> to search in <filename>/</filename>
instead of <filename>/usr</filename> it will look for the
file(s) on all mounted filesystems, including the CDROM and the
DOS partition.</para>
<para>An excellent book that explains &unix; commands and
utilities is Abrahams & Larson, <citetitle>Unix for the
Impatient</citetitle> (2nd ed., Addison-Wesley, 1996). There
is also a lot of &unix; information on the Internet.</para>
</sect1>
<sect1 xml:id="next-steps">
<title>Next Steps</title>
<para>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 <link
xlink:href="&url.base;/index.html">FreeBSD's web site</link>.
A wide variety of packages and ports are on the CDROM as well as
the web site. The handbook tells you more about how to use them
(get the package if it exists, with <command>pkg add
<replaceable>packagename</replaceable></command>, where
<replaceable>packagename</replaceable> is the filename of the
package). The CDROM has lists of the packages and ports with
brief descriptions in <filename>cdrom/packages/index</filename>,
<filename>cdrom/packages/index.txt</filename>, and
<filename>cdrom/ports/index</filename>, with fuller descriptions
in <filename>/cdrom/ports/*/*/pkg/DESCR</filename>, where the
<literal>*</literal>s represent subdirectories of kinds of
programs and program names respectively.</para>
<para>If you find the handbook too sophisticated (what with
<command>lndir</command> and all) on installing ports from the
CDROM, here is what usually works:</para>
<para>Find the port you want, say <command>kermit</command>.
There will be a directory for it on the CDROM. Copy the
subdirectory to <filename>/usr/local</filename> (a good place
for software you add that should be available to all users)
with:</para>
<informalexample>
<screen>&prompt.root; <userinput>cp -R /cdrom/ports/comm/kermit /usr/local</userinput></screen>
</informalexample>
<para>This should result in a
<filename>/usr/local/kermit</filename> subdirectory that has all
the files that the <command>kermit</command> subdirectory on the
CDROM has.</para>
<para>Next, create the directory
<filename>/usr/ports/distfiles</filename> if it does not already
exist using <command>mkdir</command>. Now check
<filename>/cdrom/ports/distfiles</filename> for a file with a
name that indicates it is the port you want. Copy that file to
<filename>/usr/ports/distfiles</filename>; in recent versions
you can skip this step, as FreeBSD will do it for you. In the
case of <command>kermit</command>, there is no distfile.</para>
<para>Then <command>cd</command> to the subdirectory of
<filename>/usr/local/kermit</filename> that has the file
<filename>Makefile</filename>. Type</para>
<informalexample>
<screen>&prompt.root; <userinput>make all install</userinput></screen>
</informalexample>
<para>During this process the port will FTP to get any compressed
files it needs that it did not find on the CDROM or in
<filename>/usr/ports/distfiles</filename>. If you do not have
your network running yet and there was no file for the port in
<filename>/cdrom/ports/distfiles</filename>, you will have to
get the distfile using another machine and copy it to
<filename>/usr/ports/distfiles</filename>.
Read <filename>Makefile</filename> (with
<command>cat</command> or <command>more</command> or
<command>view</command>) to find out where to go (the master
distribution site) to get the file and what its name is.
(Use binary file transfers!)
Then go back to <filename>/usr/local/kermit</filename>, find the
directory with <filename>Makefile</filename>, and type
<command>make all install</command>.</para>
</sect1>
<sect1 xml:id="your-working-environment">
<title>Your Working Environment</title>
<para>Your shell is the most important part of your working
environment. The shell
is what interprets the commands you type on the command line,
and thus communicates with the rest of the operating system.
You can also write shell scripts a series of commands to be run
without intervention.</para>
<para>Two shells come installed with FreeBSD:
<command>csh</command> and <command>sh</command>.
<command>csh</command> is good for command-line work, but
scripts should be written with <command>sh</command> (or
<command>bash</command>). You can find out what shell you have
by typing <command>echo $SHELL</command>.</para>
<para>The <command>csh</command> shell is okay, but
<command>tcsh</command> does everything <command>csh</command>
does and more. It allows you to recall commands with the arrow
keys and edit them. It has tab-key completion of filenames
(<command>csh</command> uses <keycap>Esc</keycap>), and
it lets you switch to the directory you were last in with
<command>cd -</command>. It is also much easier to alter your
prompt with <command>tcsh</command>. It makes life a lot
easier.</para>
<para>Here are the three steps for installing a new shell:</para>
<procedure>
<step>
<para>Install the shell as a port or a package, just as you
would any other port or package.</para>
</step>
<step>
<para>Use <command>chsh</command> to change your shell to
<command>tcsh</command> permanently, or type
<command>tcsh</command> at the prompt to change your shell
without logging in again.</para>
</step>
</procedure>
<note>
<para>It can be dangerous to change <systemitem
class="username">root</systemitem>'s shell to something
other than <command>sh</command> or <command>csh</command> on
early versions of FreeBSD and many other versions of &unix;;
you may not have a working shell when the system puts you into
single user mode. The solution is to use <command>su
-m</command> to become <systemitem
class="username">root</systemitem>, which will give you the
<command>tcsh</command> as <systemitem
class="username">root</systemitem>, because the shell is
part of the environment. You can make this permanent by
adding it to your <filename>.tcshrc</filename> as an alias
with:</para>
<programlisting>alias su su -m</programlisting>
</note>
<para>When <command>tcsh</command> starts up, it will read the
<filename>/etc/csh.cshrc</filename> and
<filename>/etc/csh.login</filename> files, as does
<command>csh</command>. It will also read
<filename>.login</filename> in your home directory and
<filename>.cshrc</filename> as well, unless you provide a
<filename>.tcshrc</filename>. This you can do by simply copying
<filename>.cshrc</filename> to
<filename>.tcshrc</filename>.</para>
<para>Now that you have installed <command>tcsh</command>, you can
adjust your prompt. You can find the details in the manual page
for <command>tcsh</command>, but here is a line to put in your
<filename>.tcshrc</filename> that will tell you how many
commands you have typed, what time it is, and what directory you
are in. It also produces a <literal>></literal> if you are
an ordinary user and a <literal>#</literal> if you are
<systemitem class="username">root</systemitem>, but tsch will do
that in any case:</para>
<para>set prompt = "%h %t %~ %# "</para>
<para>This should go in the same place as the existing set prompt
line if there is one, or under "if($?prompt) then" if not.
Comment out the old line; you can always switch back to it if
you prefer it. Do not forget the spaces and quotes. You can
get the <filename>.tcshrc</filename> reread by typing
<command>source .tcshrc</command>.</para>
<para>You can get a listing of other environmental variables that
have been set by typing <command>env</command> at the prompt.
The result will show you your default editor, pager, and
terminal type, among possibly many others. A useful command if
you log in from a remote location and cannot run a program
because the terminal is not capable is <command>setenv TERM
vt100</command>.</para>
</sect1>
<sect1 xml:id="other">
<title>Other</title>
<para>As <systemitem class="username">root</systemitem>, you can
unmount the CDROM with <command>/sbin/umount /cdrom</command>,
take it out of the drive, insert another one, and mount it with
<command>/sbin/mount_cd9660 /dev/cd0a /cdrom</command> assuming
<hardware>cd0a</hardware> is the device name for your CDROM
drive. The most recent versions of FreeBSD let you mount the
CDROM with just <command>/sbin/mount /cdrom</command>.</para>
<para>Using the live filesystem—the second of FreeBSD's
CDROM disks—is useful if you have got limited space. What
is on the live filesystem varies from release to release. You
might try playing games from the CDROM. This involves using
<command>lndir</command>, which gets installed with the X Window
System, to tell the program(s) where to find the necessary
files, because they are in <filename>/cdrom</filename> instead
of in <filename>/usr</filename> and its subdirectories, which is
where they are expected to be. Read <command>man
lndir</command>.</para>
</sect1>
<sect1 xml:id="comments-welcome">
<title>Comments Welcome</title>
<para>If you use this guide I would 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, and John
Fieber for helpful comments.</para>
<para>Annelise Anderson,
<email>andrsn@andrsn.stanford.edu</email></para>
</sect1>
</article>
|