aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/books/handbook/basics/chapter.xml
blob: d9dd5a98eb0778bde1980f80647ecee491c9f9eb (plain) (blame)
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
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
     The FreeBSD Documentation Project

     $FreeBSD$
-->

<chapter id="basics">
  <chapterinfo>
    <authorgroup>
      <author>
	<firstname>Chris</firstname>
	<surname>Shumway</surname>
	<contrib>Rewritten by </contrib>
      </author>
    </authorgroup>
    <!-- 10 Mar 2000 -->
  </chapterinfo>

  <title>UNIX Basics</title>

  <sect1 id="basics-synopsis">
    <title>Synopsis</title>

    <para>This chapter covers the basic commands and functionality of
      the &os; operating system.  Much of this material is relevant
      for any &unix;-like operating system.  New &os; users are
      encouraged to read through this chapter carefully.</para>

    <para>After reading this chapter, you will know:</para>

    <itemizedlist>
      <listitem>
	<para>How to use the <quote>virtual consoles</quote> of
	  &os;.</para>
      </listitem>

      <listitem>
	<para>How &unix; file permissions and &os; file flags
	  work.</para>
      </listitem>

      <listitem>
	<para>The default &os; file system layout.</para>
      </listitem>

      <listitem>
	<para>The &os; disk organization.</para>
      </listitem>

      <listitem>
	<para>How to mount and unmount file systems.</para>
      </listitem>

      <listitem>
	<para>What processes, daemons, and signals are.</para>
      </listitem>

      <listitem>
	<para>What a shell is, and how to change the default login
	  environment.</para>
      </listitem>

      <listitem>
	<para>How to use basic text editors.</para>
      </listitem>

      <listitem>
	<para>What devices and device nodes are.</para>
      </listitem>

      <listitem>
	<para>What binary format is used under &os;.</para>
      </listitem>

      <listitem>
	<para>How to read manual pages for more information.</para>
      </listitem>
    </itemizedlist>
  </sect1>

  <sect1 id="consoles">
    <title>Virtual Consoles and Terminals</title>

    <indexterm><primary>virtual consoles</primary></indexterm>
    <indexterm><primary>terminals</primary></indexterm>

    <para>&os; can be used in various ways.  One of them is typing
      commands to a text terminal.  A lot of the flexibility and power
      of a &unix; operating system is readily available when using
      &os; this way.  This section describes what
      <quote>terminals</quote> and <quote>consoles</quote> are, and
      how to use them in &os;.</para>

    <sect2 id="consoles-intro">
      <title>The Console</title>

      <indexterm><primary>console</primary></indexterm>

      <para>Unless &os; has been configured to automatically start
	a graphical environment during startup, the system will boot
	into a command line login prompt, as seen in this
	example:</para>

      <screen>FreeBSD/amd64 (pc3.example.org) (ttyv0)

login:</screen>

      <para>The first line contains some information about the
	system.  The <literal>amd64</literal> indicates that the
	system in this example is running a 64-bit version of &os;.
	The hostname is <hostid>pc3.example.org</hostid>, and
	<devicename>ttyv0</devicename> indicates that this is the
	system console.</para>

      <para>The second line is the login prompt.  The next section
	describes how to log into &os; at this prompt.</para>
    </sect2>

    <sect2 id="consoles-login">
      <title>Logging into &os;</title>

      <para>&os; is a multiuser, multiprocessing system.  This is
	the formal description that is usually given to a system that
	can be used by many different people, who simultaneously run a
	lot of programs on a single machine.</para>

      <para>Every multiuser system needs some way to distinguish one
	<quote>user</quote> from the rest.  In &os; (and all the
	&unix;-like operating systems), this is accomplished by
	requiring that every user must <quote>log into</quote> the
	system before being able to run programs.  Every user has a
	unique name (the <quote>username</quote>) and a personal,
	secret key (the <quote>password</quote>).  &os; will ask
	for these two before allowing a user to run any
	programs.</para>

      <indexterm><primary>startup scripts</primary></indexterm>
      <para>When a &os; system boots, startup scripts are
	automatically executed in order to prepare the system and to
	start any services which have been configured to start at
	system boot.  Once the system finishes running its startup
	scripts, it will present a login prompt:</para>

      <screen>login:</screen>

      <para>Type the username that was configured during system
	installation, as described in <xref
	  linkend="bsdinstall-addusers"/>, and press
	<keycap>Enter</keycap>.  Then enter the password associated
	with the username and press <keycap>Enter</keycap>.  The
	password is <emphasis>not echoed</emphasis> for security
	reasons.</para>

      <para>Once the correct password is input, the message of the
	day (<acronym>MOTD</acronym>) will be displayed followed
	by a command prompt (a <literal>#</literal>,
	<literal>$</literal>, or <literal>%</literal> character).  You
	are now logged into the &os; console and ready to try the
	available commands.</para>
    </sect2>

    <sect2 id="consoles-virtual">
      <title>Virtual Consoles</title>

      <para>&os; can be configured to provide many virtual consoles
	for inputting commands.  Each virtual console has its own
	login prompt and output channel, and &os; takes care of
	properly redirecting keyboard input and monitor output as
	switching occurs between virtual consoles.</para>

      <para>Special key combinations have been reserved by &os; for
	switching consoles.<footnote>
	  <para>Refer to &man.syscons.4;, &man.atkbd.4;,
	    &man.vidcontrol.1; and &man.kbdcontrol.1; for a more
	    technical description of the &os; console and its keyboard
	    drivers.</para></footnote>.  Use
	<keycombo><keycap>Alt</keycap><keycap>F1</keycap></keycombo>,
	<keycombo><keycap>Alt</keycap><keycap>F2</keycap></keycombo>,
	through
	<keycombo><keycap>Alt</keycap><keycap>F8</keycap></keycombo>
	to switch to a different virtual console in &os;.</para>

      <para>When switching from one console to the next, &os; takes
	care of saving and restoring the screen output.  The result is
	an <quote>illusion</quote> of having multiple
	<quote>virtual</quote> screens and keyboards that can be used
	to type commands for &os; to run.  The programs that are
	launched in one virtual console do not stop running when that
	console is not visible because the user has switched to a
	different virtual console.</para>
    </sect2>

    <sect2 id="consoles-ttys">
      <title>The <filename>/etc/ttys</filename> File</title>

      <para>By default, &os; is configured to start eight virtual
	consoles.  The configuration can be customized to start
	more or fewer virtual consoles.  To change the number of and
	the settings of the virtual consoles, edit
	<filename>/etc/ttys</filename>.</para>

      <para>Each uncommented line in <filename>/etc/ttys</filename>
	(lines that do not start with a <literal>#</literal>
	character) contains settings for a single terminal or virtual
	console.  The default version configures nine virtual
	consoles, and enables eight of them.  They are the lines that
	start with <literal>ttyv</literal>:</para>

      <programlisting># name    getty                         type  status comments
#
ttyv0   "/usr/libexec/getty Pc"         cons25  on  secure
# Virtual terminals
ttyv1   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv2   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv3   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv4   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv5   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv6   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv7   "/usr/libexec/getty Pc"         cons25  on  secure
ttyv8   "/usr/X11R6/bin/xdm -nodaemon"  xterm   off secure</programlisting>

      <para>For a detailed description of every column in this file
	and the available options for the virtual consoles, refer to
	&man.ttys.5;.</para>
    </sect2>

    <sect2 id="consoles-singleuser">
      <title>Single User Mode Console</title>

      <para>A detailed description of <quote>single user mode</quote>
	can be found in <xref linkend="boot-singleuser"/>.  There is
	only one console when &os; is in single user mode as no other
	virtual consoles are available in this mode.  The settings
	for single user mode are found in this section of
	<filename>/etc/ttys</filename>:</para>

      <programlisting># name  getty                           type  status  comments
#
# If console is marked "insecure", then init will ask for the root password
# when going to single-user mode.
console none                            unknown  off  secure</programlisting>

      <note>
	<para>As the comments above the <literal>console</literal>
	  line indicate, editing <literal>secure</literal> to
	  <literal>insecure</literal> will prompt for the
	  <username>root</username> password when booting into single
	  user mode.  The default setting enters single user mode
	  without prompting for a password.</para>

	<para><emphasis>Be careful when changing this setting to
	    <literal>insecure</literal></emphasis>.  If the
	  <username>root</username> password is forgotten, booting
	  into single user mode is still possible, but may be
	  difficult for someone who is not comfortable with the &os;
	  booting process.</para>
      </note>
    </sect2>

    <sect2 id="consoles-vidcontrol">
      <title>Changing Console Video Modes</title>

      <para>The &os; console default video mode may be adjusted to
	1024x768, 1280x1024, or any other size supported by the
	graphics chip and monitor.  To use a different video mode
	load the <literal>VESA</literal> module:</para>

      <screen>&prompt.root; <userinput>kldload vesa</userinput></screen>

      <para>To determine which video modes are supported by the
	hardware, use &man.vidcontrol.1;.  To get a list of supported
	video modes issue the following:</para>

      <screen>&prompt.root; <userinput>vidcontrol -i mode</userinput></screen>

      <para>The output of this command lists the video modes that
	are supported by the hardware.  To select a new video mode,
	specify the mode using &man.vidcontrol.1; as the
	<username>root</username> user:</para>

      <screen>&prompt.root; <userinput>vidcontrol MODE_279</userinput></screen>

      <para>If the new video mode is acceptable, it can be permanently
	set on boot by adding it to
	<filename>/etc/rc.conf</filename>:</para>

      <programlisting>allscreens_flags="MODE_279"</programlisting>
    </sect2>
  </sect1>

  <sect1 id="permissions">
    <title>Permissions</title>

    <indexterm><primary>UNIX</primary></indexterm>

    <para>&os;, being a direct descendant of BSD &unix;, is based
      on several key &unix; concepts.  The first and most pronounced
      is that &os; is a multi-user operating system that can handle
      several users working simultaneously on completely unrelated
      tasks.  The system is responsible for properly sharing and
      managing requests for hardware devices, peripherals, memory, and
      CPU time fairly to each user.</para>

    <para>Much more information about user accounts is in the chapter
      about <link linkend="users">accounts</link>.  It is important to
      understand that each person (user) who uses the computer should be
      given their own username and password.  The system keeps track
      of the people using the computer based on this username.  Since
      it is often the case that several people are working on the same
      project &unix; also provides groups.  Several users can be placed
      in the same group.</para>

    <para>Because the system is capable of supporting multiple users,
      everything the system manages has a set of permissions governing
      who can read, write, and execute the resource.  These
      permissions are stored as three octets broken into three pieces,
      one for the owner of the file, one for the group that the file
      belongs to, and one for everyone else.  This numerical
      representation works like this:</para>

    <note>
      <para>This section will discuss the traditional &unix;
	permissions.  For finer grained file system access
	control, see the <link linkend="fs-acl">File System
	Access Control Lists</link> section.</para>
    </note>

    <indexterm><primary>permissions</primary></indexterm>
    <indexterm>
      <primary>file permissions</primary>
    </indexterm>
    <informaltable frame="none" pgwide="1">
      <tgroup cols="3">
	<thead>
	  <row>
	    <entry>Value</entry>
	    <entry>Permission</entry>
	    <entry>Directory Listing</entry>
	  </row>
	</thead>

	<tbody>
	  <row>
	    <entry>0</entry>
	    <entry>No read, no write, no execute</entry>
	    <entry><literal>---</literal></entry>
	  </row>

	  <row>
	    <entry>1</entry>
	    <entry>No read, no write, execute</entry>
	    <entry><literal>--x</literal></entry>
	  </row>

	  <row>
	    <entry>2</entry>
	    <entry>No read, write, no execute</entry>
	    <entry><literal>-w-</literal></entry>
	  </row>

	  <row>
	    <entry>3</entry>
	    <entry>No read, write, execute</entry>
	    <entry><literal>-wx</literal></entry>
	  </row>

	  <row>
	    <entry>4</entry>
	    <entry>Read, no write, no execute</entry>
	    <entry><literal>r--</literal></entry>
	  </row>

	  <row>
	    <entry>5</entry>
	    <entry>Read, no write, execute</entry>
	    <entry><literal>r-x</literal></entry>
	  </row>

	  <row>
	    <entry>6</entry>
	    <entry>Read, write, no execute</entry>
	    <entry><literal>rw-</literal></entry>
	  </row>

	  <row>
	    <entry>7</entry>
	    <entry>Read, write, execute</entry>
	    <entry><literal>rwx</literal></entry>
	  </row>
	</tbody>
      </tgroup>
    </informaltable>
    <indexterm>
      <primary>&man.ls.1;</primary>
    </indexterm>
    <indexterm><primary>directories</primary></indexterm>

    <para>Use the <option>-l</option> argument to &man.ls.1; to view a
      long directory listing that includes a column of information
      about a file's permissions for the owner, group, and everyone
      else.  For example, a <command>ls -l</command> in an arbitrary
      directory may show:</para>

    <screen>&prompt.user; <userinput>ls -l</userinput>
