File: 09_system_tips.rawxml

package info (click to toggle)
debian-reference 2.128
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,588 kB
  • sloc: python: 586; makefile: 572; sh: 526; sed: 80
file content (3311 lines) | stat: -rw-r--r-- 217,564 bytes parent folder | download | duplicates (2)
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
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
<!-- vim: set sw=2 et sts=2 ft=xml: -->
<!-- Last content review: 2024-01-21T14:32:17 UTC -->
  <chapter id="_system_tips">
    <title>System tips</title>
    <para>Here, I describe basic tips to configure and manage systems, mostly from the console.</para>
    <section id="_the_console_tips">
      <title>The console tips</title>
      <para>There are some utility programs to help your console activities.</para>
      <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
        <title>List of programs to support console activities</title>
        <tgroup cols="4">
          <colspec colwidth="48pt" align="left"/>
          <colspec colwidth="76pt" align="left"/>
          <colspec colwidth="70pt" align="left"/>
          <colspec colwidth="304pt" align="left"/>
          <thead>
            <row>
              <entry> package </entry>
              <entry> popcon </entry>
              <entry> size </entry>
              <entry> description </entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry> <literal>mc</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> See <xref linkend="_midnight_commander_mc"/> </entry>
            </row>
            <row>
              <entry> <literal>bsdutils</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>script</literal>(1) command to make a record of terminal session </entry>
            </row>
            <row>
              <entry> <literal>screen</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> terminal multiplexer with VT100/ANSI terminal emulation </entry>
            </row>
            <row>
              <entry> <literal>tmux</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> terminal multiplexer alternative (Use "Control-B" instead) </entry>
            </row>
            <row>
              <entry> <literal>fzf</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> fuzzy text finder </entry>
            </row>
            <row>
              <entry> <literal>fzy</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> fuzzy text finder </entry>
            </row>
            <row>
              <entry> <literal>rlwrap</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> readline feature command line wrapper </entry>
            </row>
            <row>
              <entry> <literal>ledit</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> readline feature command line wrapper </entry>
            </row>
            <row>
              <entry> <literal>rlfe</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> readline feature command line wrapper </entry>
            </row>
            <row>
              <entry> <literal>ripgrep</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> fast recursive string search in the source code tree with automatic filtering </entry>
            </row>
          </tbody>
        </tgroup>
      </table>
      <section id="_recording_the_shell_activities_cleanly">
        <title>Recording the shell activities cleanly</title>
        <para>The simple use of <literal>script</literal>(1) (see <xref linkend="_recording_the_shell_activities"/>) to record shell activity produces a file with control characters.  This can be avoided by using <literal>col</literal>(1) as the following.</para>
        <screen>$ script
Script started, file is typescript</screen>
        <para>Do whatever … and press <literal>Ctrl-D</literal> to exit <literal>script</literal>.</para>
        <screen>$ col -bx &lt; typescript &gt; cleanedfile
$ vim cleanedfile</screen>
        <para>There are alternative methods to record the shell activities:</para>
        <itemizedlist>
          <listitem>
            <para> Use <literal>tee</literal> (usable during the boot process in the initramfs): </para>
            <screen>$ sh -i 2&gt;&amp;1 | tee typescript</screen>
          </listitem>
          <listitem>
            <para> Use <literal>gnome-terminal</literal> with the extend line buffer for scrollback. </para>
          </listitem>
          <listitem>
            <para>Use <literal>screen</literal> with "<literal>^A H</literal>" (see <xref linkend="_the_screen_program"/>) to perform recording of console.</para>
          </listitem>
          <listitem>
            <para>Use <literal>vim</literal> with "<literal>:terminal</literal>" to enter the terminal mode.  Use "<literal>Ctrl-W N</literal>" to exit from terminal mode to normal mode.  Use "<literal>:w typescript</literal>" to write the buffer to a file.</para>
          </listitem>
          <listitem>
            <para>Use <literal>emacs</literal> with "<literal>M-x shell</literal>", "<literal>M-x eshell</literal>", or "<literal>M-x term</literal>" to enter recording console.  Use "<literal>C-x C-w</literal>" to write the buffer to a file.</para>
          </listitem>
        </itemizedlist>
      </section>
      <section id="_the_screen_program">
        <title>The screen program</title>
        <para><literal>screen</literal>(1) not only allows one terminal window to work with multiple processes, but also allows <emphasis role="strong">remote shell process to survive interrupted connections</emphasis>.  Here is a typical use scenario of <literal>screen</literal>(1).</para>
        <orderedlist>
          <listitem> <para> You login to a remote machine.  </para> </listitem>
          <listitem> <para> You start <literal>screen</literal> on a single console.  </para> </listitem>
          <listitem> <para> You execute multiple programs in <literal>screen</literal> windows created with <literal>^A c</literal> ("Control-A" followed by "c").  </para> </listitem>
          <listitem> <para> You switch among the multiple <literal>screen</literal> windows by <literal>^A n</literal> ("Control-A" followed by "n").  </para> </listitem>
          <listitem> <para> Suddenly you need to leave your terminal, but you don't want to lose your active work by keeping the connection.  </para> </listitem>
          <listitem>
            <para> You may <emphasis role="strong">detach</emphasis> the <literal>screen</literal> session by any methods.  </para>
            <itemizedlist>
              <listitem> <para> Brutally unplug your network connection </para> </listitem>
              <listitem> <para> Type <literal>^A d</literal> ("Control-A" followed by "d") and manually logging out from the remote connection </para> </listitem>
              <listitem> <para> Type <literal>^A DD</literal> ("Control-A" followed by "DD") to have <literal>screen</literal> detach and log you out </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem> <para> You log in again to the same remote machine (even from a different terminal).  </para> </listitem>
          <listitem> <para> You start <literal>screen</literal> as "<literal>screen -r</literal>".  </para> </listitem>
          <listitem> <para><literal>screen</literal> magically <emphasis role="strong">reattaches</emphasis> all previous <literal>screen</literal> windows with all actively running programs.  </para> </listitem>
        </orderedlist>
        <tip> <para>You can save connection fees with <literal>screen</literal> for metered network connections such as dial-up and packet ones, because you can leave a process active while disconnected, and then re-attach it later when you connect again.</para> </tip>
        <para>In a <literal>screen</literal> session, all keyboard inputs are sent to your current window except for the command keystroke.  All <literal>screen</literal> command keystrokes are entered by typing <literal>^A</literal> ("Control-A") plus a single key [plus any parameters].  Here are important ones to remember.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of key bindings for screen</title>
          <tgroup cols="2">
            <colspec colwidth="65pt" align="left"/>
            <colspec colwidth="271pt" align="left"/>
            <thead>
              <row>
                <entry> key binding </entry>
                <entry> meaning </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>^A ?</literal> </entry>
                <entry> show a help screen (display key bindings) </entry>
              </row>
              <row>
                <entry> <literal>^A c</literal> </entry>
                <entry> create a new window and switch to it </entry>
              </row>
              <row>
                <entry> <literal>^A n</literal> </entry>
                <entry> go to next window </entry>
              </row>
              <row>
                <entry> <literal>^A p</literal> </entry>
                <entry> go to previous window </entry>
              </row>
              <row>
                <entry> <literal>^A 0</literal> </entry>
                <entry> go to window number 0 </entry>
              </row>
              <row>
                <entry> <literal>^A 1</literal> </entry>
                <entry> go to window number 1 </entry>
              </row>
              <row>
                <entry> <literal>^A w</literal> </entry>
                <entry> show a list of windows </entry>
              </row>
              <row>
                <entry> <literal>^A a</literal> </entry>
                <entry> send a Ctrl-A to current window as keyboard input </entry>
              </row>
              <row>
                <entry> <literal>^A h</literal> </entry>
                <entry> write a hardcopy of current window to file </entry>
              </row>
              <row>
                <entry> <literal>^A H</literal> </entry>
                <entry> begin/end logging current window to file </entry>
              </row>
              <row>
                <entry> <literal>^A ^X</literal> </entry>
                <entry> lock the terminal (password protected) </entry>
              </row>
              <row>
                <entry> <literal>^A d</literal> </entry>
                <entry> detach screen session from the terminal </entry>
              </row>
              <row>
                <entry> <literal>^A DD</literal> </entry>
                <entry> detach screen session and log out </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>See <literal>screen</literal>(1) for details.</para>
        <para>See <literal>tmux</literal>(1) for functionalities of the alternative command.</para>
      </section>
      <section id="_navigating_around_directories">
        <title>Navigating around directories</title>
        <para>In <xref linkend="_customizing_bash"/>, 2 tips to allow quick navigation around directories are described: <literal>$CDPATH</literal> and <literal>mc</literal>. </para>
        <para>If you use fuzzy text filter program, you can do without typing the exact path.  For <literal>fzf</literal>, include following in <literal>~/.bashrc</literal>. </para>
        <screen>FZF_KEYBINDINGS_PATH=/usr/share/doc/fzf/examples/key-bindings.bash
if [ -f $FZF_KEYBINDINGS_PATH ]; then
  . $FZF_KEYBINDINGS_PATH
