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
|
<!-- vim: set sw=2 et sts=2 ft=xml: -->
<!-- Last content review: 2024-01-21T08:10:39 UTC -->
<chapter id="_data_management">
<title>Data management</title>
<para>Tools and tips for managing binary and text data on the Debian system are described.</para>
<section id="_sharing_copying_and_archiving">
<title>Sharing, copying, and archiving</title>
<warning>
<para>The uncoordinated write access to actively accessed devices and files from multiple processes must not be done to avoid the <ulink url="https://en.wikipedia.org/wiki/Race_condition">race condition</ulink>. <ulink url="https://en.wikipedia.org/wiki/File_locking">File locking</ulink> mechanisms using <literal>flock</literal>(1) may be used to avoid it.</para>
</warning>
<para>The security of the data and its controlled sharing have several aspects.</para>
<itemizedlist>
<listitem> <para> The creation of data archive </para> </listitem>
<listitem> <para> The remote storage access </para> </listitem>
<listitem> <para> The duplication </para> </listitem>
<listitem> <para> The tracking of the modification history </para> </listitem>
<listitem> <para> The facilitation of data sharing </para> </listitem>
<listitem> <para> The prevention of unauthorized file access </para> </listitem>
<listitem> <para> The detection of unauthorized file modification </para> </listitem>
</itemizedlist>
<para>These can be realized by using some combination of tools.</para>
<itemizedlist>
<listitem> <para> Archive and compression tools </para> </listitem>
<listitem> <para> Copy and synchronization tools </para> </listitem>
<listitem> <para> Network filesystems </para> </listitem>
<listitem> <para> Removable storage media </para> </listitem>
<listitem> <para> The secure shell </para> </listitem>
<listitem> <para> The authentication system </para> </listitem>
<listitem> <para> Version control system tools </para> </listitem>
<listitem> <para> Hash and cryptographic encryption tools </para> </listitem>
</itemizedlist>
<section id="_archive_and_compression_tools">
<title>Archive and compression tools</title>
<para>Here is a summary of archive and compression tools available on the Debian system.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of archive and compression tools</title>
<tgroup cols="6">
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="54pt" align="left"/>
<colspec colwidth="152pt" align="left"/>
<colspec colwidth="325pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> extension </entry>
<entry> command </entry>
<entry> comment </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>tar</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.tar</literal> </entry>
<entry><literal>tar</literal>(1) </entry>
<entry> the standard archiver (de facto standard) </entry>
</row>
<row>
<entry> <literal>cpio</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.cpio</literal> </entry>
<entry><literal>cpio</literal>(1) </entry>
<entry> Unix System V style archiver, use with <literal>find</literal>(1) </entry>
</row>
<row>
<entry> <literal>binutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.ar</literal> </entry>
<entry><literal>ar</literal>(1) </entry>
<entry> archiver for the creation of static libraries </entry>
</row>
<row>
<entry> <literal>fastjar</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.jar</literal> </entry>
<entry><literal>fastjar</literal>(1) </entry>
<entry> archiver for Java (zip like) </entry>
</row>
<row>
<entry> <literal>pax</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.pax</literal> </entry>
<entry><literal>pax</literal>(1) </entry>
<entry> new POSIX standard archiver, compromise between <literal>tar</literal> and <literal>cpio</literal> </entry>
</row>
<row>
<entry> <literal>gzip</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.gz</literal> </entry>
<entry><literal>gzip</literal>(1), <literal>zcat</literal>(1), … </entry>
<entry> GNU <ulink url="https://en.wikipedia.org/wiki/LZ77_and_LZ78">LZ77</ulink> compression utility (de facto standard) </entry>
</row>
<row>
<entry> <literal>bzip2</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.bz2</literal> </entry>
<entry><literal>bzip2</literal>(1), <literal>bzcat</literal>(1), … </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Burrows-Wheeler_transform">Burrows-Wheeler block-sorting compression</ulink> utility with higher compression ratio than <literal>gzip</literal>(1) (slower than <literal>gzip</literal> with similar syntax) </entry>
</row>
<row>
<entry> <literal>lzma</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.lzma</literal> </entry>
<entry><literal>lzma</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm">LZMA</ulink> compression utility with higher compression ratio than <literal>gzip</literal>(1) (deprecated) </entry>
</row>
<row>
<entry> <literal>xz-utils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.xz</literal> </entry>
<entry><literal>xz</literal>(1), <literal>xzdec</literal>(1), … </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Xz">XZ</ulink> compression utility with higher compression ratio than <literal>bzip2</literal>(1) (slower than <literal>gzip</literal> but faster than <literal>bzip2</literal>; replacement for <ulink url="https://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm">LZMA</ulink> compression utility) </entry>
</row>
<row>
<entry> <literal>zstd</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.zstd</literal> </entry>
<entry><literal>zstd</literal>(1), <literal>zstdcat</literal>(1), … </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Zstandard">Zstandard</ulink> fast lossless compression utility </entry>
</row>
<row>
<entry> <literal>p7zip</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.7z</literal> </entry>
<entry><literal>7zr</literal>(1), <literal>p7zip</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/7-Zip">7-Zip</ulink> file archiver with high compression ratio (<ulink url="https://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm">LZMA</ulink> compression) </entry>
</row>
<row>
<entry> <literal>p7zip-full</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.7z</literal> </entry>
<entry><literal>7z</literal>(1), <literal>7za</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/7-Zip">7-Zip</ulink> file archiver with high compression ratio (<ulink url="https://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm">LZMA</ulink> compression and others) </entry>
</row>
<row>
<entry> <literal>lzop</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.lzo</literal> </entry>
<entry><literal>lzop</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Lempel-Ziv-Oberhumer">LZO</ulink> compression utility with higher compression and decompression speed than <literal>gzip</literal>(1) (lower compression ratio than <literal>gzip</literal> with similar syntax) </entry>
</row>
<row>
<entry> <literal>zip</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.zip</literal> </entry>
<entry><literal>zip</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Info-ZIP">InfoZIP</ulink>: DOS archive and compression tool </entry>
</row>
<row>
<entry> <literal>unzip</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>.zip</literal> </entry>
<entry><literal>unzip</literal>(1) </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Info-ZIP">InfoZIP</ulink>: DOS unarchive and decompression tool </entry>
</row>
</tbody>
</tgroup>
</table>
<warning> <para>Do not set the "<literal>$TAPE</literal>" variable unless you know what to expect. It changes <literal>tar</literal>(1) behavior.</para> </warning>
<itemizedlist>
<listitem> <para>The gzipped <literal>tar</literal>(1) archive uses the file extension "<literal>.tgz</literal>" or "<literal>.tar.gz</literal>".</para> </listitem>
<listitem> <para>The xz-compressed <literal>tar</literal>(1) archive uses the file extension "<literal>.txz</literal>" or "<literal>.tar.xz</literal>".</para> </listitem>
<listitem> <para>Popular compression method in <ulink url="https://en.wikipedia.org/wiki/Free_and_open_source_software">FOSS</ulink> tools such as <literal>tar</literal>(1) has been moving as follows: <literal>gzip</literal> → <literal>bzip2</literal> → <literal>xz</literal></para> </listitem>
<listitem> <para><literal>cp</literal>(1), <literal>scp</literal>(1) and <literal>tar</literal>(1) may have some limitation for special files. <literal>cpio</literal>(1) is most versatile.</para> </listitem>
<listitem> <para><literal>cpio</literal>(1) is designed to be used with <literal>find</literal>(1) and other commands and suitable for creating backup scripts since the file selection part of the script can be tested independently.</para> </listitem>
<listitem> <para>Internal structure of Libreoffice data files are "<literal>.jar</literal>" file which can be opened also by <literal>unzip</literal>.</para> </listitem>
<listitem> <para>The de-facto cross platform archive tool is <literal>zip</literal>. Use it as "<literal>zip -rX</literal>" to attain the maximum compatibility. Use also the "<literal>-s</literal>" option, if the maximum file size matters.</para> </listitem>
</itemizedlist>
</section>
<section id="_copy_and_synchronization_tools">
<title>Copy and synchronization tools</title>
<para>Here is a summary of simple copy and backup tools available on the Debian system.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of copy and synchronization tools</title>
<tgroup cols="5">
<colspec colwidth="92pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="38pt" align="left"/>
<colspec colwidth="369pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> tool </entry>
<entry> function </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>coreutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> GNU cp </entry>
<entry> locally copy files and directories ("-a" for recursive) </entry>
</row>
<row>
<entry> <literal>openssh-client</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> scp </entry>
<entry> remotely copy files and directories (client, "<literal>-r</literal>" for recursive) </entry>
</row>
<row>
<entry> <literal>openssh-server</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> sshd </entry>
<entry> remotely copy files and directories (remote server) </entry>
</row>
<row>
<entry> <literal>rsync</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> </entry>
<entry> 1-way remote synchronization and backup </entry>
</row>
<row>
<entry> <literal>unison</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> </entry>
<entry> 2-way remote synchronization and backup </entry>
</row>
</tbody>
</tgroup>
</table>
<para>Copying files with <literal>rsync</literal>(8) offers richer features than others.</para>
<itemizedlist>
<listitem> <para> delta-transfer algorithm that sends only the differences between the source files and the existing files in the destination </para> </listitem>
<listitem> <para> quick check algorithm (by default) that looks for files that have changed in size or in last-modified time </para> </listitem>
<listitem> <para> "<literal>--exclude</literal>" and "<literal>--exclude-from</literal>" options similar to <literal>tar</literal>(1) </para> </listitem>
<listitem> <para> "a trailing slash on the source directory" syntax that avoids creating an additional directory level at the destination. </para> </listitem>
</itemizedlist>
<tip> <para>Version control system (VCS) tools in <xref linkend="list-of-vcs"/> can function as the multi-way copy and synchronization tools.</para> </tip>
</section>
<section id="_idioms_for_the_archive">
<title>Idioms for the archive</title>
<para>Here are several ways to archive and unarchive the entire content of the directory "<literal>./source</literal>" using different tools.</para>
<para>GNU <literal>tar</literal>(1):</para>
<screen>$ tar -cvJf archive.tar.xz ./source
$ tar -xvJf archive.tar.xz</screen>
<para>Alternatively, by the following.</para>
<screen>$ find ./source -xdev -print0 | tar -cvJf archive.tar.xz --null -T -</screen>
<para><literal>cpio</literal>(1):</para>
<screen>$ find ./source -xdev -print0 | cpio -ov --null > archive.cpio; xz archive.cpio
$ zcat archive.cpio.xz | cpio -i</screen>
</section>
<section id="_idioms_for_the_copy">
<title>Idioms for the copy</title>
<para>Here are several ways to copy the entire content of the directory "<literal>./source</literal>" using different tools.</para>
<itemizedlist>
<listitem>
<para> Local copy: "<literal>./source</literal>" directory → "<literal>/dest</literal>" directory </para>
</listitem>
<listitem>
<para> Remote copy: "<literal>./source</literal>" directory at local host → "<literal>/dest</literal>" directory at "<literal>user@host.dom</literal>" host </para>
</listitem>
</itemizedlist>
<para><literal>rsync</literal>(8):</para>
<screen># cd ./source; rsync -aHAXSv . /dest
# cd ./source; rsync -aHAXSv . user@host.dom:/dest</screen>
<para>You can alternatively use "a trailing slash on the source directory" syntax.</para>
<screen># rsync -aHAXSv ./source/ /dest
# rsync -aHAXSv ./source/ user@host.dom:/dest</screen>
<para>Alternatively, by the following.</para>
<screen># cd ./source; find . -print0 | rsync -aHAXSv0 --files-from=- . /dest
# cd ./source; find . -print0 | rsync -aHAXSv0 --files-from=- . user@host.dom:/dest</screen>
<para>GNU <literal>cp</literal>(1) and openSSH <literal>scp</literal>(1):</para>
<screen># cd ./source; cp -a . /dest
# cd ./source; scp -pr . user@host.dom:/dest</screen>
<para>GNU <literal>tar</literal>(1):</para>
<screen># (cd ./source && tar cf - . ) | (cd /dest && tar xvfp - )
# (cd ./source && tar cf - . ) | ssh user@host.dom '(cd /dest && tar xvfp - )'</screen>
<para><literal>cpio</literal>(1):</para>
<screen># cd ./source; find . -print0 | cpio -pvdm --null --sparse /dest</screen>
<para>You can substitute "<literal>.</literal>" with "<literal>foo</literal>" for all examples containing "<literal>.</literal>" to copy files from "<literal>./source/foo</literal>" directory to "<literal>/dest/foo</literal>" directory.</para>
<para>You can substitute "<literal>.</literal>" with the absolute path "<literal>/path/to/source/foo</literal>" for all examples containing "<literal>.</literal>" to drop "<literal>cd ./source;</literal>". These copy files to different locations depending on tools used as follows.</para>
<itemizedlist>
<listitem> <para> "<literal>/dest/foo</literal>": <literal>rsync</literal>(8), GNU <literal>cp</literal>(1), and <literal>scp</literal>(1) </para> </listitem>
<listitem> <para> "<literal>/dest/path/to/source/foo</literal>": GNU <literal>tar</literal>(1), and <literal>cpio</literal>(1) </para> </listitem>
</itemizedlist>
<tip> <para><literal>rsync</literal>(8) and GNU <literal>cp</literal>(1) have option "<literal>-u</literal>" to skip files that are newer on the receiver.</para> </tip>
</section>
<section id="_idioms_for_the_selection_of_files">
<title>Idioms for the selection of files</title>
<para><literal>find</literal>(1) is used to select files for archive and copy commands (see <xref linkend="_idioms_for_the_archive"/> and <xref linkend="_idioms_for_the_copy"/>) or for <literal>xargs</literal>(1) (see <xref linkend="_repeating_a_command_looping_over_files"/>). This can be enhanced by using its command arguments.</para>
<para>Basic syntax of <literal>find</literal>(1) can be summarized as the following.</para>
<itemizedlist>
<listitem> <para> Its conditional arguments are evaluated from left to right. </para> </listitem>
<listitem> <para> This evaluation stops once its outcome is determined. </para> </listitem>
<listitem> <para> "Logical <emphasis role="strong">OR</emphasis>" (specified by "<literal>-o</literal>" between conditionals) has lower precedence than "logical <emphasis role="strong">AND</emphasis>" (specified by "<literal>-a</literal>" or nothing between conditionals). </para> </listitem>
<listitem> <para> "Logical <emphasis role="strong">NOT</emphasis>" (specified by "<literal>!</literal>" before a conditional) has higher precedence than "logical <emphasis role="strong">AND</emphasis>". </para> </listitem>
<listitem> <para> "<literal>-prune</literal>" always returns logical <emphasis role="strong">TRUE</emphasis> and, if it is a directory, searching of file is stopped beyond this point. </para> </listitem>
<listitem> <para> "<literal>-name</literal>" matches the base of the filename with shell glob (see <xref linkend="_shell_glob"/>) but it also matches its initial "<literal>.</literal>" with metacharacters such as "<literal>*</literal>" and "<literal>?</literal>". (New <ulink url="https://en.wikipedia.org/wiki/POSIX">POSIX</ulink> feature) </para> </listitem>
<listitem> <para> "<literal>-regex</literal>" matches the full path with emacs style <emphasis role="strong">BRE</emphasis> (see <xref linkend="_regular_expressions"/>) as default. </para> </listitem>
<listitem> <para> "<literal>-size</literal>" matches the file based on the file size (value precedented with "<literal>+</literal>" for larger, precedented with "<literal>-</literal>" for smaller) </para> </listitem>
<listitem> <para> "<literal>-newer</literal>" matches the file newer than the one specified in its argument. </para> </listitem>
<listitem> <para> "<literal>-print0</literal>" always returns logical <emphasis role="strong">TRUE</emphasis> and print the full filename (<ulink url="https://en.wikipedia.org/wiki/Null_character">null terminated</ulink>) on the standard output. </para> </listitem>
</itemizedlist>
<para><literal>find</literal>(1) is often used with an idiomatic style as the following.</para>
<screen># find /path/to \
-xdev -regextype posix-extended \
-type f -regex ".*\.cpio|.*~" -prune -o \
-type d -regex ".*/\.git" -prune -o \
-type f -size +99M -prune -o \
-type f -newer /path/to/timestamp -print0</screen>
<para>This means to do following actions.</para>
<orderedlist>
<listitem> <para> Search all files starting from "<literal>/path/to</literal>" </para> </listitem>
<listitem> <para> Globally limit its search within its starting filesystem and uses <emphasis role="strong">ERE</emphasis> (see <xref linkend="_regular_expressions"/>) instead </para> </listitem>
<listitem> <para> Exclude files matching regex of "<literal>.*\.cpio</literal>" or "<literal>.*~</literal>" from search by stop processing </para> </listitem>
<listitem> <para> Exclude directories matching regex of "<literal>.*/\.git</literal>" from search by stop processing </para> </listitem>
<listitem> <para> Exclude files larger than 99 Megabytes (units of 1048576 bytes) from search by stop processing </para> </listitem>
<listitem> <para> Print filenames which satisfy above search conditions and are newer than "<literal>/path/to/timestamp</literal>" </para> </listitem>
</orderedlist>
<para>Please note the idiomatic use of "<literal>-prune -o</literal>" to exclude files in the above example.</para>
<note> <para>For non-Debian <ulink url="https://en.wikipedia.org/wiki/Unix-like">Unix-like</ulink> system, some options may not be supported by <literal>find</literal>(1). In such a case, please consider to adjust matching methods and replace "<literal>-print0</literal>" with "<literal>-print</literal>". You may need to adjust related commands too.</para> </note>
</section>
<section id="_archive_media">
<title>Archive media</title>
<para>When choosing <ulink url="https://en.wikipedia.org/wiki/Computer_data_storage">computer data storage media</ulink> for important data archive, you should be careful about their limitations. For small personal data backup, I use CD-R and DVD-R by the brand name company and store in a cool, shaded, dry, clean environment. (Tape archive media seem to be popular for professional use.)</para>
<note> <para><ulink url="https://en.wikipedia.org/wiki/Safe">A fire-resistant safe</ulink> are meant for paper documents. Most of the computer data storage media have less temperature tolerance than paper. I usually rely on multiple secure encrypted copies stored in multiple secure locations.</para> </note>
<para>Optimistic storage life of archive media seen on the net (mostly from vendor info).</para>
<itemizedlist>
<listitem> <para> 100+ years : Acid free paper with ink </para> </listitem>
<listitem> <para> 100 years : Optical storage (CD/DVD, CD/DVD-R) </para> </listitem>
<listitem> <para> 30 years : Magnetic storage (tape, floppy) </para> </listitem>
<listitem> <para> 20 years : Phase change optical storage (CD-RW) </para> </listitem>
</itemizedlist>
<para>These do not count on the mechanical failures due to handling etc.</para>
<para>Optimistic write cycle of archive media seen on the net (mostly from vendor info).</para>
<itemizedlist>
<listitem> <para> 250,000+ cycles : Harddisk drive </para> </listitem>
<listitem> <para> 10,000+ cycles : Flash memory </para> </listitem>
<listitem> <para> 1,000 cycles : CD/DVD-RW </para> </listitem>
<listitem> <para> 1 cycles : CD/DVD-R, paper </para> </listitem>
</itemizedlist>
<caution> <para>Figures of storage life and write cycle here should not be used for decisions on any critical data storage. Please consult the specific product information provided by the manufacture.</para> </caution>
<tip> <para>Since CD/DVD-R and paper have only 1 write cycle, they inherently prevent accidental data loss by overwriting. This is advantage!</para> </tip>
<tip> <para>If you need fast and frequent backup of large amount of data, a hard disk on a remote host linked by a fast network connection, may be the only realistic option.</para> </tip>
<tip> <para>If you use re-writable media for your backups, use of filesystem such as <ulink url="https://en.wikipedia.org/wiki/Btrfs">btrfs</ulink> or <ulink url="https://en.wikipedia.org/wiki/ZFS">zfs</ulink> which supports read-only snapshots may be a good idea.</para> </tip>
</section>
<section id="_removable_storage_device">
<title>Removable storage device</title>
<para>Removable storage devices may be any one of the following.</para>
<itemizedlist>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/USB_flash_drive">USB flash drive</ulink> </para> </listitem>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/Hard_disk_drive">Hard disk drive</ulink> </para> </listitem>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/Optical_disc_drive">Optical disc drive</ulink> </para> </listitem>
<listitem> <para> Digital camera </para> </listitem>
<listitem> <para> Digital music player </para> </listitem>
</itemizedlist>
<para>They may be connected via any one of the following.</para>
<itemizedlist>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/Universal_Serial_Bus">USB</ulink> </para> </listitem>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/IEEE_1394">IEEE 1394 / FireWire</ulink> </para> </listitem>
<listitem> <para> <ulink url="https://en.wikipedia.org/wiki/PC_card">PC Card</ulink> </para> </listitem>
</itemizedlist>
<para>Modern desktop environments such as GNOME and KDE can mount these removable devices automatically without a matching "<literal>/etc/fstab</literal>" entry.</para>
<itemizedlist>
<listitem> <para><literal>udisks2</literal> package provides a daemon and associated utilities to mount and unmount these devices. </para> </listitem> <listitem> <para><ulink url="https://en.wikipedia.org/wiki/D-Bus">D-bus</ulink> creates events to initiate automatic processes. </para> </listitem>
<listitem> <para><ulink url="https://en.wikipedia.org/wiki/PolicyKit">PolicyKit</ulink> provides required privileges. </para> </listitem>
</itemizedlist>
<tip> <para>Automounted devices may have the "<literal>uhelper=</literal>" mount option which is used by <literal>umount</literal>(8).</para> </tip>
<tip> <para>Automounting under modern desktop environment happens only when those removable media devices are not listed in "<literal>/etc/fstab</literal>".</para> </tip>
<para>Mount point under modern desktop environment is chosen as "<literal>/media/<emphasis>username/disk_label</emphasis></literal>" which can be customized by the following.</para>
<itemizedlist>
<listitem> <para><literal>mlabel</literal>(1) for FAT filesystem </para> </listitem>
<listitem> <para><literal>genisoimage</literal>(1) with "<literal>-V</literal>" option for ISO9660 filesystem </para> </listitem>
<listitem> <para><literal>tune2fs</literal>(1) with "<literal>-L</literal>" option for ext2/ext3/ext4 filesystem </para> </listitem>
</itemizedlist>
<tip> <para>The choice of encoding may need to be provided as mount option (see <xref linkend="_filename_encoding"/>).</para> </tip>
<tip> <para>The use of the GUI menu to unmount a filesystem may remove its dynamically generated device node such as "<literal>/dev/sdc</literal>". If you wish to keep its device node, unmount it with the <literal>umount</literal>(8) command from the shell prompt.</para> </tip>
</section>
<section id="_filesystem_choice_for_sharing_data">
<title>Filesystem choice for sharing data</title>
<para>When sharing data with other system via removable storage device, you should format it with common <ulink url="https://en.wikipedia.org/wiki/File_system">filesystem</ulink> supported by both systems. Here is a list of filesystem choices.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of filesystem choices for removable storage devices with typical usage scenarios</title>
<tgroup cols="2">
<colspec colwidth="352pt" align="left"/>
<colspec colwidth="396pt" align="left"/>
<thead>
<row>
<entry> filesystem name </entry>
<entry> typical usage scenario </entry>
</row>
</thead>
<tbody>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/File_Allocation_Table">FAT12</ulink> </entry>
<entry> cross platform sharing of data on the floppy disk (<32MiB) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/File_Allocation_Table">FAT16</ulink> </entry>
<entry> cross platform sharing of data on the small hard disk like device (<2GiB) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/File_Allocation_Table">FAT32</ulink> </entry>
<entry> cross platform sharing of data on the large hard disk like device (<8TiB, supported by newer than MS Windows95 OSR2) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/ExFAT">exFAT</ulink> </entry>
<entry> cross platform sharing of data on the large hard disk like device (<512TiB, supported by WindowsXP, Mac OS X Snow Leopard 10.6.5, and Linux kernel since 5.4 release) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/NTFS">NTFS</ulink> </entry>
<entry> cross platform sharing of data on the large hard disk like device (supported natively on <ulink url="https://en.wikipedia.org/wiki/Windows_NT">MS Windows NT</ulink> and later version, and supported by <ulink url="https://en.wikipedia.org/wiki/NTFS-3G">NTFS-3G</ulink> via <ulink url="https://en.wikipedia.org/wiki/Filesystem_in_Userspace">FUSE</ulink> on Linux) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/ISO_9660">ISO9660</ulink> </entry>
<entry> cross platform sharing of static data on CD-R and DVD+/-R </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Universal_Disk_Format">UDF</ulink> </entry>
<entry> incremental data writing on CD-R and DVD+/-R (new) </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Minix_file_system">MINIX</ulink> </entry>
<entry> space efficient unix file data storage on the floppy disk </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Ext2">ext2</ulink> </entry>
<entry> sharing of data on the hard disk like device with older Linux systems </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Ext3">ext3</ulink> </entry>
<entry> sharing of data on the hard disk like device with older Linux systems </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Ext4">ext4</ulink> </entry>
<entry> sharing of data on the hard disk like device with current Linux systems </entry>
</row>
<row>
<entry> <ulink url="https://en.wikipedia.org/wiki/Btrfs">btrfs</ulink> </entry>
<entry> sharing of data on the hard disk like device with current Linux systems with read-only snapshots</entry>
</row>
</tbody>
</tgroup>
</table>
<tip> <para>See <xref linkend="_removable_disk_encryption_with_dm_crypt_luks"/> for cross platform sharing of data using device level encryption.</para> </tip>
<para>The FAT filesystem is supported by almost all modern operating systems and is quite useful for the data exchange purpose via removable hard disk like media.</para>
<para>When formatting removable hard disk like devices for cross platform sharing of data with the FAT filesystem, the following should be safe choices.</para>
<itemizedlist>
<listitem>
<para>
Partitioning them with <literal>fdisk</literal>(8), <literal>cfdisk</literal>(8) or <literal>parted</literal>(8) (see <xref linkend="_disk_partition_configuration"/>) into a single primary partition and to mark it as the following.
</para>
<itemizedlist>
<listitem> <para> Type "6" for FAT16 for media smaller than 2GB. </para> </listitem>
<listitem> <para> Type "c" for FAT32 (LBA) for larger media. </para> </listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Formatting the primary partition with <literal>mkfs.vfat</literal>(8) with the following. </para>
<itemizedlist>
<listitem> <para> Just its device name, e.g. "<literal>/dev/sda1</literal>" for FAT16 </para> </listitem>
<listitem> <para> The explicit option and its device name, e.g. "<literal>-F 32 /dev/sda1</literal>" for FAT32 </para> </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
<para>When using the FAT or ISO9660 filesystems for sharing data, the following should be the safe considerations.</para>
<itemizedlist>
<listitem> <para> Archiving files into an archive file first using <literal>tar</literal>(1), or <literal>cpio</literal>(1) to retain the long filename, the symbolic link, the original Unix file permission and the owner information. </para> </listitem>
<listitem> <para> Splitting the archive file into less than 2 GiB chunks with the <literal>split</literal>(1) command to protect it from the file size limitation. </para> </listitem>
<listitem> <para> Encrypting the archive file to secure its contents from the unauthorized access. </para> </listitem>
</itemizedlist>
<note> <para>For FAT filesystems by its design, the maximum file size is <literal>(2^32 - 1) bytes = (4GiB - 1 byte)</literal>. For some applications on the older 32 bit OS, the maximum file size was even smaller <literal>(2^31 - 1) bytes = (2GiB - 1 byte)</literal>. Debian does not suffer the latter problem.</para> </note>
<note> <para>Microsoft itself does not recommend to use FAT for drives or partitions of over 200 MB. Microsoft highlights its short comings such as inefficient disk space usage in their "<ulink url="https://support.microsoft.com/kb/100108/">Overview of FAT, HPFS, and NTFS File Systems</ulink>". Of course, we should normally use the ext4 filesystem for Linux.</para> </note>
<tip> <para>For more on filesystems and accessing filesystems, please read "<ulink url="https://tldp.org/HOWTO/Filesystems-HOWTO.html">Filesystems HOWTO</ulink>".</para> </tip>
</section>
<section id="_sharing_data_via_network">
<title>Sharing data via network</title>
<para>When sharing data with other system via network, you should use common service. Here are some hints.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of the network service to chose with the typical usage scenario</title>
<tgroup cols="2">
<colspec colwidth="798pt" align="left"/>
<colspec colwidth="716pt" align="left"/>
<thead>
<row>
<entry> network service </entry>
<entry> description of typical usage scenario </entry>
</row>
</thead>
<tbody>
<row>
<entry><ulink url="https://en.wikipedia.org/wiki/Server_Message_Block">SMB/CIFS</ulink> network mounted filesystem with <ulink url="https://en.wikipedia.org/wiki/Samba_(software)">Samba</ulink> </entry>
<entry> sharing files via "Microsoft Windows Network", see <literal>smb.conf</literal>(5) and <ulink url="https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/">The Official Samba 3.x.x HOWTO and Reference Guide</ulink> or the <literal>samba-doc</literal> package </entry>
</row>
<row>
<entry><ulink url="https://en.wikipedia.org/wiki/Network_File_System_(protocol)">NFS</ulink> network mounted filesystem with the Linux kernel </entry>
<entry> sharing files via "Unix/Linux Network", see <literal>exports</literal>(5) and <ulink url="https://tldp.org/HOWTO/NFS-HOWTO/index.html">Linux NFS-HOWTO</ulink> </entry>
</row>
<row>
<entry><ulink url="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol">HTTP</ulink> service </entry>
<entry> sharing file between the web server/client </entry>
</row>
<row>
<entry><ulink url="https://en.wikipedia.org/wiki/Https">HTTPS</ulink> service </entry>
<entry> sharing file between the web server/client with encrypted Secure Sockets Layer (SSL) or <ulink url="https://en.wikipedia.org/wiki/Transport_Layer_Security">Transport Layer Security</ulink> (TLS) </entry>
</row>
<row>
<entry><ulink url="https://en.wikipedia.org/wiki/File_Transfer_Protocol">FTP</ulink> service </entry>
<entry> sharing file between the FTP server/client </entry>
</row>
</tbody>
</tgroup>
</table>
<para>Although these filesystems mounted over network and file transfer methods over network are quite convenient for sharing data, these may be insecure. Their network connection must be secured by the following.</para>
<itemizedlist>
<listitem> <para> Encrypt it with <ulink url="https://en.wikipedia.org/wiki/Transport_Layer_Security">SSL/TLS</ulink> </para> </listitem>
<listitem> <para> Tunnel it via <ulink url="https://en.wikipedia.org/wiki/Secure_Shell">SSH</ulink> </para> </listitem>
<listitem> <para> Tunnel it via <ulink url="https://en.wikipedia.org/wiki/Virtual_private_network">VPN</ulink> </para> </listitem>
<listitem> <para> Limit it behind the secure firewall </para> </listitem>
</itemizedlist>
<para>See also <xref linkend="_other_network_application_servers"/> and <xref linkend="_other_network_application_clients"/>.</para>
</section>
</section>
<section id="_backup_and_recovery">
<title>Backup and recovery</title>
<para>We all know that computers fail sometime or human errors cause system and data damages. Backup and recovery operations are the essential part of successful system administration. All possible failure modes hit you some day.</para>
<tip> <para>Keep your backup system simple and backup your system often. Having backup data is more important than how technically good your backup method is.</para> </tip>
<section id="_backup_and_recovery_policy">
<title>Backup and recovery policy</title>
<para>There are 3 key factors which determine actual backup and recovery policy.</para>
<orderedlist>
<listitem>
<para> Knowing what to backup and recover. </para>
<itemizedlist>
<listitem> <para> Data files directly created by you: data in "<literal>~/</literal>" </para> </listitem>
<listitem> <para> Data files created by applications used by you: data in "<literal>/var/</literal>" (except "<literal>/var/cache/</literal>", "<literal>/var/run/</literal>", and "<literal>/var/tmp/</literal>") </para> </listitem>
<listitem> <para> System configuration files: data in "<literal>/etc/</literal>" </para> </listitem>
<listitem> <para> Local programs: data in "<literal>/usr/local/</literal>" or "<literal>/opt/</literal>" </para> </listitem>
<listitem> <para> System installation information: a memo in plain text on key steps (partition, …) </para> </listitem>
<listitem>
<para> Proven set of data: confirmed by experimental recovery operations in advance </para>
<itemizedlist>
<listitem> <para> Cron job as a user process: files in "<literal>/var/spool/cron/crontabs</literal>" directory and restart <literal>cron</literal>(8). See <xref linkend="_scheduling_tasks_regularly"/> for <literal>cron</literal>(8) and <literal>crontab</literal>(1).</para> </listitem>
<listitem> <para> Systemd timer jobs as user processes: files in "<literal>~/.config/systemd/user</literal>" directory. See <literal>systemd.timer</literal>(5) and <literal>systemd.service</literal>(5).</para> </listitem>
<listitem> <para> Autostart jobs as user processes: files in "<literal>~/.config/autostart</literal>" directory. See <ulink url="https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html">Desktop Application Autostart Specification</ulink>.</para> </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Knowing how to backup and recover. </para>
<itemizedlist>
<listitem> <para> Secure storage of data: protection from overwrite and system failure </para> </listitem>
<listitem> <para> Frequent backup: scheduled backup </para> </listitem>
<listitem> <para> Redundant backup: data mirroring </para> </listitem>
<listitem> <para> Fool proof process: easy single command backup </para> </listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Assessing risks and costs involved. </para>
<itemizedlist>
<listitem>
<para> Risk of data when lost </para>
<itemizedlist>
<listitem> <para>Data should be at least on different disk partitions preferably on different disks and machines to withstand the filesystem corruption. Important data are best stored on a read-only filesystem. <footnote> <para>A write-once media such as CD/DVD-R can prevent overwrite accidents. (See <xref linkend="_the_binary_data"/> for how to write to the storage media from the shell commandline. GNOME desktop GUI environment gives you easy access via menu: "Places→CD/DVD Creator".) </para> </footnote> </para> </listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Risk of data when breached </para>
<itemizedlist>
<listitem> <para>Sensitive identity data such as "<literal>/etc/ssh/ssh_host_*_key</literal>", "<literal>~/.gnupg/*</literal>", "<literal>~/.ssh/*</literal>", "<literal>~/.local/share/keyrings/*</literal>", "<literal>/etc/passwd</literal>", "<literal>/etc/shadow</literal>", "<literal>popularity-contest.conf</literal>", "<literal>/etc/ppp/pap-secrets</literal>", and "<literal>/etc/exim4/passwd.client</literal>" should be backed up as encrypted. <footnote> <para> Some of these data can not be regenerated by entering the same input string to the system.</para> </footnote> (See <xref linkend="_data_encryption_tips"/>.)</para> </listitem>
<listitem> <para>Never hard code system login password nor decryption passphrase in any script even on any trusted system. (See <xref linkend="_password_keyring"/>.)</para> </listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Failure mode and their possibility </para>
<itemizedlist>
<listitem> <para> Hardware (especially HDD) will break </para> </listitem>
<listitem> <para> Filesystem may be corrupted and data in it may be lost </para> </listitem>
<listitem> <para> Remote storage system can't be trusted for security breaches </para> </listitem>
<listitem> <para> Weak password protection can be easily compromised </para> </listitem>
<listitem> <para> File permission system may be compromised </para> </listitem>
</itemizedlist>
</listitem>
<listitem>
<para> Required resources for backup: human, hardware, software, … </para>
<itemizedlist>
<listitem> <para> Automatic scheduled backup with cron job or systemd timer job </para> </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
<tip> <para>You can recover debconf configuration data with "<literal>debconf-set-selections debconf-selections</literal>" and dpkg selection data with "<literal>dpkg --set-selection <dpkg-selections.list</literal>".</para> </tip>
<note> <para>Do not back up the pseudo-filesystem contents found on <literal>/proc</literal>, <literal>/sys</literal>, <literal>/tmp</literal>, and <literal>/run</literal> (see <xref linkend="_procfs_and_sysfs"/> and <xref linkend="_tmpfs"/>). Unless you know exactly what you are doing, they are huge useless data.</para> </note>
<note> <para>You may wish to stop some application daemons such as MTA (see <xref linkend="_mail_transport_agent_mta"/>) while backing up data.</para> </note>
</section>
<section id="_backup_utility_suites">
<title>Backup utility suites</title>
<para>Here is a select list of notable backup utility suites available on the Debian system.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of backup suite 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>bacula-common</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Bacula">Bacula</ulink>: network backup, recovery and verification - common support files </entry>
</row>
<row>
<entry> <literal>bacula-client</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Bacula">Bacula</ulink>: network backup, recovery and verification - client meta-package </entry>
</row>
<row>
<entry> <literal>bacula-console</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Bacula">Bacula</ulink>: network backup, recovery and verification - text console </entry>
</row>
<row>
<entry> <literal>bacula-server</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Bacula">Bacula</ulink>: network backup, recovery and verification - server meta-package </entry>
</row>
<row>
<entry> <literal>amanda-common</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver">Amanda</ulink>: Advanced Maryland Automatic Network Disk Archiver (Libs) </entry>
</row>
<row>
<entry> <literal>amanda-client</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver">Amanda</ulink>: Advanced Maryland Automatic Network Disk Archiver (Client) </entry>
</row>
<row>
<entry> <literal>amanda-server</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver">Amanda</ulink>: Advanced Maryland Automatic Network Disk Archiver (Server) </entry>
</row>
<row>
<entry> <literal>backuppc</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><ulink url="https://en.wikipedia.org/wiki/Backuppc">BackupPC</ulink> is a high-performance, enterprise-grade system for backing up PCs (disk based) </entry>
</row>
<row>
<entry> <literal>duplicity</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
<row>
<entry> <literal>deja-dup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> GUI frontend for duplicity </entry>
</row>
<row>
<entry> <literal>borgbackup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) deduplicating backup </entry>
</row>
<!--
<row>
<entry> <literal>borgbackup2</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) deduplicating backup </entry>
</row>
-->
<row>
<entry> <literal>borgmatic</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> borgbackup helper </entry>
</row>
<row>
<entry> <literal>rdiff-backup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
<row>
<entry> <literal>restic</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
<!-- Removed from bullseye
<row>
<entry> <literal>rsnapshot</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
-->
<row>
<entry> <literal>backupninja</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> lightweight, extensible <emphasis role="strong">meta-backup</emphasis> system </entry>
</row>
<row>
<entry> <literal>flexbackup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
<row>
<entry> <literal>slbackup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> (remote) incremental backup </entry>
</row>
<row>
<entry> <literal>backup-manager</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> command-line backup tool </entry>
</row>
<row>
<entry> <literal>backup2l</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> low-maintenance backup/restore tool for mountable media (disk based) </entry>
</row>
</tbody>
</tgroup>
</table>
<para>Backup tools have their specialized focuses.</para>
<itemizedlist>
<listitem> <para><ulink url="https://en.wikipedia.org/wiki/Mondo_Rescue">Mondo Rescue</ulink> is a backup system to facilitate restoration of complete system quickly from backup CD/DVD etc. without going through normal system installation processes. </para> </listitem>
<listitem> <para><ulink url="https://en.wikipedia.org/wiki/Bacula">Bacula</ulink>, <ulink url="https://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver">Amanda</ulink>, and <ulink url="https://en.wikipedia.org/wiki/Backuppc">BackupPC</ulink> are full featured backup suite utilities which are focused on regular backups over network. </para> </listitem>
<listitem> <para><ulink url="https://en.wikipedia.org/wiki/Duplicity_(software)">Duplicity</ulink>, and <ulink url="https://en.wikipedia.org/wiki/Borg_(backup_software)">Borg</ulink> are simpler backup utilities for typical workstations. </para> </listitem>
</itemizedlist>
</section>
<section id="_backup_tips">
<title>Backup tips</title>
<para>For a personal workstation, full featured backup suite utilities designed for the server environment may not serve well. At the same time, existing backup utilities for workstations may have some shortcomings.</para>
<para>Here are some tips to make backup easier with minimal user efforts. These techniques may be used with any backup utilities.</para>
<para>For demonstration purpose, let's assume the primary user and group name to be <literal>penguin</literal> and create a backup and snapshot script example "<literal>/usr/local/bin/bkss.sh</literal>" as:</para>
<screen>#!/bin/sh -e
SRC="$1" # source data path
DSTFS="$2" # backup destination filesystem path
DSTSV="$3" # backup destination subvolume name
DSTSS="${DSTFS}/${DSTSV}-snapshot" # snapshot destination path
if [ "$(stat -f -c %T "$DSTFS")" != "btrfs" ]; then
echo "E: $DESTFS needs to be formatted to btrfs" >&2 ; exit 1
fi
MSGID=$(notify-send -p "bkup.sh $DSTSV" "in progress ...")
if [ ! -d "$DSTFS/$DSTSV" ]; then
btrfs subvolume create "$DSTFS/$DSTSV"
mkdir -p "$DSTSS"
fi
rsync -aHxS --delete --mkpath "${SRC}/" "${DSTFS}/${DSTSV}"
btrfs subvolume snapshot -r "${DSTFS}/${DSTSV}" ${DSTSS}/$(date -u --iso=min)
notify-send -r "$MSGID" "bkup.sh $DSTSV" "finished!"
</screen>
<para>Here, only the basic tool <literal>rsync</literal>(1) is used to facilitate system backup and the storage space is efficiently used by <ulink url="https://en.wikipedia.org/wiki/Btrfs">Btrfs</ulink>.</para>
<tip> <para>FYI: This author uses his own similar shell script "<ulink url="https://github.com/osamuaoki/bss">bss: Btrfs Subvolume Snapshot Utility</ulink>" for his workstation. </para> </tip>
<section id="_gui_backup">
<title>GUI backup</title>
<para>Here is an example to setup the single GUI click backup.</para>
<itemizedlist>
<listitem> <para>Prepare a USB storage device to be used for backup.</para>
<itemizedlist>
<listitem> <para>Format a USB storage device with one partition in btrfs with its label name as "<literal>BKUP</literal>". This can be encrypted (see <xref linkend="_removable_disk_encryption_with_dm_crypt_luks" />). </para> </listitem>
<listitem> <para>Plug this in to your system. The desktop system should automatically mount it as "<literal>/media/penguin/BKUP</literal>".</para> </listitem>
<listitem> <para>Execute "<literal>sudo chown penguin:penguin /media/penguin/BKUP</literal>" to make it writable by the user.</para> </listitem>
</itemizedlist>
</listitem>
<listitem> <para>Create "<literal>~/.local/share/applications/BKUP.desktop</literal>" following techniques written in <xref linkend="_starting_a_program_from_gui" /> as: </para>
<screen>[Desktop Entry]
Name=bkss
Comment=Backup and snapshot of ~/Documents
Exec=/usr/local/bin/bkss.sh /home/penguin/Documents /media/penguin/BKUP Documents
Type=Application
</screen> </listitem>
</itemizedlist>
<para>For each GUI click, your data is backed up from "<literal>~/Documents</literal>" to a USB storage device and a read-only snapshot is created.</para>
</section>
<section id="_mount_event_triggered_backup">
<title>Mount event triggered backup</title>
<para>Here is an example to setup for the automatic backup triggered by the mount event.</para>
<itemizedlist>
<listitem> <para>Prepare a USB storage device to be used for backup as in <xref linkend="_gui_backup" />.</para> </listitem>
<listitem> <para>Create a systemd service unit file "<literal>~/.config/systemd/user/back-BKUP.service</literal>" as:</para>
<screen>[Unit]
Description=USB Disk backup
Requires=media-%u-BKUP.mount
After=media-%u-BKUP.mount
[Service]
ExecStart=/usr/local/bin/bkss.sh %h/Documents /media/%u/BKUP Documents
StandardOutput=append:%h/.cache/systemd-snap.log
StandardError=append:%h/.cache/systemd-snap.log
[Install]
WantedBy=media-%u-BKUP.mount
</screen> </listitem>
<listitem> <para>Enable this systemd unit configuration with the following: </para>
<screen> $ systemctl --user enable bkup-BKUP.service
</screen> </listitem>
</itemizedlist>
<para>For each mount event, your data is backed up from "<literal>~/Documents</literal>" to a USB storage device and a read-only snapshot is created.</para>
<para>Here, names of systemd mount units that systemd currently has in memory can be asked to the service manager of the calling user with "<literal>systemctl --user list-units --type=mount</literal>".</para>
</section>
<section id="_timer_event_triggered_backup">
<title>Timer event triggered backup</title>
<para>Here is an example to setup for the automatic backup triggered by the timer event.</para>
<itemizedlist>
<listitem> <para>Prepare a USB storage device to be used for backup as in <xref linkend="_gui_backup" />.</para> </listitem>
<listitem> <para>Create a systemd timer unit file "<literal>~/.config/systemd/user/snap-Documents.timer</literal>" as:</para>
<screen>[Unit]
Description=Run btrfs subvolume snapshot on timer
Documentation=man:btrfs(1)
[Timer]
OnStartupSec=30
OnUnitInactiveSec=900
[Install]
WantedBy=timers.target
</screen> </listitem>
<listitem> <para>Create a systemd service unit file "<literal>~/.config/systemd/user/snap-Documents.service</literal>" as:</para>
<screen>[Unit]
Description=Run btrfs subvolume snapshot
Documentation=man:btrfs(1)
[Service]
Type=oneshot
Nice=15
ExecStart=/usr/local/bin/bkss.sh %h/Documents /media/%u/BKUP Documents
IOSchedulingClass=idle
CPUSchedulingPolicy=idle
StandardOutput=append:%h/.cache/systemd-snap.log
StandardError=append:%h/.cache/systemd-snap.log
</screen> </listitem>
<listitem> <para>Enable this systemd unit configuration with the following: </para>
<screen> $ systemctl --user enable snap-Documents.timer
</screen> </listitem>
</itemizedlist>
<para>For each timer event, your data is backed up from "<literal>~/Documents</literal>" to a USB storage device and a read-only snapshot is created.</para>
<para>Here, names of systemd timer user units that systemd currently has in memory can be asked to the service manager of the calling user with "<literal>systemctl --user list-units --type=timer</literal>".</para>
<para>For the modern desktop system, this systemd approach can offer more fine grained control than the traditional Unix ones using <literal>at</literal>(1), <literal>cron</literal>(8), or <literal>anacron</literal>(8).</para>
</section>
</section>
</section>
<section id="_data_security_infrastructure">
<title>Data security infrastructure</title>
<para>The data security infrastructure is provided by the combination of data encryption tool, message digest tool, and signature tool.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of data security infrastructure tools</title>
<tgroup cols="5">
<colspec colwidth="92pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="114pt" align="left"/>
<colspec colwidth="396pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> command </entry>
<entry> description </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>gnupg</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>gpg</literal>(1) </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard</ulink> - OpenPGP encryption and signing tool </entry>
</row>
<row>
<entry> <literal>gpgv</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>gpgv</literal>(1) </entry>
<entry> GNU Privacy Guard - signature verification tool </entry>
</row>
<row>
<entry> <literal>paperkey</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>paperkey</literal>(1) </entry>
<entry> extract just the secret information out of OpenPGP secret keys </entry>
</row>
<row>
<entry> <literal>cryptsetup</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>cryptsetup</literal>(8), … </entry>
<entry> utilities for <ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink> block device encryption supporting <ulink url="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</ulink> </entry>
</row>
<row>
<entry> <literal>coreutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>md5sum</literal>(1) </entry>
<entry> compute and check MD5 message digest </entry>
</row>
<row>
<entry> <literal>coreutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>sha1sum</literal>(1) </entry>
<entry> compute and check SHA1 message digest </entry>
</row>
<row>
<entry> <literal>openssl</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>openssl</literal>(1ssl) </entry>
<entry> compute message digest with "<literal>openssl dgst</literal>" (OpenSSL) </entry>
</row>
<row>
<entry> <literal>libsecret-tools</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>secret-tool</literal>(1) </entry>
<entry> store and retrieve passwords (CLI) </entry>
</row>
<row>
<entry> <literal>seahorse</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <literal>seahorse</literal>(1) </entry>
<entry> key management tool (GNOME) </entry>
</row>
</tbody>
</tgroup>
</table>
<para>See <xref linkend="_data_encryption_tips"/> on <ulink url="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</ulink> and <ulink url="https://www.kernel.org/doc/html/latest/filesystems/fscrypt.html">fscrypt</ulink> which implement automatic data encryption infrastructure via Linux kernel modules.</para>
<section id="_key_management_for_gnupg">
<title>Key management for GnuPG</title>
<para>Here are <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard</ulink> commands for the basic key management.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of GNU Privacy Guard commands for the key management</title>
<tgroup cols="2">
<colspec colwidth="162pt" align="left"/>
<colspec colwidth="217pt" align="left"/>
<thead>
<row>
<entry> command </entry>
<entry> description </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>gpg --gen-key</literal> </entry>
<entry> generate a new key </entry>
</row>
<row>
<entry> <literal>gpg --gen-revoke my_user_ID</literal> </entry>
<entry> generate revoke key for my_user_ID </entry>
</row>
<row>
<entry> <literal>gpg --edit-key user_ID</literal> </entry>
<entry> edit key interactively, "help" for help </entry>
</row>
<row>
<entry> <literal>gpg -o file --export</literal> </entry>
<entry> export all keys to file </entry>
</row>
<row>
<entry> <literal>gpg --import file</literal> </entry>
<entry> import all keys from file </entry>
</row>
<row>
<entry> <literal>gpg --send-keys user_ID</literal> </entry>
<entry> send key of user_ID to keyserver </entry>
</row>
<row>
<entry> <literal>gpg --recv-keys user_ID</literal> </entry>
<entry> recv. key of user_ID from keyserver </entry>
</row>
<row>
<entry> <literal>gpg --list-keys user_ID</literal> </entry>
<entry> list keys of user_ID </entry>
</row>
<row>
<entry> <literal>gpg --list-sigs user_ID</literal> </entry>
<entry> list sig. of user_ID </entry>
</row>
<row>
<entry> <literal>gpg --check-sigs user_ID</literal> </entry>
<entry> check sig. of user_ID </entry>
</row>
<row>
<entry> <literal>gpg --fingerprint user_ID</literal> </entry>
<entry> check fingerprint of user_ID </entry>
</row>
<row>
<entry> <literal>gpg --refresh-keys</literal> </entry>
<entry> update local keyring </entry>
</row>
</tbody>
</tgroup>
</table>
<para>Here is the meaning of the trust code.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of the meaning of the trust code</title>
<tgroup cols="2">
<colspec colwidth="27pt" align="left"/>
<colspec colwidth="249pt" align="left"/>
<thead>
<row>
<entry> code </entry>
<entry> description of trust </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>-</literal> </entry>
<entry> no owner trust assigned / not yet calculated </entry>
</row>
<row>
<entry> <literal>e</literal> </entry>
<entry> trust calculation failed </entry>
</row>
<row>
<entry> <literal>q</literal> </entry>
<entry> not enough information for calculation </entry>
</row>
<row>
<entry> <literal>n</literal> </entry>
<entry> never trust this key </entry>
</row>
<row>
<entry> <literal>m</literal> </entry>
<entry> marginally trusted </entry>
</row>
<row>
<entry> <literal>f</literal> </entry>
<entry> fully trusted </entry>
</row>
<row>
<entry> <literal>u</literal> </entry>
<entry> ultimately trusted </entry>
</row>
</tbody>
</tgroup>
</table>
<para>The following uploads my key "<literal>1DD8D791</literal>" to the popular keyserver "<literal>hkp://keys.gnupg.net</literal>".</para>
<screen>$ gpg --keyserver hkp://keys.gnupg.net --send-keys 1DD8D791</screen>
<para>A good default keyserver set up in "<literal>~/.gnupg/gpg.conf</literal>" (or old location "<literal>~/.gnupg/options</literal>") contains the following.</para>
<screen>keyserver hkp://keys.gnupg.net</screen>
<para>The following obtains unknown keys from the keyserver.</para>
<screen>$ gpg --list-sigs --with-colons | grep '^sig.*\[User ID not found\]' |\
cut -d ':' -f 5| sort | uniq | xargs gpg --recv-keys</screen>
<!-- Following URL is stil sourceforge XXX FIXME XXX -->
<para>There was a bug in <ulink url="https://sourceforge.net/projects/pks/">OpenPGP Public Key Server</ulink> (pre version 0.9.6) which corrupted key with more than 2 sub-keys. The newer <literal>gnupg</literal> (>1.2.1-2) package can handle these corrupted subkeys. See <literal>gpg</literal>(1) under "<literal>--repair-pks-subkey-bug</literal>" option.</para>
</section>
<section id="_using_gnupg_on_files">
<title>Using GnuPG on files</title>
<para>Here are examples for using <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard</ulink> commands on files.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of GNU Privacy Guard commands on files</title>
<tgroup cols="2">
<colspec colwidth="304pt" align="left"/>
<colspec colwidth="445pt" align="left"/>
<thead>
<row>
<entry> command </entry>
<entry> description </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>gpg -a -s file</literal> </entry>
<entry> sign file into <ulink url="https://en.wikipedia.org/wiki/ASCII">ASCII</ulink> armored file.asc </entry>
</row>
<row>
<entry> <literal>gpg --armor --sign file</literal> </entry>
<entry> , , </entry>
</row>
<row>
<entry> <literal>gpg --clearsign file</literal> </entry>
<entry> clear-sign message </entry>
</row>
<row>
<entry> <literal>gpg --clearsign file|mail foo@example.org</literal> </entry>
<entry> mail a clear-signed message to <literal>foo@example.org</literal> </entry>
</row>
<row>
<entry> <literal>gpg --clearsign --not-dash-escaped patchfile</literal> </entry>
<entry> clear-sign patchfile </entry>
</row>
<row>
<entry> <literal>gpg --verify file</literal> </entry>
<entry> verify clear-signed file </entry>
</row>
<row>
<entry> <literal>gpg -o file.sig -b file</literal> </entry>
<entry> create detached signature </entry>
</row>
<row>
<entry> <literal>gpg -o file.sig --detach-sign file</literal> </entry>
<entry> , , </entry>
</row>
<row>
<entry> <literal>gpg --verify file.sig file</literal> </entry>
<entry> verify file with file.sig </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.gpg -r name -e file</literal> </entry>
<entry> public-key encryption intended for name from file to binary crypt_file.gpg </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.gpg --recipient name --encrypt file</literal> </entry>
<entry> , , </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.asc -a -r name -e file</literal> </entry>
<entry> public-key encryption intended for name from file to <ulink url="https://en.wikipedia.org/wiki/ASCII">ASCII</ulink> armored crypt_file.asc </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.gpg -c file</literal> </entry>
<entry> symmetric encryption from file to crypt_file.gpg </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.gpg --symmetric file</literal> </entry>
<entry> , , </entry>
</row>
<row>
<entry> <literal>gpg -o crypt_file.asc -a -c file</literal> </entry>
<entry> symmetric encryption intended for name from file to <ulink url="https://en.wikipedia.org/wiki/ASCII">ASCII</ulink> armored crypt_file.asc </entry>
</row>
<row>
<entry> <literal>gpg -o file -d crypt_file.gpg -r name</literal> </entry>
<entry> decryption </entry>
</row>
<row>
<entry> <literal>gpg -o file --decrypt crypt_file.gpg</literal> </entry>
<entry> , , </entry>
</row>
</tbody>
</tgroup>
</table>
</section>
<section id="_using_gnupg_with_mutt">
<title>Using GnuPG with Mutt</title>
<para>Add the following to "<literal>~/.muttrc</literal>" to keep a slow GnuPG from automatically starting, while allowing it to be used by typing "<literal>S</literal>" at the index menu.</para>
<screen>macro index S ":toggle pgp_verify_sig\n"
set pgp_verify_sig=no</screen>
</section>
<section id="_using_gnupg_with_vim">
<title>Using GnuPG with Vim</title>
<para>The <literal>gnupg</literal> plugin let you run GnuPG transparently for files with extension "<literal>.gpg</literal>", "<literal>.asc</literal>", and "<literal>.pgp</literal>".<footnote><para>If you use "<literal>~/.vimrc</literal>" instead of "<literal>~/.vim/vimrc</literal>", please substitute accordingly.</para></footnote></para>
<screen>$ sudo aptitude install vim-scripts
$ echo "packadd! gnupg" >> ~/.vim/vimrc</screen>
</section>
<section id="_the_md5_sum">
<title>The MD5 sum</title>
<para><literal>md5sum</literal>(1) provides utility to make a digest file using the method in <ulink url="https://datatracker.ietf.org/doc/rfc1321/">rfc1321</ulink> and verifying each file with it.</para>
<screen>$ md5sum foo bar >baz.md5
$ cat baz.md5
d3b07384d113edec49eaa6238ad5ff00 foo
c157a79031e1c40f85931829bc5fc552 bar
$ md5sum -c baz.md5
foo: OK
bar: OK</screen>
<note>
<para>The computation for the <ulink url="https://en.wikipedia.org/wiki/MD5">MD5</ulink> sum is less CPU intensive than the one for the cryptographic signature by <ulink url="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard (GnuPG)</ulink>. Usually, only the top level digest file is cryptographically signed to ensure data integrity.</para>
</note>
</section>
<section id="_password_keyring">
<title>Password keyring</title>
<para>On GNOME system, the GUI tool <literal>seahorse</literal>(1) manages passwords and stores them securely in the keyring <literal>~/.local/share/keyrings/*</literal>.</para>
<para><literal>secret-tool</literal>(1) can store password to the keyring from the command line.</para>
<para>Let's store passphrase used for LUKS/dm-crypt encrypted disk image</para>
<screen>$ secret-tool store --label='LUKS passphrase for disk.img' LUKS my_disk.img
Password: ********
</screen>
<para>This stored password can be retrieved and fed to other programs, e.g., <literal>cryptsetup</literal>(8).</para>
<screen>$ secret-tool lookup LUKS my_disk.img | \
cryptsetup open disk.img disk_img --type luks --keyring -
$ sudo mount /dev/mapper/disk_img /mnt
</screen>
<tip> <para>Whenever you need to provide password in a script, use <literal>secret-tool</literal> and avoid directly hardcoding the passphrase in it.</para> </tip>
</section>
</section>
<section id="_source_code_merge_tools">
<title>Source code merge tools</title>
<para>There are many merge tools for the source code. Following commands caught my eyes.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of source code merge tools</title>
<tgroup cols="5">
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="92pt" align="left"/>
<colspec colwidth="358pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> command </entry>
<entry> description </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>patch</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>patch</literal>(1) </entry>
<entry> apply a diff file to an original </entry>
</row>
<row>
<entry> <literal>vim</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>vimdiff</literal>(1) </entry>
<entry> compare 2 files side by side in vim </entry>
</row>
<row>
<entry> <literal>imediff</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>imediff</literal>(1) </entry>
<entry> interactive full screen 2/3-way merge tool </entry>
</row>
<row>
<entry> <literal>meld</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>meld</literal>(1) </entry>
<entry> compare and merge files (GTK) </entry>
</row>
<row>
<entry> <literal>wiggle</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>wiggle</literal>(1) </entry>
<entry> apply rejected patches </entry>
</row>
<row>
<entry> <literal>diffutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>diff</literal>(1) </entry>
<entry> compare files line by line </entry>
</row>
<row>
<entry> <literal>diffutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>diff3</literal>(1) </entry>
<entry> compare and merges three files line by line </entry>
</row>
<!--
<row>
<entry> <literal>dpatch</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>dpatch</literal>(1) </entry>
<entry> manage series of patches for Debian package </entry>
</row>
-->
<row>
<entry> <literal>quilt</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>quilt</literal>(1) </entry>
<entry> manage series of patches </entry>
</row>
<row>
<entry> <literal>wdiff</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>wdiff</literal>(1) </entry>
<entry> display word differences between text files </entry>
</row>
<row>
<entry> <literal>diffstat</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>diffstat</literal>(1) </entry>
<entry> produce a histogram of changes by the diff </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>combinediff</literal>(1) </entry>
<entry> create a cumulative patch from two incremental patches </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>dehtmldiff</literal>(1) </entry>
<entry> extract a diff from an HTML page </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>filterdiff</literal>(1) </entry>
<entry> extract or excludes diffs from a diff file </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>fixcvsdiff</literal>(1) </entry>
<entry> fix diff files created by CVS that <literal>patch</literal>(1) mis-interprets </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>flipdiff</literal>(1) </entry>
<entry> exchange the order of two patches </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>grepdiff</literal>(1) </entry>
<entry> show which files are modified by a patch matching a regex </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>interdiff</literal>(1) </entry>
<entry> show differences between two unified diff files </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>lsdiff</literal>(1) </entry>
<entry> show which files are modified by a patch </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>recountdiff</literal>(1) </entry>
<entry> recompute counts and offsets in unified context diffs </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>rediff</literal>(1) </entry>
<entry> fix offsets and counts of a hand-edited diff </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>splitdiff</literal>(1) </entry>
<entry> separate out incremental patches </entry>
</row>
<row>
<entry> <literal>patchutils</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>unwrapdiff</literal>(1) </entry>
<entry> demangle patches that have been word-wrapped </entry>
</row>
<row>
<entry> <literal>dirdiff</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>dirdiff</literal>(1) </entry>
<entry> display differences and merge changes between directory trees </entry>
</row>
<row>
<entry> <literal>docdiff</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>docdiff</literal>(1) </entry>
<entry> compare two files word by word / char by char </entry>
</row>
<row>
<entry> <literal>makepatch</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>makepatch</literal>(1) </entry>
<entry> generate extended patch files </entry>
</row>
<row>
<entry> <literal>makepatch</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>applypatch</literal>(1) </entry>
<entry> apply extended patch files </entry>
</row>
</tbody>
</tgroup>
</table>
<section id="_extracting_differences_for_source_files">
<title>Extracting differences for source files</title>
<para>The following procedures extract differences between two source files and create unified diff files "<literal>file.patch0</literal>" or "<literal>file.patch1</literal>" depending on the file location.</para>
<screen>$ diff -u file.old file.new > file.patch0
$ diff -u old/file new/file > file.patch1</screen>
</section>
<section id="_merging_updates_for_source_files">
<title>Merging updates for source files</title>
<para>The diff file (alternatively called patch file) is used to send a program update. The receiving party applies this update to another file by the following.</para>
<screen>$ patch -p0 file < file.patch0
$ patch -p1 file < file.patch1</screen>
</section>
<section id="_interactive_merge">
<title>Interactive merge</title>
<para>If you have two versions of a source code, you can perform 2-way merge interactively using <literal>imediff</literal>(1) by the following.</para>
<screen>$ imediff -o file.merged file.old file.new</screen>
<para>If you have three versions of a source code, you can perform 3-way merge interactively using <literal>imediff</literal>(1) by the following.</para>
<screen>$ imediff -o file.merged file.yours file.base file.theirs</screen>
</section>
</section>
<section id="_git">
<title>Git</title>
<para>Git is the tool of choice these days for the <ulink url="https://en.wikipedia.org/wiki/Revision_control">version control system (VCS)</ulink> since Git can do everything for both local and remote source code management.</para>
<para>Debian provides free Git services via <ulink url="https://salsa.debian.org/">Debian Salsa service</ulink>. Its documentation can be found at <ulink url="https://wiki.debian.org/Salsa">https://wiki.debian.org/Salsa</ulink> .</para>
<para>Here are some Git related packages.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of git related packages and commands</title>
<tgroup cols="5">
<colspec colwidth="103pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="135pt" align="left"/>
<colspec colwidth="363pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> command </entry>
<entry> description </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>git</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>git</literal>(7) </entry>
<entry> Git, the fast, scalable, distributed revision control system </entry>
</row>
<row>
<entry> <literal>gitk</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry> <entry><literal>gitk</literal>(1) </entry>
<entry> GUI Git repository browser with history </entry>
</row>
<row>
<entry> <literal>git-gui</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>git-gui</literal>(1) </entry>
<entry> GUI for Git (No history) </entry>
</row>
<row>
<entry> <literal>git-email</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>git-send-email</literal>(1) </entry>
<entry> send a collection of patches as email from the Git </entry>
</row>
<row>
<entry> <literal>git-buildpackage</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>git-buildpackage</literal>(1) </entry>
<entry> automate the Debian packaging with the Git </entry>
</row>
<row>
<entry> <literal>dgit</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>dgit</literal>(1) </entry>
<entry> git interoperability with the Debian archive </entry>
</row>
<row>
<entry> <literal>imediff</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>git-ime</literal>(1) </entry>
<entry> interactive git commit split helper tool </entry>
</row>
<row>
<entry> <literal>stgit</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry><literal>stg</literal>(1) </entry>
<entry> quilt on top of git (Python) </entry>
</row>
<row>
<entry> <literal>git-doc</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> N/A </entry>
<entry> official documentation for Git </entry>
</row>
<row>
<entry> <literal>gitmagic</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> N/A </entry>
<entry> "Git Magic", easier to understand guide for Git </entry>
</row>
</tbody>
</tgroup>
</table>
<section id="_configuration_of_git_client">
<title>Configuration of Git client</title>
<para>You may wish to set several global configuration in "<literal>~/.gitconfig</literal>" such as your name and email address used by Git by the following.</para>
<screen>$ git config --global user.name "Name Surname"
$ git config --global user.email yourname@example.com</screen>
<para>You may also customize the Git default behavior by the following.</para>
<screen>$ git config --global init.defaultBranch main
$ git config --global pull.rebase true
$ git config --global push.default current</screen>
<para>If you are too used to CVS or Subversion commands, you may wish to set several command aliases by the following.</para>
<screen>$ git config --global alias.ci "commit -a"
$ git config --global alias.co checkout</screen>
<para>You can check your global configuration by the following.</para>
<screen>$ git config --global --list</screen>
</section>
<section id="_basic_git_commands">
<title>Basic Git commands</title>
<para>Git operation involves several data.</para>
<itemizedlist>
<listitem> <para> The working tree which holds user facing files and to which you make changes. </para>
<itemizedlist>
<listitem> <para> The changes to be recorded must be explicitly selected and staged to the index. This is <literal>git add</literal> and <literal>git rm</literal> commands. </para> </listitem>
</itemizedlist>
</listitem>
<listitem> <para> The index which holds staged files.</para>
<itemizedlist>
<listitem> <para> Staged files will be committed to the local repository upon the subsequent request. This is <literal>git commit</literal> command. </para> </listitem>
</itemizedlist>
</listitem>
<listitem> <para> The local repository which holds committed files. </para>
<itemizedlist>
<listitem> <para> Git records the linked history of the committed data and organizes them as branches in the repository.</para> </listitem>
<listitem> <para> The local repository can send data to the remote repository by <literal>git push</literal> command. </para> </listitem>
<listitem> <para> The local repository can receive data from the remote repository by <literal>git fetch</literal> and <literal>git pull</literal> commands.</para>
<itemizedlist>
<listitem> <para> The <literal>git pull</literal> command performs <literal>git merge</literal> or <literal>git rebase</literal> command after <literal>git fetch</literal> command. </para> </listitem>
<listitem> <para> Here, <literal>git merge</literal> combines two separate branches of history at the end to a point. (This is default of <literal>git pull</literal> without customization and may be good for upstream people who publish branch to many people.) </para> </listitem>
<listitem> <para> Here, <literal>git rebase</literal> creates one single branch of sequential history of the remote branch one followed by the local branch one. (This is <literal>pull.rebase true</literal> customization case and may be good for rest of us.) </para> </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</listitem>
<listitem> <para> The remote repository which holds committed files. </para>
<itemizedlist>
<listitem> <para> The communication to the remote repository uses secure communication protocols such as SSH or HTTPS. </para> </listitem>
</itemizedlist>
</listitem>
</itemizedlist>
<para>The working tree is files outside of the <literal>.git/</literal> directory. Files inside of the <literal>.git/</literal> directory hold the index, the local repository data, and some git configuration text files. </para>
<para>Here is an overview of main Git commands.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>Main Git commands</title>
<tgroup cols="2">
<colspec colwidth="250pt" align="left"/>
<colspec colwidth="350pt" align="left"/>
<thead>
<row>
<entry> Git command </entry>
<entry> function </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>git init</literal> </entry>
<entry> create the (local) repository </entry>
</row>
<row>
<entry> <literal>git clone URL</literal> </entry>
<entry> clone the remote repository to a local repository with the working tree </entry>
</row>
<row>
<entry> <literal>git pull origin main</literal> </entry>
<entry> update the local <literal>main</literal> branch by the remote repository <literal>origin</literal> </entry>
</row>
<row>
<entry> <literal>git add .</literal> </entry>
<entry> add file(s) in the working tree to the index for pre-existing files in index only </entry>
</row>
<row>
<entry> <literal>git add -A .</literal> </entry>
<entry> add file(s) in the working tree to the index for all files including removals</entry>
</row>
<row>
<entry> <literal>git rm filename</literal> </entry>
<entry> remove file(s) from the working tree and the index </entry>
</row>
<row>
<entry> <literal>git commit</literal> </entry>
<entry> commit staged changes in the index to the local repository </entry>
</row>
<row>
<entry> <literal>git commit -a</literal> </entry>
<entry> add all changes in the working tree to the index and commit them to the local repository (add + commit) </entry>
</row>
<row>
<entry> <literal>git push -u origin branch_name</literal> </entry>
<entry> update the remote repository <literal>origin</literal> by the local <literal>branch_name</literal> branch (initial invocation) </entry>
</row>
<row>
<entry> <literal>git push origin branch_name</literal> </entry>
<entry> update the remote repository <literal>origin</literal> by the local <literal>branch_name</literal> branch (subsequent invocation) </entry>
</row>
<row>
<entry> <literal>git diff treeish1 treeish2</literal> </entry>
<entry> show difference between <emphasis>treeish1</emphasis> commit and <emphasis>treeish2</emphasis> commit </entry>
</row>
<row>
<entry> <literal>gitk</literal> </entry>
<entry> GUI display of VCS repository branch history tree </entry>
</row>
</tbody>
</tgroup>
</table>
</section>
<section id="_git_tips">
<title>Git tips</title>
<para>Here are some Git tips.</para>
<table pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>Git tips</title>
<tgroup cols="2">
<colspec colwidth="250pt" align="left"/>
<colspec colwidth="350pt" align="left"/>
<thead>
<row>
<entry> Git command line </entry>
<entry> function </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>gitk --all</literal> </entry>
<entry> see complete Git history and operate on them such as resetting HEAD to another commit, cheery-picking patches, creating tags and branches ... </entry>
</row>
<row>
<entry> <literal>git stash</literal> </entry>
<entry> get the clean working tree without loosing data </entry>
</row>
<row>
<entry> <literal>git remote -v</literal> </entry>
<entry> check settings for remote </entry>
</row>
<row>
<entry> <literal>git branch -vv</literal> </entry>
<entry> check settings for branch </entry>
</row>
<row>
<entry> <literal>git status</literal> </entry>
<entry> show working tree status </entry>
</row>
<row>
<entry> <literal>git config -l</literal> </entry>
<entry> list git settings </entry>
</row>
<row>
<entry> <literal>git reset --hard HEAD; git clean -x -d -f</literal> </entry>
<entry> revert all working tree changes and clean them up completely </entry>
</row>
<row>
<entry> <literal>git rm --cached filename</literal> </entry>
<entry> revert staged index changed by <literal>git add filename</literal> </entry>
</row>
<row>
<entry> <literal>git reflog</literal> </entry>
<entry> get reference log (useful for recovering commits from the removed branch)</entry>
</row>
<row>
<entry> <literal>git branch new_branch_name HEAD@{6}</literal> </entry>
<entry> create a new branch from reflog information</entry>
</row>
<row>
<entry> <literal>git remote add new_remote URL</literal> </entry>
<entry> add a <literal>new_remote</literal> remote repository pointed by URL </entry>
</row>
<row>
<entry> <literal>git remote rename origin upstream</literal> </entry>
<entry> rename the remote repository name from <literal>origin</literal> to <literal>upstream</literal> </entry>
</row>
<row>
<entry> <literal>git branch -u upstream/branch_name</literal> </entry>
<entry> set the remote tracking to the remote repository <literal>upstream</literal> and its branch name <literal>branch_name</literal>. </entry>
</row>
<row>
<entry> <literal>git remote set-url origin https://foo/bar.git</literal> </entry>
<entry> change URL of <literal>origin</literal> </entry>
</row>
<row>
<entry> <literal>git remote set-url --push upstream DISABLED</literal> </entry>
<entry> disable push to <literal>upstream</literal> (Edit <literal>.git/config</literal> to re-enable) </entry>
</row>
<row>
<entry> <literal>git remote update upstream</literal> </entry>
<entry> fetch updates of all remote branches in the <literal>upstream</literal> repository </entry>
</row>
<row>
<entry> <literal>git fetch upstream foo:upstream-foo</literal> </entry>
<entry> create a local (possibly orphan) <literal>upstream-foo</literal> branch as a copy of <literal>foo</literal> branch in the <literal>upstream</literal> repository </entry>
</row>
<row>
<entry> <literal>git checkout -b topic_branch ; git push -u topic_branch origin</literal> </entry>
<entry> make a new <literal>topic_branch</literal> and push it to <literal>origin</literal></entry>
</row>
<row>
<entry> <literal>git branch -m oldname newname</literal> </entry>
<entry> rename local branch name </entry>
</row>
<row>
<entry> <literal>git push -d origin branch_to_be_removed</literal> </entry>
<entry> remove remote branch (new method)</entry>
</row>
<row>
<entry> <literal>git push origin :branch_to_be_removed</literal> </entry>
<entry> remove remote branch (old method)</entry>
</row>
<row>
<entry> <literal>git checkout --orphan unconnected</literal> </entry>
<entry> create a new <literal>unconnected</literal> branch</entry>
</row>
<row>
<entry> <literal>git rebase -i origin/main</literal> </entry>
<entry> reorder/drop/squish commits from <literal>origin/main</literal> to clean branch history </entry>
</row>
<row>
<entry> <literal>git reset HEAD^; git commit --amend </literal> </entry>
<entry> squash last 2 commits into one</entry>
</row>
<row>
<entry> <literal>git checkout topic_branch ; git merge --squash topic_branch </literal> </entry>
<entry> squash entire <literal>topic_branch</literal> into a commit </entry>
</row>
<row>
<entry> <literal>git fetch --unshallow --update-head-ok origin '+refs/heads/*:refs/heads/*' </literal> </entry>
<entry> convert a shallow clone to the full clone of all branches </entry>
</row>
<row>
<entry> <literal>git ime</literal> </entry>
<entry> split the last commit into a series of file-by-file smaller commits etc. (<literal>imediff</literal> package required)</entry>
</row>
<row>
<entry> <literal>git repack -a -d; git prune</literal> </entry>
<entry> repack the local repository into single pack (this may limit chance of lost data recovery from erased branch etc.)</entry>
</row>
</tbody>
</tgroup>
</table>
<warning> <para>Do not use the tag string with spaces in it even if some tools such as <literal>gitk</literal>(1) allow you to use it. It may choke some other <literal>git</literal> commands.</para> </warning>
<caution> <para>If a local branch which has been pushed to remote repository is rebased or squashed, pushing this branch has risks and requires <literal>--force</literal> option. This is usually not an acceptable for <literal>main</literal> branch but may be acceptable for a topic branch before merging to <literal>main</literal> branch.</para> </caution>
<caution> <para>Invoking a <literal>git</literal> subcommand directly as "<literal>git-xyz</literal>" from the command line has been deprecated since early 2006.</para> </caution>
<tip> <para>If there is a executable file <literal>git-foo</literal> in the path specified by <literal>$PATH</literal>, entering "<literal>git foo</literal>" without hyphen to the command line invokes this <literal>git-foo</literal>. This is a feature of the <literal>git</literal> command.</para> </tip>
</section>
<section id="_git_references">
<title>Git references</title>
<para>See the following.</para>
<itemizedlist>
<listitem> <para><ulink url="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git.html">manpage: git(1)</ulink> (<literal>/usr/share/doc/git-doc/git.html</literal>) </para> </listitem>
<listitem> <para><ulink url="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/user-manual.html">Git User's Manual</ulink> (<literal>/usr/share/doc/git-doc/user-manual.html</literal>) </para> </listitem>
<listitem> <para><ulink url="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gittutorial.html">A tutorial introduction to git</ulink> (<literal>/usr/share/doc/git-doc/gittutorial.html</literal>) </para> </listitem>
<listitem> <para><ulink url="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gittutorial-2.html">A tutorial introduction to git: part two</ulink> (<literal>/usr/share/doc/git-doc/gittutorial-2.html</literal>) </para> </listitem>
<listitem> <para><ulink url="https://mirrors.edge.kernel.org/pub/software/scm/git/docs/giteveryday.html">Everyday GIT With 20 Commands Or So</ulink> (<literal>/usr/share/doc/git-doc/giteveryday.html</literal>) </para> </listitem>
<listitem> <para><ulink url="https://github.com/blynn/gitmagic">Git Magic</ulink> (<literal>/usr/share/doc/gitmagic/html/index.html</literal>) </para> </listitem>
</itemizedlist>
</section>
<section id="_other_version_control_systems">
<title>Other version control systems</title>
<para>The <ulink url="https://en.wikipedia.org/wiki/Revision_control">version control systems (VCS)</ulink> is sometimes known as the revision control system (RCS), or the software configuration management (SCM).</para>
<para>Here is a summary of the notable other non-Git VCS on the Debian system.</para>
<table id="list-of-vcs" pgwide="0" frame="topbot" rowsep="1" colsep="1">
<title>List of other version control system tools</title>
<tgroup cols="6">
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="76pt" align="left"/>
<colspec colwidth="70pt" align="left"/>
<colspec colwidth="342pt" align="left"/>
<colspec colwidth="65pt" align="left"/>
<colspec colwidth="504pt" align="left"/>
<thead>
<row>
<entry> package </entry>
<entry> popcon </entry>
<entry> size </entry>
<entry> tool </entry>
<entry> VCS type </entry>
<entry> comment </entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>mercurial</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Mercurial_(software)">Mercurial</ulink> </entry>
<entry> distributed </entry>
<entry> DVCS in Python and some C </entry>
</row>
<row>
<entry> <literal>darcs</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Darcs">Darcs</ulink> </entry>
<entry> distributed </entry>
<entry> DVCS with smart algebra of patches (slow) </entry>
</row>
<row>
<entry> <literal>bzr</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/GNU_Bazaar">GNU Bazaar</ulink> </entry>
<entry> distributed </entry>
<entry> DVCS influenced by <literal>tla</literal> written in Python (<ulink url="https://wiki.ubuntu.com/UbuntuDevelopment/MigratingFromBzrToGit">historic</ulink>) </entry>
</row>
<row>
<entry> <literal>tla</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/GNU_arch">GNU arch</ulink> </entry>
<entry> distributed </entry>
<entry> DVCS mainly by Tom Lord (historic) </entry>
</row>
<!-- No more in Debian
<row>
<entry> <literal>monotone</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Monotone_(software)">Monotone</ulink> </entry>
<entry> distributed </entry>
<entry> DVCS in C++ (historic)</entry>
</row>
-->
<row>
<entry> <literal>subversion</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Subversion_(software)">Subversion</ulink> </entry>
<entry> remote </entry>
<entry> "CVS done right", newer standard remote VCS (historic) </entry>
</row>
<row>
<entry> <literal>cvs</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</ulink> </entry>
<entry> remote </entry>
<entry> previous standard remote VCS (historic)</entry>
</row>
<row>
<entry> <literal>tkcvs</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> CVS, … </entry>
<entry> remote </entry>
<entry> GUI display of VCS (CVS, Subversion, RCS) repository tree </entry>
</row>
<row>
<entry> <literal>rcs</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://en.wikipedia.org/wiki/Revision_Control_System">RCS</ulink> </entry>
<entry> local </entry>
<entry> "<ulink url="https://en.wikipedia.org/wiki/Source_Code_Control_System">Unix SCCS</ulink> done right" (historic)</entry>
</row>
<row>
<entry> <literal>cssc</literal> </entry>
<entry> @-@popcon1@-@ </entry>
<entry> @-@psize1@-@ </entry>
<entry> <ulink url="https://www.gnu.org/software/cssc/">CSSC</ulink> </entry>
<entry> local </entry>
<entry> clone of the <ulink url="https://en.wikipedia.org/wiki/Source_Code_Control_System">Unix SCCS</ulink> (historic) </entry>
</row>
</tbody>
</tgroup>
</table>
</section>
</section>
</chapter>
|