total 530
-rw-r--r--  1 root  wheel     512 Sep  5 12:31 myfile
-rw-r--r--  1 root  wheel     512 Sep  5 12:31 otherfile
-rw-r--r--  1 root  wheel    7680 Sep  5 12:31 email.txt</screen>

    <para>The first (leftmost) character in the first column indicates
      whether this file is a regular file, a directory, a special
      character device, a socket, or any other special pseudo-file
      device.  In this example, the <literal>-</literal> indicates a
      regular file.  The next three characters, <literal>rw-</literal>
      in this example, give the permissions for the owner of the file.
      The next three characters, <literal>r--</literal>, give the
      permissions for the group that the file belongs to.  The final
      three characters, <literal>r--</literal>, give the permissions
      for the rest of the world.  A dash means that the permission is
      turned off.  In this example, the permissions are set so the
      owner can read and write to the file, the group can read the
      file, and the rest of the world can only read the file.
      According to the table above, the permissions for this file
      would be <literal>644</literal>, where each digit represents the
      three parts of the file's permission.</para>

    <para>How does the system control permissions on devices? &os;
      treats most hardware devices as a file that programs can open,
      read, and write data to.  These special device files are
      stored in <filename class="directory">/dev/</filename>.</para>

    <para>Directories are also treated as files.  They have read,
      write, and execute permissions.  The executable bit for a
      directory has a slightly different meaning than that of files.
      When a directory is marked executable, it means it is possible
      to change into that directory using &man.cd.1;.  This also
      means that it is possible to access the files within that
      directory, subject to the permissions on the files
      themselves.</para>

    <para>In order to perform a directory listing, the read permission
      must be set on the directory.  In order to delete a file that
      one knows the name of, it is necessary to have write
      <emphasis>and</emphasis> execute permissions to the directory
      containing the file.</para>

    <para>There are more permission bits, but they are primarily used
      in special circumstances such as setuid binaries and sticky
      directories.  For more information on file permissions and how
      to set them, refer to &man.chmod.1;.</para>

    <sect2>
      <sect2info>
	<authorgroup>
	  <author>
	    <firstname>Tom</firstname>
	    <surname>Rhodes</surname>
	    <contrib>Contributed by </contrib>
	  </author>
	</authorgroup>
      </sect2info>

      <title>Symbolic Permissions</title>

      <indexterm>
	<primary>permissions</primary>
	<secondary>symbolic</secondary>
      </indexterm>

      <para>Symbolic permissions use characters instead of octal
	values to assign permissions to files or directories.
	Symbolic permissions use the syntax of (who) (action)
	(permissions), where the following values are
	available:</para>

      <informaltable frame="none" pgwide="1">
	<tgroup cols="3">
	  <thead>
	    <row>
	      <entry>Option</entry>
	      <entry>Letter</entry>
	      <entry>Represents</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry>(who)</entry>
	      <entry>u</entry>
	      <entry>User</entry>
	    </row>

	    <row>
	      <entry>(who)</entry>
	      <entry>g</entry>
	      <entry>Group owner</entry>
	    </row>

	    <row>
	      <entry>(who)</entry>
	      <entry>o</entry>
	      <entry>Other</entry>
	    </row>

	    <row>
	      <entry>(who)</entry>
	      <entry>a</entry>
	      <entry>All (<quote>world</quote>)</entry>
	    </row>

	    <row>
	      <entry>(action)</entry>
	      <entry>+</entry>
	      <entry>Adding permissions</entry>
	    </row>

	    <row>
	      <entry>(action)</entry>
	      <entry>-</entry>
	      <entry>Removing permissions</entry>
	    </row>

	    <row>
	      <entry>(action)</entry>
	      <entry>=</entry>
	      <entry>Explicitly set permissions</entry>
	    </row>

	    <row>
	      <entry>(permissions)</entry>
	      <entry>r</entry>
	      <entry>Read</entry>
	    </row>

	    <row>
	      <entry>(permissions)</entry>
	      <entry>w</entry>
	      <entry>Write</entry>
	    </row>

	    <row>
	      <entry>(permissions)</entry>
	      <entry>x</entry>
	      <entry>Execute</entry>
	    </row>

	    <row>
	      <entry>(permissions)</entry>
	      <entry>t</entry>
	      <entry>Sticky bit</entry>
	    </row>

	    <row>
	      <entry>(permissions)</entry>
	      <entry>s</entry>
	      <entry>Set UID or GID</entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable>

      <para>These values are used with &man.chmod.1;, but with
	letters instead of numbers.  For example, the following
	command would block other users from accessing
	<replaceable>FILE</replaceable>:</para>

      <screen>&prompt.user; <userinput>chmod go= FILE</userinput></screen>

      <para>A comma separated list can be provided when more than one
	set of changes to a file must be made.  For example, the
	following command removes the group and
	<quote>world</quote> write permission on
	<replaceable>FILE</replaceable>, and adds the execute
	permissions for everyone:</para>

      <screen>&prompt.user; <userinput>chmod go-w,a+x <replaceable>FILE</replaceable></userinput></screen>

<!--
      <para>Most users will not notice this, but it should be pointed
	out that using the octal method will only set or assign
	permissions to a file; it does not add or delete them.</para>
-->
    </sect2>

    <sect2>
      <sect2info>
	<authorgroup>
	  <author>
	    <firstname>Tom</firstname>
	    <surname>Rhodes</surname>
	    <contrib>Contributed by </contrib>
	  </author>
	</authorgroup>
      </sect2info>

      <title>&os; File Flags</title>

      <para>In addition to file permissions, &os; supports the use of
	<quote>file flags</quote>.  These flags add an additional
	level of security and control over files, but not directories.
	With file flags, even <username>root</username> can be
	prevented from removing or altering files.</para>

      <para>File flags are modified using &man.chflags.1;.  For
	example, to enable the system undeletable flag on the file
	<filename>file1</filename>, issue the following
	command:</para>

      <screen>&prompt.root; <userinput>chflags sunlink <filename>file1</filename></userinput></screen>

      <para>To disable the system undeletable flag, put a
	<quote>no</quote> in front of the
	<option>sunlink</option>:</para>

      <screen>&prompt.root; <userinput>chflags nosunlink <filename>file1</filename></userinput></screen>

      <para>To view the flags of a file, use <option>-lo</option> with
	&man.ls.1;:</para>

      <screen>&prompt.root; <userinput>ls -lo <filename>file1</filename></userinput></screen>

      <programlisting>-rw-r--r--  1 trhodes  trhodes  sunlnk 0 Mar  1 05:54 file1</programlisting>

      <para>Several file flags may only be added or removed by the
	<username>root</username> user.  In other cases, the file
	owner may set its file flags.  Refer to &man.chflags.1; and
	&man.chflags.2; for more information.</para>
    </sect2>

    <sect2>
      <sect2info>
	<authorgroup>
	  <author>
	    <firstname>Tom</firstname>
	    <surname>Rhodes</surname>
	    <contrib>Contributed by </contrib>
	  </author>
	</authorgroup>
      </sect2info>

      <title>The <literal>setuid</literal>, <literal>setgid</literal>,
	and <literal>sticky</literal> Permissions</title>

      <para>Other than the permissions already discussed, there are
	three other specific settings that all administrators should
	know about.  They are the <literal>setuid</literal>,
	<literal>setgid</literal>, and <literal>sticky</literal>
	permissions.</para>

      <para>These settings are important for some &unix; operations
	as they provide functionality not normally granted to normal
	users.  To understand them, the difference between the real
	user ID and effective user ID must be noted.</para>

      <para>The real user ID is the <acronym>UID</acronym> who owns
	or starts the process.  The effective <acronym>UID</acronym>
	is the user ID the process runs as.  As an example,
	&man.passwd.1; runs with the real user ID when a user changes
	their password.  However, in order to update the password
	database, the command runs as the effective ID of the
	<username>root</username> user.  This allows users to change
	their passwords without seeing a
	<errorname>Permission Denied</errorname> error.</para>

      <para>The setuid permission may be set by prefixing a permission
	set with the number four (4) as shown in the following
	example:</para>

      <screen>&prompt.root; <userinput>chmod 4755 suidexample.sh</userinput></screen>

      <para>The permissions on
	<filename><replaceable>suidexample.sh</replaceable></filename>
	now look like the following:</para>

      <programlisting>-rwsr-xr-x   1 trhodes  trhodes    63 Aug 29 06:36 suidexample.sh</programlisting>

      <para>Note that a <literal>s</literal> is now part of the
	permission set designated for the file owner, replacing the
	executable bit.  This allows utilities which need elevated
	permissions, such as &man.passwd.1;.</para>

      <note>
	<para>The <literal>nosuid</literal> &man.mount.8; option will
	  cause such binaries to silently fail without alerting
	  the user.  That option is not completely reliable as a
	  <literal>nosuid</literal> wrapper may be able to circumvent
	  it.</para>
      </note>

      <para>To view this in real time, open two terminals.  On
	one, type <command>passwd</command> as a normal user.
	While it waits for a new password, check the process
	table and look at the user information for
	&man.passwd.1;:</para>

      <para>In terminal A:</para>

      <screen>Changing local password for trhodes