fi</screen>
        <para>For example:</para>
        <itemizedlist>
          <listitem> <para>You can jump to a very deep subdirectory with minimal efforts.  You first type "<literal>cd **</literal>" and press <literal>Tab</literal>.  Then you will be prompted with candidate paths.  Typing in partial path strings, e.g., <literal>s/d/b foo</literal>, will narrow down candidate paths.  You select the path to be used by <literal>cd</literal> with cursor and return keys.</para> </listitem>
          <listitem> <para>You can select a command from the command history more efficiently with minimal efforts.  You press <literal>Ctrl-R</literal> at the command prompt.  Then you will be prompted with candidate commands.  Typing in partial command strings, e.g., <literal>vim d</literal>, will narrow down candidates.  You select the one to be used with cursor and return keys.</para> </listitem>
        </itemizedlist>
      </section>
      <section id="_readline_wrapper">
        <title>Readline wrapper</title>
        <para>Some commands such as <literal>/usr/bin/dash</literal> which lacks command line history editing capability can add such functionality transparently by running under <literal>rlwrap</literal> or its equivalents.</para>
        <screen> $ rlwrap dash -i</screen>
        <para>This provides convenient platform to test subtle points for <literal>dash</literal> with friendly <literal>bash</literal>-like environment. </para>
      </section>
      <section id="_scanning_the_source_code_tree">
        <title>Scanning the source code tree</title>
        <para>The <literal>rg</literal>(1) command in the <literal>ripgrep</literal> package offers a faster alternative to the <literal>grep</literal>(1) command for scanning the source code tree for typical situation.  It takes advantage of modern multi-core CPUs and automatically applies reasonable filters to skip some files. </para>
      </section>
    </section>
    <section id="_customizing_vim">
      <title>Customizing vim</title>
      <para> After you learn basics of <literal>vim</literal>(1) through <xref linkend="_using_vim"/>, please read Bram Moolenaar's "<ulink url="https://www.moolenaar.net/habits.html">Seven habits of effective text editing (2000)</ulink>" to understand how <literal>vim</literal> should be used. </para>
      <section id="_customizing_vim_with internal_features">
        <title>Customizing vim with internal features</title>
        <para>The behavior of <literal>vim</literal> can be changed significantly by enabling its internal features through the <literal>Ex</literal>-mode commands such as "<literal>set ...</literal>" to set vim options.</para>
        <para>These <literal>Ex</literal>-mode commands can be included in user's vimrc file, traditional  "<literal>~/.vimrc</literal>" or git-friendly "<literal>~/.vim/vimrc</literal>".  Here is a very simple example
          <footnote> <para>More elaborate customization examples: "<ulink url="https://github.com/mhinz/vim-galore">Vim Galore</ulink>", "<ulink url="https://github.com/tpope/vim-sensible">sensible.vim</ulink>", ... </para> </footnote>:
        </para>
        <!--
          The following are meant to be edited by user to their taste of starting set values.
          See current https://github.com/osamuaoki/dot-vim and its rationale
          at https://osamuaoki.github.io/en/2023/03/05/vim-learn-7/
        -->
        <screen>""" Generic baseline Vim and Neovim configuration (~/.vimrc)
"""   - For NeoVim, use "nvim -u ~/.vimrc [filename]"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = ' '             " :h mapleader
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible                " :h 'cp -- sensible (n)vim mode
syntax on                       " :h :syn-on
filetype plugin indent on       " :h :filetype-overview
set encoding=utf-8              " :h 'enc (default: latin1) -- sensible encoding
""" current vim option value can be verified by :set encoding?
set backspace=indent,eol,start  " :h 'bs (default: nobs) -- sensible BS
set statusline=%&lt;%f%m%r%h%w%=%y[U+%04B]%2l/%2L=%P,%2c%V
set listchars=eol:¶,tab:⇄\ ,extends:↦,precedes:↤,nbsp:␣
set viminfo=!,'100,&lt;5000,s100,h " :h 'vi -- bigger copy buffer etc.
""" Pick "colorscheme" from blue darkblue default delek desert elflord evening
""" habamax industry koehler lunaperche morning murphy pablo peachpuff quiet ron
""" shine slate torte zellner
colorscheme industry
""" don't pick "colorscheme" as "default" which may kill SpellUnderline settings
set scrolloff=5                 " :h 'scr -- show 5 lines around cursor
set laststatus=2                " :h 'ls (default 1)  k
""" boolean options can be unset by prefixing "no"
set ignorecase                  " :h 'ic
set smartcase                   " :h 'scs
set autoindent                  " :h 'ai
set smartindent                 " :h 'si
set nowrap                      " :h 'wrap
"set list                        " :h 'list (default nolist)
set noerrorbells                " :h 'eb
set novisualbell                " :h 'vb
set t_vb=                       " :h 't_vb -- termcap visual bell
set spell                       " :h 'spell
set spelllang=en_us,cjk         " :h 'spl -- english spell, ignore CJK
set clipboard=unnamedplus       " :h 'cb -- cut/copy/paste with other app
set hidden                      " :h 'hid
set autowrite                   " :h 'aw
set timeoutlen=300              " :h 'tm</screen>
        <para>The keymap of <literal>vim</literal> can be changed in user's vimrc file.  E.g.:</para>
        <caution> <para>Don't try to change the default key bindings without very good reasons.</para> </caution>
        <!--
          These are taken from most popular settings
          "silent!" is needed to avoid error due to difference of Vim/Nvim
          I understand n and N remap may be avoided if scrolloff is big enough but I like it this way.
          How to cope with remapped <C-L>
            * Vim: <C-L> Clears and redraws the screen with "clear highlight"
            * Nvim <C-L> Clears and redraws the screen with "clear highlight" and "diff update"
                nnoremap <C-L> <Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>
            * Lazyvim uses: map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", ...)
          ==> Remap <ESC> like Lazyvim (not exacly as Nvim <C-L> for now)
          nnoremap <ESC> <CMD>noh<CR><ESC>
          inoremap <ESC> <CMD>noh<CR><ESC>

          ic/scs are set like LazyVim
          hidden/autowrite are matched with nvim defaults

          Clipboard is for console vim and nvim.
          We can use shared clipboard with y/d/p (not just primary)
        -->
        <screen>""" Popular mappings (imitating LazyVim etc.)
""" Window moves without using CTRL-W which is dangerous in INSERT mode
nnoremap &lt;C-H&gt; &lt;C-W&gt;h
nnoremap &lt;C-J&gt; &lt;C-W&gt;j
nnoremap &lt;C-K&gt; &lt;C-W&gt;k
silent! nnoremap &lt;C-L&gt; &lt;C-W&gt;l
""" Window resize
nnoremap &lt;C-LEFT&gt; &lt;CMD&gt;vertical resize -2&lt;CR&gt;
nnoremap &lt;C-DOWN&gt; &lt;CMD&gt;resize -2&lt;CR&gt;
nnoremap &lt;C-UP&gt; &lt;CMD&gt;resize +2&lt;CR&gt;
nnoremap &lt;C-RIGHT&gt; &lt;CMD&gt;vertical resize +2&lt;CR&gt;
""" Clear hlsearch with &lt;ESC&gt; (&lt;C-L&gt; is mapped as above)
nnoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt;
inoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt;
""" center after jump next
nnoremap n nzz
nnoremap N Nzz
""" fast "jk" to get out of INSERT mode (&lt;ESC&gt;)
inoremap  jk &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt;
""" fast "&lt;ESC&gt;&lt;ESC&gt;" to get out of TERM mode (CTRL-\ CTRL-N)
tnoremap &lt;ESC&gt;&lt;ESC&gt; &lt;C-\&gt;&lt;C-N&gt;
""" fast "jk" to get out of TERM mode (CTRL-\ CTRL-N)
tnoremap jk &lt;C-\&gt;&lt;C-N&gt;
""" previous/next trouble/quickfix item
nnoremap [q &lt;CMD&gt;cprevious&lt;CR&gt;
nnoremap ]q &lt;CMD&gt;cnext&lt;CR&gt;
""" buffers
nnoremap &lt;S-H&gt; &lt;CMD&gt;bprevious&lt;CR&gt;
nnoremap &lt;S-L&gt; &lt;CMD&gt;bnext&lt;CR&gt;
nnoremap [b &lt;CMD&gt;bprevious&lt;CR&gt;
nnoremap ]b &lt;CMD&gt;bnext&lt;CR&gt;
""" Add undo break-points
inoremap  , ,&lt;C-G&gt;u
inoremap  . .&lt;C-G&gt;u
inoremap  ; ;&lt;C-G&gt;u
""" save file
inoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt;
xnoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt;
nnoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt;
snoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt;
""" better indenting
vnoremap &lt; &lt;gv
vnoremap &gt; &gt;gv
""" terminal (Somehow under Linux, &lt;C-/&gt; becomes &lt;C-_&gt; in Vim)
nnoremap &lt;C-_&gt; &lt;CMD&gt;terminal&lt;CR&gt;
"nnoremap &lt;C-/&gt; &lt;CMD&gt;terminal&lt;CR&gt;
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if ! has('nvim')
""" Toggle paste mode with &lt;SPACE&gt;p for Vim (no need for Nvim)
set pastetoggle=&lt;leader&gt;p
""" nvim default mappings for Vim.  See :h default-mappings in nvim
""" copy to EOL (no delete) like D for d
noremap Y y$
""" sets a new undo point before deleting
inoremap &lt;C-U&gt; &lt;C-G&gt;u&lt;C-U&gt;
inoremap &lt;C-W&gt; &lt;C-G&gt;u&lt;C-W&gt;
""" &lt;C-L&gt; is re-purposed as above
""" execute the previous macro recorded with Q
nnoremap Q @@
""" repeat last substitute and *KEEP* flags
nnoremap &amp; :&amp;&amp;&lt;CR&gt;
""" search visual selected string for visual mode
xnoremap * y/\V&lt;C-R&gt;"&lt;CR&gt;
xnoremap # y?\V&lt;C-R&gt;"&lt;CR&gt;
endif</screen>
        <para>In order for the above keybindings to function properly, the terminal program needs to be configured to generate "ASCII DEL" for <literal>Backspace</literal>-key and "Escape sequence" for <literal>Delete</literal>-key.</para>
        <para>Other miscellaneous configuration can be changed in user's vimrc file.  E.g.:</para>
        <!--
          I excluded ripgrep for :grep since this is non-essential
            * https://www.vi-improved.org/recommendations/ to rg

          For TailingWhitespaces, regex idea is from
            * https://vim.fandom.com/wiki/Highlight_unwanted_spaces
          This tricky regex allows to avoid red while typing

          I focus on Vim8 or newer so no autocmd used for TailingWhitespaces
        -->
        <screen>""" Use faster 'rg' (ripgrep package) for :grep
if executable("rg")
  set grepprg=rg\ --vimgrep\ --smart-case
  set grepformat=%f:%l:%c:%m
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Retain last cursor position :h '"
augroup RetainLastCursorPosition
  autocmd!
  autocmd BufReadPost *
    \ if line("'\"") &gt; 0 &amp;&amp; line ("'\"") &lt;= line("$") |
    \   exe "normal! g'\"" |
    \ endif
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" Force to use underline for spell check results
augroup SpellUnderline
  autocmd!
  autocmd ColorScheme * highlight SpellBad term=Underline gui=Undercurl
  autocmd ColorScheme * highlight SpellCap term=Underline gui=Undercurl
  autocmd ColorScheme * highlight SpellLocal term=Underline gui=Undercurl
  autocmd ColorScheme * highlight SpellRare term=Underline gui=Undercurl
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" highlight tailing spaces except when typing as red (set after colorscheme)
highlight TailingWhitespaces ctermbg=red guibg=red
""" \s\+     1 or more whitespace character: &lt;Space&gt; and &lt;Tab&gt;
""" \%#\@&lt;!  Matches with zero width if the cursor position does NOT match.
match TailingWhitespaces /\s\+\%#\@&lt;!$/</screen>
      </section>
      <section id="_customizing_vim_with_external_packages">
        <title>Customizing vim with external packages</title>
        <para>Interesting external plugin packages can be found:</para>
        <itemizedlist>
          <listitem> <para> <ulink url="https://www.vim.org/"> Vim - the ubiquitous text editor </ulink> -- The official upstream site of Vim and vim scripts </para> </listitem>
          <listitem> <para> <ulink url="https://vimawesome.com/"> VimAwsome </ulink> -- The listing of Vim plugins </para> </listitem>
          <listitem> <para> <ulink url="https://packages.debian.org/unstable/vim-scripts">vim-scripts</ulink> -- Debian package: a collection of vim scripts </para> </listitem>
        </itemizedlist>
        <para>Plugin packages in the <ulink url="https://packages.debian.org/unstable/vim-scripts">vim-scripts</ulink> package can be enabled using user's vimrc file.  E.g.:</para>
        <!--
          I admit I don't use these now.  But I need to keep these as an example.
          I know "set pastetoggle" is out of place but I wanted "leader" here.
          I don't want to discuss disabled secure-modeline feature in Debian's Vim package.
        -->
        <screen>packadd! secure-modelines
packadd! winmanager
" IDE-like UI for files and buffers with &lt;space&gt;w
nnoremap &lt;leader&gt;w         :WMToggle&lt;CR&gt;</screen>
        <para>The new native Vim package system works nicely with "<literal>git</literal>" and "<literal>git submodule</literal>".  One such example configuration can be found at <ulink url="https://github.com/osamuaoki/dot-vim/tree/old">my git repository: dot-vim</ulink>.  This does essentially:</para>
        <itemizedlist>
          <listitem> <para>By using "<literal>git</literal>" and "<literal>git submodule</literal>", latest external packages, such as "<literal><emphasis>name</emphasis></literal>", are placed into <literal>~/.vim/pack/*/opt/<emphasis>name</emphasis></literal> and similar.</para> </listitem>
          <listitem> <para>By adding <literal>:packadd! <emphasis>name</emphasis></literal> line to user's vimrc file, these packages are placed on <literal>runtimepath</literal>.</para> </listitem>
          <listitem> <para>Vim loads these packages on <literal>runtimepath</literal> during its initialization.</para> </listitem>
          <listitem> <para>At the end of its initialization, tags for the installed documents are updated with "<literal>helptags ALL</literal>".</para> </listitem>
        </itemizedlist>
        <para>For more, please start <literal>vim</literal> with "<literal>vim --startuptime vimstart.log</literal>" to check actual execution sequence and time spent for each step.</para>
        <para>It is quite confusing to see too many ways<footnote><para> <ulink url="https://packages.debian.org/unstable/vim-pathogen">vim-pathogen</ulink> was popular.  </para></footnote> to manage and load these external packages to <literal>vim</literal>.  Checking the original information is the best cure.</para>
        <table>
          <title>Information on the initialization of <literal>vim</literal></title>
          <tgroup cols="2">
            <colspec colwidth="100pt" align="left"/>
            <colspec colwidth="500pt" align="left"/>
            <thead>
              <row>
                <entry> key strokes </entry>
                <entry> information </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>:help package</literal> </entry>
                <entry> explanation on the vim package mechanism </entry>
              </row>
              <row>
                <entry> <literal>:help runtimepath</literal> </entry>
                <entry> explanation on the <literal>runtimepath</literal> mechanism </entry>
              </row>
              <row>
                <entry> <literal>:version</literal> </entry>
                <entry> internal states including candidates for the vimrc file </entry>
              </row>
              <row>
                <entry> <literal>:echo $VIM</literal> </entry>
                <entry> the environment variable "<literal>$VIM</literal>" used to locate the vimrc file</entry>
              </row>
              <row>
                <entry> <literal>:set runtimepath?</literal> </entry>
                <entry> list of directories which will be searched for all runtime support files </entry>
              </row>
              <row>
                <entry> <literal>:echo $VIMRUNTIME</literal> </entry>
                <entry> the environment variable "<literal>$VIMRUNTIME</literal>" used to locate various system provided runtime support files </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
    </section>
    <section id="_data_recording_and_presentation">
      <title>Data recording and presentation</title>
      <section id="_the_log_daemon">
        <title>The log daemon</title>
        <para>Many traditional programs record their activities in the text file format under the "<literal>/var/log/</literal>" directory.</para>
        <para><literal>logrotate</literal>(8) is used to simplify the administration of log files on a system which generates a lot of log files.</para>
        <para>Many new programs record their activities in the binary file format using <literal>systemd-journald</literal>(8) Journal service under the "<literal>/var/log/journal</literal>" directory.</para>
        <para>You can log data to the <literal>systemd-journald</literal>(8) Journal from a shell script by using the <literal>systemd-cat</literal>(1) command.</para>
        <para>See <xref linkend="_the_system_message"/> and <xref linkend="_the_kernel_message"/>.</para>
      </section>
      <section id="_log_analyzer">
        <title>Log analyzer</title>
        <para>Here are notable log analyzers ("<literal>~Gsecurity::log-analyzer</literal>" in <literal>aptitude</literal>(8)).</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of system log analyzers</title>
          <tgroup cols="4">
            <colspec colwidth="92pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="325pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>logwatch</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> log analyzer with nice output written in Perl </entry>
              </row>
              <row>
                <entry> <literal>fail2ban</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> ban IPs that cause multiple authentication errors </entry>
              </row>
              <row>
                <entry> <literal>analog</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> web server log analyzer </entry>
              </row>
              <row>
                <entry> <literal>awstats</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> powerful and featureful web server log analyzer </entry>
              </row>
              <row>
                <entry> <literal>sarg</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> squid analysis report generator </entry>
              </row>
              <row>
                <entry> <literal>pflogsumm</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Postfix log entry summarizer </entry>
              </row>
              <row>
                <entry> <literal>fwlogwatch</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> firewall log analyzer </entry>
              </row>
              <row>
                <entry> <literal>squidview</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> monitor and analyze squid access.log files </entry>
              </row>
              <row>
                <entry> <literal>swatch</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> log file viewer with regexp matching, highlighting, and hooks </entry>
              </row>
              <row>
                <entry> <literal>crm114</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Controllable Regex Mutilator and Spam Filter (CRM114) </entry>
              </row>
              <row>
                <entry> <literal>icmpinfo</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> interpret ICMP messages </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <note> <para><ulink url="https://en.wikipedia.org/wiki/CRM114_(program)">CRM114</ulink> provides language infrastructure to write <emphasis role="strong">fuzzy</emphasis> filters with the <ulink url="https://github.com/laurikari/tre/">TRE regex library</ulink>.  Its popular use is spam mail filter but it can be used as log analyzer.</para> </note>
      </section>
      <section id="_customized_display_of_text_data">
        <title>Customized display of text data</title>
        <para>Although pager tools such as <literal>more</literal>(1) and <literal>less</literal>(1) (see <xref linkend="_the_pager"/>) and custom tools for highlighting and formatting (see <xref linkend="_highlighting_and_formatting_plain_text_data"/>) can display text data nicely, general purpose editors (see <xref linkend="_the_text_editor"/>) are most versatile and customizable.</para>
        <tip> <para>For <literal>vim</literal>(1) and its pager mode alias <literal>view</literal>(1), "<literal>:set hls</literal>" enables highlighted search.</para> </tip>
      </section>
      <section id="_customized_display_of_time_and_date">
        <title>Customized display of time and date</title>
        <para>The default display format of time and date by the "<literal>ls -l</literal>" command depends on the <emphasis role="strong">locale</emphasis> (see <xref linkend="_timestamps"/> for value).  The "<literal>$LANG</literal>" variable is referred first and it can be overridden by the "<literal>$LC_TIME</literal>" or "<literal>$LC_ALL</literal>" exported environment variables.</para>
        <para>The actual default display format for each locale depends on the version of  the standard C library (the <literal>libc6</literal> package) used.  I.e., different releases of Debian had different defaults.  For iso-formats, see <ulink url="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</ulink>.</para>
        <para>If you really wish to customize this display format of time and date beyond the <emphasis role="strong">locale</emphasis>, you should set the <emphasis role="strong">time style value</emphasis> by the "<literal>--time-style</literal>" argument or by the "<literal>$TIME_STYLE</literal>" value (see <literal>ls</literal>(1), <literal>date</literal>(1), "<literal>info coreutils 'ls invocation'</literal>").</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>Display examples of time and date for the "<literal>ls -l</literal>" command with the <emphasis role="strong">time style value</emphasis></title>
          <tgroup cols="3">
            <colspec colwidth="97pt" align="left"/>
            <colspec colwidth="114pt" align="left"/>
            <colspec colwidth="206pt" align="left"/>
            <thead>
              <row>
                <entry> time style value  </entry>
                <entry> locale </entry>
                <entry> display of time and date </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>iso</literal> </entry>
                <entry> any </entry>
                <entry> <literal>01-19 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>long-iso</literal> </entry>
                <entry> any </entry>
                <entry> <literal>2009-01-19 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>full-iso</literal> </entry>
                <entry> any </entry>
                <entry> <literal>2009-01-19 00:15:16.000000000 +0900</literal> </entry>
              </row>
              <row>
                <entry> <literal>locale</literal> </entry>
                <entry> <literal>C</literal> </entry>
                <entry> <literal>Jan 19 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>locale</literal> </entry>
                <entry> <literal>en_US.UTF-8</literal> </entry>
                <entry> <literal>Jan 19 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>locale</literal> </entry>
                <entry> <literal>es_ES.UTF-8</literal> </entry>
                <entry> <literal>ene 19 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>+%d.%m.%y %H:%M</literal> </entry>
                <entry> any </entry>
                <entry> <literal>19.01.09 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>+%d.%b.%y %H:%M</literal> </entry>
                <entry> <literal>C</literal> or <literal>en_US.UTF-8</literal> </entry>
                <entry> <literal>19.Jan.09 00:15</literal> </entry>
              </row>
              <row>
                <entry> <literal>+%d.%b.%y %H:%M</literal> </entry>
                <entry> <literal>es_ES.UTF-8</literal> </entry>
                <entry> <literal>19.ene.09 00:15</literal> </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <tip>
          <para>You can eliminate typing long option on commandline using command alias (see <xref linkend="_command_alias"/>):</para>
          <screen>alias ls='ls --time-style=+%d.%m.%y %H:%M'</screen>
        </tip>
      </section>
      <section id="_colorized_shell_echo">
        <title>Colorized shell echo</title>
        <para>Shell echo to most modern terminals can be colorized using <ulink url="https://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape code</ulink> (see "<literal>/usr/share/doc/xterm/ctlseqs.txt.gz</literal>").</para>
        <para>For example, try the following</para>
        <screen>$ RED=$(printf "\x1b[31m")
$ NORMAL=$(printf "\x1b[0m")
$ REVERSE=$(printf "\x1b[7m")
$ echo "${RED}RED-TEXT${NORMAL} ${REVERSE}REVERSE-TEXT${NORMAL}"</screen>
      </section>
      <section id="_colorized_commands">
        <title>Colorized commands</title>
        <para>Colorized commands are handy for inspecting their output in the interactive environment.  I include the following in my "<literal>~/.bashrc</literal>".</para>
        <screen>if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=always'
    alias ll='ls --color=always -l'
    alias la='ls --color=always -A'
    alias less='less -R'
    alias ls='ls --color=always'
    alias grep='grep --color=always'
    alias egrep='egrep --color=always'
    alias fgrep='fgrep --color=always'
    alias zgrep='zgrep --color=always'
else
    alias ll='ls -l'
    alias la='ls -A'
fi</screen>
        <para>The use of alias limits color effects to the interactive command usage.  It has advantage over exporting environment variable "<literal>export GREP_OPTIONS='--color=auto'</literal>" since color can be seen under pager programs such as <literal>less</literal>(1).  If you wish to suppress color when piping to other programs, use "<literal>--color=auto</literal>" instead in the above example for "<literal>~/.bashrc</literal>".</para>
        <tip> <para>You can turn off these colorizing aliases in the interactive environment by invoking shell with "<literal>TERM=dumb bash</literal>".</para> </tip>
      </section>
      <section id="_recording_the_editor_activities_for_complex_repeats">
        <title>Recording the editor activities for complex repeats</title>
        <para>You can record the editor activities for complex repeats.</para>
        <para>For <ulink url="https://en.wikipedia.org/wiki/Vim_(text_editor)">Vim</ulink>, as follows.</para>
        <itemizedlist>
          <listitem> <para> "<literal>qa</literal>": start recording typed characters into named register "<literal>a</literal>".  </para> </listitem>
          <listitem> <para> … editor activities </para> </listitem>
          <listitem> <para> "<literal>q</literal>": end recording typed characters.  </para> </listitem>
          <listitem> <para> "<literal>@a</literal>": execute the contents of register "<literal>a</literal>".  </para> </listitem>
        </itemizedlist>
        <para>For <ulink url="https://en.wikipedia.org/wiki/Emacs">Emacs</ulink>, as follows.</para>
        <itemizedlist>
          <listitem> <para> "<literal>C-x (</literal>": start defining a keyboard macro.  </para> </listitem>
          <listitem> <para> … editor activities </para> </listitem>
          <listitem> <para> "<literal>C-x )</literal>": end defining a keyboard macro.  </para> </listitem>
          <listitem> <para> "<literal>C-x e</literal>": execute a keyboard macro.  </para> </listitem>
        </itemizedlist>
      </section>
      <section id="_recording_the_graphic_image_of_an_x_application">
        <title>Recording the graphics image of an X application</title>
        <para>There are few ways to record the graphics image of an X application, including an <literal>xterm</literal> display.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of graphics image manipulation tools</title>
          <tgroup cols="4">
            <colspec colwidth="86pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="65pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> screen </entry>
                <entry> command </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>gnome-screenshot</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Wayland </entry>
                <entry> screenshot application for GNOME </entry>
              </row>
              <row>
                <entry> <literal>flameshot</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Wayland </entry>
                <entry> screenshot application on steroid </entry>
              </row>
              <row>
                <entry> <literal>gimp</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Wayland + X </entry>
                <entry> screenshot in GUI menu </entry>
              </row>
              <row>
                <entry> <literal>x11-apps</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> X </entry>
                <entry> <literal>xwd</literal>(1) </entry>
        </row>
              <row>
                <entry> <literal>imagemagick</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> X </entry>
                <entry> <literal>import</literal>(1) </entry>
              </row>
              <row>
                <entry> <literal>scrot</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> X </entry>
                <entry> <literal>scrot</literal>(1) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_recording_changes_in_configuration_files">
        <title>Recording changes in configuration files</title>
        <para>There are specialized tools to record changes in configuration files with help of DVCS and to make system snapshots on <ulink url="https://en.wikipedia.org/wiki/Btrfs">Btrfs</ulink>.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of packages which can record configuration history</title>
          <tgroup cols="4">
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="526pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>etckeeper</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> store configuration files and their metadata with <ulink url="https://en.wikipedia.org/wiki/Git_(software)">Git</ulink> (default), <ulink url="https://en.wikipedia.org/wiki/Mercurial_(software)">Mercurial</ulink>, or <ulink url="https://en.wikipedia.org/wiki/GNU_Bazaar">GNU Bazaar</ulink> </entry>
              </row>
              <row>
                <entry> <literal>timeshift</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> system restore utility using rsync or BTRFS snapshots </entry>
              </row>
              <row>
                <entry> <literal>snapper</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Linux filesystem snapshot management tool </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>You may also think about local script <xref linkend="_backup_tips"/> approach.</para>
      </section>
    </section>
    <section id="_monitoring_controlling_and_starting_program_activities">
      <title>Monitoring, controlling, and starting program activities</title>
      <para>Program activities can be monitored and controlled using specialized tools.</para>
      <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
        <title>List of tools for monitoring and controlling program activities</title>
        <tgroup cols="4">
          <colspec colwidth="65pt" align="left"/>
          <colspec colwidth="76pt" align="left"/>
          <colspec colwidth="70pt" align="left"/>
          <colspec colwidth="488pt" align="left"/>
          <thead>
            <row>
              <entry> package </entry>
              <entry> popcon </entry>
              <entry> size </entry>
              <entry> description </entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry> <literal>coreutils</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry><literal>nice</literal>(1): run a program with modified scheduling priority </entry>
            </row>
            <row>
              <entry> <literal>bsdutils</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry><literal>renice</literal>(1): modify the scheduling priority of a running process </entry>
            </row>
            <row>
              <entry> <literal>procps</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> "<literal>/proc</literal>" filesystem utilities: <literal>ps</literal>(1), <literal>top</literal>(1), <literal>kill</literal>(1), <literal>watch</literal>(1), … </entry>
            </row>
            <row>
              <entry> <literal>psmisc</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> "<literal>/proc</literal>" filesystem utilities: <literal>killall</literal>(1), <literal>fuser</literal>(1), <literal>peekfd</literal>(1), <literal>pstree</literal>(1) </entry>
            </row>
            <row>
              <entry> <literal>time</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>time</literal>(1): run a program to report system resource usages with respect to time </entry>
            </row>
            <row>
              <entry> <literal>sysstat</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>sar</literal>(1), <literal>iostat</literal>(1), <literal>mpstat</literal>(1), …: system performance tools for Linux </entry>
            </row>
            <row>
              <entry> <literal>isag</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> Interactive System Activity Grapher for sysstat </entry>
            </row>
            <row>
              <entry> <literal>lsof</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>lsof</literal>(8): list files opened by a running process using "<literal>-p</literal>" option </entry>
            </row>
            <row>
              <entry> <literal>strace</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>strace</literal>(1): trace system calls and signals </entry>
            </row>
            <row>
              <entry> <literal>ltrace</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>ltrace</literal>(1): trace library calls </entry>
            </row>
            <row>
              <entry> <literal>xtrace</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>xtrace</literal>(1): trace communication between X11 client and server </entry>
            </row>
            <row>
              <entry> <literal>powertop</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>powertop</literal>(1): information about system power use </entry>
            </row>
            <row>
              <entry> <literal>cron</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> run processes according to a schedule in background from <literal>cron</literal>(8) daemon </entry>
            </row>
            <row>
              <entry> <literal>anacron</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> cron-like command scheduler for systems that don't run 24 hours a day </entry>
            </row>
            <row>
              <entry> <literal>at</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> <literal>at</literal>(1) or <literal>batch</literal>(1): run a job at a specified time or below certain load level </entry>
            </row>
          </tbody>
        </tgroup>
      </table>
      <tip> <para>The <literal>procps</literal> packages provide very basics of monitoring, controlling, and starting program activities.  You should learn all of them.</para> </tip>
      <section id="_timing_a_process">
        <title>Timing a process</title>
        <para>Display time used by the process invoked by the command.</para>
        <screen># time some_command &gt;/dev/null
real    0m0.035s       # time on wall clock (elapsed real time)
user    0m0.000s       # time in user mode
sys     0m0.020s       # time in kernel mode</screen>
      </section>
      <section id="_the_scheduling_priority">
        <title>The scheduling priority</title>
        <para>A nice value is used to control the scheduling priority for the process.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of nice values for the scheduling priority</title>
          <tgroup cols="2">
            <colspec colwidth="59pt" align="left"/>
            <colspec colwidth="260pt" align="left"/>
            <thead>
              <row>
                <entry> nice value </entry>
                <entry> scheduling priority </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> 19 </entry>
                <entry> lowest priority process (nice) </entry>
              </row>
              <row>
                <entry> 0 </entry>
                <entry> very high priority process for user </entry>
              </row>
              <row>
                <entry> -20 </entry>
                <entry> very high priority process for root (not-nice) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <screen># nice  -19 top                                      # very nice
# nice --20 wodim -v -eject speed=2 dev=0,0 disk.img # very fast</screen>
        <para>Sometimes an extreme nice value does more harm than good to the system.  Use this command carefully.</para>
      </section>
      <section id="_the_ps_command">
        <title>The ps command</title>
        <para>The <literal>ps</literal>(1) command on a Debian system support both BSD and SystemV features and helps to identify the process activity statically.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of ps command styles</title>
          <tgroup cols="3">
            <colspec colwidth="48pt" align="left"/>
            <colspec colwidth="86pt" align="left"/>
            <colspec colwidth="97pt" align="left"/>
            <thead>
              <row>
                <entry> style </entry>
                <entry> typical command </entry>
                <entry> feature </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> BSD </entry>
                <entry> <literal>ps aux</literal> </entry>
                <entry> display %CPU %MEM </entry>
              </row>
              <row>
                <entry> System V </entry>
                <entry> <literal>ps -efH</literal> </entry>
                <entry> display PPID </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>For the zombie (defunct) children process, you can kill them by the parent process ID identified in the "<literal>PPID</literal>" field.</para>
        <para>The <literal>pstree</literal>(1) command display a tree of processes.</para>
      </section>
      <section id="_the_top_command">
        <title>The top command</title>
        <para><literal>top</literal>(1) on the Debian system has rich features and helps to identify what process is acting funny dynamically.</para>
        <para>It is an interactive full screen program.  You can get its usage help press by pressing the "h"-key and terminate it by pressing the "q"-key.</para>
      </section>
      <section id="_listing_files_opened_by_a_process">
        <title>Listing files opened by a process</title>
        <para>You can list all files opened by a process with a process ID (PID), e.g. 1, by the following.</para>
        <screen>$ sudo lsof -p 1</screen>
        <para>PID=1 is usually the <literal>init</literal> program.</para>
      </section>
      <section id="_tracing_program_activities">
        <title>Tracing program activities</title>
        <para>You can trace program activity with <literal>strace</literal>(1), <literal>ltrace</literal>(1), or <literal>xtrace</literal>(1) for system calls and signals, library calls, or communication between X11 client and server.</para>
        <para>You can trace system calls of the <literal>ls</literal> command as the following.</para>
        <screen>$ sudo strace ls</screen>
      <tip> <para> Use <emphasis role="strong">strace-graph</emphasis> script found in <emphasis role="strong">/usr/share/doc/strace/examples/</emphasis> to make a nice tree view </para> </tip>
      </section>
      <section id="_identification_of_processes_using_files_or_sockets">
        <title>Identification of processes using files or sockets</title>
        <para>You can also identify processes using files by <literal>fuser</literal>(1), e.g. for "<literal>/var/log/mail.log</literal>" by the following.</para>
        <screen>$ sudo fuser -v /var/log/mail.log
                     USER        PID ACCESS COMMAND
/var/log/mail.log:   root       2946 F.... rsyslogd</screen>
        <para>You see that file "<literal>/var/log/mail.log</literal>" is open for writing by the <literal>rsyslogd</literal>(8) command.</para>
        <para>You can also identify processes using sockets by <literal>fuser</literal>(1), e.g. for "<literal>smtp/tcp</literal>" by the following.</para>
        <screen>$ sudo fuser -v smtp/tcp
                     USER        PID ACCESS COMMAND
smtp/tcp:            Debian-exim   3379 F.... exim4</screen>
        <para>Now you know your system runs <literal>exim4</literal>(8) to handle <ulink url="https://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP</ulink> connections to <ulink url="https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol">SMTP</ulink> port (25).</para>
      </section>
      <section id="_repeating_a_command_with_a_constant_interval">
        <title>Repeating a command with a constant interval</title>
        <para><literal>watch</literal>(1) executes a program repeatedly with a constant interval while showing its output in fullscreen.</para>
        <screen>$ watch w</screen>
        <para>This displays who is logged on to the system updated every 2 seconds.</para>
      </section>
      <section id="_repeating_a_command_looping_over_files">
        <title>Repeating a command looping over files</title>
        <para>There are several ways to repeat a command looping over files matching some condition, e.g. matching glob pattern "<literal>*.ext</literal>".</para>
        <itemizedlist>
          <listitem> <para> Shell for-loop method (see <xref linkend="_shell_loops"/>): </para> </listitem>
        </itemizedlist>
        <screen>for x in *.ext; do if [ -f "$x"]; then command "$x" ; fi; done</screen>
        <itemizedlist>
          <listitem> <para><literal>find</literal>(1) and <literal>xargs</literal>(1) combination: </para> </listitem>
        </itemizedlist>
        <screen>find . -type f -maxdepth 1 -name '*.ext' -print0 | xargs -0 -n 1 command</screen>
        <itemizedlist>
          <listitem> <para><literal>find</literal>(1) with "<literal>-exec</literal>" option with a command: </para> </listitem>
        </itemizedlist>
        <screen>find . -type f -maxdepth 1 -name '*.ext' -exec command '{}' \;</screen>
        <itemizedlist>
          <listitem> <para><literal>find</literal>(1) with "<literal>-exec</literal>" option with a short shell script: </para> </listitem>
        </itemizedlist>
        <screen>find . -type f -maxdepth 1 -name '*.ext' -exec sh -c "command '{}' &amp;&amp; echo 'successful'" \;</screen>
        <para>The above examples are written to ensure proper handling of funny file names such as ones containing spaces.  See <xref linkend="_idioms_for_the_selection_of_files"/> for more advance uses of <literal>find</literal>(1).</para>
      </section>
      <section id="_starting_a_program_from_gui">
        <title>Starting a program from GUI</title>
        <para>For the <ulink url="https://en.wikipedia.org/wiki/Command-line_interface">command-line interface (CLI)</ulink>, the first program with the matching name found in the directories specified in the <literal>$PATH</literal> environment variable is executed. See <xref linkend="_the_literal_path_literal_variable"/>.</para>
        <para>For the <ulink url="https://en.wikipedia.org/wiki/Graphical_user_interface">graphical user interface (GUI)</ulink> compliant to the <ulink url="https://www.freedesktop.org/wiki/">freedesktop.org</ulink> standards, the <literal>*.desktop</literal> files in the <literal>/usr/share/applications/</literal> directory provide necessary attributes for the GUI menu display of each program.  Each package which is compliant to Freedesktop.org's xdg menu system installs its menu data provided by "*.desktop" under "/usr/share/applications/". Modern desktop environments which are compliant to Freedesktop.org standard use these data to generate their menu using the xdg-utils package. See "/usr/share/doc/xdg-utils/README". </para>
        <para>For example, the <literal>chromium.desktop</literal> file defines attributes for the "Chromium Web Browser" such as "Name" for the program name, "Exec" for the program execution path and arguments, "Icon" for the icon used, etc. (see the <ulink url="https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html">Desktop Entry Specification</ulink>) as follows:</para>
        <screen>[Desktop Entry]
Version=1.0
Name=Chromium Web Browser
GenericName=Web Browser
Comment=Access the Internet
Comment[fr]=Explorer le Web
Exec=/usr/bin/chromium %U
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=chromium
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https;
StartupWMClass=Chromium
StartupNotify=true</screen>
        <para>This is an oversimplified description. The <literal>*.desktop</literal> files are scanned as follows.</para>
        <para>The desktop environment sets <literal>$XDG_DATA_HOME</literal> and <literal>$XDG_DATA_DIR</literal> environment variables.  For example, under the GNOME 3:</para>
        <itemizedlist>
          <listitem> <para><literal>$XDG_DATA_HOME</literal> is unset. (The default value of <literal>$HOME/.local/share</literal> is used.) </para> </listitem>
          <listitem> <para><literal>$XDG_DATA_DIRS</literal> is set to <literal>/usr/share/gnome:/usr/local/share/:/usr/share/</literal>.  </para> </listitem>
        </itemizedlist>
        <para>So the base directories (see <ulink url="https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory Specification</ulink>) and the <literal>applications</literal> directories are as follows.</para>
        <itemizedlist>
          <listitem> <para><literal>$HOME/.local/share/</literal> → <literal>$HOME/.local/share/applications/</literal> </para> </listitem>
          <listitem> <para><literal>/usr/share/gnome/</literal> → <literal>/usr/share/gnome/applications/</literal> </para> </listitem>
          <listitem> <para><literal>/usr/local/share/</literal> → <literal>/usr/local/share/applications/</literal> </para> </listitem>
          <listitem> <para><literal>/usr/share/</literal> → <literal>/usr/share/applications/</literal> </para> </listitem>
        </itemizedlist>
        <para>The <literal>*.desktop</literal> files are scanned in these <literal>applications</literal> directories in this order.</para>
        <tip> <para>A user custom GUI menu entry can be created by adding a <literal>*.desktop</literal> file in the <literal>$HOME/.local/share/applications/</literal> directory.</para> </tip>
        <tip> <para>The "<literal>Exec=...</literal>" line isn't parsed by the shell.  Use the <literal>env</literal>(1) command if environment variables need to be set.</para> </tip>
        <tip> <para>Similarly, if a <literal>*.desktop</literal> file is created in the <literal>autostart</literal> directory under these base directories, the specified program in the <literal>*.desktop</literal> file is executed automatically when the desktop environment is started. See <ulink url="https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html">Desktop Application Autostart Specification</ulink>.</para> </tip>
        <tip> <para>Similarly, if a <literal>*.desktop</literal> file is created in the <literal>$HOME/Desktop</literal> directory and the Desktop environment is configured to support the desktop icon launcher feature, the specified program in it is executed upon clicking the icon. Please note that the actual name of the <literal>$HOME/Desktop</literal> directory is locale dependent.  See <literal>xdg-user-dirs-update</literal>(1).</para> </tip>
      </section>
      <section id="_customizing_program_to_be_started">
        <title>Customizing program to be started</title>
        <para>Some programs start another program automatically.  Here are check points for customizing this process.</para>
        <itemizedlist>
          <listitem>
            <para> Application configuration menu: </para>
            <itemizedlist>
              <listitem>
                <para> GNOME3 desktop: "Settings" → "System" → "Details" → "Default Applications" </para>
              </listitem>
              <listitem>
                <para> KDE desktop: "K" → "Control Center" → "KDE Components" → "Component Chooser" </para>
              </listitem>
              <listitem>
                <para> Iceweasel browser: "Edit" → "Preferences" → "Applications" </para>
              </listitem>
              <listitem>
                <para><literal>mc</literal>(1): "<literal>/etc/mc/mc.ext</literal>" </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Environment variables such as "<literal>$BROWSER</literal>", "<literal>$EDITOR</literal>", "<literal>$VISUAL</literal>", and "<literal>$PAGER</literal>" (see <literal>environ</literal>(7)) </para>
          </listitem>
          <listitem>
            <para> The <literal>update-alternatives</literal>(1) system for programs such as "<literal>editor</literal>", "<literal>view</literal>", "<literal>x-www-browser</literal>", "<literal>gnome-www-browser</literal>", and "<literal>www-browser</literal>" (see <xref linkend="_setting_a_default_text_editor"/>) </para>
          </listitem>
          <listitem>
            <para> the "<literal>~/.mailcap</literal>" and "<literal>/etc/mailcap</literal>" file contents which associate <ulink url="https://en.wikipedia.org/wiki/MIME">MIME</ulink> type with program (see <literal>mailcap</literal>(5)) </para>
          </listitem>
          <listitem>
            <para> The "<literal>~/.mime.types</literal>" and "<literal>/etc/mime.types</literal>" file contents which associate file name extension with <ulink url="https://en.wikipedia.org/wiki/MIME">MIME</ulink> type (see <literal>run-mailcap</literal>(1)) </para>
          </listitem>
        </itemizedlist>
        <tip> <para><literal>update-mime</literal>(8) updates the "<literal>/etc/mailcap</literal>" file using "<literal>/etc/mailcap.order</literal>" file (see <literal>mailcap.order</literal>(5)).</para> </tip>
        <tip> <para>The <literal>debianutils</literal> package provides <literal>sensible-browser</literal>(1), <literal>sensible-editor</literal>(1), and <literal>sensible-pager</literal>(1) which make sensible decisions on which editor, pager, and web browser to call, respectively.  I recommend you to read these shell scripts.</para> </tip>
        <tip> <para>In order to run a console application such as <literal>mutt</literal> under GUI as your preferred application, you should create an GUI application as following and set "<literal>/usr/local/bin/mutt-term</literal>" as your preferred application to be started as described.</para>
        <screen># cat /usr/local/bin/mutt-term &lt;&lt;EOF
#!/bin/sh
gnome-terminal -e "mutt \$@"
EOF
# chmod 755 /usr/local/bin/mutt-term</screen>
        </tip>
      </section >
      <section id="_killing_a_process">
        <title>Killing a process</title>
        <para>Use <literal>kill</literal>(1) to kill (or send a signal to) a process by the process ID.</para>
        <para>Use <literal>killall</literal>(1) or <literal>pkill</literal>(1) to do the same by the process command name and other attributes.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of frequently used signals for kill command</title>
          <tgroup cols="4">
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="65pt" align="left"/>
            <colspec colwidth="81pt" align="left"/>
            <colspec colwidth="81pt" align="left"/>
            <thead>
              <row>
                <entry> signal value </entry>
                <entry> signal name </entry>
                <entry> action </entry>
                <entry> note </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> 0 </entry>
                <entry> --- </entry>
                <entry> no signal is sent (see <literal>kill</literal>(2)) </entry>
                <entry> check if process is running </entry>
              </row>
              <row>
                <entry> 1 </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/SIGHUP">SIGHUP</ulink> </entry>
                <entry> terminate the process </entry>
                <entry> disconnected terminal (signal hang up) </entry>
              </row>
              <row>
                <entry> 2 </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Signals_intelligence">SIGINT</ulink> </entry>
                <entry> terminate the process </entry>
                <entry> interrupt from keyboard (<literal>CTRL-C</literal>) </entry>
              </row>
              <row>
                <entry> 3 </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGQUIT">SIGQUIT</ulink> </entry>
                <entry> terminate the process and <ulink url="https://en.wikipedia.org/wiki/Core_dump">dump core</ulink> </entry>
                <entry> quit from keyboard (<literal>CTRL-\</literal>) </entry>
              </row>
              <row>
                <entry> 9 </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL">SIGKILL</ulink> </entry>
                <entry> terminate the process </entry>
                <entry> unblockable kill signal </entry>
              </row>
              <row>
                <entry> 15 </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM">SIGTERM</ulink> </entry>
                <entry> terminate the process </entry>
                <entry> blockable termination signal </entry>
              </row>
<!--
              <row>
                <entry> 18 </entry>
                <entry> SIGCONT </entry>
                <entry> continue the process if stopped </entry>
                <entry> </entry>
              </row>
              <row>
                <entry> 19 </entry>
                <entry> SIGSTOP </entry>
                <entry> stop the process </entry>
                <entry> </entry>
              </row>
-->
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_scheduling_tasks_once">
        <title>Scheduling tasks once</title>
        <para>Run the <literal>at</literal>(1) command to schedule a one-time job by the following.</para>
        <screen>$ echo 'command -args'| at 3:40 monday</screen>
      </section>
      <section id="_scheduling_tasks_regularly">
        <title>Scheduling tasks regularly</title>
        <para>Use <literal>cron</literal>(8) to schedule tasks regularly.  See <literal>crontab</literal>(1) and <literal>crontab</literal>(5).</para>
        <para>You can schedule to run processes as a normal user, e.g. <literal>foo</literal> by creating a <literal>crontab</literal>(5) file as "<literal>/var/spool/cron/crontabs/foo</literal>" with "<literal>crontab -e</literal>" command.</para>
        <para>Here is an example of a <literal>crontab</literal>(5) file.</para>
        <screen># use /usr/bin/sh to run commands, no matter what /etc/passwd says
SHELL=/bin/sh
# mail any output to paul, no matter whose crontab this is
MAILTO=paul
# Min Hour DayOfMonth Month DayOfWeek command (Day... are OR'ed)
# run at 00:05, every day
5  0  *  * *   $HOME/bin/daily.job &gt;&gt; $HOME/tmp/out 2&gt;&amp;1
# run at 14:15 on the first of every month -- output mailed to paul
15 14 1  * *   $HOME/bin/monthly
# run at 22:00 on weekdays(1-5), annoy Joe. % for newline, last % for cc:
0 22 *   * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%.%%
23 */2 1 2 *   echo "run 23 minutes after 0am, 2am, 4am ..., on Feb 1"
5  4 *   * sun echo "run at 04:05 every Sunday"
# run at 03:40 on the first Monday of each month
40 3 1-7 * *   [ "$(date +%a)" == "Mon" ] &amp;&amp; command -args</screen>
        <tip> <para>For the system not running continuously, install the <literal>anacron</literal> package to schedule periodic commands at the specified intervals as closely as machine-uptime permits.  See <literal>anacron</literal>(8) and <literal>anacrontab</literal>(5).</para> </tip>
        <tip> <para>For scheduled system maintenance scripts, you can run them periodically from root account by placing such scripts in "<literal>/etc/cron.hourly/</literal>", "<literal>/etc/cron.daily/</literal>", "<literal>/etc/cron.weekly/</literal>", or "<literal>/etc/cron.monthly/</literal>".  Execution timings of these scripts can be customized by "<literal>/etc/crontab</literal>" and "<literal>/etc/anacrontab</literal>".</para> </tip>
        <para> <ulink url="https://en.wikipedia.org/wiki/Systemd">Systemd</ulink> has low level capability to schedule programs to run without <literal>cron</literal> daemon.  For example, <literal>/lib/systemd/system/apt-daily.timer</literal> and <literal>/lib/systemd/system/apt-daily.service</literal> set up daily apt download activities.  See <literal>systemd.timer</literal>(5) .</para>
      </section>
      <section id="_scheduling_tasks_on_event">
        <title>Scheduling tasks on event</title>
        <para> <ulink url="https://en.wikipedia.org/wiki/Systemd">Systemd</ulink> can schedule program not only on the timer event but also on the mount event.  See <xref linkend="_timer_event_triggered_backup" /> and <xref linkend="_mount_event_triggered_backup" /> for examples.  </para>
      </section>
      <section id="_alt_sysrq_key">
        <title>Alt-SysRq key</title>
        <para>Pressing Alt-SysRq (PrtScr) followed by one keys does the magic of rescuing control of the system.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of notable SAK command keys</title>
          <tgroup cols="2">
            <colspec colwidth="130pt" align="left"/>
            <colspec colwidth="472pt" align="left"/>
            <thead>
              <row>
                <entry> key following Alt-SysRq </entry>
                <entry> description of action </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>k</literal> </entry>
                <entry><emphasis role="strong">k</emphasis>ill all processes on the <emphasis role="strong">current virtual console</emphasis> (<ulink url="https://en.wikipedia.org/wiki/Secure_attention_key">SAK</ulink>) </entry>
              </row>
              <row>
                <entry> <literal>s</literal> </entry>
                <entry><emphasis role="strong">s</emphasis>ync all mounted filesystems to avoid data corruption </entry>
              </row>
              <row>
                <entry> <literal>u</literal> </entry>
                <entry> remount all mounted filesystems read-only (<emphasis role="strong">u</emphasis>mount) </entry>
              </row>
              <row>
                <entry> <literal>r</literal> </entry>
                <entry> restore the keyboard from <emphasis role="strong">r</emphasis>aw mode after X crashes </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>See more on <ulink url="https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html">Linux kernel user’s and administrator’s guide » Linux Magic System Request Key Hacks</ulink></para>
        <tip> <para>From SSH terminal etc., you can use the Alt-SysRq feature by writing to the "<literal>/proc/sysrq-trigger</literal>". For example, "<literal>echo s &gt; /proc/sysrq-trigger; echo u &gt; /proc/sysrq-trigger</literal>" from the root shell prompt <emphasis role="strong">s</emphasis>yncs and <emphasis role="strong">u</emphasis>mounts all mounted filesystems.</para> </tip>
        <para>The current (2021) Debian amd64 Linux kernel has <literal>/proc/sys/kernel/sysrq=438=0b110110110</literal>:</para>
        <itemizedlist>
          <listitem> <para>2 =   0x2 - enable control of console logging level (ON)</para> </listitem>
          <listitem> <para>4 =   0x4 - enable control of keyboard (SAK, unraw) (ON)</para> </listitem>
          <listitem> <para>8 =   0x8 - enable debugging dumps of processes etc. (OFF)</para> </listitem>
          <listitem> <para>16 =  0x10 - enable sync command (ON)</para> </listitem>
          <listitem> <para>32 =  0x20 - enable remount read-only (ON)</para> </listitem>
          <listitem> <para>64 =  0x40 - enable signaling of processes (term, kill, oom-kill) (OFF)</para> </listitem>
          <listitem> <para>128 =  0x80 - allow reboot/poweroff (ON)</para> </listitem>
          <listitem> <para>256 = 0x100 - allow nicing of all RT tasks (ON)</para> </listitem>
        </itemizedlist>
      </section>
    </section>
    <section id="_system_maintenance_tips">
      <title>System maintenance tips</title>
      <section id="_who_is_on_the_system">
        <title>Who is on the system?</title>
        <para>You can check who is on the system by the following.</para>
        <itemizedlist>
          <listitem> <para><literal>who</literal>(1) shows who is logged on.  </para> </listitem>
          <listitem> <para><literal>w</literal>(1) shows who is logged on and what they are doing.  </para> </listitem>
          <listitem> <para><literal>last</literal>(1) shows listing of last logged in user.  </para> </listitem>
          <listitem> <para><literal>lastb</literal>(1) shows listing of last bad logged in users.  </para> </listitem>
        </itemizedlist>
        <tip> <para>"<literal>/var/run/utmp</literal>", and "<literal>/var/log/wtmp</literal>" hold such user information.  See <literal>login</literal>(1) and <literal>utmp</literal>(5).</para> </tip>
      </section>
      <section id="_warning_everyone">
        <title>Warning everyone</title>
        <para>You can send message to everyone who is logged on to the system with <literal>wall</literal>(1) by the following.</para>
        <screen>$ echo "We are shutting down in 1 hour" | wall</screen>
      </section>
      <section id="_hardware_identification">
        <title>Hardware identification</title>
        <para>For the <ulink url="https://en.wikipedia.org/wiki/Peripheral_Component_Interconnect">PCI</ulink>-like devices (<ulink url="https://en.wikipedia.org/wiki/Accelerated_Graphics_Port">AGP</ulink>, <ulink url="https://en.wikipedia.org/wiki/PCI_Express">PCI-Express</ulink>, <ulink url="https://en.wikipedia.org/wiki/PC_Card#CardBus">CardBus</ulink>, <ulink url="https://en.wikipedia.org/wiki/ExpressCard">ExpressCard</ulink>, etc.), <literal>lspci</literal>(8) (probably with "<literal>-nn</literal>" option) is a good start for the hardware identification.</para>
        <para>Alternatively, you can identify the hardware by reading contents of "<literal>/proc/bus/pci/devices</literal>" or browsing directory tree under "<literal>/sys/bus/pci</literal>" (see <xref linkend="_procfs_and_sysfs"/>).</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of hardware identification tools</title>
          <tgroup cols="4">
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="336pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>pciutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Linux PCI Utilities: <literal>lspci</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>usbutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Linux USB utilities: <literal>lsusb</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>nvme-cli</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> NVMe utilities for Linux: <literal>nvme</literal>(1) </entry>
              </row>
              <row>
                <entry> <literal>pcmciautils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> PCMCIA utilities for Linux: <literal>pccardctl</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>scsitools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> collection of tools for SCSI hardware management: <literal>lsscsi</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>procinfo</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> system information obtained from "<literal>/proc</literal>": <literal>lsdev</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>lshw</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> information about hardware configuration: <literal>lshw</literal>(1) </entry>
              </row>
              <row>
                <entry> <literal>discover</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> hardware identification system: <literal>discover</literal>(8) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_hardware_configuration">
        <title>Hardware configuration</title>
        <para>Although most of the hardware configuration on modern GUI desktop systems such as GNOME and KDE can be managed through accompanying GUI configuration tools, it is a good idea to know some basics methods to configure them.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of hardware configuration tools</title>
          <tgroup cols="4">
            <colspec colwidth="108pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="477pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>console-setup</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Linux console font and keytable utilities </entry>
              </row>
              <row>
                <entry> <literal>x11-xserver-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> X server utilities: <literal>xset</literal>(1), <literal>xmodmap</literal>(1) </entry>
              </row>
              <row>
                <entry> <literal>acpid</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> daemon to manage events delivered by the Advanced Configuration and Power Interface (ACPI) </entry>
              </row>
              <row>
                <entry> <literal>acpi</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility to display information on ACPI devices </entry>
              </row>
              <row>
                <entry> <literal>sleepd</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> daemon to put a laptop to sleep during inactivity </entry>
              </row>
              <row>
                <entry> <literal>hdparm</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> hard disk access optimization (see <xref linkend="_optimization_of_hard_disk"/>) </entry>
              </row>
              <row>
                <entry> <literal>smartmontools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> control and monitor storage systems using <ulink url="https://en.wikipedia.org/wiki/S.M.A.R.T.">S.M.A.R.T.</ulink> </entry>
              </row>
              <row>
                <entry> <literal>setserial</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> collection of tools for serial port management </entry>
              </row>
              <row>
                <entry> <literal>memtest86+</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> collection of tools for memory hardware management </entry>
              </row>
              <row>
                <entry> <literal>scsitools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> collection of tools for <ulink url="https://en.wikipedia.org/wiki/SCSI">SCSI</ulink> hardware management </entry>
              </row>
              <row>
                <entry> <literal>setcd</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> compact disc drive access optimization </entry>
              </row>
              <row>
                <entry> <literal>big-cursor</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> larger mouse cursors for X </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>Here, <ulink url="https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface">ACPI</ulink> is a newer framework for the power management system than <ulink url="https://en.wikipedia.org/wiki/Advanced_Power_Management">APM</ulink>.</para>
        <tip> <para>CPU frequency scaling on modern system is governed by kernel modules such as <literal>acpi_cpufreq</literal>.</para> </tip>
      </section>
      <section id="_system_and_hardware_time">
        <title>System and hardware time</title>
        <para>The following sets system and hardware time to MM/DD hh:mm, CCYY.</para>
        <screen># date MMDDhhmmCCYY
# hwclock --utc --systohc
# hwclock --show</screen>
        <para>Times are normally displayed in the local time on the Debian system but the hardware and system time usually use <ulink url="https://en.wikipedia.org/wiki/UTC">UTC(GMT)</ulink>.</para>
        <para>If the hardware time is set to UTC, change the setting to "<literal>UTC=yes</literal>" in the "<literal>/etc/default/rcS</literal>".</para>
        <para>The following reconfigure the timezone used by the Debian system.</para>
        <screen># dpkg-reconfigure tzdata</screen>
        <para>If you wish to update system time via network, consider to use the <ulink url="https://en.wikipedia.org/wiki/Network_Time_Protocol">NTP</ulink> service with the packages such as <literal>ntp</literal>, <literal>ntpdate</literal>, and <literal>chrony</literal>.</para>
        <tip>
          <para>Under <ulink url="https://en.wikipedia.org/wiki/Systemd">systemd</ulink>, use <literal>systemd-timesyncd</literal> for the network time synchronization instead.  See <literal>systemd-timesyncd</literal>(8).</para>
        </tip>
        <para>See the following.</para>
        <itemizedlist>
          <listitem> <para> <ulink url="https://tldp.org/HOWTO/TimePrecision-HOWTO/index.html">Managing Accurate Date and Time HOWTO</ulink> </para> </listitem>
          <listitem> <para> <ulink url="https://www.ntp.org/">NTP Public Services Project</ulink> </para> </listitem>
          <listitem> <para> The <literal>ntp-doc</literal> package </para> </listitem>
        </itemizedlist>
        <tip> <para><literal>ntptrace</literal>(8) in the <literal>ntp</literal> package can trace a chain of NTP servers back to the primary source.</para> </tip>
      </section>
      <section id="_the_terminal_configuration">
        <title>The terminal configuration</title>
        <para>There are several components to configure character console and <literal>ncurses</literal>(3) system features.</para>
        <itemizedlist>
          <listitem> <para> The "<literal>/etc/terminfo/*/*</literal>" file (<literal>terminfo</literal>(5)) </para> </listitem>
          <listitem> <para> The "<literal>$TERM</literal>" environment variable (<literal>term</literal>(7)) </para> </listitem>
          <listitem> <para><literal>setterm</literal>(1), <literal>stty</literal>(1), <literal>tic</literal>(1), and <literal>toe</literal>(1) </para> </listitem>
        </itemizedlist>
        <para>If the <literal>terminfo</literal> entry for <literal>xterm</literal> doesn't work with a non-Debian <literal>xterm</literal>, change your terminal type, "<literal>$TERM</literal>", from "<literal>xterm</literal>" to one of the feature-limited versions such as "<literal>xterm-r6</literal>" when you log in to a Debian system remotely.  See "<literal>/usr/share/doc/libncurses5/FAQ</literal>" for more.  "<literal>dumb</literal>" is the lowest common denominator for "<literal>$TERM</literal>".</para>
      </section>
      <section id="_the_sound_infrastructure">
        <title>The sound infrastructure</title>
        <para>Device drivers for sound cards for current Linux are provided by <ulink url="https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture">Advanced Linux Sound Architecture (ALSA)</ulink>.  ALSA provides emulation mode for previous <ulink url="https://en.wikipedia.org/wiki/Open_Sound_System">Open Sound System (OSS)</ulink> for compatibility.</para>
        <para>Application softwares may be configured not only to access sound devices directly but also to access them via some standardized sound server system.  Currently, PulseAudio, JACK, and PipeWire are used as sound server system.  See <ulink url="https://wiki.debian.org/Sound">Debian wiki page on Sound</ulink> for the latest situation.</para>
        <para>There is usually a common sound engine for each popular desktop environment. Each sound engine used by the application can choose to connect to different sound servers.</para>
        <tip> <para>Use "<literal>cat /dev/urandom &gt; /dev/audio</literal>" or <literal>speaker-test</literal>(1) to test speaker (^C to stop).</para> </tip>
        <tip> <para>If you can not get sound, your speaker may be connected to a muted output.  Modern sound system has many outputs.  <literal>alsamixer</literal>(1) in the <literal>alsa-utils</literal> package is useful to configure volume and mute settings.</para> </tip>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of sound packages</title>
          <tgroup cols="4">
            <colspec colwidth="114pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="488pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>alsa-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for configuring and using ALSA </entry>
              </row>
              <row>
                <entry> <literal>oss-compat</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> OSS compatibility under ALSA preventing "<literal>/dev/dsp not found</literal>" errors </entry>
              </row>
              <row>
                <entry> <literal>pipewire</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</ulink> - metapackage </entry>
              </row>
              <row>
                <entry> <literal>pipewire-bin</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</ulink> - audio server and CLI programs </entry>
              </row>
              <row>
                <entry> <literal>pipewire-alsa</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</ulink> - audio server to replace ALSA </entry>
              </row>
              <row>
                <entry> <literal>pipewire-pulse</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</ulink> - audio server to replace PulseAudio </entry>
              </row>
              <row>
                <entry> <literal>pulseaudio</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PulseAudio">PulseAudio</ulink> server </entry>
              </row>
              <row>
                <entry> <literal>libpulse0</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/PulseAudio">PulseAudio</ulink> client library  </entry>
              </row>
              <row>
                <entry> <literal>jackd</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit">JACK Audio Connection Kit. (JACK)</ulink> server (low latency) </entry>
              </row>
              <row>
                <entry> <literal>libjack0</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit">JACK Audio Connection Kit. (JACK)</ulink> library (low latency) </entry>
              </row>
              <row>
                <entry> <literal>libgstreamer1.0-0</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/GStreamer">GStreamer</ulink>: GNOME sound engine </entry>
              </row>
              <row>
                <entry> <literal>libphonon4qt5-4</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/Phonon_(KDE)">Phonon</ulink>: KDE sound engine </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_disabling_the_screen_saver">
        <title>Disabling the screen saver</title>
        <para>For disabling the screen saver, use following commands.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of commands for disabling the screen saver</title>
          <tgroup cols="2">
            <colspec colwidth="271pt" align="left"/>
            <colspec colwidth="162pt" align="left"/>
            <thead>
              <row>
                <entry> environment </entry>
                <entry> command </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> The Linux console </entry>
                <entry> <literal>setterm -powersave off</literal> </entry>
              </row>
              <row>
                <entry> The X Window (turning off screensaver) </entry>
                <entry> <literal>xset s off</literal> </entry>
              </row>
              <row>
                <entry> The X Window (disabling dpms) </entry>
                <entry> <literal>xset -dpms</literal> </entry>
              </row>
              <row>
                <entry> The X Window (GUI configuration of screen saver) </entry>
                <entry> <literal>xscreensaver-command -prefs</literal> </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_disabling_beep_sounds">
        <title>Disabling beep sounds</title>
        <para>One can always unplug the PC speaker to disable beep sounds.  Removing <literal>pcspkr</literal> kernel module does this for you.</para>
        <para>The following prevents the <literal>readline</literal>(3) program used by <literal>bash</literal>(1) to beep when encountering an alert character (ASCII=7).</para>
        <screen>$ echo "set bell-style none"&gt;&gt; ~/.inputrc</screen>
      </section>
      <section id="_memory_usage">
        <title>Memory usage</title>
        <para>There are 2 resources available for you to get the memory usage situation.</para>
        <itemizedlist>
          <listitem> <para> The kernel boot message in the "<literal>/var/log/dmesg</literal>" contains the total exact size of available memory.  </para> </listitem>
          <listitem> <para><literal>free</literal>(1) and <literal>top</literal>(1) display information on memory resources on the running system.  </para> </listitem>
        </itemizedlist>
        <para>Here is an example.</para>
        <screen># grep '\] Memory' /var/log/dmesg
[    0.004000] Memory: 990528k/1016784k available (1975k kernel code, 25868k reserved, 931k data, 296k init)
$ free -k
             total       used       free     shared    buffers     cached
Mem:        997184     976928      20256          0     129592     171932
-/+ buffers/cache:     675404     321780
Swap:      4545576          4    4545572</screen>
        <para>You may be wondering "dmesg tells me a free of 990 MB, and free -k says 320 MB is free. More than 600 MB missing …".</para>
        <para>Do not worry about the large size of "<literal>used</literal>" and the small size of "<literal>free</literal>" in the "<literal>Mem:</literal>" line, but read the one under them (675404 and 321780 in the example above) and relax.</para>
        <para>For my MacBook with 1GB=1048576k DRAM (video system steals some of this), I see the following.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of memory sizes reported</title>
          <tgroup cols="2">
            <colspec colwidth="108pt" align="left"/>
            <colspec colwidth="130pt" align="left"/>
            <thead>
              <row>
                <entry> report </entry>
                <entry> size </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> Total size in dmesg </entry>
                <entry> 1016784k = 1GB - 31792k </entry>
              </row>
              <row>
                <entry> Free in dmesg </entry>
                <entry> 990528k </entry>
              </row>
              <row>
                <entry> Total under shell </entry>
                <entry> 997184k </entry>
              </row>
              <row>
                <entry> Free under shell </entry>
                <entry> 20256k (but effectively 321780k) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_system_security_and_integrity_check">
        <title>System security and integrity check</title>
        <para>Poor system maintenance may expose your system to external exploitation.</para>
        <para>For system security and integrity check, you should start with the following.</para>
        <itemizedlist>
          <listitem> <para> The <literal>debsums</literal> package, see <literal>debsums</literal>(1) and <xref linkend="_top_level_release_file_and_authenticity"/>.  </para> </listitem>
          <listitem> <para> The <literal>chkrootkit</literal> package, see <literal>chkrootkit</literal>(1).  </para> </listitem>
          <listitem> <para> The <literal>clamav</literal> package family, see <literal>clamscan</literal>(1) and <literal>freshclam</literal>(1).  </para> </listitem>
          <listitem> <para><ulink url="https://www.debian.org/security/faq">Debian security FAQ</ulink>.  </para> </listitem>
          <listitem> <para><ulink url="https://www.debian.org/doc/manuals/securing-debian-manual/">Securing Debian Manual</ulink>.  </para> </listitem>
        </itemizedlist>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of tools for system security and integrity check</title>
          <tgroup cols="4">
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="352pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>logcheck</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> daemon to mail anomalies in the system logfiles to the administrator </entry>
              </row>
              <row>
                <entry> <literal>debsums</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility to verify installed package files against MD5 checksums </entry>
              </row>
              <row>
                <entry> <literal>chkrootkit</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/Rootkit">rootkit</ulink> detector </entry>
              </row>
              <row>
                <entry> <literal>clamav</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> anti-virus utility for Unix - command-line interface </entry>
              </row>
              <row>
                <entry> <literal>tiger</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> report system security vulnerabilities </entry>
              </row>
              <row>
                <entry> <literal>tripwire</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> file and directory integrity checker </entry>
              </row>
              <row>
                <entry> <literal>john</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> active password cracking tool </entry>
              </row>
              <row>
                <entry> <literal>aide</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Advanced Intrusion Detection Environment - static binary </entry>
              </row>
              <row>
                <entry> <literal>integrit</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> file integrity verification program </entry>
              </row>
              <row>
                <entry> <literal>crack</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> password guessing program </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>Here is a simple script to check for typical world writable incorrect file permissions.</para>
        <screen># find / -perm 777 -a \! -type s -a \! -type l -a \! \( -type d -a -perm 1777 \)</screen>
        <caution> <para>Since the <literal>debsums</literal> package uses <ulink url="https://en.wikipedia.org/wiki/MD5">MD5</ulink> checksums stored locally, it can not be fully trusted as the system security audit tool against malicious attacks.</para> </caution>
      </section>
    </section>
    <section id="_data_storage_tips">
      <title>Data storage tips</title>
      <para>Booting your system with Linux <ulink url="https://en.wikipedia.org/wiki/Live_CD">live CDs</ulink> or <ulink url="https://www.debian.org/releases/stable/debian-installer/">debian-installer CDs</ulink> in rescue mode makes it easy for you to reconfigure data storage on your boot device.</para>
      <para>You may need to <literal>umount</literal>(8) some devices manually from the command line before operating on them if they are automatically mounted by the GUI desktop system.</para>
      <section id="_disk_space_usage">
        <title>Disk space usage</title>
        <para>The disk space usage can be evaluated by programs provided by the <literal>mount</literal>, <literal>coreutils</literal>, and <literal>xdu</literal> packages:</para>
        <itemizedlist>
          <listitem> <para><literal>mount</literal>(8) reports all mounted filesystems (= disks).  </para> </listitem>
          <listitem> <para><literal>df</literal>(1) reports the disk space usage for the file system.  </para> </listitem>
          <listitem> <para><literal>du</literal>(1) reports the disk space usage for the directory tree.  </para> </listitem>
        </itemizedlist>
        <tip> <para>You can feed the output of <literal>du</literal>(8) to <literal>xdu</literal>(1x) to produce its graphical and interactive presentation with "<literal>du -k . |xdu</literal>", "<literal>sudo du -k -x / |xdu</literal>", etc.</para> </tip>
      </section>
      <section id="_disk_partition_configuration">
        <title>Disk partition configuration</title>
        <para>For <ulink url="https://en.wikipedia.org/wiki/Disk_partitioning">disk partition</ulink> configuration, although <literal>fdisk</literal>(8) has been considered standard, <literal>parted</literal>(8) deserves some attention.  "Disk partitioning data", "partition table", "partition map", and "disk label" are all synonyms.</para>
        <para>Older PCs use the classic <ulink url="https://en.wikipedia.org/wiki/Master_boot_record">Master Boot Record (MBR)</ulink> scheme to hold <ulink url="https://en.wikipedia.org/wiki/Disk_partitioning">disk partitioning</ulink> data in the first sector, i.e., <ulink url="https://en.wikipedia.org/wiki/Logical_block_addressing">LBA</ulink> sector 0 (512 bytes).</para>
        <para>Recent PCs with <ulink url="https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface">Unified Extensible Firmware Interface (UEFI)</ulink>, including Intel-based Macs, use <ulink url="https://en.wikipedia.org/wiki/GUID_Partition_Table">GUID Partition Table (GPT)</ulink> scheme to hold <ulink url="https://en.wikipedia.org/wiki/Disk_partitioning">disk partitioning</ulink> data not in the first sector.</para>
        <para>Although <literal>fdisk</literal>(8) has been standard for the disk partitioning tool, <literal>parted</literal>(8) is replacing it.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of disk partition management packages</title>
          <tgroup cols="4">
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="369pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>util-linux</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> miscellaneous system utilities including <literal>fdisk</literal>(8) and <literal>cfdisk</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>parted</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> GNU Parted disk partition resizing program </entry>
              </row>
              <row>
                <entry> <literal>gparted</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> GNOME partition editor based on <literal>libparted</literal> </entry>
              </row>
              <row>
                <entry> <literal>gdisk</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> partition editor for the GPT/MBR hybrid disk </entry>
              </row>
              <row>
                <entry> <literal>kpartx</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> program to create device mappings for partitions </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <caution> <para>Although <literal>parted</literal>(8) claims to create and to resize filesystem too, it is safer to do such things using best maintained specialized tools such as <literal>mkfs</literal>(8) (<literal>mkfs.msdos</literal>(8), <literal>mkfs.ext2</literal>(8), <literal>mkfs.ext3</literal>(8), <literal>mkfs.ext4</literal>(8), …) and <literal>resize2fs</literal>(8).</para> </caution>
        <note> <para>In order to switch between <ulink url="https://en.wikipedia.org/wiki/GUID_Partition_Table">GPT</ulink> and <ulink url="https://en.wikipedia.org/wiki/Master_boot_record">MBR</ulink>, you need to erase first few blocks of disk contents directly (see <xref linkend="_clearing_file_contents"/>) and use "<literal>parted /dev/sdx mklabel gpt</literal>" or "<literal>parted /dev/sdx mklabel msdos</literal>" to set it.  Please note "<literal>msdos</literal>" is use here for <ulink url="https://en.wikipedia.org/wiki/Master_boot_record">MBR</ulink>.</para> </note>
      </section>
      <section id="_accessing_partition_using_uuid">
        <title>Accessing partition using UUID</title>
        <para>Although reconfiguration of your partition or activation order of removable storage media may yield different names for partitions, you can access them consistently. This is also helpful if you have multiple disks and your BIOS/UEFI doesn't give them consistent device names.</para>
        <itemizedlist>
          <listitem> <para><literal>mount</literal>(8) with "<literal>-U</literal>" option can mount a block device using <ulink url="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</ulink>, instead of using its file name such as "<literal>/dev/sda3</literal>".  </para> </listitem>
          <listitem> <para> "<literal>/etc/fstab</literal>" (see <literal>fstab</literal>(5)) can use <ulink url="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</ulink>.  </para> </listitem>
          <listitem> <para> Boot loaders (<xref linkend="_stage_2_the_boot_loader"/>) may use <ulink url="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</ulink> too.  </para> </listitem>
        </itemizedlist>
        <tip>
          <para>You can probe <ulink url="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</ulink> of a block special device with <literal>blkid</literal>(8).</para>
          <para>You can also probe UUID and other information with "<literal>lsblk -f</literal>".</para>
        </tip>
      </section>
      <section id="_lvm2">
        <title>LVM2</title>
        <para>LVM2 is a <ulink url="https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">logical volume manager</ulink> for the Linux kernel.  With LVM2, disk partitions can be created on logical volumes instead of the physical harddisks.</para>
        <para>LVM requires the following.</para>
        <itemizedlist>
          <listitem> <para> device-mapper support in the Linux kernel (default for Debian kernels) </para> </listitem>
          <listitem> <para> the userspace device-mapper support library (<literal>libdevmapper*</literal> package) </para> </listitem>
          <listitem> <para> the userspace LVM2 tools (<literal>lvm2</literal> package) </para> </listitem>
        </itemizedlist>
        <para>Please start learning LVM2 from the following manpages.</para>
        <itemizedlist>
          <listitem> <para><literal>lvm</literal>(8): Basics of LVM2 mechanism (list of all LVM2 commands) </para> </listitem>
          <listitem> <para><literal>lvm.conf</literal>(5): Configuration file for LVM2 </para> </listitem>
          <listitem> <para><literal>lvs</literal>(8): Report information about logical volumes </para> </listitem>
          <listitem> <para><literal>vgs</literal>(8): Report information about volume groups </para> </listitem>
          <listitem> <para><literal>pvs</literal>(8): Report information about physical volumes </para> </listitem>
        </itemizedlist>
      </section>
      <section id="_filesystem_configuration">
        <title>Filesystem configuration</title>
        <para>For <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem, the <literal>e2fsprogs</literal> package provides the following.</para>
        <itemizedlist>
          <listitem> <para><literal>mkfs.ext4</literal>(8) to create new <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem </para> </listitem>
          <listitem> <para><literal>fsck.ext4</literal>(8) to check and to repair existing <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem </para> </listitem>
          <listitem> <para><literal>tune2fs</literal>(8) to configure superblock of <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem </para> </listitem>
          <listitem> <para><literal>debugfs</literal>(8) to debug <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem interactively. (It has <literal>undel</literal> command to recover deleted files.) </para> </listitem>
        </itemizedlist>
        <para>The <literal>mkfs</literal>(8) and <literal>fsck</literal>(8) commands are provided by the <literal>e2fsprogs</literal> package as front-ends to various filesystem dependent programs (<literal>mkfs.fstype</literal> and <literal>fsck.fstype</literal>). For <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystem, they are <literal>mkfs.ext4</literal>(8) and <literal>fsck.ext4</literal>(8) (they are symlinked to <literal>mke2fs</literal>(8) and <literal>e2fsck</literal>(8)).</para>
        <para>Similar commands are available for each filesystem supported by Linux.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of filesystem management packages</title>
          <tgroup cols="4">
            <colspec colwidth="86pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="515pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>e2fsprogs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/Ext2">ext2</ulink>/<ulink url="https://en.wikipedia.org/wiki/Ext3">ext3</ulink>/<ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystems </entry>
              </row>
              <row>
                <entry> <literal>btrfs-progs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/Btrfs">Btrfs</ulink> filesystem </entry>
              </row>
              <row>
                <entry> <literal>reiserfsprogs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/Reiserfs">Reiserfs</ulink> filesystem </entry>
              </row>
              <row>
                <entry> <literal>zfsutils-linux</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/OpenZFS">OpenZFS</ulink> filesystem </entry>
              </row>
              <row>
                <entry> <literal>dosfstools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/File_Allocation_Table">FAT</ulink> filesystem. (Microsoft: MS-DOS, Windows) </entry>
              </row>
              <row>
                <entry> <literal>exfatprogs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/ExFAT">exFAT</ulink> filesystem maintained by Samsung. </entry>
              </row>
              <row>
                <entry> <literal>exfat-fuse</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> read/write <ulink url="https://en.wikipedia.org/wiki/ExFAT">exFAT</ulink> filesystem (Microsoft) driver for FUSE. </entry>
              </row>
              <row>
                <entry> <literal>exfat-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/ExFAT">exFAT</ulink> filesystem maintained by the exfat-fuse author. </entry>
              </row>
              <row>
                <entry> <literal>xfsprogs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/XFS">XFS</ulink> filesystem. (SGI: IRIX) </entry>
              </row>
              <row>
                <entry> <literal>ntfs-3g</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> read/write <ulink url="https://en.wikipedia.org/wiki/NTFS">NTFS</ulink> filesystem (Microsoft: Windows NT, …) driver for FUSE. </entry>
              </row>
              <row>
                <entry> <literal>jfsutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/JFS_(file_system)">JFS</ulink> filesystem. (IBM: AIX, OS/2) </entry>
              </row>
              <row>
                <entry> <literal>reiser4progs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for the <ulink url="https://en.wikipedia.org/wiki/Reiser4">Reiser4</ulink> filesystem </entry>
              </row>
              <row>
                <entry> <literal>hfsprogs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for <ulink url="https://en.wikipedia.org/wiki/Hierarchical_File_System">HFS</ulink> and <ulink url="https://en.wikipedia.org/wiki/HFS_Plus">HFS Plus</ulink> filesystem. (Apple: Mac OS) </entry>
              </row>
              <row>
                <entry> <literal>zerofree</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> program to zero free blocks from ext2/3/4 filesystems </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <tip>
          <para><ulink url="https://en.wikipedia.org/wiki/Ext4">Ext4</ulink> filesystem is the default filesystem for the Linux system and strongly recommended to use it unless you have some specific reasons not to.</para>
          <para><ulink url="https://en.wikipedia.org/wiki/Btrfs">Btrfs</ulink> status can be found at <ulink url="https://wiki.debian.org/Btrfs">Debian wiki on btrfs</ulink> and <ulink url="https://btrfs.wiki.kernel.org/index.php/Status">kernel.org wiki on btrfs</ulink>.  It is expected to be the next default filesystem after the ext4 filesystem.</para>
          <para>Some tools allow access to filesystem without Linux kernel support (see <xref linkend="_manipulating_files_without_mounting_disk"/>).</para>
        </tip>
      </section>
      <section id="_filesystem_creation_and_integrity_check">
        <title>Filesystem creation and integrity check</title>
        <para>The <literal>mkfs</literal>(8) command creates the filesystem on a Linux system. The <literal>fsck</literal>(8) command provides the filesystem integrity check and repair on a Linux system.</para>
        <para>Debian now defaults to no periodic <literal>fsck</literal> after filesystem creation.</para>
        <caution> <para>It is generally not safe to run <literal>fsck</literal> on <emphasis role="strong">mounted filesystems</emphasis>.</para> </caution>
        <tip>
          <para>You can run the <literal>fsck</literal>(8) command safely on all filesystems including root filesystem on reboot by setting "<literal>enable_periodic_fsck</literal>" in "<literal>/etc/mke2fs.conf</literal>"  and the max mount count to 0 using "<literal>tune2fs -c0 /dev/<emphasis>partition_name</emphasis></literal>".  See <literal>mke2fs.conf</literal>(5) and <literal>tune2fs</literal>(8).</para>
          <para>Check files in "<literal>/var/log/fsck/</literal>" for the result of the <literal>fsck</literal>(8) command run from the boot script.</para>
        </tip>
      </section>
      <section id="_optimization_of_filesystem_by_mount_options">
        <title>Optimization of filesystem by mount options</title>
        <para>The basic static filesystem configuration is given by "<literal>/etc/fstab</literal>".  For example,</para>
        <screen>«file system»                   «mount point» «type» «options»    «dump» «pass»
proc                                      /proc proc   defaults          0 0
UUID=709cbe4c-80c1-56db-8ab1-dbce3146d2f7 /     ext4   errors=remount-ro 0 1
UUID=817bae6b-45d2-5aca-4d2a-1267ab46ac23 none  swap   sw                0 0
/dev/scd0                        /media/cdrom0  udf,iso9660 user,noauto  0 0</screen>
        <tip> <para><ulink url="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</ulink> (see <xref linkend="_accessing_partition_using_uuid"/>) may be used to identify a block device instead of normal block device names such as "<literal>/dev/sda1</literal>", "<literal>/dev/sda2</literal>", …</para> </tip>
        <para>Since  Linux 2.6.30, the kernel defaults to the behavior provided by "<literal>relatime</literal>" option. </para>
        <para>See <literal>fstab</literal>(5) and <literal>mount</literal>(8).</para>
      </section>
      <section id="_optimization_of_filesystem_via_superblock">
        <title>Optimization of filesystem via superblock</title>
        <para>Characteristics of a filesystem can be optimized via its superblock using the <literal>tune2fs</literal>(8) command.</para>
        <itemizedlist>
          <listitem> <para> Execution of "<literal>sudo tune2fs -l /dev/hda1</literal>" displays the contents of the filesystem superblock on "<literal>/dev/hda1</literal>".  </para> </listitem>
          <listitem> <para> Execution of "<literal>sudo tune2fs -c 50 /dev/hda1</literal>" changes frequency of filesystem checks (<literal>fsck</literal> execution during boot-up) to every 50 boots on "<literal>/dev/hda1</literal>".  </para> </listitem>
          <listitem> <para> Execution of "<literal>sudo tune2fs -j /dev/hda1</literal>" adds journaling capability to the filesystem, i.e. filesystem conversion from <ulink url="https://en.wikipedia.org/wiki/Ext2">ext2</ulink> to <ulink url="https://en.wikipedia.org/wiki/Ext3">ext3</ulink> on "<literal>/dev/hda1</literal>".  (Do this on the unmounted filesystem.) </para> </listitem>
          <listitem> <para> Execution of "<literal>sudo tune2fs -O extents,uninit_bg,dir_index /dev/hda1 &amp;&amp; fsck -pf /dev/hda1</literal>" converts it from <ulink url="https://en.wikipedia.org/wiki/Ext3">ext3</ulink> to <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> on "<literal>/dev/hda1</literal>".  (Do this on the unmounted filesystem.) </para> </listitem>
        </itemizedlist>
        <tip> <para>Despite its name, <literal>tune2fs</literal>(8) works not only on the <ulink url="https://en.wikipedia.org/wiki/Ext2">ext2</ulink> filesystem but also on the <ulink url="https://en.wikipedia.org/wiki/Ext3">ext3</ulink> and <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> filesystems.</para> </tip>
      </section>
      <section id="_optimization_of_hard_disk">
        <title>Optimization of hard disk</title>
        <warning> <para>Please check your hardware and read manpage of <literal>hdparm</literal>(8) before playing with hard disk configuration because this may be quite dangerous for the data integrity.</para> </warning>
        <para>You can test disk access speed of a hard disk, e.g. "<literal>/dev/hda</literal>", by "<literal>hdparm -tT /dev/hda</literal>". For some hard disk connected with (E)IDE, you can speed it up with "<literal>hdparm -q -c3 -d1 -u1 -m16 /dev/hda</literal>" by enabling the "(E)IDE 32-bit I/O support", enabling the "using_dma flag", setting "interrupt-unmask flag", and setting the "multiple 16 sector I/O" (dangerous!).</para>
        <para>You can test write cache feature of a hard disk, e.g. "<literal>/dev/sda</literal>", by "<literal>hdparm -W /dev/sda</literal>". You can disable its write cache feature with "<literal>hdparm -W 0 /dev/sda</literal>".</para>
        <para>You may be able to read badly pressed CDROMs on modern high speed CD-ROM drive by slowing it down with "<literal>setcd -x 2</literal>".</para>
      </section>
      <section id="_optimization_of_solid_state_drive">
        <title>Optimization of solid state drive</title>
        <para><ulink url="https://en.wikipedia.org/wiki/Solid-state_drive">Solid state drive (SSD)</ulink> is auto detected now.</para>
        <para>Reduce unnecessary disk accesses to prevent disk wear out by mounting "<literal>tmpfs</literal>" on volatile data path in <literal>/etc/fstab</literal>.  </para>
      </section>
      <section id="_using_smart_to_predict_hard_disk_failure">
        <title>Using SMART to predict hard disk failure</title>
        <para>You can monitor and log your hard disk which is compliant to <ulink url="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</ulink> with the <literal>smartd</literal>(8) daemon.</para>
        <orderedlist>
          <listitem> <para> Enable <ulink url="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</ulink> feature in <ulink url="https://en.wikipedia.org/wiki/BIOS">BIOS</ulink>.  </para> </listitem>
          <listitem> <para> Install the <literal>smartmontools</literal> package.  </para> </listitem>
          <listitem>
            <para> Identify your hard disk drives by listing them with <literal>df</literal>(1).  </para>
            <itemizedlist>
              <listitem> <para> Let's assume a hard disk drive to be monitored as "<literal>/dev/hda</literal>".  </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Check the output of "<literal>smartctl -a /dev/hda</literal>" to see if <ulink url="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</ulink> feature is actually enabled.  </para>
            <itemizedlist>
              <listitem> <para> If not, enable it by "<literal>smartctl -s on -a /dev/hda</literal>".  </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Enable <literal>smartd</literal>(8) daemon to run by the following.  </para>
            <itemizedlist>
              <listitem> <para> uncomment "<literal>start_smartd=yes</literal>" in the "<literal>/etc/default/smartmontools</literal>" file.  </para> </listitem>
              <listitem> <para> restart the <literal>smartd</literal>(8) daemon by "<literal>sudo systemctl restart smartmontools</literal>".  </para> </listitem>
            </itemizedlist>
          </listitem>
        </orderedlist>
        <tip> <para>The <literal>smartd</literal>(8) daemon can be customized with the <literal>/etc/smartd.conf</literal> file including how to be notified of warnings.</para> </tip>
      </section>
      <section id="_specify_temporary_storage_directory_via_tmpdir">
        <title>Specify temporary storage directory via $TMPDIR</title>
        <para>Applications create temporary files normally under the temporary storage directory "<literal>/tmp</literal>".  If "<literal>/tmp</literal>" does not provide enough space, you can specify such temporary storage directory via the <literal>$TMPDIR</literal> variable for well-behaving programs.</para>
      </section>
      <section id="_expansion_of_usable_storage_space_via_lvm">
        <title>Expansion of usable storage space via LVM</title>
        <para>For partitions created on <ulink url="https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">Logical Volume Manager (LVM)</ulink> (Linux feature) at install time, they can be resized easily by concatenating extents onto them or truncating extents from them over multiple storage devices without major system reconfiguration.</para>
      </section>
      <section id="_expansion_of_usable_storage_space_by_mounting_another_partition">
        <title>Expansion of usable storage space by mounting another partition</title>
        <para>If you have an empty partition (e.g., "<literal>/dev/sdx</literal>"), you can format it with <literal>mkfs.ext4</literal>(1) and <literal>mount</literal>(8) it to a directory where you need more space. (You need to copy original data contents.)</para>
        <screen>$ sudo mv work-dir old-dir
$ sudo mkfs.ext4 /dev/sdx
$ sudo mount -t ext4 /dev/sdx work-dir
$ sudo cp -a old-dir/* work-dir
$ sudo rm -rf old-dir</screen>
        <tip> <para>You may alternatively mount an empty disk image file (see <xref linkend="_making_the_empty_disk_image_file"/>) as a loop device (see <xref linkend="_mounting_the_disk_image_file"/>).  The actual disk usage grows with the actual data stored.</para> </tip>
      </section>
      <section id="_expansion_of_usable_storage_space_by_bind_mounting_another_directory">
        <title>Expansion of usable storage space by bind-mounting another directory</title>
        <para>If you have an empty directory (e.g., "<literal>/path/to/emp-dir</literal>") on another partition with usable space, you can mount(8) it with "<literal>--bind</literal>" option to a directory (e.g., "<literal>work-dir</literal>") where you need more space.</para>
        <screen>$ sudo mount --bind /path/to/emp-dir work-dir</screen>
      </section>
      <section id="_expansion_of_usable_storage_space_by_overlay_mounting_another_directory">
        <title>Expansion of usable storage space by overlay-mounting another directory</title>
        <para>If you have usable space in another partition (e.g., "<literal>/path/to/empty</literal>" and "<literal>/path/to/work</literal>"), you can create a directory in it and stack that on to an old directory (e.g., "<literal>/path/to/old</literal>") where you need space using the <ulink url="https://en.wikipedia.org/wiki/OverlayFS">OverlayFS</ulink> for Linux kernel 3.18 or newer (Debian Stretch 9.0 or newer).</para>
        <screen>$ sudo mount -t overlay overlay \
  -olowerdir=/path/to/old-dir,upperdir=/path/to/empty,workdir=/path/to/work</screen>
        <para>Here, "<literal>/path/to/empty</literal>" and "<literal>/path/to/work</literal>" should be on the RW-enabled partition to write on "<literal>/path/to/old</literal>".</para>
      </section>
      <section id="_expansion_of_usable_storage_space_using_symlink">
        <title>Expansion of usable storage space using symlink</title>
        <caution> <para>This is a deprecated method.  Some software may not function well with "symlink to a directory".  Instead, use the "mounting" approaches described in the above.</para> </caution>
        <para>If you have an empty directory (e.g., "<literal>/path/to/emp-dir</literal>") in another partition with usable space, you can create a symlink to the directory with <literal>ln</literal>(8).</para>
        <screen>$ sudo mv work-dir old-dir
$ sudo mkdir -p /path/to/emp-dir
$ sudo ln -sf /path/to/emp-dir work-dir
$ sudo cp -a old-dir/* work-dir
$ sudo rm -rf old-dir</screen>
        <warning> <para>Do not use "symlink to a directory" for directories managed by the system such as "<literal>/opt</literal>".  Such a symlink may be overwritten when the system is upgraded.</para> </warning>
      </section>
    </section>
    <section id="_the_disk_image">
      <title>The disk image</title>
      <para>Here, we discuss manipulations of the disk image.</para>
      <section id="_making_the_disk_image_file">
        <title>Making the disk image file</title>
        <para>The disk image file, "<literal>disk.img</literal>", of an unmounted device, e.g., the second SCSI or serial ATA drive "<literal>/dev/sdb</literal>", can be made using <literal>cp</literal>(1) or <literal>dd</literal>(1) by the following.</para>
        <screen># cp /dev/sdb disk.img
# dd if=/dev/sdb of=disk.img</screen>
        <para>The disk image of the traditional PC's <ulink url="https://en.wikipedia.org/wiki/Master_boot_record">master boot record (MBR)</ulink> (see <xref linkend="_disk_partition_configuration"/>) which reside on the first sector on the primary IDE disk can be made by using <literal>dd</literal>(1) by the following.</para>
        <screen># dd if=/dev/hda of=mbr.img bs=512 count=1
# dd if=/dev/hda of=mbr-nopart.img bs=446 count=1
# dd if=/dev/hda of=mbr-part.img skip=446 bs=1 count=66</screen>
        <itemizedlist>
          <listitem> <para> "<literal>mbr.img</literal>": The MBR with the partition table </para> </listitem>
          <listitem> <para> "<literal>mbr-nopart.img</literal>": The MBR without the partition table </para> </listitem>
          <listitem> <para> "<literal>mbr-part.img</literal>": The partition table of the MBR only </para> </listitem>
        </itemizedlist>
        <para>If you have an SCSI or serial ATA device as the boot disk, substitute "<literal>/dev/hda</literal>" with "<literal>/dev/sda</literal>".</para>
        <para>If you are making an image of a disk partition of the original disk, substitute "<literal>/dev/hda</literal>" with "<literal>/dev/hda1</literal>" etc.</para>
      </section>
      <section id="_writing_directly_to_the_disk">
        <title>Writing directly to the disk</title>
        <para>The disk image file, "<literal>disk.img</literal>" can be written to an unmounted device, e.g., the second SCSI drive "<literal>/dev/sdb</literal>" with matching size, by the following.</para>
        <screen># dd if=disk.img of=/dev/sdb</screen>
        <para>Similarly, the disk partition image file, "<literal>partition.img</literal>" can be written to an unmounted partition, e.g., the first partition of the second SCSI drive "<literal>/dev/sdb1</literal>" with matching size, by the following.</para>
        <screen># dd if=partition.img of=/dev/sdb1</screen>
      </section>
      <section id="_mounting_the_disk_image_file">
        <title>Mounting the disk image file</title>
        <para>The disk image "<literal>partition.img</literal>" containing a single partition image can be mounted and unmounted by using the <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink> as follows.</para>
        <screen># losetup --show -f partition.img
/dev/loop0
# mkdir -p /mnt/loop0
# mount -t auto /dev/loop0 /mnt/loop0
...hack...hack...hack
# umount /dev/loop0
# losetup -d /dev/loop0</screen>
        <para>This can be simplified as follows.</para>
        <screen># mkdir -p /mnt/loop0
# mount -t auto -o loop partition.img /mnt/loop0
...hack...hack...hack
# umount partition.img</screen>
        <!--
          Post kernel version 3.2+ and util-linux 2.21+ support mounting multiple partitions. (After 2012-01).
          losetup and kpartx has changed behavior.  So script outputs are updated in 2024-04-03.
          Disk image used below is the official cloud Debian image from https://cloud.debian.org/images/cloud/
        -->
        <para>Each partition of the disk image "<literal>disk.img</literal>" containing multiple partitions can be mounted by using the <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink>.</para>
        <screen># losetup --show -f -P disk.img
/dev/loop0
# ls -l /dev/loop0*
brw-rw---- 1 root disk   7,  0 Apr  2 22:51 /dev/loop0
brw-rw---- 1 root disk 259, 12 Apr  2 22:51 /dev/loop0p1
brw-rw---- 1 root disk 259, 13 Apr  2 22:51 /dev/loop0p14
brw-rw---- 1 root disk 259, 14 Apr  2 22:51 /dev/loop0p15
# fdisk -l /dev/loop0
Disk /dev/loop0: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 6A1D9E28-C48C-2144-91F7-968B3CBC9BD1

Device         Start     End Sectors  Size Type
/dev/loop0p1  262144 4192255 3930112  1.9G Linux root (x86-64)
/dev/loop0p14   2048    8191    6144    3M BIOS boot
/dev/loop0p15   8192  262143  253952  124M EFI System

Partition table entries are not in disk order.
# mkdir -p /mnt/loop0p1
# mkdir -p /mnt/loop0p15
# mount -t auto /dev/loop0p1 /mnt/loop0p1
# mount -t auto /dev/loop0p15 /mnt/loop0p15
# mount |grep loop
/dev/loop0p1 on /mnt/loop0p1 type ext4 (rw,relatime)
/dev/loop0p15 on /mnt/loop0p15 type vfat (rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
...hack...hack...hack
# umount /dev/loop0p1
# umount /dev/loop0p15
# losetup -d /dev/loop0</screen>
        <para>Alternatively, similar effects can be done by using the <ulink url="https://en.wikipedia.org/wiki/Device_mapper">device mapper</ulink> devices created by <literal>kpartx</literal>(8) from the <literal>kpartx</literal> package as follows.</para>
        <screen># kpartx -a -v disk.img
add map loop0p1 (253:0): 0 3930112 linear 7:0 262144
add map loop0p14 (253:1): 0 6144 linear 7:0 2048
add map loop0p15 (253:2): 0 253952 linear 7:0 8192
# fdisk -l /dev/loop0
Disk /dev/loop0: 2 GiB, 2147483648 bytes, 4194304 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 6A1D9E28-C48C-2144-91F7-968B3CBC9BD1

Device         Start     End Sectors  Size Type
/dev/loop0p1  262144 4192255 3930112  1.9G Linux root (x86-64)
/dev/loop0p14   2048    8191    6144    3M BIOS boot
/dev/loop0p15   8192  262143  253952  124M EFI System

Partition table entries are not in disk order.
# ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Apr  2 22:45 control
lrwxrwxrwx 1 root root       7 Apr  2 23:19 loop0p1 -> ../dm-0
lrwxrwxrwx 1 root root       7 Apr  2 23:19 loop0p14 -> ../dm-1
lrwxrwxrwx 1 root root       7 Apr  2 23:19 loop0p15 -> ../dm-2
# mkdir -p /mnt/loop0p1
# mkdir -p /mnt/loop0p15
# mount -t auto /dev/mapper/loop0p1 /mnt/loop0p1
# mount -t auto /dev/mapper/loop0p15 /mnt/loop0p15
# mount |grep loop
/dev/loop0p1 on /mnt/loop0p1 type ext4 (rw,relatime)
/dev/loop0p15 on /mnt/loop0p15 type vfat (rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)
...hack...hack...hack
# umount /dev/mapper/loop0p1
# umount /dev/mapper/loop0p15
# kpartx -d disk.img</screen>
      </section>
      <section id="_cleaning_a_disk_image_file">
        <title>Cleaning a disk image file</title>
        <para>A disk image file, "<literal>disk.img</literal>" can be cleaned of all removed files into clean sparse image "<literal>new.img</literal>" by the following.</para>
        <screen># mkdir old; mkdir new
# mount -t auto -o loop disk.img old
# dd bs=1 count=0 if=/dev/zero of=new.img seek=5G
# mount -t auto -o loop new.img new
# cd old
# cp -a --sparse=always ./ ../new/
# cd ..
# umount new.img
# umount disk.img</screen>
        <para>If "<literal>disk.img</literal>" is in ext2, ext3 or ext4, you can also use <literal>zerofree</literal>(8) from the <literal>zerofree</literal> package as follows.</para>
        <screen># losetup --show -f disk.img
/dev/loop0
# zerofree /dev/loop0
# cp --sparse=always disk.img new.img
# losetup -d /dev/loop0</screen>
      </section>
      <section id="_making_the_empty_disk_image_file">
        <title>Making the empty disk image file</title>
        <para>The empty disk image "<literal>disk.img</literal>" which can grow up to 5GiB can be made using <literal>dd</literal>(1) as follows.</para>
        <screen>$ dd bs=1 count=0 if=/dev/zero of=disk.img seek=5G</screen>
        <para>Instead of using <literal>dd</literal>(1), specialized <literal>fallocate</literal>(8) may be used here.</para>
        <para>You can create an ext4 filesystem on this disk image "<literal>disk.img</literal>" using the <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink> as follows.</para>
        <screen># losetup --show -f disk.img
/dev/loop0
# mkfs.ext4 /dev/loop0
...hack...hack...hack
# losetup -d /dev/loop0
$ du  --apparent-size -h disk.img
5.0G  disk.img
$ du -h disk.img
83M disk.img</screen>
        <para>For "<literal>disk.img</literal>", its file size is 5.0 GiB and its actual disk usage is mere 83MiB.  This discrepancy is possible since <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> can hold <ulink url="https://en.wikipedia.org/wiki/Sparse_file">sparse file</ulink>.</para>
        <tip> <para>The actual disk usage of <ulink url="https://en.wikipedia.org/wiki/Sparse_file">sparse file</ulink> grows with data which are written to it.</para> </tip>
        <para>Using similar operation on devices created by the <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink> or the <ulink url="https://en.wikipedia.org/wiki/Device_mapper">device mapper</ulink> devices as  <xref linkend="_mounting_the_disk_image_file"/>, you can partition this disk image "<literal>disk.img</literal>" using <literal>parted</literal>(8) or <literal>fdisk</literal>(8), and can create filesystem on it using <literal>mkfs.ext4</literal>(8), <literal>mkswap</literal>(8), etc.</para>
      </section>
      <section id="_making_the_iso9660_image_file">
        <title>Making the ISO9660 image file</title>
        <para>The <ulink url="https://en.wikipedia.org/wiki/ISO_9660">ISO9660</ulink> image file, "<literal>cd.iso</literal>", from the source directory tree at "<literal>source_directory</literal>" can be made using <literal>genisoimage</literal>(1) provided by <ulink url="https://en.wikipedia.org/wiki/Cdrkit">cdrkit</ulink> by the following.</para>
        <screen>#  genisoimage -r -J -T -V volume_id -o cd.iso source_directory</screen>
        <para>Similarly, the bootable ISO9660 image file, "<literal>cdboot.iso</literal>", can be made from <literal>debian-installer</literal> like directory tree at "<literal>source_directory</literal>" by the following.</para>
        <screen>#  genisoimage -r -o cdboot.iso -V volume_id \
   -b isolinux/isolinux.bin -c isolinux/boot.cat \
   -no-emul-boot -boot-load-size 4 -boot-info-table source_directory</screen>
        <para>Here <ulink url="https://en.wikipedia.org/wiki/SYSLINUX">Isolinux boot loader</ulink> (see <xref linkend="_stage_2_the_boot_loader"/>) is used for booting.</para>
        <para>You can calculate the md5sum value and make the ISO9660 image directly from the CD-ROM device as follows.</para>
        <screen>$ isoinfo -d -i /dev/cdrom
CD-ROM is in ISO 9660 format
...
Logical block size is: 2048
Volume size is: 23150592
...
# dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror | md5sum
# dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror &gt; cd.iso</screen>
        <warning> <para>You must carefully avoid ISO9660 filesystem read ahead bug of Linux as above to get the right result.</para> </warning>
      </section>
      <section id="_writing_directly_to_the_cd_dvd_r_rw">
        <title>Writing directly to the CD/DVD-R/RW</title>
        <tip> <para>DVD is only a large CD to <literal>wodim</literal>(1) provided by <ulink url="https://en.wikipedia.org/wiki/Cdrkit">cdrkit</ulink>.</para> </tip>
        <para>You can find a usable device by the following.</para>
        <screen># wodim --devices</screen>
        <para>Then the blank CD-R is inserted to the CD drive, and the ISO9660 image file, "<literal>cd.iso</literal>" is written to this device, e.g., "<literal>/dev/hda</literal>", using <literal>wodim</literal>(1) by the following.</para>
        <screen># wodim -v -eject dev=/dev/hda cd.iso</screen>
        <para>If CD-RW is used instead of CD-R, do this instead by the following.</para>
        <screen># wodim -v -eject blank=fast dev=/dev/hda cd.iso</screen>
        <tip> <para>If your desktop system mounts CDs automatically, unmount it by "<literal>sudo umount /dev/hda</literal>" from console before using <literal>wodim</literal>(1).</para> </tip>
      </section>
      <section id="_mounting_the_iso9660_image_file">
        <title>Mounting the ISO9660 image file</title>
        <para>If "<literal>cd.iso</literal>" contains an ISO9660 image, then the following manually mounts it to "<literal>/cdrom</literal>".</para>
        <screen># mount -t iso9660 -o ro,loop cd.iso /cdrom</screen>
        <tip> <para>Modern desktop system may mount removable media such as ISO9660 formatted CD automatically (see <xref linkend="_removable_storage_device"/>).</para> </tip>
      </section>
    </section>
    <section id="_the_binary_data">
      <title>The binary data</title>
      <para>Here, we discuss direct manipulations of the binary data on storage media.</para>
      <section id="_viewing_and_editing_binary_data">
        <title>Viewing and editing binary data</title>
        <para>The most basic viewing method of binary data is to use "<literal>od -t x1</literal>" command.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of packages which view and edit binary data</title>
          <tgroup cols="4">
            <colspec colwidth="97pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="504pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>coreutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> basic package which has <literal>od</literal>(1) to dump files (HEX, ASCII, OCTAL, …) </entry>
              </row>
              <row>
                <entry> <literal>bsdmainutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility package which has <literal>hd</literal>(1) to dump files (HEX, ASCII, OCTAL, …) </entry>
              </row>
              <row>
                <entry> <literal>hexedit</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> binary editor and viewer (HEX, ASCII) </entry>
              </row>
              <row>
                <entry> <literal>bless</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> full featured hexadecimal editor (GNOME) </entry>
              </row>
              <row>
                <entry> <literal>okteta</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> full featured hexadecimal editor (KDE4) </entry>
              </row>
              <row>
                <entry> <literal>ncurses-hexedit</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> binary editor and viewer (HEX, ASCII, EBCDIC) </entry>
              </row>
              <row>
                <entry> <literal>beav</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> binary editor and viewer (HEX, ASCII, EBCDIC, OCTAL, …) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <tip> <para>HEX is used as an acronym for <ulink url="https://en.wikipedia.org/wiki/Hexadecimal">hexadecimal</ulink> format with <ulink url="https://en.wikipedia.org/wiki/Radix">radix</ulink> 16.  OCTAL is for <ulink url="https://en.wikipedia.org/wiki/Octal">octal</ulink> format with <ulink url="https://en.wikipedia.org/wiki/Radix">radix</ulink> 8.  ASCII is for <ulink url="https://en.wikipedia.org/wiki/ASCII">American Standard Code for Information Interchange</ulink>, i.e., normal English text code.  EBCDIC is for <ulink url="https://en.wikipedia.org/wiki/Extended_Binary_Coded_Decimal_Interchange_Code">Extended Binary Coded Decimal Interchange Code</ulink> used on <ulink url="https://en.wikipedia.org/wiki/IBM_mainframe">IBM mainframe</ulink> operating systems.</para> </tip>
      </section>
      <section id="_manipulating_files_without_mounting_disk">
        <title>Manipulating files without mounting disk</title>
        <para>There are tools to read and write files without mounting disk.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of packages to manipulate files without mounting disk</title>
          <tgroup cols="4">
            <colspec colwidth="59pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="304pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>mtools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for MSDOS files without mounting them </entry>
              </row>
              <row>
                <entry> <literal>hfsutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for HFS and HFS+ files without mounting them </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_data_redundancy">
        <title>Data redundancy</title>
        <para>Software <ulink url="https://en.wikipedia.org/wiki/RAID">RAID</ulink> systems offered by the Linux kernel provide data redundancy in the kernel filesystem level to achieve high levels of storage reliability.</para>
        <para>There are tools to add data redundancy to files in application program level to achieve high levels of storage reliability, too.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of tools to add data redundancy to files</title>
          <tgroup cols="4">
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="347pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>par2</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> Parity Archive Volume Set, for checking and repair of files </entry>
              </row>
              <row>
                <entry> <literal>dvdisaster</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> data loss/scratch/aging protection for CD/DVD media </entry>
              </row>
              <row>
                <entry> <literal>dvbackup</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> backup tool using MiniDV camcorders (providing <literal>rsbep</literal>(1)) </entry>
              </row>
<!--
              <row>
                <entry> <literal>vdmfec</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> recover lost blocks using Forward Error Correction </entry>
              </row>
-->
            </tbody>
          </tgroup>
        </table>
      </section>
      <section id="_data_file_recovery_and_forensic_analysis">
        <title>Data file recovery and forensic analysis</title>
        <para>There are tools for data file recovery and forensic analysis.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of packages for data file recovery and forensic analysis</title>
          <tgroup cols="4">
            <colspec colwidth="86pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="304pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>testdisk</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utilities for partition scan and disk recovery </entry>
              </row>
              <row>
                <entry> <literal>magicrescue</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility to recover files by looking for magic bytes </entry>
              </row>
              <row>
                <entry> <literal>scalpel</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> frugal, high performance file carver </entry>
              </row>
              <row>
                <entry> <literal>myrescue</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> rescue data from damaged harddisks </entry>
              </row>
              <row>
                <entry> <literal>extundelete</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility to undelete files on the ext3/4 filesystem </entry>
              </row>
              <row>
                <entry> <literal>ext4magic</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> utility to undelete files on the ext3/4 filesystem </entry>
              </row>
              <row>
                <entry> <literal>ext3grep</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> tool to help recover deleted files on the ext3 filesystem </entry>
              </row>
              <row>
                <entry> <literal>scrounge-ntfs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> data recovery program for NTFS filesystems </entry>
              </row>
              <row>
                <entry> <literal>gzrt</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> gzip recovery toolkit </entry>
              </row>
              <row>
                <entry> <literal>sleuthkit</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> tools for forensics analysis. (Sleuthkit) </entry>
              </row>
              <row>
                <entry> <literal>autopsy</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> graphical interface to SleuthKit </entry>
              </row>
              <row>
                <entry> <literal>foremost</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> forensics application to recover data </entry>
              </row>
              <row>
                <entry> <literal>guymager</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> forensic imaging tool based on Qt </entry>
              </row>
              <row>
                <entry> <literal>dcfldd</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> enhanced version of <literal>dd</literal> for forensics and security </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <tip> <para>You can undelete files on the ext2 filesystem using <literal>list_deleted_inodes</literal> and <literal>undel</literal> commands of <literal>debugfs</literal>(8) in the <literal>e2fsprogs</literal> package.</para> </tip>
      </section>
      <section id="_splitting_a_large_file_into_small_files">
        <title>Splitting a large file into small files</title>
        <para>When a data is too big to backup as a single file, you can backup its content after splitting it into, e.g. 2000MiB chunks and merge those chunks back into the original file later.</para>
        <screen>$ split -b 2000m large_file
$ cat x* &gt;large_file</screen>
        <caution> <para>Please make sure you do not have any files starting with "<literal>x</literal>" to avoid name crashes.</para> </caution>
      </section>
      <section id="_clearing_file_contents">
        <title>Clearing file contents</title>
        <para>In order to clear the contents of a file such as a log file, do not use <literal>rm</literal>(1) to delete the file and then create a new empty file, because the file may still be accessed in the interval between commands.  The following is the safe way to clear the contents of the file.</para>
        <screen>$ :&gt;file_to_be_cleared</screen>
      </section>
      <section id="_dummy_files">
        <title>Dummy files</title>
        <para>The following commands create dummy or empty files.</para>
        <screen>$ dd if=/dev/zero    of=5kb.file bs=1k count=5
$ dd if=/dev/urandom of=7mb.file bs=1M count=7
$ touch zero.file
$ : &gt; alwayszero.file</screen>
        <para>You should find following files.</para>
        <itemizedlist>
          <listitem> <para> "<literal>5kb.file</literal>" is 5KB of zeros.  </para> </listitem>
          <listitem> <para> "<literal>7mb.file</literal>" is 7MB of random data.  </para> </listitem>
          <listitem> <para> "<literal>zero.file</literal>" may be a 0 byte file.  If it existed, its <literal>mtime</literal> is updated while its content and its length are kept.  </para> </listitem>
          <listitem> <para> "<literal>alwayszero.file</literal>" is always a 0 byte file.  If it existed, its <literal>mtime</literal> is updated and its content is reset.  </para> </listitem>
        </itemizedlist>
      </section>
      <section id="_erasing_an_entire_hard_disk">
        <title>Erasing an entire hard disk</title>
        <para>There are several ways to completely erase data from an entire hard disk like device, e.g., USB memory stick at "<literal>/dev/sda</literal>".</para>
        <caution> <para>Check your USB memory stick location with <literal>mount</literal>(8) first before executing commands here.  The device pointed by "<literal>/dev/sda</literal>" may be SCSI hard disk or serial-ATA hard disk where your entire system resides.</para> </caution>
        <para>Erase all the disk content by resetting data to 0 with the following.</para>
        <screen># dd if=/dev/zero of=/dev/sda</screen>
        <para>Erase everything by overwriting with random data as follows.</para>
        <screen># dd if=/dev/urandom of=/dev/sda</screen>
        <para>Erase everything by overwriting with random data very efficiently as follows.</para>
        <screen># shred -v -n 1 /dev/sda</screen>
        <para>You may alternatively use <literal>badblocks</literal>(8) with <literal>-t random</literal> option.</para>
        <para>Since <literal>dd</literal>(1) is available from the shell of many bootable Linux CDs such as Debian installer CD, you can erase your installed system completely by running an erase command from such media on the system hard disk, e.g., "<literal>/dev/hda</literal>", "<literal>/dev/sda</literal>", etc.</para>
      </section>
      <section id="_erasing_unused_area_of_an_hard_disk">
        <title>Erasing unused area of an hard disk</title>
        <para>Unused area on an hard disk (or USB memory stick), e.g. "<literal>/dev/sdb1</literal>" may still contain erased data themselves since they are only unlinked from the filesystem.  These can be cleaned by overwriting them.</para>
        <screen># mount -t auto /dev/sdb1 /mnt/foo
# cd /mnt/foo
# dd if=/dev/zero of=junk
dd: writing to `junk': No space left on device
...
# sync
# umount /dev/sdb1</screen>
        <warning>
          <para>This is usually good enough for your USB memory stick.  But this is not perfect.  Most parts of erased filenames and their attributes may be hidden and remain in the filesystem.</para>
        </warning>
      </section>
      <section id="_undeleting_deleted_but_still_open_files">
        <title>Undeleting deleted but still open files</title>
        <para>Even if you have accidentally deleted a file, as long as that file is still being used by some application (read or write mode), it is possible to recover such a file.</para>
        <para>For example, try the following</para>
        <screen>$ echo foo &gt; bar
$ less bar
$ ps aux | grep ' less[ ]'
bozo    4775  0.0  0.0  92200   884 pts/8    S+   00:18   0:00 less bar
$ rm bar
$ ls -l /proc/4775/fd | grep bar
lr-x------ 1 bozo bozo 64 2008-05-09 00:19 4 -&gt; /home/bozo/bar (deleted)
$ cat /proc/4775/fd/4 &gt;bar
$ ls -l
-rw-r--r-- 1 bozo bozo 4 2008-05-09 00:25 bar
$ cat bar
foo</screen>
        <para>Execute on another terminal (when you have the <literal>lsof</literal> package installed) as follows.</para>
        <screen>$ ls -li bar
2228329 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:02 bar
$ lsof |grep bar|grep less
less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar
$ rm bar
$ lsof |grep bar|grep less
less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar (deleted)
$ cat /proc/4775/fd/4 &gt;bar
$ ls -li bar
2228302 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:05 bar
$ cat bar
foo</screen>
      </section>
      <section id="_searching_all_hardlinks">
        <title>Searching all hardlinks</title>
        <para>Files with hardlinks can be identified by "<literal>ls -li</literal>".</para>
        <screen>$ ls -li
total 0
2738405 -rw-r--r-- 1 root root 0 2008-09-15 20:21 bar
2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 baz
2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 foo</screen>
        <para>Both "<literal>baz</literal>" and "<literal>foo</literal>" have link counts of "2" (&gt;1) showing them to have hardlinks.  Their <ulink url="https://en.wikipedia.org/wiki/Inode">inode</ulink> numbers are common "2738404".  This means they are the same hardlinked file.  If you do not happen to find all hardlinked files by chance, you can search it by the <ulink url="https://en.wikipedia.org/wiki/Inode">inode</ulink>, e.g., "2738404" as the following.</para>
        <screen># find /path/to/mount/point -xdev -inum 2738404</screen>
      </section>
      <section id="_invisible_disk_space_consumption">
        <title>Invisible disk space consumption</title>
        <para>All deleted but open files consume disk space although they are not visible from normal <literal>du</literal>(1).  They can be listed with their size by the following.</para>
        <screen># lsof -s -X / |grep deleted</screen>
      </section>
    </section>
    <section id="_data_encryption_tips">
      <title>Data encryption tips</title>
      <para>With physical access to your PC, anyone can easily gain root privilege and access all the files on your PC (see <xref linkend="_securing_the_root_password"/>).  This means that login password system can not secure your private and sensitive data against possible theft of your PC.  You must deploy data encryption technology to do it.  Although <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU privacy guard</ulink> (see <xref linkend="_data_security_infrastructure"/>) can encrypt files, it takes some user efforts.</para>
      <para><ulink url="https://en.wikipedia.org/wiki/Dm-crypt">Dm-crypt</ulink> facilitates automatic data encryption via native Linux kernel modules with minimal user efforts using <ulink url="https://en.wikipedia.org/wiki/Device_mapper">device-mapper</ulink>.</para>
      <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
        <title>List of data encryption utilities</title>
        <tgroup cols="4">
          <colspec colwidth="92pt" align="left"/>
          <colspec colwidth="76pt" align="left"/>
          <colspec colwidth="70pt" align="left"/>
          <colspec colwidth="510pt" align="left"/>
          <thead>
            <row>
              <entry> package </entry>
              <entry> popcon </entry>
              <entry> size </entry>
              <entry> description </entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry> <literal>cryptsetup</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> utilities for encrypted block device (<ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink> / <ulink url="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</ulink>) </entry>
            </row>
            <row>
              <entry> <literal>cryptmount</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> utilities for encrypted block device (<ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink> / <ulink url="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</ulink>) with focus on mount/unmount by normal users </entry>
            </row>
            <row>
              <entry> <literal>fscrypt</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> utilities for Linux filesystem encryption (<ulink url="https://www.kernel.org/doc/html/latest/filesystems/fscrypt.html">fscrypt</ulink>) </entry>
            </row>
            <row>
              <entry> <literal>libpam-fscrypt</literal> </entry>
              <entry> @-@popcon1@-@ </entry>
              <entry> @-@psize1@-@ </entry>
              <entry> PAM module for Linux filesystem encryption (<ulink url="https://www.kernel.org/doc/html/latest/filesystems/fscrypt.html">fscrypt</ulink>) </entry>
            </row>
          </tbody>
        </tgroup>
      </table>
      <caution> <para>Data encryption costs CPU time etc.  Encrypted data becomes inaccessible if its password is lost.  Please weigh its benefits and costs.</para> </caution>
      <note> <para>Entire Debian system can be installed on a encrypted disk by the <ulink url="https://www.debian.org/devel/debian-installer/">debian-installer</ulink> (lenny or newer) using <ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink>/<ulink url="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</ulink> and initramfs.</para> </note>
      <tip> <para>See <xref linkend="_data_security_infrastructure"/> for user space encryption utility: <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard</ulink>.</para> </tip>
      <section id="_removable_disk_encryption_with_dm_crypt_luks">
        <title>Removable disk encryption with dm-crypt/LUKS</title>
        <para>You can encrypt contents of removable mass devices, e.g. USB memory stick on "<literal>/dev/sdx</literal>", using <ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink>/<ulink url="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</ulink>.  You simply format it as the following.</para>
        <screen># fdisk /dev/sdx
... "n" "p" "1" "return" "return" "w"
# cryptsetup luksFormat /dev/sdx1
...
# cryptsetup open /dev/sdx1 secret
...
# ls -l /dev/mapper/
total 0
crw-rw---- 1 root root  10, 60 2021-10-04 18:44 control
lrwxrwxrwx 1 root root       7 2021-10-04 23:55 secret -> ../dm-0
# mkfs.vfat /dev/mapper/secret
...
# cryptsetup close secret</screen>
        <para>Then, it can be mounted just like normal one on to "<literal>/media/<emphasis>username/disk_label</emphasis></literal>", except for asking password (see <xref linkend="_removable_storage_device"/>) under modern desktop environment using the <literal>udisks2</literal> package.  The difference is that every data written to it is encrypted.  The password entry may be automated using keyring (see <xref linkend="_password_keyring"/>).</para>
        <para>You may alternatively format media in different filesystem, e.g., ext4 with "<literal>mkfs.ext4 /dev/mapper/sdx1</literal>".  If btrfs is used instead, the <literal>udisks2-btrfs</literal> package needs to be installed.  For these filesystems, the file ownership and permissions may need to be configured.</para>
      </section>
      <section id="_mounting_encrypted_disk_with_dm_crypt_luks">
        <title>Mounting encrypted disk with dm-crypt/LUKS</title>
        <para>For example, an encrypted disk partition created with dm-crypt/LUKS on "<literal>/dev/sdc5</literal>" by Debian Installer can be mounted onto "<literal>/mnt</literal>" as follows:</para>
        <screen>$ sudo cryptsetup open /dev/sdc5 ninja --type luks
Enter passphrase for /dev/sdc5: ****
$ sudo lvm
lvm&gt; lvscan
  inactive          '/dev/ninja-vg/root' [13.52 GiB] inherit
  inactive          '/dev/ninja-vg/swap_1' [640.00 MiB] inherit
  ACTIVE            '/dev/goofy/root' [180.00 GiB] inherit
  ACTIVE            '/dev/goofy/swap' [9.70 GiB] inherit
lvm&gt; lvchange -a y /dev/ninja-vg/root
lvm&gt; exit
  Exiting.
$ sudo mount /dev/ninja-vg/root /mnt</screen>
      </section>
    </section>
    <section id="_the_kernel">
      <title>The kernel</title>
      <para>Debian distributes modularized <ulink url="https://en.wikipedia.org/wiki/Linux_kernel">Linux kernel</ulink> as packages for supported architectures.</para>
      <para>If you are reading this documentation, you probably don't need to compile Linux kernel by yourself.</para>
      <section id="_kernel_parameters">
        <title>Kernel parameters</title>
        <para>Many Linux features are configurable via kernel parameters as follows.</para>
        <itemizedlist>
          <listitem> <para> Kernel parameters initialized by the bootloader (see <xref linkend="_stage_2_the_boot_loader"/>) </para> </listitem>
          <listitem> <para> Kernel parameters changed by <literal>sysctl</literal>(8) at runtime for ones accessible via sysfs (see <xref linkend="_procfs_and_sysfs"/>) </para> </listitem>
          <listitem> <para> Module parameters set by arguments of <literal>modprobe</literal>(8) when a module is activated (see <xref linkend="_mounting_the_disk_image_file"/>) </para> </listitem>
        </itemizedlist>
        <para>See "<ulink url="https://www.kernel.org/doc/html/latest/admin-guide/index.html">The Linux kernel user’s and administrator’s guide</ulink> » <ulink url="https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html">The kernel’s command-line parameters</ulink>" for the detail.</para>
      </section>
      <section id="_kernel_headers">
        <title>Kernel headers</title>
        <para>Most <emphasis role="strong">normal programs</emphasis> don't need kernel headers and in fact may break if you use them directly for compiling. They should be compiled against the headers in "<literal>/usr/include/linux</literal>" and "<literal>/usr/include/asm</literal>" provided by the <literal>libc6-dev</literal> package (created from the <literal>glibc</literal> source package) on the Debian system.</para>
        <note> <para>For compiling some kernel-specific programs such as the kernel modules from the external source and the automounter daemon (<literal>amd</literal>), you must include path to the corresponding kernel headers, e.g. "<literal>-I/usr/src/linux-particular-version/include/</literal>", to your command line. </para> </note>
      </section>
      <section id="_compiling_the_kernel_and_related_modules">
        <title>Compiling the kernel and related modules</title>
        <para>Debian has its own method of compiling the kernel and related modules.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of key packages to be installed for the kernel recompilation on the Debian system</title>
          <tgroup cols="4">
            <colspec colwidth="108pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="418pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>build-essential</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> essential packages for building Debian packages: <literal>make</literal>, <literal>gcc</literal>, … </entry>
              </row>
              <row>
                <entry> <literal>bzip2</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> compress and decompress utilities for bz2 files </entry>
              </row>
              <row>
                <entry> <literal>libncurses5-dev</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> developer's libraries and docs for ncurses </entry>
              </row>
              <row>
                <entry> <literal>git</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> git: distributed revision control system used by the Linux kernel </entry>
              </row>
              <row>
                <entry> <literal>fakeroot</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> provide fakeroot environment for building package as non-root </entry>
              </row>
              <row>
                <entry> <literal>initramfs-tools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> tool to build an initramfs (Debian specific) </entry>
              </row>
              <row>
                <entry> <literal>dkms</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support">dynamic kernel module support (DKMS)</ulink> (generic) </entry>
              </row>
              <row>
                <entry> <literal>module-assistant</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> helper tool to make module package (Debian specific) </entry>
              </row>
              <row>
                <entry> <literal>devscripts</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> helper scripts for a Debian Package maintainer (Debian specific) </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>If you use <literal>initrd</literal> in <xref linkend="_stage_2_the_boot_loader"/>, make sure to read the related information in <literal>initramfs-tools</literal>(8), <literal>update-initramfs</literal>(8), <literal>mkinitramfs</literal>(8) and <literal>initramfs.conf</literal>(5).</para>
        <warning> <para>Do not put symlinks to the directories in the source tree (e.g. "<literal>/usr/src/linux*</literal>") from "<literal>/usr/include/linux</literal>" and "<literal>/usr/include/asm</literal>" when compiling the Linux kernel source. (Some outdated documents suggest this.)</para> </warning>
        <note>
         <para>When compiling the latest Linux kernel on the Debian <literal>stable</literal> system, the use of backported latest tools from the Debian <literal>unstable</literal> may be needed.</para>
         <para> <literal>module-assistant</literal>(8) (or its short form <literal>m-a</literal>) helps users to build and install module package(s) easily for one or more custom kernels.</para>
         <para>The <ulink url="https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support">dynamic kernel module support (DKMS)</ulink> is a new distribution independent framework designed to allow individual kernel modules to be upgraded without changing the whole kernel. This is used for the maintenance of out-of-tree modules.  This also makes it very easy to rebuild modules as you upgrade kernels.</para>
        </note>
      </section>
      <section id="_compiling_the_kernel_source_debian_kernel_team_recommendation">
        <title>Compiling the kernel source: Debian Kernel Team recommendation</title>
        <para>For building custom kernel binary packages from the upstream kernel source, you should use the "<literal>deb-pkg</literal>" target provided by it.</para>
        <screen>$ sudo apt-get build-dep linux
$ cd /usr/src
$ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-<emphasis>version</emphasis>.tar.xz
$ tar --xz -xvf linux-<emphasis>version</emphasis>.tar.xz
$ cd linux-<emphasis>version</emphasis>
$ cp /boot/config-<emphasis>version</emphasis> .config
$ make menuconfig
 ...
$ make deb-pkg</screen>
        <tip> <para>The linux-source-<emphasis>version</emphasis> package provides the Linux kernel source with Debian patches as "<literal>/usr/src/linux-<emphasis>version</emphasis>.tar.bz2</literal>".</para> </tip>
        <para>For building specific binary packages from the Debian kernel source package, you should use the "<literal>binary-arch_<emphasis>architecture</emphasis>_<emphasis>featureset</emphasis>_<emphasis>flavour</emphasis></literal>" targets in "<literal>debian/rules.gen</literal>".</para>
        <screen>$ sudo apt-get build-dep linux
$ apt-get source linux
$ cd linux-3.*
$ fakeroot make -f debian/rules.gen binary-arch_i386_none_686</screen>
        <para>See further information:</para>
        <itemizedlist>
          <listitem> <para> Debian Wiki: <ulink url="https://wiki.debian.org/KernelFAQ">KernelFAQ</ulink> </para> </listitem>
          <listitem> <para> Debian Wiki: <ulink url="https://wiki.debian.org/DebianKernel">DebianKernel</ulink> </para> </listitem>
          <listitem> <para> Debian Linux Kernel Handbook: <ulink url="https://kernel-team.pages.debian.net/kernel-handbook/">https://kernel-handbook.debian.net</ulink> </para> </listitem>
        </itemizedlist>
      </section>
      <section id="_hardware_drivers_and_firmware">
        <title>Hardware drivers and firmware</title>
        <para>The hardware driver is the code running on the main CPUs of the target system. Most hardware drivers are available as free software now and are included in the normal Debian kernel packages in the <literal>main</literal> area.</para>
        <itemizedlist>
          <listitem>
            <para><ulink url="https://en.wikipedia.org/wiki/Graphics_processing_unit">GPU</ulink> driver </para>
            <itemizedlist>
              <listitem> <para> Intel GPU driver (<literal>main</literal>) </para> </listitem>
              <listitem> <para> AMD/ATI GPU driver (<literal>main</literal>) </para> </listitem>
              <listitem> <para> NVIDIA GPU driver (<literal>main</literal> for <ulink url="https://en.wikipedia.org/wiki/Nouveau_(software)">nouveau</ulink> driver, and <literal>non-free</literal> for binary-only drivers supported by the vendor.) </para>
              </listitem>
            </itemizedlist>
          </listitem>
        </itemizedlist>
        <para>The firmware is the code or data loaded on the device attach to the target system (e.g., CPU <ulink url="https://en.wikipedia.org/wiki/Microcode">microcode</ulink>, rendering code running on GPU, or <ulink url="https://en.wikipedia.org/wiki/FPGA">FPGA</ulink> / <ulink url="https://en.wikipedia.org/wiki/Complex_programmable_logic_device">CPLD</ulink> data, …).  Some firmware packages are available as free software but many firmware packages are not available as free software since they contain sourceless binary data.  Installing these firmware data is essential for the device to function as expected.</para>
        <itemizedlist>
          <listitem>
            <para>The firmware data packages containing data loaded to the volatile memory on the target device.</para>
            <itemizedlist>
              <listitem> <para> firmware-linux-free (<literal>main</literal>) </para> </listitem>
              <listitem> <para> firmware-linux-nonfree (<literal>non-free-firmware</literal>) </para> </listitem>
              <listitem> <para> firmware-linux-* (<literal>non-free-firmware</literal>) </para> </listitem>
              <listitem> <para> *-firmware (<literal>non-free-firmware</literal>) </para> </listitem>
              <listitem> <para> intel-microcode (<literal>non-free-firmware</literal>) </para> </listitem>
              <listitem> <para> amd64-microcode (<literal>non-free-firmware</literal>) </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para>The firmware update program packages which update data on the non-volatile memory on the target device.</para>
            <itemizedlist>
              <listitem> <para> <ulink url="https://en.wikipedia.org/wiki/Fwupd">fwupd</ulink> (<literal>main</literal>): Firmware update daemon which downloads firmware data from <ulink url="https://fwupd.org/">Linux Vendor Firmware Service</ulink>.</para> </listitem>
              <listitem> <para> gnome-firmware (<literal>main</literal>): GTK front end for fwupd </para> </listitem>
              <listitem> <para> plasma-discover-backend-fwupd  (<literal>main</literal>): Qt front end for fwupd </para> </listitem>
            </itemizedlist>
          </listitem>
        </itemizedlist>
        <para>Please note that access to <literal>non-free-firmware</literal> packages are provided by the official installation media to offer functional installation experience to the user since Debian 12 Bookworm.  The <literal>non-free-firmware</literal> area is described in <xref linkend="_debian_archive_basics"/>.</para>
        <para>Please also note that the firmware data downloaded by <ulink url="https://en.wikipedia.org/wiki/Fwupd">fwupd</ulink> from <ulink url="https://fwupd.org/">Linux Vendor Firmware Service</ulink> and loaded to the running Linux kernel may be <literal>non-free</literal>.</para>
      </section>
    </section>
    <section id="_virtualized_system">
      <title>Virtualized system</title>
      <para>Use of virtualized system enables us to run multiple instances of system simultaneously on a single hardware.</para>
      <tip> <para>See <ulink url="https://wiki.debian.org/SystemVirtualization">Debian wiki on SystemVirtualization</ulink>.</para> </tip>
      <section id="_virtualization_tools">
        <title>Virtualization and emulation tools</title>
        <para>There are several <ulink url="https://en.wikipedia.org/wiki/Virtualization">virtualization</ulink> and emulation tool platforms.</para>
        <itemizedlist>
          <listitem> <para> Complete <ulink url="https://en.wikipedia.org/wiki/Hardware_emulation">hardware emulation</ulink> packages such as ones installed by the <ulink url="https://packages.debian.org/sid/games-emulator">games-emulator</ulink> metapackage</para> </listitem>
          <listitem> <para> Mostly CPU level emulation with some I/O device emulations such as <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> </para> </listitem>
          <listitem> <para> Mostly CPU level virtualization with some I/O device emulations such as <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">Kernel-based Virtual Machine (KVM)</ulink> </para> </listitem>
          <listitem> <para> OS level container virtualization with the kernel level support such as <ulink url="https://en.wikipedia.org/wiki/LXC">LXC (Linux Containers)</ulink>, <ulink url="https://en.wikipedia.org/wiki/Docker_(software)">Docker</ulink>, <literal>systemd-nspawn</literal>(1), ... </para> </listitem>
          <listitem> <para> OS level filesystem access virtualization with the system library call override on the file path such as <ulink url="https://en.wikipedia.org/wiki/Chroot">chroot</ulink> </para> </listitem>
          <listitem> <para> OS level filesystem access virtualization with the system library call override on the file ownership such as <ulink url="https://en.wikipedia.org/wiki/">fakeroot</ulink> </para> </listitem>
          <listitem> <para> OS API emulation such as <ulink url="https://en.wikipedia.org/wiki/Wine_(software)">Wine</ulink> </para> </listitem>
          <listitem> <para> Interpreter level virtualization with its executable selection and run-time library overrides such as <ulink url="https://virtualenv.pypa.io/">virtualenv</ulink> and <ulink url="https://docs.python.org/3/library/venv.html">venv</ulink> for Python </para> </listitem>
        </itemizedlist>
        <para>The container virtualization uses <xref linkend="_linux_security_features"/> and is the backend technology of <xref linkend="_sandbox"/>.</para>
        <para>Here are some packages to help you to setup the virtualized system.</para>
        <table pgwide="0" frame="topbot" rowsep="1" colsep="1">
          <title>List of virtualization tools</title>
          <tgroup cols="4">
            <colspec colwidth="97pt" align="left"/>
            <colspec colwidth="76pt" align="left"/>
            <colspec colwidth="70pt" align="left"/>
            <colspec colwidth="504pt" align="left"/>
            <thead>
              <row>
                <entry> package </entry>
                <entry> popcon </entry>
                <entry> size </entry>
                <entry> description </entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry> <literal>coreutils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> GNU core utilities which contain <literal>chroot</literal>(8) </entry>
              </row>
              <row>
                <entry> <literal>systemd-container</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> systemd container/nspawn tools which contain <literal>systemd-nspawn</literal>(1) </entry>
              </row>
              <row>
                <entry> <literal>schroot</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> specialized tool for executing Debian binary packages in chroot </entry>
              </row>
              <row>
                <entry> <literal>sbuild</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> tool for building Debian binary packages from Debian sources </entry>
              </row>
<!--
              <row>
                <entry> <literal>pbuilder</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> personal package builder for Debian packages </entry>
              </row>
-->
              <row>
                <entry> <literal>debootstrap</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> bootstrap a basic Debian system (written in sh) </entry>
              </row>
              <row>
                <entry> <literal>cdebootstrap</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> bootstrap a Debian system (written in C) </entry>
              </row>
              <row>
                <entry> <literal>cloud-image-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> cloud image management utilities </entry>
              </row>
              <row>
                <entry> <literal>cloud-guest-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> cloud guest utilities </entry>
              </row>
              <row>
                <entry> <literal>virt-manager</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Virt-manager">Virtual Machine Manager</ulink>: desktop application for managing virtual machines </entry>
              </row>
              <row>
                <entry> <literal>libvirt-clients</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> programs for the <ulink url="https://en.wikipedia.org/wiki/Libvirt">libvirt</ulink> library </entry>
              </row>
              <row>
                <entry> <literal>incus</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://wiki.debian.org/Incus">Incus</ulink>: system container and virtual machine manager (for Debian 13 "Trixie") </entry>
              </row>
              <row>
                <entry> <literal>lxd</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://wiki.debian.org/LXD">LXD</ulink>: system container and virtual machine manager (for Debian 12 "Bookworm") </entry>
              </row>
              <row>
                <entry> <literal>podman</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://podman.io/">podman</ulink>: engine to run OCI-based containers in Pods </entry>
              </row>
              <row>
                <entry> <literal>podman-docker</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> engine to run OCI-based containers in Pods - wrapper for docker </entry>
              </row>
              <row>
                <entry> <literal>docker.io</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Docker_(software)">docker</ulink>: Linux container runtime </entry>
              </row>
              <row>
                <entry> <literal>games-emulator</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://packages.debian.org/sid/games-emulator">games-emulator</ulink>: Debian's emulators for games </entry>
              </row>
              <row>
                <entry> <literal>bochs</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/Bochs">Bochs</ulink>: IA-32 PC emulator </entry>
              </row>
              <row>
                <entry> <literal>qemu</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>: fast generic processor emulator </entry>
              </row>
              <row>
                <entry> <literal>qemu-system</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>: full system emulation binaries </entry>
              </row>
              <row>
                <entry> <literal>qemu-user</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>: user mode emulation binaries </entry>
              </row>
              <row>
                <entry> <literal>qemu-utils</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>: utilities </entry>
              </row>
              <row>
                <entry> <literal>qemu-system-x86</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</ulink>: full virtualization on x86 hardware with the <ulink url="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</ulink> </entry>
              </row>
              <row>
                <entry> <literal>virtualbox</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/VirtualBox">VirtualBox</ulink>: x86 virtualization solution on i386 and amd64 </entry>
              </row>
              <row>
                <entry> <literal>gnome-boxes</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://wiki.gnome.org/Apps/Boxes">Boxes</ulink>: Simple GNOME app to access virtual systems </entry>
              </row>
              <row>
                <entry> <literal>xen-tools</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> tools to manage debian <ulink url="https://en.wikipedia.org/wiki/Xen">XEN</ulink> virtual server </entry>
              </row>
              <row>
                <entry> <literal>wine</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/Wine_(software)">Wine</ulink>: Windows API Implementation (standard suite) </entry>
              </row>
              <row>
                <entry> <literal>dosbox</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/DOSBox">DOSBox</ulink>: x86 emulator with Tandy/Herc/CGA/EGA/VGA/SVGA graphics, sound and DOS </entry>
              </row>
<!--
              <row>
                <entry> <literal></literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry>  </entry>
              </row>
              <row>
                <entry> <literal>dosemu</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/DOSEMU">DOSEMU</ulink>: The Linux DOS Emulator </entry>
              </row>
              <row>
                <entry> <literal>vzctl</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/OpenVZ">OpenVZ</ulink> server virtualization solution - control tools </entry>
              </row>
              <row>
                <entry> <literal>vzquota</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry><ulink url="https://en.wikipedia.org/wiki/OpenVZ">OpenVZ</ulink> server virtualization solution - quota tools </entry>
              </row>
-->
              <row>
                <entry> <literal>lxc</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://en.wikipedia.org/wiki/LXC">Linux containers user space tools</ulink> </entry>
              </row>
              <row>
                <entry> <literal>python3-venv</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://docs.python.org/3/library/venv.html">venv</ulink> for creating virtual python environments (system library) </entry>
              </row>
              <row>
                <entry> <literal>python3-virtualenv</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://virtualenv.pypa.io/">virtualenv</ulink> for creating isolated virtual python environments </entry>
              </row>
              <row>
                <entry> <literal>pipx</literal> </entry>
                <entry> @-@popcon1@-@ </entry>
                <entry> @-@psize1@-@ </entry>
                <entry> <ulink url="https://pipx.pypa.io/">pipx</ulink> for installing python applications in isolated environments </entry>
              </row>
            </tbody>
          </tgroup>
        </table>
        <para>See Wikipedia article <ulink url="https://en.wikipedia.org/wiki/Comparison_of_platform_virtual_machines">Comparison of platform virtual machines</ulink> for detail comparison of different platform virtualization solutions.</para>
      </section>
      <section id="_virtualization_work_flow">
        <title>Virtualization work flow</title>
        <note> <para>Default Debian kernels support <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</ulink> since <literal>lenny</literal>.</para> </note>
        <para>Typical work flow for <ulink url="https://en.wikipedia.org/wiki/Virtualization">virtualization</ulink> involves several steps.</para>
        <itemizedlist>
          <listitem>
            <para> Create an empty filesystem (a file tree or a disk image).  </para>
            <itemizedlist>
              <listitem> <para> The file tree can be created by "<literal>mkdir -p /path/to/chroot</literal>".  </para> </listitem>
              <listitem> <para> The raw disk image file can be created with <literal>dd</literal>(1) (see <xref linkend="_making_the_disk_image_file"/> and <xref linkend="_making_the_empty_disk_image_file"/>).  </para> </listitem>
              <listitem> <para><literal>qemu-img</literal>(1) can be used to create and convert disk image files supported by <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>.  </para> </listitem>
              <listitem> <para> The raw and <ulink url="https://en.wikipedia.org/wiki/VMDK">VMDK</ulink> file format can be used as common format among virtualization tools. </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Mount the disk image with <literal>mount</literal>(8) to the filesystem (optional).  </para>
            <itemizedlist>
              <listitem> <para> For the raw disk image file, mount it as <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink> or <ulink url="https://en.wikipedia.org/wiki/Device_mapper">device mapper</ulink> devices (see <xref linkend="_mounting_the_disk_image_file"/>).  </para> </listitem>
              <listitem> <para> For disk images supported by <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>, mount them as <ulink url="https://en.wikipedia.org/wiki/Network_block_device">network block device</ulink> (see <xref linkend="_mounting_the_virtual_disk_image_file"/>).  </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Populate the target filesystem with required system data.  </para>
            <itemizedlist>
              <listitem> <para> The use of programs such as <literal>debootstrap</literal> and <literal>cdebootstrap</literal> helps with this process (see <xref linkend="_chroot_system"/>).  </para> </listitem>
              <listitem> <para> Use installers of OSs under the full system emulation.  </para> </listitem>
            </itemizedlist>
          </listitem>
          <listitem>
            <para> Run a program under a virtualized environment.  </para>
            <itemizedlist>
              <listitem> <para><ulink url="https://en.wikipedia.org/wiki/Chroot">chroot</ulink> provides basic virtualized environment enough to compile programs, run console applications, and run daemons in it.  </para> </listitem>
              <listitem> <para><ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> provides cross-platform CPU emulation.  </para> </listitem>
              <listitem> <para><ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> with <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</ulink> provides full system emulation by the <ulink url="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</ulink>.  </para> </listitem>
              <listitem> <para><ulink url="https://en.wikipedia.org/wiki/VirtualBox">VirtualBox</ulink> provides full system emulation on i386 and amd64 with or without the <ulink url="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</ulink>.  </para> </listitem>
            </itemizedlist>
          </listitem>
        </itemizedlist>
      </section>
      <section id="_mounting_the_virtual_disk_image_file">
        <title>Mounting the virtual disk image file</title>
        <para>For the raw disk image file, see <xref linkend="_the_disk_image"/>.</para>
        <para>For other virtual disk image files, you can use <literal>qemu-nbd</literal>(8) to export them using <ulink url="https://en.wikipedia.org/wiki/Network_block_device">network block device</ulink> protocol and mount them using the <literal>nbd</literal> kernel module.</para>
        <para><literal>qemu-nbd</literal>(8) supports disk formats supported by <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink>: raw, <ulink url="https://en.wikipedia.org/wiki/Qcow">qcow2, qcow</ulink>, <ulink url="https://en.wikipedia.org/wiki/VMDK">vmdk</ulink>, <ulink url="https://en.wikipedia.org/wiki/VirtualBox#Virtual_Desktop_Image">vdi</ulink>, <ulink url="https://en.wikipedia.org/wiki/Bochs">bochs</ulink>, cow (user-mode Linux copy-on-write), <ulink url="https://en.wikipedia.org/wiki/Parallels_Workstation">parallels</ulink>, <ulink url="https://en.wikipedia.org/wiki/Apple_Disk_Image">dmg</ulink>, <ulink url="https://en.wikipedia.org/wiki/Cloop">cloop</ulink>, <ulink url="https://en.wikipedia.org/wiki/VHD_(file_format)">vpc</ulink>, vvfat (virtual VFAT), and host_device.</para>
        <para>The <ulink url="https://en.wikipedia.org/wiki/Network_block_device">network block device</ulink> can support partitions in the same way as the <ulink url="https://en.wikipedia.org/wiki/Loop_device">loop device</ulink> (see <xref linkend="_mounting_the_disk_image_file"/>).  You can mount the first partition of "<literal>disk.img</literal>" as follows.</para>
        <screen># modprobe nbd max_part=16
# qemu-nbd -v -c /dev/nbd0 disk.img
...
# mkdir /mnt/part1
# mount /dev/nbd0p1 /mnt/part1</screen>
        <tip> <para>You may export only the first partition of "<literal>disk.img</literal>" using "<literal>-P 1</literal>" option to <literal>qemu-nbd</literal>(8).</para> </tip>
      </section>
      <section id="_chroot_system">
        <title>Chroot system</title>
        <para>If you wish to try a new Debian environment from a terminal console, I recommend you to use <ulink url="https://en.wikipedia.org/wiki/Chroot">chroot</ulink>.  This enables you to run console applications of Debian <literal>unstable</literal> and <literal>testing</literal> without usual risks associated  and without rebooting.  <literal>chroot</literal>(8) is the most basic way.</para>
        <caution> <para>Examples below assumes both parent system and chroot system share the same <literal>amd64</literal> CPU architecture.</para> </caution>
        <para>Although you can manually create a <literal>chroot</literal>(8) environment using <literal>debootstrap</literal>(1), this requires non-trivial efforts.</para>
        <para>The <ulink url="https://packages.debian.org/search?keywords=sbuild">sbuild</ulink> package to build Debian packages from source uses the chroot environment managed by the <ulink url="https://packages.debian.org/search?keywords=schroot">schroot</ulink> package.  It comes with helper script <literal>sbuild-createchroot</literal>(1).  Let's learn how it works by running it as follows.</para>
        <screen>$ sudo mkdir -p /srv/chroot
$ sudo sbuild-createchroot -v --include=eatmydata,ccache unstable /srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian
 ...</screen>
        <para>You see how <literal>debootstrap</literal>(8) populates system data for <literal>unstable</literal> environment under "<literal>/srv/chroot/unstable-amd64-sbuild</literal>" for a minimal build system.</para>
        <para>You can login to this environment using <literal>schroot</literal>(1).</para>
        <screen>$ sudo schroot -v -c chroot:unstable-amd64-sbuild</screen>
        <para>You see how a system shell running under <literal>unstable</literal> environment is created.</para>
        <note> <para>The "<literal>/usr/sbin/policy-rc.d</literal>" file which always exits with 101 prevents daemon programs to be started automatically on the Debian system.  See "<literal>/usr/share/doc/init-system-helpers/README.policy-rc.d.gz</literal>".</para> </note>
        <note> <para>Some programs under chroot may require access to more files from the parent system to function than <literal>sbuild-createchroot</literal> provides as above.  For example, "<literal>/sys</literal>", "<literal>/etc/passwd</literal>", "<literal>/etc/group</literal>", "<literal>/var/run/utmp</literal>", "<literal>/var/log/wtmp</literal>", etc. may need to be bind-mounted or copied.</para> </note>
        <tip> <para>The <literal>sbuild</literal> package helps to construct a chroot system and builds a package inside the chroot using <literal>schroot</literal> as its backend.  It is an ideal system to check build-dependencies.  See more on <ulink url="https://wiki.debian.org/sbuild">sbuild at Debian wiki</ulink> and <ulink url="https://www.debian.org/doc/manuals/debmake-doc/ch03.en.html#sbuild-setup">sbuild configuration example in "Guide for Debian Maintainers"</ulink>. </para> </tip>
        <tip> <para>The <literal>systemd-nspawn</literal>(1) command helps to run a command or OS in a light-weight container in similar ways to <literal>chroot</literal>.  It is more powerful since it uses namespaces to fully virtualize the the process tree, IPC, hostname, domain name and, optionally, networking and user databases.  See <ulink url="https://wiki.debian.org/nspawn">systemd-nspawn</ulink>. </para> </tip>
      </section>
      <!--
        OCI
          - Docker
          - Podman
            Cliché: https://osamuaoki.github.io/en/2024/02/14/podman-1/#typical-clich%C3%A9-for-dockerpodman
          - Kubertner
      -->
      <!--
        Incus (LXD replacement)
          - with Linux Container
          - with Vm (KVM, qemu)
      -->
      <!--
        Virt-manager/Gnome Box
          - with Vm (KVM, qemu)
      -->
      <section id="_multiple_desktop_systems">
        <title>Multiple desktop systems</title>
        <para>If you wish to try a new GUI Desktop environment of any OS, I recommend you to use <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> or <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</ulink> on a Debian <literal>stable</literal> system to run multiple desktop systems safely using <ulink url="https://en.wikipedia.org/wiki/Virtualization">virtualization</ulink>.  These enable you to run any desktop applications including ones of Debian <literal>unstable</literal> and <literal>testing</literal> without usual risks associated with them and without rebooting.</para>
        <para>Since pure <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> is very slow, it is recommended to accelerate it with <ulink url="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</ulink> when the host system supports it.</para>
        <para><ulink url="https://en.wikipedia.org/wiki/Virt-manager">Virtual Machine Manager</ulink> also known as <literal>virt-manager</literal> is a convenient GUI tool for managing KVM virtual machines via <ulink url="https://en.wikipedia.org/wiki/Libvirt">libvirt</ulink>.</para>
        <para>The virtual disk image "<literal>virtdisk.qcow2</literal>" containing a Debian system for <ulink url="https://en.wikipedia.org/wiki/QEMU">QEMU</ulink> can be created using <ulink url="https://www.debian.org/distrib/netinst">debian-installer: Small CDs</ulink> as follows.</para>
        <screen>$ wget https://cdimage.debian.org/debian-cd/5.0.3/amd64/iso-cd/debian-503-amd64-netinst.iso
$ qemu-img create -f qcow2 virtdisk.qcow2 5G
$ qemu -hda virtdisk.qcow2 -cdrom debian-503-amd64-netinst.iso -boot d -m 256
...</screen>
        <tip> <para>Running other GNU/Linux distributions such as <ulink url="https://www.ubuntu.com/">Ubuntu</ulink> and <ulink url="https://fedoraproject.org/">Fedora</ulink> under <ulink url="https://en.wikipedia.org/wiki/Virtualization">virtualization</ulink> is a great way to learn configuration tips.  Other proprietary OSs may be run nicely under this GNU/Linux <ulink url="https://en.wikipedia.org/wiki/Virtualization">virtualization</ulink>, too.</para> </tip>
        <para>See more tips at <ulink url="https://wiki.debian.org/SystemVirtualization">Debian wiki: SystemVirtualization</ulink>.</para>
      </section>
    </section>
  </chapter>