Old Password:</screen>

      <para>In terminal B:</para>

      <screen>&prompt.root; <userinput>ps aux | grep passwd</userinput></screen>

      <screen>trhodes  5232  0.0  0.2  3420  1608   0  R+    2:10AM   0:00.00 grep passwd
root     5211  0.0  0.2  3620  1724   2  I+    2:09AM   0:00.01 passwd</screen>

      <para>Although &man.passwd.1; is run as a normal user, it is
	using the effective <acronym>UID</acronym> of
	<username>root</username>.</para>

      <para>The <literal>setgid</literal> permission performs the
	same function as the <literal>setuid</literal> permission;
	except that it alters the group settings.  When an application
	or utility executes with this setting, it will be granted the
	permissions based on the group that owns the file, not the
	user who started the process.</para>

      <para>To set the <literal>setgid</literal> permission on a
	file, provide &man.chmod.1; with a leading two (2):</para>

      <screen>&prompt.root; <userinput>chmod 2755 sgidexample.sh</userinput></screen>

      <para>In the following listing, notice that the
	<literal>s</literal> is now in the field designated for the
	group permission settings:</para>

      <screen>-rwxr-sr-x   1 trhodes  trhodes    44 Aug 31 01:49 sgidexample.sh</screen>

      <note>
	<para>In these examples, even though the shell script in
	  question is an executable file, it will not run with
	  a different <acronym>EUID</acronym> or effective user ID.
	  This is because shell scripts may not access the
	  &man.setuid.2; system calls.</para>
      </note>

      <para>The <literal>setuid</literal> and
	<literal>setgid</literal> permission bits may lower system
	security, by allowing for elevated permissions.  The third
	special permission, the <literal>sticky bit</literal>, can
	strengthen the security of a system.</para>

      <para>When the <literal>sticky bit</literal> is set on a
	directory, it allows file deletion only by the file owner.
	This is useful to prevent file deletion in public directories,
	such as <filename class="directory">/tmp</filename>, by users
	who do not own the file.  To utilize this permission, prefix
	the permission set with a one (1):</para>

      <screen>&prompt.root; <userinput>chmod 1777 /tmp</userinput></screen>

      <para>The <literal>sticky bit</literal> permission will display
	as a <literal>t</literal> at the very end of the permission
	set:</para>

      <screen>&prompt.root; <userinput>ls -al / | grep tmp</userinput></screen>

      <screen>drwxrwxrwt  10 root  wheel         512 Aug 31 01:49 tmp</screen>

    </sect2>
  </sect1>

  <sect1 id="dirstructure">
    <title>Directory Structure</title>

    <indexterm><primary>directory hierarchy</primary></indexterm>

    <para>The &os; directory hierarchy is fundamental to obtaining
      an overall understanding of the system.  The most important
      directory is root or, <quote>/</quote>.  This directory is the
      first one mounted at boot time and it contains the base system
      necessary to prepare the operating system for multi-user
      operation.  The root directory also contains mount points for
      other file systems that are mounted during the transition to
      multi-user operation.</para>

    <para>A mount point is a directory where additional file systems
      can be grafted onto a parent file system (usually the root file
      system).  This is further described in <xref
	linkend="disk-organization"/>.  Standard mount points
      include <filename class="directory">/usr/</filename>,
      <filename class="directory">/var/</filename>,
      <filename class="directory">/tmp/</filename>,
      <filename class="directory">/mnt/</filename>, and
      <filename class="directory">/cdrom/</filename>.  These
      directories are usually referenced to entries in
      <filename>/etc/fstab</filename>.  This file is a table of
      various file systems and mount points and is read by the system.
      Most of the file systems in <filename>/etc/fstab</filename> are
      mounted automatically at boot time from the script &man.rc.8;
      unless their entry includes <option>noauto</option>.  Details
      can be found in <xref linkend="disks-fstab"/>.</para>

    <para>A complete description of the file system hierarchy is
      available in &man.hier.7;.  The following table provides a brief
      overview of the most common directories.</para>

    <para>
      <informaltable frame="none" pgwide="1">
	<tgroup cols="2">
	  <thead>
	    <row>
	      <entry>Directory</entry>
	      <entry>Description</entry>
	    </row>
	  </thead>
	  <tbody valign="top">
	    <row>
	      <entry><filename class="directory">/</filename></entry>
	      <entry>Root directory of the file system.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/bin/</filename></entry>
	      <entry>User utilities fundamental to both single-user
		and multi-user environments.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/boot/</filename></entry>
	      <entry>Programs and configuration files used during
		operating system bootstrap.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/boot/defaults/</filename></entry>
	      <entry>Default boot configuration files.  Refer to
		&man.loader.conf.5; for details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/dev/</filename></entry>
	      <entry>Device nodes.  Refer to &man.intro.4; for
		details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/</filename></entry>
	      <entry>System configuration files and scripts.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/defaults/</filename></entry>
	      <entry>Default system configuration files.  Refer to
		&man.rc.8; for details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/mail/</filename></entry>
	      <entry>Configuration files for mail transport agents
		such as &man.sendmail.8;.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/namedb/</filename></entry>
	      <entry>&man.named.8; configuration files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/periodic/</filename></entry>
	      <entry>Scripts that run daily, weekly, and monthly,
		via &man.cron.8;.  Refer to &man.periodic.8; for
		details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/etc/ppp/</filename></entry>
	      <entry>&man.ppp.8; configuration files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/mnt/</filename></entry>
	      <entry>Empty directory commonly used by system
		administrators as a temporary mount point.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/proc/</filename></entry>
	      <entry>Process file system.  Refer to &man.procfs.5;,
		&man.mount.procfs.8; for details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/rescue/</filename></entry>
	      <entry>Statically linked programs for emergency
		recovery as described in &man.rescue.8;.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/root/</filename></entry>
	      <entry>Home directory for the <username>root</username>
		account.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/sbin/</filename></entry>
	      <entry>System programs and administration utilities
		fundamental to both single-user and multi-user
		environments.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/tmp/</filename></entry>
	      <entry>Temporary files which are usually
		<emphasis>not</emphasis> preserved across a system
		reboot.  A memory-based file system is often mounted
		at <filename class="directory">/tmp</filename>.  This
		can be automated using the tmpmfs-related variables of
		&man.rc.conf.5; or with an entry in
		<filename>/etc/fstab</filename>; refer to
		&man.mdmfs.8; for details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/</filename></entry>
	      <entry>The majority of user utilities and
		applications.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/bin/</filename></entry>
	      <entry>Common utilities, programming tools, and
		applications.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/include/</filename></entry>
	      <entry>Standard C include files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/lib/</filename></entry>
	      <entry>Archive libraries.</entry>
	    </row>


	    <row>
	      <entry><filename
		  class="directory">/usr/libdata/</filename></entry>
	      <entry>Miscellaneous utility data files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/libexec/</filename></entry>
	      <entry>System daemons and system utilities executed
		by other programs.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/local/</filename></entry>
	      <entry>Local executables and libraries.  Also used as
		the default destination for the &os; ports framework.
		Within <filename
		  class="directory">/usr/local</filename>, the
		general layout sketched out by &man.hier.7; for
		<filename class="directory">/usr</filename> should be
		used.  Exceptions are the man directory, which is
		directly under <filename
		  class="directory">/usr/local</filename>
		rather than under <filename
		  class="directory">/usr/local/share</filename>,
		and the ports documentation is in <filename
		  class="directory">share/doc/<replaceable>port</replaceable></filename>.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/obj/</filename></entry>
	      <entry>Architecture-specific target tree produced by
		building the <filename
		  class="directory">/usr/src</filename>
		tree.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/ports/</filename></entry>
	      <entry>The &os; Ports Collection (optional).</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/sbin/</filename></entry>
	      <entry>System daemons and system utilities executed
		by users.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/share/</filename></entry>
	      <entry>Architecture-independent files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/usr/src/</filename></entry>
	      <entry>BSD and/or local source files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/</filename></entry>
	      <entry>Multi-purpose log, temporary, transient, and
		spool files.  A memory-based file system is sometimes
		mounted at <filename
		  class="directory">/var</filename>. This can be
		automated using the varmfs-related variables in
		&man.rc.conf.5; or with an entry in
		<filename>/etc/fstab</filename>; refer to
		&man.mdmfs.8; for details.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/log/</filename></entry>
	      <entry>Miscellaneous system log files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/mail/</filename></entry>
	      <entry>User mailbox files.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/spool/</filename></entry>
	      <entry>Miscellaneous printer and mail system spooling
		directories.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/tmp/</filename></entry>
	      <entry>Temporary files which are usually preserved
		across a system reboot, unless <filename
		  class="directory">/var</filename> is a
		memory-based file system.</entry>
	    </row>

	    <row>
	      <entry><filename
		  class="directory">/var/yp/</filename></entry>
	      <entry>NIS maps.</entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable></para>
  </sect1>

  <sect1 id="disk-organization">
    <title>Disk Organization</title>

    <para>The smallest unit of organization that &os; uses to find
      files is the filename.  Filenames are case-sensitive, which
      means that <filename>readme.txt</filename> and
      <filename>README.TXT</filename> are two separate files.  &os;
      does not use the extension of a file to determine whether the
      file is a program, document, or some other form of data.</para>

    <para>Files are stored in directories.  A directory may contain no
      files, or it may contain many hundreds of files.  A directory
      can also contain other directories, allowing a hierarchy of
      directories within one another in order to organize
      data.</para>

    <para>Files and directories are referenced by giving the file or
      directory name, followed by a forward slash,
      <literal>/</literal>, followed by any other directory names that
      are necessary.  For example, if the directory <filename
	class="directory">foo</filename> contains a directory
      <filename class="directory">bar</filename> which contains the
      file <filename>readme.txt</filename>, the full name, or
      <firstterm>path</firstterm>, to the file is
      <filename>foo/bar/readme.txt</filename>.  Note that this is
      different from &windows; which uses <literal>\</literal> to
      separate file and directory names.  &os; does not use drive
      letters, or other drive names in the path.  For example, one
      would not type <filename>c:/foo/bar/readme.txt</filename> on
      &os;.</para>

    <para>Directories and files are stored in a file system.  Each
      file system contains exactly one directory at the very top
      level, called the <firstterm>root directory</firstterm> for that
      file system.  This root directory can contain other directories.
      One file system is designated the <firstterm>root file
	system</firstterm> or <literal>/</literal>.  Every other file
      system is <firstterm>mounted</firstterm> under the root file
      system.  No matter how many disks are on the &os; system, every
      directory appears to be part of the same disk.</para>

    <para>Consider three file systems, called <literal>A</literal>,
      <literal>B</literal>, and <literal>C</literal>.  Each file
      system has one root directory, which contains two other
      directories, called <literal>A1</literal>, <literal>A2</literal>
      (and likewise <literal>B1</literal>, <literal>B2</literal> and
      <literal>C1</literal>, <literal>C2</literal>).</para>

    <para>Call <literal>A</literal> the root file system.  If
      &man.ls.1; is used to view the contents of this directory,
      it will show two subdirectories, <literal>A1</literal> and
      <literal>A2</literal>.  The directory tree looks like
      this:</para>

    <mediaobject>
      <imageobject>
	<imagedata fileref="install/example-dir1"/>
      </imageobject>

      <textobject>
	<literallayout class="monospaced"> /
 |
 +--- A1
 |
 `--- A2</literallayout>
      </textobject>
    </mediaobject>

    <para>A file system must be mounted on to a directory in another
      file system.  When mounting file system <literal>B</literal>
      on to the directory <literal>A1</literal>, the root directory
      of <literal>B</literal> replaces <literal>A1</literal>, and
      the directories in <literal>B</literal> appear
      accordingly:</para>

    <mediaobject>
      <imageobject>
	<imagedata fileref="install/example-dir2"/>
      </imageobject>

      <textobject>
	<literallayout class="monospaced"> /
 |
 +--- A1
 |     |
 |     +--- B1
 |     |
 |     `--- B2
 |
 `--- A2</literallayout>
      </textobject>
    </mediaobject>

    <para>Any files that are in the <literal>B1</literal> or
      <literal>B2</literal> directories can be reached with the path
      <filename class="directory">/A1/B1</filename> or <filename
	class="directory">/A1/B2</filename> as necessary.  Any files
      that were in <filename class="directory">/A1</filename> have
      been temporarily hidden.  They will reappear if
      <literal>B</literal> is <firstterm>unmounted</firstterm> from
      <literal>A</literal>.</para>

    <para>If <literal>B</literal> had been mounted on
      <literal>A2</literal> then the diagram would look like
      this:</para>

    <mediaobject>
      <imageobject>
	<imagedata fileref="install/example-dir3"/>
      </imageobject>

      <textobject>
	<literallayout class="monospaced"> /
 |
 +--- A1
 |
 `--- A2
       |
       +--- B1
       |
       `--- B2</literallayout>
      </textobject>
    </mediaobject>

    <para>and the paths would be
      <filename class="directory">/A2/B1</filename> and <filename
	class="directory">/A2/B2</filename> respectively.</para>

    <para>File systems can be mounted on top of one another.
      Continuing the last example, the <literal>C</literal> file
      system could be mounted on top of the <literal>B1</literal>
      directory in the <literal>B</literal> file system, leading to
      this arrangement:</para>

    <mediaobject>
      <imageobject>
	<imagedata fileref="install/example-dir4"/>
      </imageobject>

      <textobject>
	<literallayout class="monospaced"> /
 |
 +--- A1
 |
 `--- A2
       |
       +--- B1
       |     |
       |     +--- C1
       |     |
       |     `--- C2
       |
       `--- B2</literallayout>
      </textobject>
    </mediaobject>

    <para>Or <literal>C</literal> could be mounted directly on to the
      <literal>A</literal> file system, under the
      <literal>A1</literal> directory:</para>

    <mediaobject>
      <imageobject>
	<imagedata fileref="install/example-dir5"/>
      </imageobject>

      <textobject>
	<literallayout class="monospaced"> /
 |
 +--- A1
 |     |
 |     +--- C1
 |     |
 |     `--- C2
 |
 `--- A2
       |
       +--- B1
       |
       `--- B2</literallayout>
      </textobject>
    </mediaobject>

    <para>It is entirely possible to have one large root file system,
      and not need to create any others.  There are some drawbacks to
      this approach, and one advantage.</para>

    <itemizedlist>
      <title>Benefits of Multiple File Systems</title>

      <listitem>
	<para>Different file systems can have different
	  <firstterm>mount options</firstterm>.  For example, the root
	  file system can be mounted read-only, making it impossible
	  for users to inadvertently delete or edit a critical file.
	  Separating user-writable file systems, such as <filename
	    class="directory">/home</filename>, from other file
	  systems allows them to be mounted
	  <firstterm>nosuid</firstterm>.  This option prevents the
	  <firstterm>suid</firstterm>/<firstterm>guid</firstterm> bits
	  on executables stored on the file system from taking effect,
	  possibly improving security.</para>
      </listitem>

      <listitem>
	<para>&os; automatically optimizes the layout of files on a
	  file system, depending on how the file system is being used.
	  So a file system that contains many small files that are
	  written frequently will have a different optimization to one
	  that contains fewer, larger files.  By having one big file
	  system this optimization breaks down.</para>
      </listitem>

      <listitem>
	<para>&os;'s file systems are robust if power is lost.
	  However, a power loss at a critical point could still
	  damage the structure of the file system.  By splitting
	  data over multiple file systems it is more likely that the
	  system will still come up, making it easier to restore from
	  backup as necessary.</para>
      </listitem>
    </itemizedlist>

    <itemizedlist>
      <title>Benefit of a Single File System</title>

      <listitem>
	<para>File systems are a fixed size.  If you create a file
	  system when you install &os; and give it a specific size,
	  you may later discover that you need to make the partition
	  bigger.  This is not easily accomplished without backing up,
	  recreating the file system with the new size, and then
	  restoring the backed up data.</para>

	<important>
	  <para>&os; features the &man.growfs.8; command, which
	    makes it possible to increase the size of file system on
	    the fly, removing this limitation.</para>
	</important>
      </listitem>
    </itemizedlist>

    <para>File systems are contained in partitions.  This does not
      have the same meaning as the common usage of the term partition
      (for example, &ms-dos; partition), because of &os;'s &unix;
      heritage.  Each partition is identified by a letter from
      <literal>a</literal> through to <literal>h</literal>.  Each
      partition can contain only one file system, which means that
      file systems are often described by either their typical mount
      point in the file system hierarchy, or the letter of the
      partition they are contained in.</para>

    <para>&os; also uses disk space for <firstterm>swap
	space</firstterm> to provide
      <firstterm>virtual memory</firstterm>.  This allows your
      computer to behave as though it has much more memory than it
      actually does.  When &os; runs out of memory, it moves some of
      the data that is not currently being used to the swap space, and
      moves it back in (moving something else out) when it needs
      it.</para>

    <para>Some partitions have certain conventions associated with
      them.</para>

    <informaltable frame="none" pgwide="1">
      <tgroup cols="2">
	<colspec colwidth="1*"/>
	<colspec colwidth="5*"/>

	<thead>
	  <row>
	    <entry>Partition</entry>
	    <entry>Convention</entry>
	  </row>
	</thead>

	<tbody valign="top">
	  <row>
	    <entry><literal>a</literal></entry>
	    <entry>Normally contains the root file system.</entry>
	  </row>

	  <row>
	    <entry><literal>b</literal></entry>
	    <entry>Normally contains swap space.</entry>
	  </row>

	  <row>
	    <entry><literal>c</literal></entry>
	    <entry>Normally the same size as the enclosing slice.
	      This allows utilities that need to work on the entire
	      slice, such as a bad block scanner, to work on the
	      <literal>c</literal> partition.  A file system would not
	      normally be
	      created on this partition.</entry>
	  </row>

	  <row>
	    <entry><literal>d</literal></entry>
	    <entry>Partition <literal>d</literal> used to have a
	      special meaning associated with it, although that is now
	      gone and <literal>d</literal> may work as any normal
	      partition.</entry>
	  </row>
	</tbody>
      </tgroup>
    </informaltable>

    <para>Disks in &os; are divided into slices, referred to in
      &windows; as partitions, which are numbered from 1 to 4.  These
      are then then divided into partitions, which contain file
      systems, and are labeled using letters.</para>

    <indexterm><primary>slices</primary></indexterm>
    <indexterm><primary>partitions</primary></indexterm>
    <indexterm><primary>dangerously dedicated</primary></indexterm>

    <para>Slice numbers follow the device name, prefixed with an
      <literal>s</literal>, starting at 1.  So
      <quote>da0<emphasis>s1</emphasis></quote> is the first slice on
      the first SCSI drive.  There can only be four physical slices on
      a disk, but there can be logical slices inside physical slices
      of the appropriate type.  These extended slices are numbered
      starting at 5, so <quote>ad0<emphasis>s5</emphasis></quote> is
      the first extended slice on the first IDE disk.  These devices
      are used by file systems that expect to occupy a slice.</para>

    <para>Slices, <quote>dangerously dedicated</quote> physical
      drives, and other drives contain
      <firstterm>partitions</firstterm>, which are represented as
      letters from <literal>a</literal> to <literal>h</literal>.  This
      letter is appended to the device name, so
      <quote>da0<emphasis>a</emphasis></quote> is the
      <literal>a</literal> partition on the first
      <literal>da</literal> drive, which is <quote>dangerously
	dedicated</quote>.  <quote>ad1s3<emphasis>e</emphasis></quote>
      is the fifth partition in the third slice of the second IDE
      disk drive.</para>

    <para>Finally, each disk on the system is identified.  A disk name
      starts with a code that indicates the type of disk, and then a
      number, indicating which disk it is.  Unlike slices, disk
      numbering starts at 0.  Common codes are listed in <xref
	linkend="basics-dev-codes"/>.</para>

    <para>When referring to a partition, include the disk name,
      <literal>s</literal>, the slice number, and then the partition
      letter.  Examples are shown in <xref
	linkend="basics-disk-slice-part"/>.</para>

    <para><xref linkend="basics-concept-disk-model"/> shows a
      conceptual model of a disk layout.</para>

    <para>When installing &os;, configure the disk slices, create
      partitions within the slice to be used for &os;, create a file
      system or swap space in each partition, and decide where each
      file system will be mounted.</para>

    <table frame="none" pgwide="1" id="basics-dev-codes">
      <title>Disk Device Codes</title>

      <tgroup cols="2">
	<colspec colwidth="1*"/>
	<colspec colwidth="5*"/>

	<thead>
	  <row>
	    <entry>Code</entry>
	    <entry>Meaning</entry>
	  </row>
	</thead>

	<tbody>
	  <row>
	    <entry><devicename>ad</devicename></entry>
	    <entry>ATAPI (IDE) disk</entry>
	  </row>

	  <row>
	    <entry><devicename>da</devicename></entry>
	    <entry>SCSI direct access disk</entry>
	  </row>

	  <row>
	    <entry><devicename>acd</devicename></entry>
	    <entry>ATAPI (IDE) CDROM</entry>
	  </row>

	  <row>
	    <entry><devicename>cd</devicename></entry>
	    <entry>SCSI CDROM</entry>
	  </row>

	  <row>
	    <entry><devicename>fd</devicename></entry>
	    <entry>Floppy disk</entry>
	  </row>
	</tbody>
      </tgroup>
    </table>

    <example id="basics-disk-slice-part">
      <title>Sample Disk, Slice, and Partition Names</title>

      <informaltable frame="none" pgwide="1">
	<tgroup cols="2">
	  <colspec colwidth="1*"/>
	  <colspec colwidth="5*"/>

	  <thead>
	    <row>
	      <entry>Name</entry>
	      <entry>Meaning</entry>
	    </row>
	  </thead>

	  <tbody>
	    <row>
	      <entry><literal>ad0s1a</literal></entry>
	      <entry>The first partition (<literal>a</literal>) on the
		first slice (<literal>s1</literal>) on the first IDE
		disk (<literal>ad0</literal>).</entry>
	    </row>

	    <row>
	      <entry><literal>da1s2e</literal></entry>

	      <entry>The fifth partition (<literal>e</literal>) on the
		second slice (<literal>s2</literal>) on the second
		SCSI disk (<literal>da1</literal>).</entry>
	    </row>
	  </tbody>
	</tgroup>
      </informaltable>
    </example>

    <example id="basics-concept-disk-model">
      <title>Conceptual Model of a Disk</title>

      <para>This diagram shows &os;'s view of the first IDE disk
	attached to the system.  Assume that the disk is 4&nbsp;GB in
	size, and contains two 2&nbsp;GB slices (&ms-dos; partitions).
	The first slice contains a &ms-dos; disk,
	<devicename>C:</devicename>, and the second slice contains a
	&os; installation.  This example &os; installation has
	three data partitions, and a swap partition.</para>

      <para>The three partitions will each hold a file system.
	Partition <literal>a</literal> will be used for the root file
	system, <literal>e</literal> for the <filename
	  class="directory">/var/</filename> directory hierarchy, and
	<literal>f</literal> for the <filename
	  class="directory">/usr/</filename> directory
	hierarchy.</para>

      <mediaobject>
	<imageobject>
	  <imagedata fileref="install/disk-layout"/>
	</imageobject>

	<textobject>
	  <literallayout class="monospaced">.-----------------.  --.
|                 |    |
|  DOS / Windows  |    |
:                 :     &gt;  First slice, ad0s1
:                 :    |
|                 |    |
:=================:  ==:                               --.
|                 |    |  Partition a, mounted as /      |
|                 |     &gt; referred to as ad0s2a          |
|                 |    |                                 |
:-----------------:  ==:                                 |
|                 |    |  Partition b, used as swap      |
|                 |     &gt; referred to as ad0s2b          |
|                 |    |                                 |
:-----------------:  ==:                                 |  Partition c, no
|                 |    |  Partition e, used as /var       &gt; file system, all
|                 |     &gt; referred to as ad0s2e          |  of FreeBSD slice,
|                 |    |                                 |  ad0s2c
:-----------------:  ==:                                 |
|                 |    |                                 |
:                 :    |  Partition f, used as /usr      |
:                 :     &gt; referred to as ad0s2f          |
:                 :    |                                 |
|                 |    |                                 |
|                 |  --'                                 |
`-----------------'                                    --'</literallayout>
	</textobject>
      </mediaobject>
    </example>
  </sect1>

  <sect1 id="mount-unmount">
    <title>Mounting and Unmounting File Systems</title>

    <para>The file system is best visualized as a tree,
      rooted, as it were, at <filename class="directory">/</filename>.
      <filename class="directory">/dev</filename>, <filename
	class="directory">/usr</filename>, and the other directories
      in the root directory are branches, which may have their own
      branches, such as <filename
	class="directory">/usr/local</filename>, and so on.</para>

    <indexterm><primary>root file system</primary></indexterm>
    <para>There are various reasons to house some of these
      directories on separate file systems.  <filename
	class="directory">/var</filename> contains the directories
      <filename class="directory">log/</filename>,
      <filename class="directory">spool/</filename>, and various types
      of temporary files, and as such, may get filled up.  Filling up
      the root file system is not a good idea, so splitting <filename
	class="directory">/var</filename> from <filename
	class="directory">/</filename> is often favorable.</para>

    <para>Another common reason to contain certain directory trees on
      other file systems is if they are to be housed on separate
      physical disks, or are separate virtual disks, such as Network
      File System  mounts, described in <xref linkend="network-nfs"/>,
      or CDROM drives.</para>

    <sect2 id="disks-fstab">
      <title>The <filename>fstab</filename> File</title>

      <indexterm>
	<primary>file systems</primary>
	<secondary>mounted with fstab</secondary>
      </indexterm>

      <para>During the boot process (<xref linkend="boot"/>),
	file systems listed in <filename>/etc/fstab</filename> are
	automatically mounted except for the entries containing
	<option>noauto</option>.  This file contains entries in the
	following format:</para>

      <programlisting><replaceable>device</replaceable>       <replaceable>/mount-point</replaceable> <replaceable>fstype</replaceable>     <replaceable>options</replaceable>      <replaceable>dumpfreq</replaceable>     <replaceable>passno</replaceable></programlisting>

      <variablelist>
	<varlistentry>
	  <term><literal>device</literal></term>
	  <listitem>
	    <para>An existing device name as explained in
	      <xref linkend="disks-naming"/>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><literal>mount-point</literal></term>

	  <listitem>
	    <para>An existing directory on which to mount the file
	      system.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><literal>fstype</literal></term>

	  <listitem>
	    <para>The file system type to pass to &man.mount.8;.  The
	      default &os; file system is
	      <literal>ufs</literal>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><literal>options</literal></term>

	  <listitem>
	    <para>Either <option>rw</option> for read-write file
	      systems, or <option>ro</option> for read-only file
	      systems, followed by any other options that may be
	      needed.  A common option is <option>noauto</option> for
	      file systems not normally mounted during the boot
	      sequence.  Other options are listed in
	      &man.mount.8;.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><literal>dumpfreq</literal></term>

	  <listitem>
	    <para>Used by &man.dump.8; to determine which file systems
	      require dumping.  If the field is missing, a value of
	      zero is assumed.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><literal>passno</literal></term>

	  <listitem>
	    <para>Determines the order in which file systems should be
	      checked.  File systems that should be skipped should
	      have their <literal>passno</literal> set to zero.  The
	      root file system needs to be checked before everything
	      else and should have its <literal>passno</literal> set
	      to one.  The other file systems should be set to
	      values greater than one.  If more than one file system
	      has the same <literal>passno</literal>, &man.fsck.8;
	      will attempt to check file systems in parallel if
	      possible.</para>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para>Refer to &man.fstab.5; for more information on the format
	of <filename>/etc/fstab</filename> and its options.</para>
    </sect2>

    <sect2 id="disks-mount">
      <title>Using &man.mount.8;</title>

      <indexterm>
	<primary>file systems</primary>
	<secondary>mounting</secondary>
      </indexterm>

      <para>File systems are mounted using &man.mount.8;.  The most
	basic syntax is as follows:</para>

      <informalexample>
	<screen>&prompt.root; <userinput>mount <replaceable>device</replaceable> <replaceable>mountpoint</replaceable></userinput></screen>
      </informalexample>

      <para>This command provides many options which are described in
	&man.mount.8;, The most commonly used options include:</para>

      <variablelist>
	<title>Mount Options</title>

	<varlistentry>
	  <term><option>-a</option></term>

	  <listitem>
	    <para>Mount all the file systems listed in
	      <filename>/etc/fstab</filename>, except those marked as
	      <quote>noauto</quote>, excluded by the
	      <option>-t</option> flag, or those that are already
	      mounted.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-d</option></term>

	  <listitem>

	    <para>Do everything except for the actual mount system
	      call.  This option is useful in conjunction with the
	      <option>-v</option> flag to determine what &man.mount.8;
	      is actually trying to do.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-f</option></term>

	  <listitem>
	    <para>Force the mount of an unclean file system
	      (dangerous), or the revocation of write access when
	      downgrading a file system's mount status from read-write
	      to read-only.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-r</option></term>

	  <listitem>
	    <para>Mount the file system read-only.  This is identical
	      to using <option>-o ro</option>.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-t</option>
	    <replaceable>fstype</replaceable></term>

	  <listitem>
	    <para>Mount the specified file system type or mount only
	      file systems of the given type, if <option>-a</option>
	      is included.  <quote>ufs</quote> is the default file
	      system type.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-u</option></term>

	  <listitem>
	    <para>Update mount options on the file system.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-v</option></term>

	  <listitem>
	    <para>Be verbose.</para>
	  </listitem>
	</varlistentry>

	<varlistentry>
	  <term><option>-w</option></term>

	  <listitem>
	    <para>Mount the file system read-write.</para>
	  </listitem>
	</varlistentry>
      </variablelist>

      <para>The following options can be passed to <option>-o</option>
	as a comma-separated list:</para>

      <variablelist>
	<varlistentry>
	  <term>nosuid</term>

	  <listitem>
	    <para>Do not interpret setuid or setgid flags on the
	      file system.  This is also a useful security
	      option.</para>
	  </listitem>
	</varlistentry>
      </variablelist>
    </sect2>

    <sect2 id="disks-umount">
      <title>Using &man.umount.8;</title>

      <indexterm>
	<primary>file systems</primary>
	<secondary>unmounting</secondary>
      </indexterm>

      <para>To unmount a file system use &man.umount.8;.  This command
	takes one parameter which can be a mountpoint, device name,
	<option>-a</option> or <option>-A</option>.</para>

      <para>All forms take <option>-f</option> to force unmounting,
	and <option>-v</option> for verbosity.  Be warned that
	<option>-f</option> is not generally a good idea as it might
	crash the computer or damage data on the file system.</para>

      <para>To unmount all mounted file systems, or just the file
	system types listed after <option>-t</option>, use
	<option>-a</option> or <option>-A</option>.  Note that
	<option>-A</option> does not attempt to unmount the root file
	system.</para>
    </sect2>
  </sect1>

  <sect1 id="basics-processes">
    <title>Processes</title>

    <para>&os; is a multi-tasking operating system.  Each program
      running at any one time is called a
      <firstterm>process</firstterm>.  Every running command starts
      at least one new process and there are a number of system
      processes that are run by &os;.</para>

    <para>Each process is uniquely identified by a number called a
      <firstterm>process ID</firstterm> (<acronym>PID</acronym>).
      Similar to files, each process has one owner and group, and
      the owner and group permissions are used to determine which
      files and devices the process can open.  Most processes also
      have a parent process that started them.  For example, the
      shell is a process, and any command started in the shell is a
      process which has the shell as its parent process.  The
      exception is a special process called &man.init.8; which is
      always the first process to start at boot time and which always
      has a <acronym>PID</acronym> of 1.</para>

    <para>To see the processes on the system, use &man.ps.1; and
      &man.top.1;.   To display a static list of the currently running
      processes, their <acronym>PID</acronym>s, how much memory they
      are using, and the command they were started with, use
      &man.ps.1;.  To display all the running processes and update
      the display every few seconds in order to interactively see
      what the computer is doing, use &man.top.1;.</para>

    <para>By default, &man.ps.1; only shows the commands that are
      running and owned by the user.  For example:</para>

    <screen>&prompt.user; <userinput>ps</userinput>
  PID  TT  STAT      TIME COMMAND
  298  p0  Ss     0:01.10 tcsh
 7078  p0  S      2:40.88 xemacs mdoc.xsl (xemacs-21.1.14)
37393  p0  I      0:03.11 xemacs freebsd.dsl (xemacs-21.1.14)
72210  p0  R+     0:00.00 ps
  390  p1  Is     0:01.14 tcsh
 7059  p2  Is+    1:36.18 /usr/local/bin/mutt -y
 6688  p3  IWs    0:00.00 tcsh
10735  p4  IWs    0:00.00 tcsh
20256  p5  IWs    0:00.00 tcsh
  262  v0  IWs    0:00.00 -tcsh (tcsh)
  270  v0  IW+    0:00.00 /bin/sh /usr/X11R6/bin/startx -- -bpp 16
  280  v0  IW+    0:00.00 xinit /home/nik/.xinitrc -- -bpp 16
  284  v0  IW     0:00.00 /bin/sh /home/nik/.xinitrc
  285  v0  S      0:38.45 /usr/X11R6/bin/sawfish</screen>

    <para>The output from &man.ps.1; is organized into a number of
      columns.  The <literal>PID</literal> column displays the process
      ID.  <acronym>PID</acronym>s are assigned starting at 1, go up
      to 99999, then wrap around back to the beginning.  However, a
      <acronym>PID</acronym> is not reassigned if it is already in
      use.  The <literal>TT</literal> column shows the tty the program
      is running on and <literal>STAT</literal> shows the program's
      state.  <literal>TIME</literal> is the amount of time the
      program has been running on the CPU.  This is usually not the
      elapsed time since the program was started, as most programs
      spend a lot of time waiting for things to happen before they
      need to spend time on the CPU.  Finally,
      <literal>COMMAND</literal> is the command that was used to start
      the program.</para>

    <para>&man.ps.1; supports a number of different options to change
      the information that is displayed.  One of the most useful sets
      is <literal>auxww</literal>.  <option>a</option> displays
      information about all the running processes of all users.
      <option>u</option> displays the username of the process' owner,
      as well as memory usage.  <option>x</option> displays
      information about daemon processes, and <option>ww</option>
      causes &man.ps.1; to display the full command line for each
      process, rather than truncating it once it gets too long to fit
      on the screen.</para>

    <para>The output from &man.top.1; is similar.  A sample session
      looks like this:</para>

    <screen>&prompt.user; <userinput>top</userinput>
last pid: 72257;  load averages:  0.13,  0.09,  0.03    up 0+13:38:33  22:39:10
47 processes:  1 running, 46 sleeping
CPU states: 12.6% user,  0.0% nice,  7.8% system,  0.0% interrupt, 79.7% idle
Mem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K Free
Swap: 256M Total, 38M Used, 217M Free, 15% Inuse

  PID USERNAME PRI NICE  SIZE    RES STATE    TIME   WCPU    CPU COMMAND
72257 nik       28   0  1960K  1044K RUN      0:00 14.86%  1.42% top
 7078 nik        2   0 15280K 10960K select   2:54  0.88%  0.88% xemacs-21.1.14
  281 nik        2   0 18636K  7112K select   5:36  0.73%  0.73% XF86_SVGA
  296 nik        2   0  3240K  1644K select   0:12  0.05%  0.05% xterm
  175 root       2   0   924K   252K select   1:41  0.00%  0.00% syslogd
 7059 nik        2   0  7260K  4644K poll     1:38  0.00%  0.00% mutt
...</screen>

    <para>The output is split into two sections.  The header (the
      first five lines) shows the <acronym>PID</acronym> of the last
      process to run, the system load averages (which are a measure
      of how busy the system is), the system uptime (time since the
      last reboot) and the current time.  The other figures in the
      header relate to how many processes are running (47 in this
      case), how much memory and swap space has been used, and how
      much time the system is spending in different CPU states.</para>

    <para>Below the header is a series of columns containing similar
      information to the output from &man.ps.1;, such as the
      <acronym>PID</acronym>, username, amount of CPU time, and the
      command that started the process.  By default, &man.top.1; also
      displays the amount of memory space taken by the process.
      This is split into two columns: one for total size and one for
      resident size.  Total size is how much memory the application
      has needed and the resident size is how much it is actually
      using at the moment.  In this example,
      <application>mutt</application> has required almost 8&nbsp;MB
      of RAM, but is currently only using 5&nbsp;MB.</para>

    <para>&man.top.1; automatically updates the display every two
      seconds.  A different interval can be specified with
      <option>-s</option>.</para>
  </sect1>

  <sect1 id="basics-daemons">
    <title>Daemons, Signals, and Killing Processes</title>

    <para>When using an editor, it is easy to control the editor and
      load files because the editor provides facilities to do so, and
      because the editor is attached to a
      <firstterm>terminal</firstterm>.  Some programs are not designed
      to be run with continuous user input and disconnect from the
      terminal at the first opportunity.  For example, a web server
      responds to web requests, rather than user input.  Mail servers
      are another example of this type of application.</para>

    <para>These programs are known as <firstterm>daemons</firstterm>.
      The term daemon comes from Greek mythology and represents an
      entity that is neither good or evil, and which invisibly
      performs useful tasks.  This is why the BSD mascot is the
      cheerful-looking daemon with sneakers and a pitchfork.</para>

    <para>There is a convention to name programs that normally run as
      daemons with a trailing <quote>d</quote>.
      <application>BIND</application> is the Berkeley Internet Name
      Domain, but the actual program that executes is &man.named.8;.
      The <application>Apache</application> web server program is
      <command>httpd</command> and the line printer spooling daemon
      is &man.lpd.8;.  This is only a naming convention.  For example,
      the main mail daemon for the <application>Sendmail</application>
      application is &man.sendmail.8;, and not
      <literal>maild</literal>.</para>

    <para>One way to communicate with a daemon, or any running
      process, is to send a <firstterm>signal</firstterm> using
      &man.kill.1;.  There are a number of different signals; some
      have a specific meaning while others are described in the
      application's documentation.  A user can only send a signal to a
      process they own and sending a signal to someone else's process
      will result in a permission denied error.  The exception is the
      <username>root</username> user, who can send signals to anyone's
      processes.</para>

    <para>&os; can also send a signal to a process.  If an application
      is badly written and tries to access memory that it is not
      supposed to, &os; will send the process the
      <firstterm>Segmentation Violation</firstterm> signal
      (<literal>SIGSEGV</literal>).  If an application has used the
      &man.alarm.3; system call to be alerted after a period of time
      has elapsed, it will be sent the Alarm signal
      (<literal>SIGALRM</literal>).</para>

    <para>Two signals can be used to stop a process:
      <literal>SIGTERM</literal> and <literal>SIGKILL</literal>.
      <literal>SIGTERM</literal> is the polite way to kill a process
      as the process can read the signal, close any log files it may
      have open, and attempt to finish what it is doing before
      shutting down.  In some cases, a process may ignore
      <literal>SIGTERM</literal> if it is in the middle of some task
      that can not be interrupted.</para>

    <para><literal>SIGKILL</literal> can not be ignored by a process.
      This is the <quote>I do not care what you are doing, stop right
      now</quote> signal.  Sending a <literal>SIGKILL</literal> to a
      process will usually stop that process there and then.<footnote>
	<para>There are a few tasks that can not be interrupted.  For
	  example, if the process is trying to read from a file that
	  is on another computer on the network, and the other
	  computer is unavailable, the process is said to be
	  <quote>uninterruptible</quote>.  Eventually the process will
	  time out, typically after two minutes.  As soon as this time
	  out occurs the process will be killed.</para>
	</footnote>.</para>

    <para>Other commonly used signals are <literal>SIGHUP</literal>,
      <literal>SIGUSR1</literal>, and <literal>SIGUSR2</literal>.
      These are general purpose signals and different applications
      will respond differently.</para>

    <para>For example, after changing a web server's configuration
      file, the web server needs to be told to re-read its
      configuration.  Restarting <command>httpd</command> would result
      in a brief outage period on the web server.  Instead, send the
      daemon the <literal>SIGHUP</literal> signal.  Be aware that
      different daemons will have different behavior, so refer to the
      documentation for the daemon to determine if
      <literal>SIGHUP</literal> will achieve the desired
      results.</para>

    <procedure>
      <title>Sending a Signal to a Process</title>

      <para>This example shows how to send a signal to &man.inetd.8;.
	The &man.inetd.8; configuration file is
	<filename>/etc/inetd.conf</filename>, and &man.inetd.8; will
	re-read this configuration file when it is sent a
	<literal>SIGHUP</literal>.</para>

      <step>
	<para>Find the <acronym>PID</acronym> of the process to send
	  the signal to using &man.pgrep.1;.  In this example, the
	  <acronym>PID</acronym> for &man.inetd.8; is 198:</para>

	<screen>&prompt.user; <userinput>pgrep -l inetd</userinput>
198  inetd -wW</screen>

      </step>

      <step>
	<para>Use &man.kill.1; to send the signal.  Because
	  &man.inetd.8; is owned by <username>root</username>, use
	  &man.su.1; to become <username>root</username> first.</para>

	<screen>&prompt.user; <userinput>su</userinput>
<prompt>Password:</prompt>
&prompt.root; <userinput>/bin/kill -s HUP 198</userinput></screen>

	<para>Like most &unix; commands, &man.kill.1; will not print
	  any output if it is successful.  If a signal is sent to a
	  process not owned by that user, the message
	  <errorname>kill: <replaceable>PID</replaceable>: Operation
	    not permitted</errorname> will be displayed.  Mistyping
	  the <acronym>PID</acronym> will either send the signal to
	  the wrong process, which could have negative results, or
	  will send the signal to a <acronym>PID</acronym> that is
	  not currently in use, resulting in the error
	  <errorname>kill: <replaceable>PID</replaceable>: No such
	    process</errorname>.</para>

	<note>
	  <title>Why Use <command>/bin/kill</command>?</title>

	  <para>Many shells provide <command>kill</command> as a built
	    in command, meaning that the shell will send the signal
	    directly, rather than running
	    <filename>/bin/kill</filename>.  Be aware that different
	    shells have a different syntax for specifying the name of
	    the signal to send.  Rather than try to learn all of them,
	    it can be simpler to use <command>/bin/kill
	      <replaceable>...</replaceable></command>
	    directly.</para>
	</note>
      </step>
    </procedure>

    <para>When sending other signals, substitute
      <literal>TERM</literal> or <literal>KILL</literal> in the
      command line as necessary.</para>

    <important>
      <para>Killing a random process on the system can be a bad idea.
	In particular, &man.init.8;, <acronym>PID</acronym> 1, is
	special.  Running <command>/bin/kill -s KILL 1</command> is
	a quick, and unrecommended, way to shutdown the system.
	<emphasis>Always</emphasis> double check the arguments to
	&man.kill.1; <emphasis>before</emphasis> pressing
	<keycap>Return</keycap>.</para>
    </important>
  </sect1>

  <sect1 id="shells">
    <title>Shells</title>

    <indexterm><primary>shells</primary></indexterm>
    <indexterm><primary>command line</primary></indexterm>

    <para>&os; provides a command line interface called a shell.  A
      shell receives commands from the input channel and executes
      them.  Many shells provide built in functions to help with
      everyday tasks such as file management, file globbing, command
      line editing, command macros, and environment variables.  &os;
      comes with several shells, including the Bourne shell
      (&man.sh.1;) and the extended C shell (&man.tcsh.1;).  Other
      shells are available from the &os; Ports Collection, such as
      <command>zsh</command> and <command>bash</command>.</para>

    <para>The shell that is used is really a matter of taste.  A C
      programmer might feel more comfortable with a C-like shell such
      as &man.tcsh.1;.  A &linux; user might prefer
      <command>bash</command>.  Each shell has unique properties that
      may or may not work with a user's preferred working environment,
      which is why there is a choice of which shell to use.</para>

    <para>One common shell feature is filename completion.  After a
      user types the first few letters of a command or filename and
      presses <keycap>Tab</keycap>, the shell will automatically
      complete the rest of the command or filename.  Consider two
      files called <filename>foobar</filename> and
      <filename>foo.bar</filename>.  To delete
      <filename>foo.bar</filename>, type <command>rm
	fo[<keycap>Tab</keycap>].[<keycap>Tab</keycap>]</command>.</para>

    <para>The shell should print out <command>rm
	foo[BEEP].bar</command>.</para>

    <para>The [BEEP] is the console bell, which the shell used to
      indicate it was unable to complete the filename because there
      is more than one match.  Both <filename>foobar</filename> and
      <filename>foo.bar</filename> start with <literal>fo</literal>.
      By typing <literal>.</literal>, then pressing
      <keycap>Tab</keycap> again, the shell would be able to fill in
      the rest of the filename.</para>

    <indexterm><primary>environment variables</primary></indexterm>

    <para>Another feature of the shell is the use of environment
      variables.  Environment variables are a variable/key pair stored
      in the shell's environment.  This environment can be read by any
      program invoked by the shell, and thus contains a lot of program
      configuration.  Here is a list of common environment variables
      and their meanings:</para>

    <informaltable frame="none" pgwide="1">
      <tgroup cols="2">
	<thead>
	  <row>
	    <entry>Variable</entry>
	    <entry>Description</entry>
	  </row>
	</thead>

	<tbody>
	  <row>
	    <entry><envar>USER</envar></entry>
	    <entry>Current logged in user's name.</entry>
	  </row>

	  <row>
	    <entry><envar>PATH</envar></entry>
	    <entry>Colon-separated list of directories to search for
	      binaries.</entry>
	  </row>

	  <row>
	    <entry><envar>DISPLAY</envar></entry>
	    <entry>Network name of the
	      <application>&xorg;</application>
	      display to connect to, if available.</entry>
	  </row>

	  <row>
	    <entry><envar>SHELL</envar></entry>
	    <entry>The current shell.</entry>
	  </row>

	  <row>
	    <entry><envar>TERM</envar></entry>

	    <entry>The name of the user's type of terminal.  Used to
	      determine the capabilities of the terminal.</entry>
	  </row>

	  <row>
	    <entry><envar>TERMCAP</envar></entry>

	    <entry>Database entry of the terminal escape codes to
	      perform various terminal functions.</entry>
	  </row>

	  <row>
	    <entry><envar>OSTYPE</envar></entry>
	    <entry>Type of operating system.</entry>
	  </row>

	  <row>
	    <entry><envar>MACHTYPE</envar></entry>
	    <entry>The system's CPU architecture.</entry>
	  </row>

	  <row>
	    <entry><envar>EDITOR</envar></entry>
	    <entry>The user's preferred text editor.</entry>
	  </row>

	  <row>
	    <entry><envar>PAGER</envar></entry>
	    <entry>The user's preferred text pager.</entry>
	  </row>

	  <row>
	    <entry><envar>MANPATH</envar></entry>
	    <entry>Colon-separated list of directories to search for
	      manual pages.</entry>
	  </row>
	</tbody>
      </tgroup>
    </informaltable>

    <indexterm><primary>Bourne shells</primary></indexterm>

    <para>How to set an environment variable differs between shells.
      In &man.tcsh.1; and &man.csh.1;, use
      <command>setenv</command> to set environment variables.  In
      &man.sh.1; and <command>bash</command>, use
      <command>export</command> to set the current environment
      variables.  This example sets the default <envar>EDITOR</envar>
      to <filename>/usr/local/bin/emacs</filename> for the
      &man.tcsh.1; shell:</para>

    <screen>&prompt.user; <userinput>setenv EDITOR /usr/local/bin/emacs</userinput></screen>

    <para>The equivalent command for <command>bash</command>
      would be:</para>

    <screen>&prompt.user; <userinput>export EDITOR="/usr/local/bin/emacs"</userinput></screen>

    <para>To expand an environment variable in order to see its
      current setting, type a <literal>$</literal> character in front
      of its name on the command line.  For example,
      <command>echo $TERM</command> displays the current
      <envar>$TERM</envar> setting.</para>

    <para>Shells treat special characters, known as meta-characters,
      as special representations of data.  The most common
      meta-character is <literal>*</literal>, which represents any
      number of characters in a filename.  Meta-characters can be
      used to perform filename globbing.  For example, <command>echo
	*</command> is equivalent to &man.ls.1; because the shell
      takes all the files that match <literal>*</literal> and
      &man.echo.1; lists them on the command line.</para>

    <para>To prevent the shell from interpreting a special character,
      escape it from the shell by starting it with a backslash
      (<literal>\</literal>).  For example,
      <command>echo $TERM</command> prints the terminal setting
      whereas <command>echo \$TERM</command> literally prints the
      string <literal>$TERM</literal>.</para>

    <sect2 id="changing-shells">
      <title>Changing Your Shell</title>

      <para>The easiest way to permanently change the default shell is
	to use <command>chsh</command>.  Running this command will
	open the editor that is configured in the
	<envar>EDITOR</envar> environment variable, which by default
	is set to &man.vi.1;.  Change the <quote>Shell:</quote> line
	to the full path of the new shell.</para>

      <para>Alternately, use <command>chsh -s</command> which will set
	the specified shell without opening an editor.  For example,
	to change the shell to <command>bash</command>:</para>

      <screen>&prompt.user; <userinput>chsh -s /usr/local/bin/bash</userinput></screen>

      <note>
	<para>The new shell <emphasis>must</emphasis> be present in
	  <filename>/etc/shells</filename>.  If the shell was
	  installed from the &os; Ports Collection as described in
	  <xref linkend="ports"/>, it should be automatically added
	  to this file.  If it is missing, add it using this
	  command, replacing the path with the path of the
	  shell:</para>

	<screen>&prompt.root; <userinput>echo <replaceable>/usr/local/bin/bash</replaceable> &gt;&gt; /etc/shells</userinput></screen>

	<para>Then rerun &man.chsh.1;.</para>
      </note>
    </sect2>
  </sect1>

  <sect1 id="editors">
    <title>Text Editors</title>

    <indexterm><primary>text editors</primary></indexterm>
    <indexterm><primary>editors</primary></indexterm>

    <para>Most &os; configuration is done by editing text files.
      Because of this, it is a good idea to become familiar with a
      text editor.  &os; comes with a few as part of the base system,
      and many more are available in the Ports Collection.</para>

    <indexterm>
      <primary><command>ee</command></primary>
    </indexterm>
    <indexterm>
      <primary>editors</primary>
      <secondary>&man.ee.1;</secondary>
    </indexterm>

    <para>A simple editor to learn is &man.ee.1;, which stands for
      easy editor.  To start this editor, type <command>ee
	<replaceable>filename</replaceable></command> where
      <replaceable>filename</replaceable> is the name of the file to
      be edited.  Once inside the editor, all of the commands for
      manipulating the editor's functions are listed at the top of the
      display.  The caret <literal>^</literal> represents
      <keycap>Ctrl</keycap>, so <literal>^e</literal> expands to
      <keycombo
	action="simul"><keycap>Ctrl</keycap><keycap>e</keycap></keycombo>.
      To leave &man.ee.1;, press <keycap>Esc</keycap>, then choose
      the <quote>leave editor</quote> option from the main menu.
      The editor will prompt to save any changes if the file has been
      modified.</para>

    <indexterm>
      <primary>&man.vi.1;</primary>
    </indexterm>
    <indexterm>
      <primary>editors</primary>
      <secondary>&man.vi.1;</secondary>
    </indexterm>
    <indexterm>
      <primary><command>emacs</command></primary>
    </indexterm>
    <indexterm>
      <primary>editors</primary>
      <secondary><command>emacs</command></secondary>
    </indexterm>

    <para>&os; also comes with more powerful text editors, such as
      &man.vi.1;, as part of the base system.  Other editors, like
      <filename role="package">editors/emacs</filename> and
      <filename role="package">editors/vim</filename>, are part of the
      &os; Ports Collection.  These editors offer more functionality
      at the expense of being a more complicated to learn.  Learning a
      more powerful editor such as <application>vim</application> or
      <application>Emacs</application> can save more time in the long
      run.</para>

    <para>Many applications which modify files or require typed input
      will automatically open a text editor.  To alter the default
      editor used, set the <envar>EDITOR</envar> environment
      variable as described in <xref linkend="shells"/>.</para>
  </sect1>

  <sect1 id="basics-devices">
    <title>Devices and Device Nodes</title>

    <para>A device is a term used mostly for hardware-related
      activities in a system, including disks, printers, graphics
      cards, and keyboards.  When &os; boots, the majority of the boot
      messages refer to devices being detected.  A copy of the boot
      messages are saved to
      <filename>/var/run/dmesg.boot</filename>.</para>

    <para>Each device has a device name and number.  For example,
      <devicename>acd0</devicename> is the first IDE CD-ROM drive,
      while <devicename>kbd0</devicename> represents the
      keyboard.</para>

    <para>Most devices in a &os; must be accessed through special
      files called device nodes, which are located in
      <filename class="directory">/dev</filename>.</para>
  </sect1>

  <sect1 id="binary-formats">
    <title>Binary Formats</title>

    <para>Typically when a command is passed to the shell, the shell
      will arrange for an executable file to be loaded into memory and
      a new process is created.  Executable files can either be a binary
      file (usually created by the linker as part of compiling a program)
      or a shell script (text file to be interpreted by a binary file,
      like &man.sh.1; or &man.perl.1;).  The &man.file.1; command can
      usually determine what is inside a file.</para>

    <para>Binary files need to have a well defined format for the system
      to be able to use them properly.  Part of the file will be the
      executable machine code (the instructions that tell the CPU what
      to do), part of it will be data space with pre-defined values,
      part will be data space with no pre-defined values, etc.  Through
      time, different binary file formats have evolved.</para>

    <para>To understand why &os; uses the &man.elf.5; format, the three
      currently <quote>dominant</quote>, executable formats for &unix;
      must be described:</para>

    <itemizedlist>
      <listitem>
	<para>&man.a.out.5;</para>

	<para>The oldest and <quote>classic</quote> &unix; object
	  format.  It uses a short and compact header with a
	  &man.magic.5; number at the beginning that is often used to
	  characterize the format.  It contains three loaded segments:
	  .text, .data, and .bss, plus a symbol table and a string
	  table.</para>
      </listitem>

      <listitem>
	<para><acronym>COFF</acronym></para>

	<para>The SVR3 object format.  The header comprises a section
	  table which can contain more than just .text, .data, and
	  .bss sections.</para>
      </listitem>

      <listitem>
	<para>&man.elf.5;</para>

	<para>The successor to <acronym>COFF</acronym>, featuring
	  multiple sections and 32-bit or 64-bit possible values.  One
	  major drawback is that <acronym>ELF</acronym> was designed
	  with the assumption that there would be only one ABI per
	  system architecture.  That assumption is actually incorrect,
	  and not even in the commercial SYSV world (which has at
	  least three ABIs: SVR4, Solaris, SCO) does it hold
	  true.</para>

	<para>&os; tries to work around this problem somewhat by
	  providing a utility for <emphasis>branding</emphasis> a
	  known <acronym>ELF</acronym> executable with information
	  about its compliant ABI.  Refer to &man.brandelf.1; for more
	  information.</para>
      </listitem>
    </itemizedlist>

    <para>&os; comes from the <quote>classic</quote> camp and used
      the &man.a.out.5; format, a technology tried and proven through
      many generations of BSD releases, until the beginning of the 3.X
      branch.  Though it was possible to build and run native
      <acronym>ELF</acronym> binaries and kernels on a &os; system
      for some time before that, &os; initially resisted the
      <quote>push</quote> to switch to <acronym>ELF</acronym> as the
      default format.  Why?  When Linux made its painful transition to
      <acronym>ELF</acronym>, it was due to their inflexible
      jump-table based shared library mechanism, which made the
      construction of shared libraries difficult for vendors and
      developers.  Since <acronym>ELF</acronym> tools offered a
      solution to the shared library problem and were generally seen
      as <quote>the way forward</quote>, the migration cost was
      accepted as necessary and the transition made.  &os;'s shared
      library mechanism is based more closely on the &sunos; style
      shared library mechanism and is easy to use.</para>

    <para>So, why are there so many different formats?  Back in the
      PDP-11 days when simple hardware supported a simple, small
      system, <filename>a.out</filename> was adequate for the job of
      representing binaries.  As &unix; was ported, the
      <filename>a.out</filename> format was retained because it was
      sufficient for the early ports of &unix; to architectures like
      the Motorola 68k or VAXen.</para>

    <para>Then some hardware engineer decided that if he could force
      software to do some sleazy tricks, a few gates could be shaved
      off the design and the CPU core could run faster.
      <filename>a.out</filename> was ill-suited for this new kind of
      hardware, known as <acronym>RISC</acronym>.  Many formats were
      developed to get better performance from this hardware than the
      limited, simple <filename>a.out</filename> format could offer.
      <acronym>COFF</acronym>, <acronym>ECOFF</acronym>, and a few
      others were invented and their limitations explored before
      settling on <acronym>ELF</acronym>.</para>

    <para>In addition, program sizes were getting huge while disks
      and physical memory were still relatively small, so the concept
      of a shared library was born.  The virtual memory system became
      more sophisticated. While each advancement was done using the
      <filename>a.out</filename> format, its usefulness was stretched
      with each new feature.  In addition, people wanted to
      dynamically load things at run time, or to junk parts of their
      program after the init code had run to save in core memory and
      swap space.  Languages became more sophisticated and people
      wanted code called before the main() function automatically.
      Lots of hacks were done to the <filename>a.out</filename> format
      to allow all of these things to happen, and they basically
      worked for a time.  In time, <filename>a.out</filename> was not
      up to handling all these problems without an ever increasing
      overhead in code and complexity.  While <acronym>ELF</acronym>
      solved many of these problems, it would be painful to switch
      from the system that basically worked.  So
      <acronym>ELF</acronym> had to wait until it was more painful to
      remain with <filename>a.out</filename> than it was to migrate to
      <acronym>ELF</acronym>.</para>

    <para>As time passed, the build tools that &os; derived their
      build tools from, especially the assembler and loader, evolved
      in two parallel trees.  The &os; tree added shared libraries and
      fixed some bugs.  The GNU folks that originally wrote these
      programs rewrote them and added simpler support for building
      cross compilers and plugging in different formats.  Those who
      wanted to build cross compilers targeting &os; were out of luck
      since the older sources that &os; had for &man.as.1; and
      &man.ld.1; were not up to the task.  The new GNU tools chain
      (<application>binutils</application>) supports cross
      compiling, <acronym>ELF</acronym>, shared libraries, and C++
      extensions.  In addition, many vendors release
      <acronym>ELF</acronym> binaries, and &os; should be able to run
      them.</para>

    <para><acronym>ELF</acronym> is more expressive than
      <filename>a.out</filename> and allows more extensibility in the
      base system.  The <acronym>ELF</acronym> tools are better
      maintained and offer cross compilation support.
      <acronym>ELF</acronym> may be a little slower than
      <filename>a.out</filename>, but trying to measure it can be
      difficult.  There are also numerous details that are different
      between the two such as how they map pages and handle init
      code.</para>
  </sect1>

  <sect1 id="basics-more-information">
    <title>For More Information</title>

    <sect2 id="basics-man">
      <title>Manual Pages</title>

      <indexterm><primary>manual pages</primary></indexterm>

      <para>The most comprehensive documentation on &os; is in the
	form of manual pages.  Nearly every program on the system
	comes with a short reference manual explaining the basic
	operation and available arguments.  These manuals can be
	viewed using <command>man</command>:</para>

      <screen>&prompt.user; <userinput>man <replaceable>command</replaceable></userinput></screen>

      <para>where <replaceable>command</replaceable> is the name of
	the command to learn about.  For example, to learn more about
	&man.ls.1;, type:</para>

      <screen>&prompt.user; <userinput>man ls</userinput></screen>

      <para>The online manual is divided into numbered
	sections:</para>

      <orderedlist>
	<listitem>
	  <para>User commands.</para>
	</listitem>

	<listitem>
	  <para>System calls and error numbers.</para>
	</listitem>

	<listitem>
	  <para>Functions in the C libraries.</para>
	</listitem>

	<listitem>
	  <para>Device drivers.</para>
	</listitem>

	<listitem>
	  <para>File formats.</para>
	</listitem>

	<listitem>
	  <para>Games and other diversions.</para>
	</listitem>

	<listitem>
	  <para>Miscellaneous information.</para>
	</listitem>

	<listitem>
	  <para>System maintenance and operation commands.</para>
	</listitem>

	<listitem>
	  <para>Kernel developers.</para>
	</listitem>
      </orderedlist>

      <para>In some cases, the same topic may appear in more than one
	section of the online manual.  For example, there is a
	&man.chmod.1; user command and a
	<function>chmod()</function> system call.  To tell &man.man.1;
	which section to display, specify the section number:</para>

      <screen>&prompt.user; <userinput>man 1 chmod</userinput></screen>

      <para>This will display the manual page for the user command
	&man.chmod.1;.  References to a particular section of the
	online manual are traditionally placed in parenthesis in
	written documentation, so &man.chmod.1; refers to the user
	command and &man.chmod.2; refers to the system call.</para>

      <para>If the command name is unknown, use <command>man
	  -k</command> to search for keywords in the command
	descriptions:</para>

      <screen>&prompt.user; <userinput>man -k <replaceable>mail</replaceable></userinput></screen>

      <para>This command displays a list of commands that have the
	keyword <quote>mail</quote> in their descriptions.  This is
	equivalent to using &man.apropos.1;.</para>

      <para>To determine what the commands in <filename
	  class="directory">/usr/bin</filename> do,
	type:</para>

      <screen>&prompt.user; <userinput>cd /usr/bin</userinput>
&prompt.user; <userinput>man -f *</userinput></screen>

      <para>or</para>

      <screen>&prompt.user; <userinput>cd /usr/bin</userinput>
&prompt.user; <userinput>whatis *</userinput></screen>

    </sect2>

    <sect2 id="basics-info">
      <title>GNU Info Files</title>

      <indexterm>
	<primary>Free Software Foundation</primary>
      </indexterm>

      <para>&os; includes many applications and utilities produced
	by the Free Software Foundation (FSF).  In addition to manual
	pages, these programs may include hypertext documents called
	<literal>info</literal> files.  These can be viewed using
	&man.info.1; or, if <filename
	  role="package">editors/emacs</filename> is installed, the
	info mode of <application>emacs</application>.</para>

      <para>To use &man.info.1;, type:</para>

      <screen>&prompt.user; <userinput>info</userinput></screen>

      <para>For a brief introduction, type <literal>h</literal>.  For
	a quick command reference, type <literal>?</literal>.</para>
    </sect2>
  </sect1>
</chapter>