old-www/LDP/www.debian.org/doc/manuals/debian-reference/ch10.en.html

4702 lines
246 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 10. Data management</title>
<link rel="stylesheet" href="debian-reference.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.en.html" title="Debian Reference">
<link rel="up" href="index.en.html" title="Debian Reference">
<link rel="prev" href="ch09.en.html" title="Chapter 9. System tips">
<link rel="next" href="ch11.en.html" title="Chapter 11. Data conversion">
<link rel="preface" href="pr01.en.html" title="Preface">
<link rel="chapter" href="ch01.en.html" title="Chapter 1. GNU/Linux tutorials">
<link rel="chapter" href="ch02.en.html" title="Chapter 2. Debian package management">
<link rel="chapter" href="ch03.en.html" title="Chapter 3. The system initialization">
<link rel="chapter" href="ch04.en.html" title="Chapter 4. Authentication">
<link rel="chapter" href="ch05.en.html" title="Chapter 5. Network setup">
<link rel="chapter" href="ch06.en.html" title="Chapter 6. Network applications">
<link rel="chapter" href="ch07.en.html" title="Chapter 7. The X Window System">
<link rel="chapter" href="ch08.en.html" title="Chapter 8. I18N and L10N">
<link rel="chapter" href="ch09.en.html" title="Chapter 9. System tips">
<link rel="chapter" href="ch10.en.html" title="Chapter 10. Data management">
<link rel="chapter" href="ch11.en.html" title="Chapter 11. Data conversion">
<link rel="chapter" href="ch12.en.html" title="Chapter 12. Programming">
<link rel="appendix" href="apa.en.html" title="Appendix A. Appendix">
<link rel="section" href="ch10.en.html#_sharing_copying_and_archiving" title="10.1. Sharing, copying, and archiving">
<link rel="section" href="ch10.en.html#_the_disk_image" title="10.2. The disk image">
<link rel="section" href="ch10.en.html#_the_binary_data" title="10.3. The binary data">
<link rel="section" href="ch10.en.html#_data_security_infrastructure" title="10.4. Data security infrastructure">
<link rel="section" href="ch10.en.html#_source_code_merge_tools" title="10.5. Source code merge tools">
<link rel="section" href="ch10.en.html#_version_control_systems" title="10.6. Version control systems">
<link rel="section" href="ch10.en.html#_cvs" title="10.7. CVS">
<link rel="section" href="ch10.en.html#_subversion" title="10.8. Subversion">
<link rel="section" href="ch10.en.html#_git" title="10.9. Git">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 10. Data management</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="ch09.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="ch11.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="_data_management"></a>Chapter 10. Data management</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="ch10.en.html#_sharing_copying_and_archiving">10.1. Sharing, copying, and archiving</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_archive_and_compression_tools">10.1.1. Archive and compression tools</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_copy_and_synchronization_tools">10.1.2. Copy and synchronization tools</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_idioms_for_the_archive">10.1.3. Idioms for the archive</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_idioms_for_the_copy">10.1.4. Idioms for the copy</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_idioms_for_the_selection_of_files">10.1.5. Idioms for the selection of files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_backup_and_recovery">10.1.6. Backup and recovery</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_backup_utility_suites">10.1.7. Backup utility suites</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_an_example_script_for_the_system_backup">10.1.8. An example script for the system backup</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_a_copy_script_for_the_data_backup">10.1.9. A copy script for the data backup</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_removable_storage_device">10.1.10. Removable storage device</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_filesystem_choice_for_sharing_data">10.1.11. Filesystem choice for sharing data</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_sharing_data_via_network">10.1.12. Sharing data via network</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_archive_media">10.1.13. Archive media</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_the_disk_image">10.2. The disk image</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_making_the_disk_image_file">10.2.1. Making the disk image file</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_writing_directly_to_the_disk">10.2.2. Writing directly to the disk</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_mounting_the_disk_image_file">10.2.3. Mounting the disk image file</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_cleaning_a_disk_image_file">10.2.4. Cleaning a disk image file</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_making_the_empty_disk_image_file">10.2.5. Making the empty disk image file</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_making_the_iso9660_image_file">10.2.6. Making the ISO9660 image file</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_writing_directly_to_the_cd_dvd_r_rw">10.2.7. Writing directly to the CD/DVD-R/RW</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_mounting_the_iso9660_image_file">10.2.8. Mounting the ISO9660 image file</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_the_binary_data">10.3. The binary data</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_viewing_and_editing_binary_data">10.3.1. Viewing and editing binary data</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_manipulating_files_without_mounting_disk">10.3.2. Manipulating files without mounting disk</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_data_redundancy">10.3.3. Data redundancy</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_data_file_recovery_and_forensic_analysis">10.3.4. Data file recovery and forensic analysis</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_splitting_a_large_file_into_small_files">10.3.5. Splitting a large file into small files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_clearing_file_contents">10.3.6. Clearing file contents</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_dummy_files">10.3.7. Dummy files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_erasing_an_entire_hard_disk">10.3.8. Erasing an entire hard disk</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_erasing_unused_area_of_an_hard_disk">10.3.9. Erasing unused area of an hard disk</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_undeleting_deleted_but_still_open_files">10.3.10. Undeleting deleted but still open files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_searching_all_hardlinks">10.3.11. Searching all hardlinks</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_invisible_disk_space_consumption">10.3.12. Invisible disk space consumption</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_data_security_infrastructure">10.4. Data security infrastructure</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_key_management_for_gnupg">10.4.1. Key management for GnuPG</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_using_gnupg_on_files">10.4.2. Using GnuPG on files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_using_gnupg_with_mutt">10.4.3. Using GnuPG with Mutt</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_using_gnupg_with_vim">10.4.4. Using GnuPG with Vim</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_the_md5_sum">10.4.5. The MD5 sum</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_source_code_merge_tools">10.5. Source code merge tools</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_extracting_differences_for_source_files">10.5.1. Extracting differences for source files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_merging_updates_for_source_files">10.5.2. Merging updates for source files</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_updating_via_3_way_merge">10.5.3. Updating via 3-way-merge</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_version_control_systems">10.6. Version control systems</a></span></dt>
<dd><dl><dt><span class="section"><a href="ch10.en.html#_comparison_of_vcs_commands">10.6.1. Comparison of VCS commands</a></span></dt></dl></dd>
<dt><span class="section"><a href="ch10.en.html#_cvs">10.7. CVS</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_configuration_of_cvs_repository">10.7.1. Configuration of CVS repository</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_local_access_to_cvs">10.7.2. Local access to CVS</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_remote_access_to_cvs_with_pserver">10.7.3. Remote access to CVS with pserver</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_remote_access_to_cvs_with_ssh">10.7.4. Remote access to CVS with ssh</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_importing_a_new_source_to_cvs">10.7.5. Importing a new source to CVS</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_file_permissions_in_cvs_repository">10.7.6. File permissions in CVS repository</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_work_flow_of_cvs">10.7.7. Work flow of CVS</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_latest_files_from_cvs">10.7.8. Latest files from CVS</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_administration_of_cvs">10.7.9. Administration of CVS</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_execution_bit_for_cvs_checkout">10.7.10. Execution bit for CVS checkout</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_subversion">10.8. Subversion</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_configuration_of_subversion_repository">10.8.1. Configuration of Subversion repository</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_access_to_subversion_via_apache2_server">10.8.2. Access to Subversion via Apache2 server</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_local_access_to_subversion_by_group">10.8.3. Local access to Subversion by group</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_remote_access_to_subversion_via_ssh">10.8.4. Remote access to Subversion via SSH</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_subversion_directory_structure">10.8.5. Subversion directory structure</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_importing_a_new_source_to_subversion">10.8.6. Importing a new source to Subversion</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_work_flow_of_subversion">10.8.7. Work flow of Subversion</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch10.en.html#_git">10.9. Git</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch10.en.html#_configuration_of_git_client">10.9.1. Configuration of Git client</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_git_references">10.9.2. Git references</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_git_commands">10.9.3. Git commands</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_git_for_the_subversion_repository">10.9.4. Git for the Subversion repository</a></span></dt>
<dt><span class="section"><a href="ch10.en.html#_git_for_recording_configuration_history">10.9.5. Git for recording configuration history</a></span></dt>
</dl></dd>
</dl>
</div>
<p>Tools and tips for managing binary and text data on the Debian system are described.</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>The uncoordinated write access to actively accessed devices and files from multiple processes must not be done to avoid the <a class="ulink" href="http://en.wikipedia.org/wiki/Race_condition" target="_top">race condition</a>. <a class="ulink" href="http://en.wikipedia.org/wiki/File_locking" target="_top">File locking</a> mechanisms using <span class="citerefentry"><span class="refentrytitle">flock</span>(1)</span> may be used to avoid it.</p></td></tr>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_sharing_copying_and_archiving"></a>10.1. Sharing, copying, and archiving</h2></div></div></div>
<p>The security of the data and its controlled sharing have several aspects.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
The creation of data archive
</p></li>
<li class="listitem"><p>
The remote storage access
</p></li>
<li class="listitem"><p>
The duplication
</p></li>
<li class="listitem"><p>
The tracking of the modification history
</p></li>
<li class="listitem"><p>
The facilitation of data sharing
</p></li>
<li class="listitem"><p>
The prevention of unauthorized file access
</p></li>
<li class="listitem"><p>
The detection of unauthorized file modification
</p></li>
</ul></div>
<p>These can be realized by using some combination of tools.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Archive and compression tools
</p></li>
<li class="listitem"><p>
Copy and synchronization tools
</p></li>
<li class="listitem"><p>
Network filesystems
</p></li>
<li class="listitem"><p>
Removable storage media
</p></li>
<li class="listitem"><p>
The secure shell
</p></li>
<li class="listitem"><p>
The authentication system
</p></li>
<li class="listitem"><p>
Version control system tools
</p></li>
<li class="listitem"><p>
Hash and cryptographic encryption tools
</p></li>
</ul></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_archive_and_compression_tools"></a>10.1.1. Archive and compression tools</h3></div></div></div>
<p>Here is a summary of archive and compression tools available on the Debian system.</p>
<div class="table">
<a name="listofarchiveandcompressiontools"></a><p class="title"><b>Table 10.1. List of archive and compression tools</b></p>
<div class="table-contents"><table summary="List of archive and compression tools" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
command
</th>
<th align="left">
extension
</th>
<th align="left">
comment
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/tar" target="_top">
<code class="literal">tar</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=tar" target="_top">http://qa.debian.org/popcon.php?package=tar</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/t/tar.html" target="_top">2464</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>
</td>
<td align="left">
<code class="literal">.tar</code>
</td>
<td align="left">
the standard archiver (de facto standard)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/cpio" target="_top">
<code class="literal">cpio</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=cpio" target="_top">http://qa.debian.org/popcon.php?package=cpio</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/cpio.html" target="_top">920</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span>
</td>
<td align="left">
<code class="literal">.cpio</code>
</td>
<td align="left">
Unix System V style archiver, use with <span class="citerefentry"><span class="refentrytitle">find</span>(1)</span>
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/binutils" target="_top">
<code class="literal">binutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=binutils" target="_top">http://qa.debian.org/popcon.php?package=binutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/binutils.html" target="_top">14823</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">ar</span>(1)</span>
</td>
<td align="left">
<code class="literal">.ar</code>
</td>
<td align="left">
archiver for the creation of static libraries
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/fastjar" target="_top">
<code class="literal">fastjar</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=fastjar" target="_top">http://qa.debian.org/popcon.php?package=fastjar</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/f/fastjar.html" target="_top">216</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">fastjar</span>(1)</span>
</td>
<td align="left">
<code class="literal">.jar</code>
</td>
<td align="left">
archiver for Java (zip like)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/pax" target="_top">
<code class="literal">pax</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=pax" target="_top">http://qa.debian.org/popcon.php?package=pax</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/pax.html" target="_top">178</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">pax</span>(1)</span>
</td>
<td align="left">
<code class="literal">.pax</code>
</td>
<td align="left">
new POSIX standard archiver, compromise between <code class="literal">tar</code> and <code class="literal">cpio</code>
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gzip" target="_top">
<code class="literal">gzip</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gzip" target="_top">http://qa.debian.org/popcon.php?package=gzip</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gzip.html" target="_top">179</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">zcat</span>(1)</span>, …
</td>
<td align="left">
<code class="literal">.gz</code>
</td>
<td align="left">
GNU <a class="ulink" href="http://en.wikipedia.org/wiki/LZ77_and_LZ78" target="_top">LZ77</a> compression utility (de facto standard)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bzip2" target="_top">
<code class="literal">bzip2</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bzip2" target="_top">http://qa.debian.org/popcon.php?package=bzip2</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bzip2.html" target="_top">86</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">bzip2</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">bzcat</span>(1)</span>, …
</td>
<td align="left">
<code class="literal">.bz2</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Burrows-Wheeler_transform" target="_top">Burrows-Wheeler block-sorting compression</a> utility with higher compression ratio than <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> (slower than <code class="literal">gzip</code> with similar syntax)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/lzma" target="_top">
<code class="literal">lzma</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=lzma" target="_top">http://qa.debian.org/popcon.php?package=lzma</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/l/lzma.html" target="_top">144</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">lzma</span>(1)</span>
</td>
<td align="left">
<code class="literal">.lzma</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm" target="_top">LZMA</a> compression utility with higher compression ratio than <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> (deprecated)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/xz-utils" target="_top">
<code class="literal">xz-utils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=xz-utils" target="_top">http://qa.debian.org/popcon.php?package=xz-utils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/x/xz-utils.html" target="_top">383</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">xz</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">xzdec</span>(1)</span>, …
</td>
<td align="left">
<code class="literal">.xz</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Xz" target="_top">XZ</a> compression utility with higher compression ratio than <span class="citerefentry"><span class="refentrytitle">bzip2</span>(1)</span> (slower than <code class="literal">gzip</code> but faster than <code class="literal">bzip2</code>; replacement for <a class="ulink" href="http://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm" target="_top">LZMA</a> compression utility)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/p7zip" target="_top">
<code class="literal">p7zip</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=p7zip" target="_top">http://qa.debian.org/popcon.php?package=p7zip</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/p7zip.html" target="_top">986</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">7zr</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">p7zip</span>(1)</span>
</td>
<td align="left">
<code class="literal">.7z</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/7-Zip" target="_top">7-Zip</a> file archiver with high compression ratio (<a class="ulink" href="http://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm" target="_top">LZMA</a> compression)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/p7zip-full" target="_top">
<code class="literal">p7zip-full</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=p7zip-full" target="_top">http://qa.debian.org/popcon.php?package=p7zip-full</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/p7zip-full.html" target="_top">3895</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">7z</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">7za</span>(1)</span>
</td>
<td align="left">
<code class="literal">.7z</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/7-Zip" target="_top">7-Zip</a> file archiver with high compression ratio (<a class="ulink" href="http://en.wikipedia.org/wiki/Lempel-Ziv-Markov_chain_algorithm" target="_top">LZMA</a> compression and others)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/lzop" target="_top">
<code class="literal">lzop</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=lzop" target="_top">http://qa.debian.org/popcon.php?package=lzop</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/l/lzop.html" target="_top">112</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">lzop</span>(1)</span>
</td>
<td align="left">
<code class="literal">.lzo</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Lempel-Ziv-Oberhumer" target="_top">LZO</a> compression utility with higher compression and decompression speed than <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> (lower compression ratio than <code class="literal">gzip</code> with similar syntax)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/zip" target="_top">
<code class="literal">zip</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=zip" target="_top">http://qa.debian.org/popcon.php?package=zip</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/z/zip.html" target="_top">636</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">zip</span>(1)</span>
</td>
<td align="left">
<code class="literal">.zip</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Info-ZIP" target="_top">InfoZIP</a>: DOS archive and compression tool
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/unzip" target="_top">
<code class="literal">unzip</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=unzip" target="_top">http://qa.debian.org/popcon.php?package=unzip</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/u/unzip.html" target="_top">377</a></td>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">unzip</span>(1)</span>
</td>
<td align="left">
<code class="literal">.zip</code>
</td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Info-ZIP" target="_top">InfoZIP</a>: DOS unarchive and decompression tool
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>Do not set the "<code class="literal">$TAPE</code>" variable unless you know what to expect. It changes <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span> behavior.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The gzipped <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span> archive uses the file extension "<code class="literal">.tgz</code>" or "<code class="literal">.tar.gz</code>".</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The xz-compressed <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span> archive uses the file extension "<code class="literal">.txz</code>" or "<code class="literal">.tar.xz</code>".</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Popular compression method in <a class="ulink" href="http://en.wikipedia.org/wiki/Free_and_open_source_software" target="_top">FOSS</a> tools such as <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span> has been moving as follows: <code class="literal">gzip</code><code class="literal">bzip2</code><code class="literal">xz</code></p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p><span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span>, <span class="citerefentry"><span class="refentrytitle">scp</span>(1)</span> and <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span> may have some limitation for special files. <span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span> is most versatile.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p><span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span> is designed to be used with <span class="citerefentry"><span class="refentrytitle">find</span>(1)</span> and other commands and suitable for creating backup scripts since the file selection part of the script can be tested independently.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Internal structure of OpenOffice data files are "<code class="literal">.jar</code>" file.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_copy_and_synchronization_tools"></a>10.1.2. Copy and synchronization tools</h3></div></div></div>
<p>Here is a summary of simple copy and backup tools available on the Debian system.</p>
<div class="table">
<a name="listofcopyandsynhronizationtools"></a><p class="title"><b>Table 10.2. List of copy and synchronization tools</b></p>
<div class="table-contents"><table summary="List of copy and synchronization tools" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
tool
</th>
<th align="left">
function
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/coreutils" target="_top">
<code class="literal">coreutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=coreutils" target="_top">http://qa.debian.org/popcon.php?package=coreutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/coreutils.html" target="_top">14088</a></td>
<td align="left">
GNU cp
</td>
<td align="left">
locally copy files and directories ("-a" for recursive)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/openssh-client" target="_top">
<code class="literal">openssh-client</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=openssh-client" target="_top">http://qa.debian.org/popcon.php?package=openssh-client</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/o/openssh-client.html" target="_top">2246</a></td>
<td align="left">
scp
</td>
<td align="left">
remotely copy files and directories (client, "<code class="literal">-r</code>" for recursive)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/openssh-server" target="_top">
<code class="literal">openssh-server</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=openssh-server" target="_top">http://qa.debian.org/popcon.php?package=openssh-server</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/o/openssh-server.html" target="_top">701</a></td>
<td align="left">
sshd
</td>
<td align="left">
remotely copy files and directories (remote server)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/rsync" target="_top">
<code class="literal">rsync</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=rsync" target="_top">http://qa.debian.org/popcon.php?package=rsync</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/rsync.html" target="_top">724</a></td>
<td align="left">
-
</td>
<td align="left">
1-way remote synchronization and backup
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/unison" target="_top">
<code class="literal">unison</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=unison" target="_top">http://qa.debian.org/popcon.php?package=unison</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/u/unison.html" target="_top">1987</a></td>
<td align="left">
-
</td>
<td align="left">
2-way remote synchronization and backup
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>Copying files with <span class="citerefentry"><span class="refentrytitle">rsync</span>(8)</span> offers richer features than others.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
delta-transfer algorithm that sends only the differences between the source files and the existing files in the destination
</p></li>
<li class="listitem"><p>
quick check algorithm (by default) that looks for files that have changed in size or in last-modified time
</p></li>
<li class="listitem"><p>
"<code class="literal">--exclude</code>" and "<code class="literal">--exclude-from</code>" options similar to <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>
</p></li>
<li class="listitem"><p>
"a trailing slash on the source directory" syntax that avoids creating an additional directory level at the destination.
</p></li>
</ul></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Execution of the <code class="literal">bkup</code> script mentioned in <a class="xref" href="ch10.en.html#_a_copy_script_for_the_data_backup" title="10.1.9. A copy script for the data backup">Section 10.1.9, “A copy script for the data backup”</a> with the "<code class="literal">-gl</code>" option under <span class="citerefentry"><span class="refentrytitle">cron</span>(8)</span> should provide very similar functionality as Plan9's <code class="literal">dumpfs</code> for the static data archive.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Version control system (VCS) tools in <a class="xref" href="ch10.en.html#list-of-vcs" title="Table 10.15. List of version control system tools">Table 10.15, “List of version control system tools”</a> can function as the multi-way copy and synchronization tools.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_idioms_for_the_archive"></a>10.1.3. Idioms for the archive</h3></div></div></div>
<p>Here are several ways to archive and unarchive the entire content of the directory "<code class="literal">./source</code>" using different tools.</p>
<p>GNU <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>:</p>
<pre class="screen">$ tar cvzf archive.tar.gz ./source
$ tar xvzf archive.tar.gz</pre>
<p><span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span>:</p>
<pre class="screen">$ find ./source -xdev -print0 | cpio -ov --null &gt; archive.cpio; gzip archive.cpio
$ zcat archive.cpio.gz | cpio -i</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_idioms_for_the_copy"></a>10.1.4. Idioms for the copy</h3></div></div></div>
<p>Here are several ways to copy the entire content of the directory "<code class="literal">./source</code>" using different tools.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Local copy: "<code class="literal">./source</code>" directory → "<code class="literal">/dest</code>" directory
</p></li>
<li class="listitem"><p>
Remote copy: "<code class="literal">./source</code>" directory at local host → "<code class="literal">/dest</code>" directory at "<code class="literal">user@host.dom</code>" host
</p></li>
</ul></div>
<p><span class="citerefentry"><span class="refentrytitle">rsync</span>(8)</span>:</p>
<pre class="screen"># cd ./source; rsync -av . /dest
# cd ./source; rsync -av . user@host.dom:/dest</pre>
<p>You can alternatively use "a trailing slash on the source directory" syntax.</p>
<pre class="screen"># rsync -av ./source/ /dest
# rsync -av ./source/ user@host.dom:/dest</pre>
<p>GNU <span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span> and openSSH <span class="citerefentry"><span class="refentrytitle">scp</span>(1)</span>:</p>
<pre class="screen"># cd ./source; cp -a . /dest
# cd ./source; scp -pr . user@host.dom:/dest</pre>
<p>GNU <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>:</p>
<pre class="screen"># (cd ./source &amp;&amp; tar cf - . ) | (cd /dest &amp;&amp; tar xvfp - )
# (cd ./source &amp;&amp; tar cf - . ) | ssh user@host.dom '(cd /dest &amp;&amp; tar xvfp - )'</pre>
<p><span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span>:</p>
<pre class="screen"># cd ./source; find . -print0 | cpio -pvdm --null --sparse /dest</pre>
<p>You can substitute "<code class="literal">.</code>" with "<code class="literal">foo</code>" for all examples containing "<code class="literal">.</code>" to copy files from "<code class="literal">./source/foo</code>" directory to "<code class="literal">/dest/foo</code>" directory.</p>
<p>You can substitute "<code class="literal">.</code>" with the absolute path "<code class="literal">/path/to/source/foo</code>" for all examples containing "<code class="literal">.</code>" to drop "<code class="literal">cd ./source;</code>". These copy files to different locations depending on tools used as follows.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
"<code class="literal">/dest/foo</code>": <span class="citerefentry"><span class="refentrytitle">rsync</span>(8)</span>, GNU <span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span>, and <span class="citerefentry"><span class="refentrytitle">scp</span>(1)</span>
</p></li>
<li class="listitem"><p>
"<code class="literal">/path/to/source/foo</code>": GNU <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>, and <span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span>
</p></li>
</ul></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p><span class="citerefentry"><span class="refentrytitle">rsync</span>(8)</span> and GNU <span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span> have option "<code class="literal">-u</code>" to skip files that are newer on the receiver.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_idioms_for_the_selection_of_files"></a>10.1.5. Idioms for the selection of files</h3></div></div></div>
<p><span class="citerefentry"><span class="refentrytitle">find</span>(1)</span> is used to select files for archive and copy commands (see <a class="xref" href="ch10.en.html#_idioms_for_the_archive" title="10.1.3. Idioms for the archive">Section 10.1.3, “Idioms for the archive”</a> and <a class="xref" href="ch10.en.html#_idioms_for_the_copy" title="10.1.4. Idioms for the copy">Section 10.1.4, “Idioms for the copy”</a>) or for <span class="citerefentry"><span class="refentrytitle">xargs</span>(1)</span> (see <a class="xref" href="ch09.en.html#_repeating_a_command_looping_over_files" title="9.5.9. Repeating a command looping over files">Section 9.5.9, “Repeating a command looping over files”</a>). This can be enhanced by using its command arguments.</p>
<p>Basic syntax of <span class="citerefentry"><span class="refentrytitle">find</span>(1)</span> can be summarized as the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Its conditional arguments are evaluated from left to right.
</p></li>
<li class="listitem"><p>
This evaluation stops once its outcome is determined.
</p></li>
<li class="listitem"><p>
"Logical <span class="strong"><strong>OR</strong></span>" (specified by "<code class="literal">-o</code>" between conditionals) has lower precedence than "logical <span class="strong"><strong>AND</strong></span>" (specified by "<code class="literal">-a</code>" or nothing between conditionals).
</p></li>
<li class="listitem"><p>
"Logical <span class="strong"><strong>NOT</strong></span>" (specified by "<code class="literal">!</code>" before a conditional) has higher precedence than "logical <span class="strong"><strong>AND</strong></span>".
</p></li>
<li class="listitem"><p>
"<code class="literal">-prune</code>" always returns logical <span class="strong"><strong>TRUE</strong></span> and, if it is a directory, searching of file is stopped beyond this point.
</p></li>
<li class="listitem"><p>
"<code class="literal">-name</code>" matches the base of the filename with shell glob (see <a class="xref" href="ch01.en.html#_shell_glob" title="1.5.6. Shell glob">Section 1.5.6, “Shell glob”</a>) but it also matches its initial "<code class="literal">.</code>" with metacharacters such as "<code class="literal">*</code>" and "<code class="literal">?</code>". (New <a class="ulink" href="http://en.wikipedia.org/wiki/POSIX" target="_top">POSIX</a> feature)
</p></li>
<li class="listitem"><p>
"<code class="literal">-regex</code>" matches the full path with emacs style <span class="strong"><strong>BRE</strong></span> (see <a class="xref" href="ch01.en.html#_regular_expressions" title="1.6.2. Regular expressions">Section 1.6.2, “Regular expressions”</a>) as default.
</p></li>
<li class="listitem"><p>
"<code class="literal">-size</code>" matches the file based on the file size (value precedented with "<code class="literal">+</code>" for larger, precedented with "<code class="literal">-</code>" for smaller)
</p></li>
<li class="listitem"><p>
"<code class="literal">-newer</code>" matches the file newer than the one specified in its argument.
</p></li>
<li class="listitem"><p>
"<code class="literal">-print0</code>" always returns logical <span class="strong"><strong>TRUE</strong></span> and print the full filename (<a class="ulink" href="http://en.wikipedia.org/wiki/Null_character" target="_top">null terminated</a>) on the standard output.
</p></li>
</ul></div>
<p><span class="citerefentry"><span class="refentrytitle">find</span>(1)</span> is often used with an idiomatic style as the following.</p>
<pre class="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</pre>
<p>This means to do following actions.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
Search all files starting from "<code class="literal">/path/to</code>"
</p></li>
<li class="listitem"><p>
Globally limit its search within its starting filesystem and uses <span class="strong"><strong>ERE</strong></span> (see <a class="xref" href="ch01.en.html#_regular_expressions" title="1.6.2. Regular expressions">Section 1.6.2, “Regular expressions”</a>) instead
</p></li>
<li class="listitem"><p>
Exclude files matching regex of "<code class="literal">.*\.cpio</code>" or "<code class="literal">.*~</code>" from search by stop processing
</p></li>
<li class="listitem"><p>
Exclude directories matching regex of "<code class="literal">.*/\.git</code>" from search by stop processing
</p></li>
<li class="listitem"><p>
Exclude files larger than 99 Megabytes (units of 1048576 bytes) from search by stop processing
</p></li>
<li class="listitem"><p>
Print filenames which satisfy above search conditions and newer than "<code class="literal">/path/to/timestamp</code>"
</p></li>
</ol></div>
<p>Please note the idiomatic use of "<code class="literal">-prune -o</code>" to exclude files in the above example.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>For non-Debian <a class="ulink" href="http://en.wikipedia.org/wiki/Unix-like" target="_top">Unix-like</a> system, some options may not be supported by <span class="citerefentry"><span class="refentrytitle">find</span>(1)</span>. In such a case, please consider to adjust matching methods and replace "<code class="literal">-print0</code>" with "<code class="literal">-print</code>". You may need to adjust related commands too.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_backup_and_recovery"></a>10.1.6. Backup and recovery</h3></div></div></div>
<p>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.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Keep your backup system simple and backup your system often. Having backup data is more important than how technically good your backup method is.</p></td></tr>
</table></div>
<p>There are 3 key factors which determine actual backup and recovery policy.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<p>
Knowing what to backup and recover.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Data files directly created by you: data in "<code class="literal">~/</code>"
</p></li>
<li class="listitem"><p>
Data files created by applications used by you: data in "<code class="literal">/var/</code>" (except "<code class="literal">/var/cache/</code>", "<code class="literal">/var/run/</code>", and "<code class="literal">/var/tmp/</code>")
</p></li>
<li class="listitem"><p>
System configuration files: data in "<code class="literal">/etc/</code>"
</p></li>
<li class="listitem"><p>
Local softwares: data in "<code class="literal">/usr/local/</code>" or "<code class="literal">/opt/</code>"
</p></li>
<li class="listitem"><p>
System installation information: a memo in plain text on key steps (partition, …)
</p></li>
<li class="listitem"><p>
Proven set of data: confirmed by experimental recovery operations in advance
</p></li>
</ul></div>
</li>
<li class="listitem">
<p>
Knowing how to backup and recover.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Secure storage of data: protection from overwrite and system failure
</p></li>
<li class="listitem"><p>
Frequent backup: scheduled backup
</p></li>
<li class="listitem"><p>
Redundant backup: data mirroring
</p></li>
<li class="listitem"><p>
Fool proof process: easy single command backup
</p></li>
</ul></div>
</li>
<li class="listitem">
<p>
Assessing risks and costs involved.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Value of data when lost
</p></li>
<li class="listitem"><p>
Required resources for backup: human, hardware, software, …
</p></li>
<li class="listitem"><p>
Failure mode and their possibility
</p></li>
</ul></div>
</li>
</ol></div>
<p>As for secure storage of data, 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 write-once media such as CD/DVD-R to prevent overwrite accidents. (See <a class="xref" href="ch10.en.html#_the_binary_data" title="10.3. The binary data">Section 10.3, “The binary data”</a> 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".)</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>You may wish to stop some application daemons such as MTA (see <a class="xref" href="ch06.en.html#_mail_transport_agent_mta" title="6.3. Mail transport agent (MTA)">Section 6.3, “Mail transport agent (MTA)”</a>) while backing up data.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>You should pay extra care to the backup and restoration of identity related data files such as "<code class="literal">/etc/ssh/ssh_host_dsa_key</code>", "<code class="literal">/etc/ssh/ssh_host_rsa_key</code>", "<code class="literal">~/.gnupg/*</code>", "<code class="literal">~/.ssh/*</code>", "<code class="literal">/etc/passwd</code>", "<code class="literal">/etc/shadow</code>", "<code class="literal">/etc/fetchmailrc</code>", "<code class="literal">popularity-contest.conf</code>", "<code class="literal">/etc/ppp/pap-secrets</code>", and "<code class="literal">/etc/exim4/passwd.client</code>". Some of these data can not be regenerated by entering the same input string to the system.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>If you run a cron job as a user process, you must restore files in "<code class="literal">/var/spool/cron/crontabs</code>" directory and restart <span class="citerefentry"><span class="refentrytitle">cron</span>(8)</span>. See <a class="xref" href="ch09.en.html#_scheduling_tasks_regularly" title="9.5.14. Scheduling tasks regularly">Section 9.5.14, “Scheduling tasks regularly”</a> for <span class="citerefentry"><span class="refentrytitle">cron</span>(8)</span> and <span class="citerefentry"><span class="refentrytitle">crontab</span>(1)</span>.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_backup_utility_suites"></a>10.1.7. Backup utility suites</h3></div></div></div>
<p>Here is a select list of notable backup utility suites available on the Debian system.</p>
<div class="table">
<a name="listofbackupsuiteutilities"></a><p class="title"><b>Table 10.3. List of backup suite utilities</b></p>
<div class="table-contents"><table summary="List of backup suite utilities" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/rdiff-backup" target="_top">
<code class="literal">rdiff-backup</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=rdiff-backup" target="_top">http://qa.debian.org/popcon.php?package=rdiff-backup</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/rdiff-backup.html" target="_top">704</a></td>
<td align="left">
(remote) incremental backup
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dump" target="_top">
<code class="literal">dump</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dump" target="_top">http://qa.debian.org/popcon.php?package=dump</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dump.html" target="_top">716</a></td>
<td align="left">
4.4 <a class="ulink" href="http://en.wikipedia.org/wiki/Berkeley_Software_Distribution" target="_top">BSD</a> <span class="citerefentry"><span class="refentrytitle">dump</span>(8)</span> and <span class="citerefentry"><span class="refentrytitle">restore</span>(8)</span> for <a class="ulink" href="http://en.wikipedia.org/wiki/Ext2" target="_top">ext2</a>/<a class="ulink" href="http://en.wikipedia.org/wiki/Ext3" target="_top">ext3</a> filesystems
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/xfsdump" target="_top">
<code class="literal">xfsdump</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=xfsdump" target="_top">http://qa.debian.org/popcon.php?package=xfsdump</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/x/xfsdump.html" target="_top">595</a></td>
<td align="left">
dump and restore with <span class="citerefentry"><span class="refentrytitle">xfsdump</span>(8)</span> and <span class="citerefentry"><span class="refentrytitle">xfsrestore</span>(8)</span> for <a class="ulink" href="http://en.wikipedia.org/wiki/XFS" target="_top">XFS</a> filesystem on GNU/Linux and <a class="ulink" href="http://en.wikipedia.org/wiki/IRIX" target="_top">IRIX</a>
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/backupninja" target="_top">
<code class="literal">backupninja</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=backupninja" target="_top">http://qa.debian.org/popcon.php?package=backupninja</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/backupninja.html" target="_top">276</a></td>
<td align="left">
lightweight, extensible <span class="strong"><strong>meta-backup</strong></span> system
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/sbackup" target="_top">
<code class="literal">sbackup</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=sbackup" target="_top">http://qa.debian.org/popcon.php?package=sbackup</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/sbackup.html" target="_top">488</a></td>
<td align="left">
simple backup suite for GNOME desktop
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bacula-common" target="_top">
<code class="literal">bacula-common</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bacula-common" target="_top">http://qa.debian.org/popcon.php?package=bacula-common</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bacula-common.html" target="_top">1083</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Bacula" target="_top">Bacula</a>: network backup, recovery and verification - common support files
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bacula-client" target="_top">
<code class="literal">bacula-client</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bacula-client" target="_top">http://qa.debian.org/popcon.php?package=bacula-client</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bacula-client.html" target="_top">53</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Bacula" target="_top">Bacula</a>: network backup, recovery and verification - client meta-package
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bacula-console" target="_top">
<code class="literal">bacula-console</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bacula-console" target="_top">http://qa.debian.org/popcon.php?package=bacula-console</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bacula-console.html" target="_top">154</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Bacula" target="_top">Bacula</a>: network backup, recovery and verification - text console
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bacula-server" target="_top">
<code class="literal">bacula-server</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bacula-server" target="_top">http://qa.debian.org/popcon.php?package=bacula-server</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bacula-server.html" target="_top">53</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Bacula" target="_top">Bacula</a>: network backup, recovery and verification - server meta-package
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/amanda-common" target="_top">
<code class="literal">amanda-common</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=amanda-common" target="_top">http://qa.debian.org/popcon.php?package=amanda-common</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/a/amanda-common.html" target="_top">7013</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver" target="_top">Amanda</a>: Advanced Maryland Automatic Network Disk Archiver (Libs)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/amanda-client" target="_top">
<code class="literal">amanda-client</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=amanda-client" target="_top">http://qa.debian.org/popcon.php?package=amanda-client</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/a/amanda-client.html" target="_top">789</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver" target="_top">Amanda</a>: Advanced Maryland Automatic Network Disk Archiver (Client)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/amanda-server" target="_top">
<code class="literal">amanda-server</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=amanda-server" target="_top">http://qa.debian.org/popcon.php?package=amanda-server</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/a/amanda-server.html" target="_top">920</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver" target="_top">Amanda</a>: Advanced Maryland Automatic Network Disk Archiver (Server)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/backuppc" target="_top">
<code class="literal">backuppc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=backuppc" target="_top">http://qa.debian.org/popcon.php?package=backuppc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/backuppc.html" target="_top">1955</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Backuppc" target="_top">BackupPC</a> is a high-performance, enterprise-grade system for backing up PCs (disk based)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/backup-manager" target="_top">
<code class="literal">backup-manager</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=backup-manager" target="_top">http://qa.debian.org/popcon.php?package=backup-manager</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/backup-manager.html" target="_top">615</a></td>
<td align="left">
command-line backup tool
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/backup2l" target="_top">
<code class="literal">backup2l</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=backup2l" target="_top">http://qa.debian.org/popcon.php?package=backup2l</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/backup2l.html" target="_top">86</a></td>
<td align="left">
low-maintenance backup/restore tool for mountable media (disk based)
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>Backup tools have their specialized focuses.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Mondo_Rescue" target="_top">Mondo Rescue</a> is a backup system to facilitate restoration of complete system quickly from backup CD/DVD etc. without going through normal system installation processes.
</p></li>
<li class="listitem"><p><code class="literal">sbackup</code> and <code class="literal">keep</code> packages provide easy GUI frontend for desktop users to make regular backups of user data. An equivalent function can be realized by a simple script (<a class="xref" href="ch10.en.html#_an_example_script_for_the_system_backup" title="10.1.8. An example script for the system backup">Section 10.1.8, “An example script for the system backup”</a>) and <span class="citerefentry"><span class="refentrytitle">cron</span>(8)</span>.
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Bacula" target="_top">Bacula</a>, <a class="ulink" href="http://en.wikipedia.org/wiki/Advanced_Maryland_Automatic_Network_Disk_Archiver" target="_top">Amanda</a>, and <a class="ulink" href="http://en.wikipedia.org/wiki/Backuppc" target="_top">BackupPC</a> are full featured backup suite utilities which are focused on regular backups over network.
</p></li>
</ul></div>
<p>Basic tools described in <a class="xref" href="ch10.en.html#_archive_and_compression_tools" title="10.1.1. Archive and compression tools">Section 10.1.1, “Archive and compression tools”</a> and <a class="xref" href="ch10.en.html#_copy_and_synchronization_tools" title="10.1.2. Copy and synchronization tools">Section 10.1.2, “Copy and synchronization tools”</a> can be used to facilitate system backup via custom scripts. Such script can be enhanced by the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
The <code class="literal">rdiff-backup</code> package enables incremental (remote) backups.
</p></li>
<li class="listitem"><p>
The <code class="literal">dump</code> package helps to archive and restore the whole filesystem incrementally and efficiently.
</p></li>
</ul></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>See files in "<code class="literal">/usr/share/doc/dump/</code>" and <a class="ulink" href="http://dump.sourceforge.net/isdumpdeprecated.html" target="_top">"Is dump really deprecated?"</a> to lean about the <code class="literal">dump</code> package.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_an_example_script_for_the_system_backup"></a>10.1.8. An example script for the system backup</h3></div></div></div>
<p>For a personal Debian desktop system running <code class="literal">unstable</code> suite, I only need to protect personal and critical data. I reinstall system once a year anyway. Thus I see no reason to backup the whole system or to install a full featured backup utility.</p>
<p>I use a simple script to make a backup archive and burn it into CD/DVD using GUI. Here is an example script for this.</p>
<pre class="screen">#!/bin/sh -e
# Copyright (C) 2007-2008 Osamu Aoki &lt;osamu@debian.org&gt;, Public Domain
BUUID=1000; USER=osamu # UID and name of a user who accesses backup files
BUDIR="/var/backups"
XDIR0=".+/Mail|.+/Desktop"
XDIR1=".+/\.thumbnails|.+/\.?Trash|.+/\.?[cC]ache|.+/\.gvfs|.+/sessions"
XDIR2=".+/CVS|.+/\.git|.+/\.svn|.+/Downloads|.+/Archive|.+/Checkout|.+/tmp"
XSFX=".+\.iso|.+\.tgz|.+\.tar\.gz|.+\.tar\.bz2|.+\.cpio|.+\.tmp|.+\.swp|.+~"
SIZE="+99M"
DATE=$(date --utc +"%Y%m%d-%H%M")
[ -d "$BUDIR" ] || mkdir -p "BUDIR"
umask 077
dpkg --get-selections \* &gt; /var/lib/dpkg/dpkg-selections.list
debconf-get-selections &gt; /var/cache/debconf/debconf-selections
{
find /etc /usr/local /opt /var/lib/dpkg/dpkg-selections.list \
/var/cache/debconf/debconf-selections -xdev -print0
find /home/$USER /root -xdev -regextype posix-extended \
-type d -regex "$XDIR0|$XDIR1" -prune -o -type f -regex "$XSFX" -prune -o \
-type f -size "$SIZE" -prune -o -print0
find /home/$USER/Mail/Inbox /home/$USER/Mail/Outbox -print0
find /home/$USER/Desktop -xdev -regextype posix-extended \
-type d -regex "$XDIR2" -prune -o -type f -regex "$XSFX" -prune -o \
-type f -size "$SIZE" -prune -o -print0
} | cpio -ov --null -O $BUDIR/BU$DATE.cpio
chown $BUUID $BUDIR/BU$DATE.cpio
touch $BUDIR/backup.stamp</pre>
<p>This is meant to be a script example executed from root.</p>
<p>I expect you to change and execute this as follows.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Edit this script to cover all your important data (see <a class="xref" href="ch10.en.html#_idioms_for_the_selection_of_files" title="10.1.5. Idioms for the selection of files">Section 10.1.5, “Idioms for the selection of files”</a> and <a class="xref" href="ch10.en.html#_backup_and_recovery" title="10.1.6. Backup and recovery">Section 10.1.6, “Backup and recovery”</a>).
</p></li>
<li class="listitem"><p>
Replace "<code class="literal">find … -print0</code>" with "<code class="literal">find … -newer $BUDIR/backup.stamp -print0</code>" to make a incremental backup.
</p></li>
<li class="listitem"><p>
Transfer backup files to the remote host using <span class="citerefentry"><span class="refentrytitle">scp</span>(1)</span> or <span class="citerefentry"><span class="refentrytitle">rsync</span>(1)</span> or burn them to CD/DVD for extra data security. (I use GNOME desktop GUI for burning CD/DVD. See <a class="xref" href="ch12.en.html#_shell_script_example_with_zenity" title="12.1.8. Shell script example with zenity">Section 12.1.8, “Shell script example with zenity”</a> for extra redundancy.)
</p></li>
</ul></div>
<p>Keep it simple!</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can recover debconf configuration data with "<code class="literal">debconf-set-selections debconf-selections</code>" and dpkg selection data with "<code class="literal">dpkg --set-selection &lt;dpkg-selections.list</code>".</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_a_copy_script_for_the_data_backup"></a>10.1.9. A copy script for the data backup</h3></div></div></div>
<p>For the set of data under a directory tree, the copy with "<code class="literal">cp -a</code>" provides the normal backup.</p>
<p>For the set of large non-overwritten static data under a directory tree such as the one under the "<code class="literal">/var/cache/apt/packages/</code>" directory, hardlinks with "<code class="literal">cp -al</code>" provide an alternative to the normal backup with efficient use of the disk space.</p>
<p>Here is a copy script, which I named as <code class="literal">bkup</code>, for the data backup. This script copies all (non-VCS) files under the current directory to the dated directory on the parent directory or on a remote host.</p>
<pre class="screen">#!/bin/sh -e
# Copyright (C) 2007-2008 Osamu Aoki &lt;osamu@debian.org&gt;, Public Domain
fdot(){ find . -type d \( -iname ".?*" -o -iname "CVS" \) -prune -o -print0;}
fall(){ find . -print0;}
mkdircd(){ mkdir -p "$1";chmod 700 "$1";cd "$1"&gt;/dev/null;}
FIND="fdot";OPT="-a";MODE="CPIOP";HOST="localhost";EXTP="$(hostname -f)"
BKUP="$(basename $(pwd)).bkup";TIME="$(date +%Y%m%d-%H%M%S)";BU="$BKUP/$TIME"
while getopts gcCsStrlLaAxe:h:T f; do case $f in
g) MODE="GNUCP";; # cp (GNU)
c) MODE="CPIOP";; # cpio -p
C) MODE="CPIOI";; # cpio -i
s) MODE="CPIOSSH";; # cpio/ssh
t) MODE="TARSSH";; # tar/ssh
r) MODE="RSYNCSSH";; # rsync/ssh
l) OPT="-alv";; # hardlink (GNU cp)
L) OPT="-av";; # copy (GNU cp)
a) FIND="fall";; # find all
A) FIND="fdot";; # find non CVS/ .???/
x) set -x;; # trace
e) EXTP="${OPTARG}";; # hostname -f
h) HOST="${OPTARG}";; # user@remotehost.example.com
T) MODE="TEST";; # test find mode
\?) echo "use -x for trace."
esac; done
shift $(expr $OPTIND - 1)
if [ $# -gt 0 ]; then
for x in $@; do cp $OPT $x $x.$TIME; done
elif [ $MODE = GNUCP ]; then
mkdir -p "../$BU";chmod 700 "../$BU";cp $OPT . "../$BU/"
elif [ $MODE = CPIOP ]; then
mkdir -p "../$BU";chmod 700 "../$BU"
$FIND|cpio --null --sparse -pvd ../$BU
elif [ $MODE = CPIOI ]; then
$FIND|cpio -ov --null | ( mkdircd "../$BU"&amp;&amp;cpio -i )
elif [ $MODE = CPIOSSH ]; then
$FIND|cpio -ov --null|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&amp;&amp;cpio -i )"
elif [ $MODE = TARSSH ]; then
(tar cvf - . )|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&amp;&amp; tar xvfp - )"
elif [ $MODE = RSYNCSSH ]; then
rsync -rlpt ./ "${HOST}:${EXTP}-${BKUP}-${TIME}"
else
echo "Any other idea to backup?"
$FIND |xargs -0 -n 1 echo
fi</pre>
<p>This is meant to be command examples. Please read script and edit it by yourself before using it.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>I keep this <code class="literal">bkup</code> in my "<code class="literal">/usr/local/bin/</code>" directory. I issue this <code class="literal">bkup</code> command without any option in the working directory whenever I need a temporary snapshot backup.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>For making snapshot history of a source file tree or a configuration file tree, it is easier and space efficient to use <span class="citerefentry"><span class="refentrytitle">git</span>(7)</span> (see <a class="xref" href="ch10.en.html#_git_for_recording_configuration_history" title="10.9.5. Git for recording configuration history">Section 10.9.5, “Git for recording configuration history”</a>).</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_removable_storage_device"></a>10.1.10. Removable storage device</h3></div></div></div>
<p>Removable storage devices may be any one of the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/USB_flash_drive" target="_top">USB flash drive</a>
</p></li>
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/Hard_disk_drive" target="_top">Hard disk drive</a>
</p></li>
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/Optical_disc_drive" target="_top">Optical disc drive</a>
</p></li>
<li class="listitem"><p>
Digital camera
</p></li>
<li class="listitem"><p>
Digital music player
</p></li>
</ul></div>
<p>They may be connected via any one of the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/Universal_Serial_Bus" target="_top">USB</a>
</p></li>
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/IEEE_1394" target="_top">IEEE 1394 / FireWire</a>
</p></li>
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/PC_card" target="_top">PC Card</a>
</p></li>
</ul></div>
<p>Modern desktop environments such as GNOME and KDE can mount these removable devices automatically without a matching "<code class="literal">/etc/fstab</code>" entry.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><code class="literal">udisks</code> package provides a daemon and associated utilities to mount and unmount these devices.
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/D-Bus" target="_top">D-bus</a> creates events to initiate automatic processes.
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/PolicyKit" target="_top">PolicyKit</a> provides required privileges.
</p></li>
</ul></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Automounted devices may have the "<code class="literal">uhelper=</code>" mount option which is used by <span class="citerefentry"><span class="refentrytitle">umount</span>(8)</span>.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Automounting under modern desktop environment happens only when those removable media devices are not listed in "<code class="literal">/etc/fstab</code>".</p></td></tr>
</table></div>
<p>Mount point under modern desktop environment is chosen as "<code class="literal">/media/&lt;disk_label&gt;</code>" which can be customized by the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">mlabel</span>(1)</span> for FAT filesystem
</p></li>
<li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">genisoimage</span>(1)</span> with "<code class="literal">-V</code>" option for ISO9660 filesystem
</p></li>
<li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">tune2fs</span>(1)</span> with "<code class="literal">-L</code>" option for ext2/ext3/ext4 filesystem
</p></li>
</ul></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>The choice of encoding may need to be provided as mount option (see <a class="xref" href="ch08.en.html#_filename_encoding" title="8.3.6. Filename encoding">Section 8.3.6, “Filename encoding”</a>).</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_filesystem_choice_for_sharing_data"></a>10.1.11. Filesystem choice for sharing data</h3></div></div></div>
<p>When sharing data with other system via removable storage device, you should format it with common <a class="ulink" href="http://en.wikipedia.org/wiki/File_system" target="_top">filesystem</a> supported by both systems. Here is a list of filesystem choices.</p>
<div class="table">
<a name="listoffilesystemalusagescenarios"></a><p class="title"><b>Table 10.4. List of filesystem choices for removable storage devices with typical usage scenarios</b></p>
<div class="table-contents"><table summary="List of filesystem choices for removable storage devices with typical usage scenarios" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
filesystem
</th>
<th align="left">
description of typical usage scenario
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/File_Allocation_Table" target="_top">FAT12</a>
</td>
<td align="left">
cross platform sharing of data on the floppy disk (&lt;32MiB)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/File_Allocation_Table" target="_top">FAT16</a>
</td>
<td align="left">
cross platform sharing of data on the small hard disk like device (&lt;2GiB)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/File_Allocation_Table" target="_top">FAT32</a>
</td>
<td align="left">
cross platform sharing of data on the large hard disk like device (&lt;8TiB, supported by newer than MS Windows95 OSR2)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/NTFS" target="_top">NTFS</a>
</td>
<td align="left">
cross platform sharing of data on the large hard disk like device (supported natively on <a class="ulink" href="http://en.wikipedia.org/wiki/Windows_NT" target="_top">MS Windows NT</a> and later version, and supported by <a class="ulink" href="http://en.wikipedia.org/wiki/NTFS-3G" target="_top">NTFS-3G</a> via <a class="ulink" href="http://en.wikipedia.org/wiki/Filesystem_in_Userspace" target="_top">FUSE</a> on Linux)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/ISO_9660" target="_top">ISO9660</a>
</td>
<td align="left">
cross platform sharing of static data on CD-R and DVD+/-R
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Universal_Disk_Format" target="_top">UDF</a>
</td>
<td align="left">
incremental data writing on CD-R and DVD+/-R (new)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Minix_file_system" target="_top">MINIX filesystem</a>
</td>
<td align="left">
space efficient unix file data storage on the floppy disk
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Ext2" target="_top">ext2 filesystem</a>
</td>
<td align="left">
sharing of data on the hard disk like device with older Linux systems
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Ext3" target="_top">ext3 filesystem</a>
</td>
<td align="left">
sharing of data on the hard disk like device with older Linux systems
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Ext4" target="_top">ext4 filesystem</a>
</td>
<td align="left">
sharing of data on the hard disk like device with current Linux systems
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>See <a class="xref" href="ch09.en.html#_removable_disk_encryption_with_dm_crypt_luks" title="9.4.1. Removable disk encryption with dm-crypt/LUKS">Section 9.4.1, “Removable disk encryption with dm-crypt/LUKS”</a> for cross platform sharing of data using device level encryption.</p></td></tr>
</table></div>
<p>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.</p>
<p>When formatting removable hard disk like devices for cross platform sharing of data with the FAT filesystem, the following should be safe choices.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<p>
Partitioning them with <span class="citerefentry"><span class="refentrytitle">fdisk</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">cfdisk</span>(8)</span> or <span class="citerefentry"><span class="refentrytitle">parted</span>(8)</span> (see <a class="xref" href="ch09.en.html#_disk_partition_configuration" title="9.3.2. Disk partition configuration">Section 9.3.2, “Disk partition configuration”</a>) into a single primary partition and to mark it as the following.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem"><p>
Type "6" for FAT16 for media smaller than 2GB.
</p></li>
<li class="listitem"><p>
Type "c" for FAT32 (LBA) for larger media.
</p></li>
</ul></div>
</li>
<li class="listitem">
<p>
Formatting the primary partition with <span class="citerefentry"><span class="refentrytitle">mkfs.vfat</span>(8)</span> with the following.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem"><p>
Just its device name, e.g. "<code class="literal">/dev/sda1</code>" for FAT16
</p></li>
<li class="listitem"><p>
The explicit option and its device name, e.g. "<code class="literal">-F 32 /dev/sda1</code>" for FAT32
</p></li>
</ul></div>
</li>
</ul></div>
<p>When using the FAT or ISO9660 filesystems for sharing data, the following should be the safe considerations.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Archiving files into an archive file first using <span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span>, or <span class="citerefentry"><span class="refentrytitle">cpio</span>(1)</span> to retain the long filename, the symbolic link, the original Unix file permission and the owner information.
</p></li>
<li class="listitem"><p>
Splitting the archive file into less than 2 GiB chunks with the <span class="citerefentry"><span class="refentrytitle">split</span>(1)</span> command to protect it from the file size limitation.
</p></li>
<li class="listitem"><p>
Encrypting the archive file to secure its contents from the unauthorized access.
</p></li>
</ul></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>For FAT filesystems by its design, the maximum file size is <code class="literal">(2^32 - 1) bytes = (4GiB - 1 byte)</code>. For some applications on the older 32 bit OS, the maximum file size was even smaller <code class="literal">(2^31 - 1) bytes = (2GiB - 1 byte)</code>. Debian does not suffer the latter problem.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>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 "<a class="ulink" href="http://support.microsoft.com/kb/100108/" target="_top">Overview of FAT, HPFS, and NTFS File Systems</a>". Of course, we should normally use the ext4 filesystem for Linux.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>For more on filesystems and accessing filesystems, please read "<a class="ulink" href="http://tldp.org/HOWTO/Filesystems-HOWTO.html" target="_top">Filesystems HOWTO</a>".</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_sharing_data_via_network"></a>10.1.12. Sharing data via network</h3></div></div></div>
<p>When sharing data with other system via network, you should use common service. Here are some hints.</p>
<div class="table">
<a name="listofthenetworkcalusagescenario"></a><p class="title"><b>Table 10.5. List of the network service to chose with the typical usage scenario</b></p>
<div class="table-contents"><table summary="List of the network service to chose with the typical usage scenario" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
network service
</th>
<th align="left">
description of typical usage scenario
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Server_Message_Block" target="_top">SMB/CIFS</a> network mounted filesystem with <a class="ulink" href="http://en.wikipedia.org/wiki/Samba_(software)" target="_top">Samba</a>
</td>
<td align="left">
sharing files via "Microsoft Windows Network", see <span class="citerefentry"><span class="refentrytitle">smb.conf</span>(5)</span> and <a class="ulink" href="http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/" target="_top">The Official Samba 3.2.x HOWTO and Reference Guide</a> or the <code class="literal">samba-doc</code> package
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Network_File_System_(protocol)" target="_top">NFS</a> network mounted filesystem with the Linux kernel
</td>
<td align="left">
sharing files via "Unix/Linux Network", see <span class="citerefentry"><span class="refentrytitle">exports</span>(5)</span> and <a class="ulink" href="http://tldp.org/HOWTO/NFS-HOWTO/index.html" target="_top">Linux NFS-HOWTO</a>
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol" target="_top">HTTP</a> service
</td>
<td align="left">
sharing file between the web server/client
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Https" target="_top">HTTPS</a> service
</td>
<td align="left">
sharing file between the web server/client with encrypted Secure Sockets Layer (SSL) or <a class="ulink" href="http://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">Transport Layer Security</a> (TLS)
</td>
</tr>
<tr>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/File_Transfer_Protocol" target="_top">FTP</a> service
</td>
<td align="left">
sharing file between the FTP server/client
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>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.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Encrypt it with <a class="ulink" href="http://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">SSL/TLS</a>
</p></li>
<li class="listitem"><p>
Tunnel it via <a class="ulink" href="http://en.wikipedia.org/wiki/Secure_Shell" target="_top">SSH</a>
</p></li>
<li class="listitem"><p>
Tunnel it via <a class="ulink" href="http://en.wikipedia.org/wiki/Virtual_private_network" target="_top">VPN</a>
</p></li>
<li class="listitem"><p>
Limit it behind the secure firewall
</p></li>
</ul></div>
<p>See also <a class="xref" href="ch06.en.html#_other_network_application_servers" title="6.10. Other network application servers">Section 6.10, “Other network application servers”</a> and <a class="xref" href="ch06.en.html#_other_network_application_clients" title="6.11. Other network application clients">Section 6.11, “Other network application clients”</a>.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_archive_media"></a>10.1.13. Archive media</h3></div></div></div>
<p>When choosing <a class="ulink" href="http://en.wikipedia.org/wiki/Computer_data_storage" target="_top">computer data storage media</a> 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.)</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Safe" target="_top">A fire-resistant safe</a> 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.</p></td></tr>
</table></div>
<p>Optimistic storage life of archive media seen on the net (mostly from vendor info).</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
100+ years : Acid free paper with ink
</p></li>
<li class="listitem"><p>
100 years : Optical storage (CD/DVD, CD/DVD-R)
</p></li>
<li class="listitem"><p>
30 years : Magnetic storage (tape, floppy)
</p></li>
<li class="listitem"><p>
20 years : Phase change optical storage (CD-RW)
</p></li>
</ul></div>
<p>These do not count on the mechanical failures due to handling etc.</p>
<p>Optimistic write cycle of archive media seen on the net (mostly from vendor info).</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
250,000+ cycles : Harddisk drive
</p></li>
<li class="listitem"><p>
10,000+ cycles : Flash memory
</p></li>
<li class="listitem"><p>
1,000 cycles : CD/DVD-RW
</p></li>
<li class="listitem"><p>
1 cycles : CD/DVD-R, paper
</p></li>
</ul></div>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>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.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Since CD/DVD-R and paper have only 1 write cycle, they inherently prevent accidental data loss by overwriting. This is advantage!</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>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.</p></td></tr>
</table></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_the_disk_image"></a>10.2. The disk image</h2></div></div></div>
<p>Here, we discuss manipulations of the disk image. See <a class="xref" href="ch09.en.html#_data_storage_tips" title="9.3. Data storage tips">Section 9.3, “Data storage tips”</a>, too.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_making_the_disk_image_file"></a>10.2.1. Making the disk image file</h3></div></div></div>
<p>The disk image file, "<code class="literal">disk.img</code>", of an unmounted device, e.g., the second SCSI drive "<code class="literal">/dev/sdb</code>", can be made using <span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span> or <span class="citerefentry"><span class="refentrytitle">dd</span>(1)</span> by the following.</p>
<pre class="screen"># cp /dev/sdb disk.img
# dd if=/dev/sdb of=disk.img</pre>
<p>The disk image of the traditional PC's <a class="ulink" href="http://en.wikipedia.org/wiki/Master_boot_record" target="_top">master boot record (MBR)</a> (see <a class="xref" href="ch09.en.html#_disk_partition_configuration" title="9.3.2. Disk partition configuration">Section 9.3.2, “Disk partition configuration”</a>) which reside on the first sector on the primary IDE disk can be made by using <span class="citerefentry"><span class="refentrytitle">dd</span>(1)</span> by the following.</p>
<pre class="screen"># dd if=/dev/hda of=mbr.img bs=512 count=1
# dd if=/dev/hda of=mbr-nopart.img bs=446 count=1
# dd if=/dev/hda of=mbr-part.img skip=446 bs=1 count=66</pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
"<code class="literal">mbr.img</code>": The MBR with the partition table
</p></li>
<li class="listitem"><p>
"<code class="literal">mbr-nopart.img</code>": The MBR without the partition table
</p></li>
<li class="listitem"><p>
"<code class="literal">part.img</code>": The partition table of the MBR only
</p></li>
</ul></div>
<p>If you have a SCSI device (including the new serial ATA drive) as the boot disk, substitute "<code class="literal">/dev/hda</code>" with "<code class="literal">/dev/sda</code>".</p>
<p>If you are making an image of a disk partition of the original disk, substitute "<code class="literal">/dev/hda</code>" with "<code class="literal">/dev/hda1</code>" etc.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_writing_directly_to_the_disk"></a>10.2.2. Writing directly to the disk</h3></div></div></div>
<p>The disk image file, "<code class="literal">disk.img</code>" can be written to an unmounted device, e.g., the second SCSI drive "<code class="literal">/dev/sdb</code>" with matching size, by the following.</p>
<pre class="screen"># dd if=disk.img of=/dev/sdb</pre>
<p>Similarly, the disk partition image file, "<code class="literal">partition.img</code>" can be written to an unmounted partition, e.g., the first partition of the second SCSI drive "<code class="literal">/dev/sdb1</code>" with matching size, by the following.</p>
<pre class="screen"># dd if=partition.img of=/dev/sdb1</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_mounting_the_disk_image_file"></a>10.2.3. Mounting the disk image file</h3></div></div></div>
<p>The disk image "<code class="literal">partition.img</code>" containing a single partition image can be mounted and unmounted by using the <a class="ulink" href="http://en.wikipedia.org/wiki/Loop_device" target="_top">loop device</a> as follows.</p>
<pre class="screen"># losetup -v -f partition.img
Loop device is /dev/loop0
# mkdir -p /mnt/loop0
# mount -t auto /dev/loop0 /mnt/loop0
...hack...hack...hack
# umount /dev/loop0
# losetup -d /dev/loop0</pre>
<p>This can be simplified as follows.</p>
<pre class="screen"># mkdir -p /mnt/loop0
# mount -t auto -o loop partition.img /mnt/loop0
...hack...hack...hack
# umount partition.img</pre>
<p>Each partition of the disk image "<code class="literal">disk.img</code>" containing multiple partitions can be mounted by using the <a class="ulink" href="http://en.wikipedia.org/wiki/Loop_device" target="_top">loop device</a>. Since the loop device does not manage partitions by default, we need to reset it as follows.</p>
<pre class="screen"># modinfo -p loop # verify kernel capability
max_part:Maximum number of partitions per loop device
max_loop:Maximum number of loop devices
# losetup -a # verify nothing using the loop device
# rmmod loop
# modprobe loop max_part=16</pre>
<p>Now, the loop device can manage up to 16 partitions.</p>
<pre class="screen"># losetup -v -f disk.img
Loop device is /dev/loop0
# fdisk -l /dev/loop0
Disk /dev/loop0: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x452b6464
Device Boot Start End Blocks Id System
/dev/loop0p1 1 600 4819468+ 83 Linux
/dev/loop0p2 601 652 417690 83 Linux
# mkdir -p /mnt/loop0p1
# mount -t ext3 /dev/loop0p1 /mnt/loop0p1
# mkdir -p /mnt/loop0p2
# mount -t ext3 /dev/loop0p2 /mnt/loop0p2
...hack...hack...hack
# umount /dev/loop0p1
# umount /dev/loop0p2
# losetup -d /dev/loop0</pre>
<p>Alternatively, similar effects can be done by using the <a class="ulink" href="http://en.wikipedia.org/wiki/Device_mapper" target="_top">device mapper</a> devices created by <span class="citerefentry"><span class="refentrytitle">kpartx</span>(8)</span> from the <code class="literal">kpartx</code> package as follows.</p>
<pre class="screen"># kpartx -a -v disk.img
...
# mkdir -p /mnt/loop0p2
# mount -t ext3 /dev/mapper/loop0p2 /mnt/loop0p2
...
...hack...hack...hack
# umount /dev/mapper/loop0p2
...
# kpartx -d /mnt/loop0</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>You can mount a single partition of such disk image with <a class="ulink" href="http://en.wikipedia.org/wiki/Loop_device" target="_top">loop device</a> using offset to skip <a class="ulink" href="http://en.wikipedia.org/wiki/Master_boot_record" target="_top">MBR</a> etc., too. But this is more error prone.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_cleaning_a_disk_image_file"></a>10.2.4. Cleaning a disk image file</h3></div></div></div>
<p>A disk image file, "<code class="literal">disk.img</code>" can be cleaned of all removed files into clean sparse image "<code class="literal">new.img</code>" by the following.</p>
<pre class="screen"># mkdir old; mkdir new
# mount -t auto -o loop disk.img old
# dd bs=1 count=0 if=/dev/zero of=new.img seek=5G
# mount -t auto -o loop new.img new
# cd old
# cp -a --sparse=always ./ ../new/
# cd ..
# umount new.img
# umount disk.img</pre>
<p>If "<code class="literal">disk.img</code>" is in ext2 or ext3, you can also use <span class="citerefentry"><span class="refentrytitle">zerofree</span>(8)</span> from the <code class="literal">zerofree</code> package as follows.</p>
<pre class="screen"># losetup -f -v disk.img
Loop device is /dev/loop3
# zerofree /dev/loop3
# cp --sparse=always disk.img new.img</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_making_the_empty_disk_image_file"></a>10.2.5. Making the empty disk image file</h3></div></div></div>
<p>The empty disk image "<code class="literal">disk.img</code>" which can grow up to 5GiB can be made using <span class="citerefentry"><span class="refentrytitle">dd</span>(1)</span> as follows.</p>
<pre class="screen">$ dd bs=1 count=0 if=/dev/zero of=disk.img seek=5G</pre>
<p>You can create an ext3 filesystem on this disk image "<code class="literal">disk.img</code>" using the <a class="ulink" href="http://en.wikipedia.org/wiki/Loop_device" target="_top">loop device</a> as follows.</p>
<pre class="screen"># losetup -f -v disk.img
Loop device is /dev/loop1
# mkfs.ext3 /dev/loop1
...hack...hack...hack
# losetup -d /dev/loop1
$ du --apparent-size -h disk.img
5.0G disk.img
$ du -h disk.img
83M disk.img</pre>
<p>For "<code class="literal">disk.img</code>", its file size is 5.0 GiB and its actual disk usage is mere 83MiB. This discrepancy is possible since <a class="ulink" href="http://en.wikipedia.org/wiki/Ext3" target="_top">ext2fs</a> can hold <a class="ulink" href="http://en.wikipedia.org/wiki/Sparse_file" target="_top">sparse file</a>.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>The actual disk usage of <a class="ulink" href="http://en.wikipedia.org/wiki/Sparse_file" target="_top">sparse file</a> grows with data which are written to it.</p></td></tr>
</table></div>
<p>Using similar operation on devices created by the <a class="ulink" href="http://en.wikipedia.org/wiki/Loop_device" target="_top">loop device</a> or the <a class="ulink" href="http://en.wikipedia.org/wiki/Device_mapper" target="_top">device mapper</a> devices as <a class="xref" href="ch10.en.html#_mounting_the_disk_image_file" title="10.2.3. Mounting the disk image file">Section 10.2.3, “Mounting the disk image file”</a>, you can partition this disk image "<code class="literal">disk.img</code>" using <span class="citerefentry"><span class="refentrytitle">parted</span>(8)</span> or <span class="citerefentry"><span class="refentrytitle">fdisk</span>(8)</span>, and can create filesystem on it using <span class="citerefentry"><span class="refentrytitle">mkfs.ext3</span>(8)</span>, <span class="citerefentry"><span class="refentrytitle">mkswap</span>(8)</span>, etc.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_making_the_iso9660_image_file"></a>10.2.6. Making the ISO9660 image file</h3></div></div></div>
<p>The <a class="ulink" href="http://en.wikipedia.org/wiki/ISO_9660" target="_top">ISO9660</a> image file, "<code class="literal">cd.iso</code>", from the source directory tree at "<code class="literal">source_directory</code>" can be made using <span class="citerefentry"><span class="refentrytitle">genisoimage</span>(1)</span> provided by <a class="ulink" href="http://en.wikipedia.org/wiki/Cdrkit" target="_top">cdrkit</a> by the following.</p>
<pre class="screen"># genisoimage -r -J -T -V volume_id -o cd.iso source_directory</pre>
<p>Similarly, the bootable ISO9660 image file, "<code class="literal">cdboot.iso</code>", can be made from <code class="literal">debian-installer</code> like directory tree at "<code class="literal">source_directory</code>" by the following.</p>
<pre class="screen"># genisoimage -r -o cdboot.iso -V volume_id \
-b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table source_directory</pre>
<p>Here <a class="ulink" href="http://en.wikipedia.org/wiki/SYSLINUX" target="_top">Isolinux boot loader</a> (see <a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.3. Stage 2: the boot loader">Section 3.3, “Stage 2: the boot loader”</a>) is used for booting.</p>
<p>You can calculate the md5sum value and make the ISO9660 image directly from the CD-ROM device as follows.</p>
<pre class="screen">$ isoinfo -d -i /dev/cdrom
CD-ROM is in ISO 9660 format
...
Logical block size is: 2048
Volume size is: 23150592
...
# dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror | md5sum
# dd if=/dev/cdrom bs=2048 count=23150592 conv=notrunc,noerror &gt; cd.iso</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>You must carefully avoid ISO9660 filesystem read ahead bug of Linux as above to get the right result.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_writing_directly_to_the_cd_dvd_r_rw"></a>10.2.7. Writing directly to the CD/DVD-R/RW</h3></div></div></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>DVD is only a large CD to <span class="citerefentry"><span class="refentrytitle">wodim</span>(1)</span> provided by <a class="ulink" href="http://en.wikipedia.org/wiki/Cdrkit" target="_top">cdrkit</a>.</p></td></tr>
</table></div>
<p>You can find a usable device by the following.</p>
<pre class="screen"># wodim --devices</pre>
<p>Then the blank CD-R is inserted to the CD drive, and the ISO9660 image file, "<code class="literal">cd.iso</code>" is written to this device, e.g., "<code class="literal">/dev/hda</code>", using <span class="citerefentry"><span class="refentrytitle">wodim</span>(1)</span> by the following.</p>
<pre class="screen"># wodim -v -eject dev=/dev/hda cd.iso</pre>
<p>If CD-RW is used instead of CD-R, do this instead by the following.</p>
<pre class="screen"># wodim -v -eject blank=fast dev=/dev/hda cd.iso</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>If your desktop system mounts CD automatically, unmount it by "<code class="literal">sudo unmount /dev/hda</code>" before using <span class="citerefentry"><span class="refentrytitle">wodim</span>(1)</span>.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_mounting_the_iso9660_image_file"></a>10.2.8. Mounting the ISO9660 image file</h3></div></div></div>
<p>If "<code class="literal">cd.iso</code>" contains an ISO9660 image, then the following manually mounts it to "<code class="literal">/cdrom</code>".</p>
<pre class="screen"># mount -t iso9660 -o ro,loop cd.iso /cdrom</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Modern desktop system mounts removable media automatically (see <a class="xref" href="ch10.en.html#_removable_storage_device" title="10.1.10. Removable storage device">Section 10.1.10, “Removable storage device”</a>).</p></td></tr>
</table></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_the_binary_data"></a>10.3. The binary data</h2></div></div></div>
<p>Here, we discuss direct manipulations of the binary data on storage media. See <a class="xref" href="ch09.en.html#_data_storage_tips" title="9.3. Data storage tips">Section 9.3, “Data storage tips”</a>, too.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_viewing_and_editing_binary_data"></a>10.3.1. Viewing and editing binary data</h3></div></div></div>
<p>The most basic viewing method of binary data is to use "<code class="literal">od -t x1</code>" command.</p>
<div class="table">
<a name="listofpackageswhndeditbinarydata"></a><p class="title"><b>Table 10.6. List of packages which view and edit binary data</b></p>
<div class="table-contents"><table summary="List of packages which view and edit binary data" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/coreutils" target="_top">
<code class="literal">coreutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=coreutils" target="_top">http://qa.debian.org/popcon.php?package=coreutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/coreutils.html" target="_top">14088</a></td>
<td align="left">
basic package which has <span class="citerefentry"><span class="refentrytitle">od</span>(1)</span> to dump files (HEX, ASCII, OCTAL, …)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bsdmainutils" target="_top">
<code class="literal">bsdmainutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bsdmainutils" target="_top">http://qa.debian.org/popcon.php?package=bsdmainutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bsdmainutils.html" target="_top">558</a></td>
<td align="left">
utility package which has <span class="citerefentry"><span class="refentrytitle">hd</span>(1)</span> to dump files (HEX, ASCII, OCTAL, …)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/hexedit" target="_top">
<code class="literal">hexedit</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=hexedit" target="_top">http://qa.debian.org/popcon.php?package=hexedit</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/h/hexedit.html" target="_top">108</a></td>
<td align="left">
binary editor and viewer (HEX, ASCII)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bless" target="_top">
<code class="literal">bless</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bless" target="_top">http://qa.debian.org/popcon.php?package=bless</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bless.html" target="_top">991</a></td>
<td align="left">
full featured hexadecimal editor (GNOME)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/okteta" target="_top">
<code class="literal">okteta</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=okteta" target="_top">http://qa.debian.org/popcon.php?package=okteta</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/o/okteta.html" target="_top">295</a></td>
<td align="left">
full featured hexadecimal editor (KDE4)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/ncurses-hexedit" target="_top">
<code class="literal">ncurses-hexedit</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=ncurses-hexedit" target="_top">http://qa.debian.org/popcon.php?package=ncurses-hexedit</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/n/ncurses-hexedit.html" target="_top">192</a></td>
<td align="left">
binary editor and viewer (HEX, ASCII, EBCDIC)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/beav" target="_top">
<code class="literal">beav</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=beav" target="_top">http://qa.debian.org/popcon.php?package=beav</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/beav.html" target="_top">164</a></td>
<td align="left">
binary editor and viewer (HEX, ASCII, EBCDIC, OCTAL, …)
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>HEX is used as an acronym for <a class="ulink" href="http://en.wikipedia.org/wiki/Hexadecimal" target="_top">hexadecimal</a> format with <a class="ulink" href="http://en.wikipedia.org/wiki/Radix" target="_top">radix</a> 16. OCTAL is for <a class="ulink" href="http://en.wikipedia.org/wiki/Octal" target="_top">octal</a> format with <a class="ulink" href="http://en.wikipedia.org/wiki/Radix" target="_top">radix</a> 8. ASCII is for <a class="ulink" href="http://en.wikipedia.org/wiki/ASCII" target="_top">American Standard Code for Information Interchange</a>, i.e., normal English text code. EBCDIC is for <a class="ulink" href="http://en.wikipedia.org/wiki/Extended_Binary_Coded_Decimal_Interchange_Code" target="_top">Extended Binary Coded Decimal Interchange Code</a> used on <a class="ulink" href="http://en.wikipedia.org/wiki/IBM_mainframe" target="_top">IBM mainframe</a> operating systems.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_manipulating_files_without_mounting_disk"></a>10.3.2. Manipulating files without mounting disk</h3></div></div></div>
<p>There are tools to read and write files without mounting disk.</p>
<div class="table">
<a name="listofpackagestohoutmountingdisk"></a><p class="title"><b>Table 10.7. List of packages to manipulate files without mounting disk</b></p>
<div class="table-contents"><table summary="List of packages to manipulate files without mounting disk" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/mtools" target="_top">
<code class="literal">mtools</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=mtools" target="_top">http://qa.debian.org/popcon.php?package=mtools</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/mtools.html" target="_top">408</a></td>
<td align="left">
utilities for MSDOS files without mounting them
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/hfsutils" target="_top">
<code class="literal">hfsutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=hfsutils" target="_top">http://qa.debian.org/popcon.php?package=hfsutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/h/hfsutils.html" target="_top">236</a></td>
<td align="left">
utilities for HFS and HFS+ files without mounting them
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_data_redundancy"></a>10.3.3. Data redundancy</h3></div></div></div>
<p>Software <a class="ulink" href="http://en.wikipedia.org/wiki/RAID" target="_top">RAID</a> systems offered by the Linux kernel provide data redundancy in the kernel filesystem level to achieve high levels of storage reliability.</p>
<p>There are tools to add data redundancy to files in application program level to achieve high levels of storage reliability, too.</p>
<div class="table">
<a name="listoftoolstoaddedundancytofiles"></a><p class="title"><b>Table 10.8. List of tools to add data redundancy to files</b></p>
<div class="table-contents"><table summary="List of tools to add data redundancy to files" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/par2" target="_top">
<code class="literal">par2</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=par2" target="_top">http://qa.debian.org/popcon.php?package=par2</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/par2.html" target="_top">272</a></td>
<td align="left">
Parity Archive Volume Set, for checking and repair of files
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dvdisaster" target="_top">
<code class="literal">dvdisaster</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dvdisaster" target="_top">http://qa.debian.org/popcon.php?package=dvdisaster</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dvdisaster.html" target="_top">1481</a></td>
<td align="left">
data loss/scratch/aging protection for CD/DVD media
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dvbackup" target="_top">
<code class="literal">dvbackup</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dvbackup" target="_top">http://qa.debian.org/popcon.php?package=dvbackup</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dvbackup.html" target="_top">392</a></td>
<td align="left">
backup tool using MiniDV camcorders (providing <span class="citerefentry"><span class="refentrytitle">rsbep</span>(1)</span>)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/vdmfec" target="_top">
<code class="literal">vdmfec</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=vdmfec" target="_top">http://qa.debian.org/popcon.php?package=vdmfec</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/v/vdmfec.html" target="_top">88</a></td>
<td align="left">
recover lost blocks using Forward Error Correction
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_data_file_recovery_and_forensic_analysis"></a>10.3.4. Data file recovery and forensic analysis</h3></div></div></div>
<p>There are tools for data file recovery and forensic analysis.</p>
<div class="table">
<a name="listofpackagesfoforensicanalysis"></a><p class="title"><b>Table 10.9. List of packages for data file recovery and forensic analysis</b></p>
<div class="table-contents"><table summary="List of packages for data file recovery and forensic analysis" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/testdisk" target="_top">
<code class="literal">testdisk</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=testdisk" target="_top">http://qa.debian.org/popcon.php?package=testdisk</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/t/testdisk.html" target="_top">1153</a></td>
<td align="left">
utilities for partition scan and disk recovery
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/magicrescue" target="_top">
<code class="literal">magicrescue</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=magicrescue" target="_top">http://qa.debian.org/popcon.php?package=magicrescue</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/magicrescue.html" target="_top">344</a></td>
<td align="left">
utility to recover files by looking for magic bytes
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/scalpel" target="_top">
<code class="literal">scalpel</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=scalpel" target="_top">http://qa.debian.org/popcon.php?package=scalpel</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/scalpel.html" target="_top">124</a></td>
<td align="left">
frugal, high performance file carver
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/myrescue" target="_top">
<code class="literal">myrescue</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=myrescue" target="_top">http://qa.debian.org/popcon.php?package=myrescue</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/myrescue.html" target="_top">84</a></td>
<td align="left">
rescue data from damaged harddisks
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/recover" target="_top">
<code class="literal">recover</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=recover" target="_top">http://qa.debian.org/popcon.php?package=recover</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/recover.html" target="_top">104</a></td>
<td align="left">
utility to undelete files on the ext2 filesystem
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/e2undel" target="_top">
<code class="literal">e2undel</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=e2undel" target="_top">http://qa.debian.org/popcon.php?package=e2undel</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/e/e2undel.html" target="_top">244</a></td>
<td align="left">
utility to undelete files on the ext2 filesystem
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/ext3grep" target="_top">
<code class="literal">ext3grep</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=ext3grep" target="_top">http://qa.debian.org/popcon.php?package=ext3grep</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/e/ext3grep.html" target="_top">296</a></td>
<td align="left">
tool to help recover deleted files on the ext3 filesystem
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/scrounge-ntfs" target="_top">
<code class="literal">scrounge-ntfs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=scrounge-ntfs" target="_top">http://qa.debian.org/popcon.php?package=scrounge-ntfs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/scrounge-ntfs.html" target="_top">80</a></td>
<td align="left">
data recovery program for NTFS filesystems
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gzrt" target="_top">
<code class="literal">gzrt</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gzrt" target="_top">http://qa.debian.org/popcon.php?package=gzrt</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gzrt.html" target="_top">68</a></td>
<td align="left">
gzip recovery toolkit
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/sleuthkit" target="_top">
<code class="literal">sleuthkit</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=sleuthkit" target="_top">http://qa.debian.org/popcon.php?package=sleuthkit</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/sleuthkit.html" target="_top">750</a></td>
<td align="left">
tools for forensics analysis. (Sleuthkit)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/autopsy" target="_top">
<code class="literal">autopsy</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=autopsy" target="_top">http://qa.debian.org/popcon.php?package=autopsy</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/a/autopsy.html" target="_top">1372</a></td>
<td align="left">
graphical interface to SleuthKit
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/foremost" target="_top">
<code class="literal">foremost</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=foremost" target="_top">http://qa.debian.org/popcon.php?package=foremost</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/f/foremost.html" target="_top">140</a></td>
<td align="left">
forensics application to recover data
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/guymager" target="_top">
<code class="literal">guymager</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=guymager" target="_top">http://qa.debian.org/popcon.php?package=guymager</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/guymager.html" target="_top">949</a></td>
<td align="left">
forensic imaging tool based on Qt
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dcfldd" target="_top">
<code class="literal">dcfldd</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dcfldd" target="_top">http://qa.debian.org/popcon.php?package=dcfldd</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dcfldd.html" target="_top">109</a></td>
<td align="left">
enhanced version of <code class="literal">dd</code> for forensics and security
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/rdd" target="_top">
<code class="literal">rdd</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=rdd" target="_top">http://qa.debian.org/popcon.php?package=rdd</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/rdd.html" target="_top">200</a></td>
<td align="left">
forensic copy program
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_splitting_a_large_file_into_small_files"></a>10.3.5. Splitting a large file into small files</h3></div></div></div>
<p>When a data is too big to backup as a single file, you can backup its content after splitting it into, e.g. 2000MiB chunks and merge those chunks back into the original file later.</p>
<pre class="screen">$ split -b 2000m large_file
$ cat x* &gt;large_file</pre>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>Please make sure you do not have any files starting with "<code class="literal">x</code>" to avoid name crashes.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_clearing_file_contents"></a>10.3.6. Clearing file contents</h3></div></div></div>
<p>In order to clear the contents of a file such as a log file, do not use <span class="citerefentry"><span class="refentrytitle">rm</span>(1)</span> to delete the file and then create a new empty file, because the file may still be accessed in the interval between commands. The following is the safe way to clear the contents of the file.</p>
<pre class="screen">$ :&gt;file_to_be_cleared</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_dummy_files"></a>10.3.7. Dummy files</h3></div></div></div>
<p>The following commands create dummy or empty files.</p>
<pre class="screen">$ dd if=/dev/zero of=5kb.file bs=1k count=5
$ dd if=/dev/urandom of=7mb.file bs=1M count=7
$ touch zero.file
$ : &gt; alwayszero.file</pre>
<p>You should find following files.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
"<code class="literal">5kb.file</code>" is 5KB of zeros.
</p></li>
<li class="listitem"><p>
"<code class="literal">7mb.file</code>" is 7MB of random data.
</p></li>
<li class="listitem"><p>
"<code class="literal">zero.file</code>" may be a 0 byte file. If it existed, its <code class="literal">mtime</code> is updated while its content and its length are kept.
</p></li>
<li class="listitem"><p>
"<code class="literal">alwayszero.file</code>" is always a 0 byte file. If it existed, its <code class="literal">mtime</code> is updated and its content is reset.
</p></li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_erasing_an_entire_hard_disk"></a>10.3.8. Erasing an entire hard disk</h3></div></div></div>
<p>There are several ways to completely erase data from an entire hard disk like device, e.g., USB memory stick at "<code class="literal">/dev/sda</code>".</p>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>Check your USB memory stick location with <span class="citerefentry"><span class="refentrytitle">mount</span>(8)</span> first before executing commands here. The device pointed by "<code class="literal">/dev/sda</code>" may be SCSI hard disk or serial-ATA hard disk where your entire system resides.</p></td></tr>
</table></div>
<p>Erase all the disk content by resetting data to 0 with the following.</p>
<pre class="screen"># dd if=/dev/zero of=/dev/sda</pre>
<p>Erase all by overwriting random data with the following.</p>
<pre class="screen"># dd if=/dev/urandom of=/dev/sda</pre>
<p>Erase all by overwriting random data very efficiently with the following.</p>
<pre class="screen"># shred -v -n 1 /dev/sda</pre>
<p>Since <span class="citerefentry"><span class="refentrytitle">dd</span>(1)</span> is available from the shell of many bootable Linux CDs such as Debian installer CD, you can erase your installed system completely by running an erase command from such media on the system hard disk, e.g., "<code class="literal">/dev/hda</code>", "<code class="literal">/dev/sda</code>", etc.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_erasing_unused_area_of_an_hard_disk"></a>10.3.9. Erasing unused area of an hard disk</h3></div></div></div>
<p>Unused area on an hard disk (or USB memory stick), e.g. "<code class="literal">/dev/sdb1</code>" may still contain erased data themselves since they are only unlinked from the filesystem. These can be cleaned by overwriting them.</p>
<pre class="screen"># mount -t auto /dev/sdb1 /mnt/foo
# cd /mnt/foo
# dd if=/dev/zero of=junk
dd: writing to `junk': No space left on device
...
# sync
# umount /dev/sdb1</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>This is usually a good enough for your USB memory stick. But this is not perfect. Most parts of erased filenames and their attributes may be hidden and remain in the filesystem.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_undeleting_deleted_but_still_open_files"></a>10.3.10. Undeleting deleted but still open files</h3></div></div></div>
<p>Even if you have accidentally deleted a file, as long as that file is still being used by some application (read or write mode), it is possible to recover such a file.</p>
<p>For example, try the following</p>
<pre class="screen">$ echo foo &gt; bar
$ less bar
$ ps aux | grep ' less[ ]'
bozo 4775 0.0 0.0 92200 884 pts/8 S+ 00:18 0:00 less bar
$ rm bar
$ ls -l /proc/4775/fd | grep bar
lr-x------ 1 bozo bozo 64 2008-05-09 00:19 4 -&gt; /home/bozo/bar (deleted)
$ cat /proc/4775/fd/4 &gt;bar
$ ls -l
-rw-r--r-- 1 bozo bozo 4 2008-05-09 00:25 bar
$ cat bar
foo</pre>
<p>Execute on another terminal (when you have the <code class="literal">lsof</code> package installed) as follows.</p>
<pre class="screen">$ ls -li bar
2228329 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:02 bar
$ lsof |grep bar|grep less
less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar
$ rm bar
$ lsof |grep bar|grep less
less 4775 bozo 4r REG 8,3 4 2228329 /home/bozo/bar (deleted)
$ cat /proc/4775/fd/4 &gt;bar
$ ls -li bar
2228302 -rw-r--r-- 1 bozo bozo 4 2008-05-11 11:05 bar
$ cat bar
foo</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_searching_all_hardlinks"></a>10.3.11. Searching all hardlinks</h3></div></div></div>
<p>Files with hardlinks can be identified by "<code class="literal">ls -li</code>".</p>
<pre class="screen">$ ls -li
total 0
2738405 -rw-r--r-- 1 root root 0 2008-09-15 20:21 bar
2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 baz
2738404 -rw-r--r-- 2 root root 0 2008-09-15 20:21 foo</pre>
<p>Both "<code class="literal">baz</code>" and "<code class="literal">foo</code>" have link counts of "2" (&gt;1) showing them to have hardlinks. Their <a class="ulink" href="http://en.wikipedia.org/wiki/Inode" target="_top">inode</a> numbers are common "2738404". This means they are the same hardlinked file. If you do not happen to find all hardlinked files by chance, you can search it by the <a class="ulink" href="http://en.wikipedia.org/wiki/Inode" target="_top">inode</a>, e.g., "2738404" as the following.</p>
<pre class="screen"># find /path/to/mount/point -xdev -inum 2738404</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_invisible_disk_space_consumption"></a>10.3.12. Invisible disk space consumption</h3></div></div></div>
<p>All deleted but open files consumes disk space although they are not visible from normal <span class="citerefentry"><span class="refentrytitle">du</span>(1)</span>. They can be listed with their size by the following.</p>
<pre class="screen"># lsof -s -X / |grep deleted</pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_data_security_infrastructure"></a>10.4. Data security infrastructure</h2></div></div></div>
<p>The data security infrastructure is provided by the combination of data encryption tool, message digest tool, and signature tool.</p>
<div class="table">
<a name="listofdatasecurirastructuretools"></a><p class="title"><b>Table 10.10. List of data security infrastructure tools</b></p>
<div class="table-contents"><table summary="List of data security infrastructure tools" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">gpg</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gnupg" target="_top">
<code class="literal">gnupg</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gnupg" target="_top">http://qa.debian.org/popcon.php?package=gnupg</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gnupg.html" target="_top">4621</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard" target="_top">GNU Privacy Guard</a> - OpenPGP encryption and signing tool
</td>
</tr>
<tr>
<td align="left">
N/A
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gnupg-doc" target="_top">
<code class="literal">gnupg-doc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gnupg-doc" target="_top">http://qa.debian.org/popcon.php?package=gnupg-doc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gnupg-doc.html" target="_top">4124</a></td>
<td align="left">
GNU Privacy Guard documentation
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">gpgv</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gpgv" target="_top">
<code class="literal">gpgv</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gpgv" target="_top">http://qa.debian.org/popcon.php?package=gpgv</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gpgv.html" target="_top">397</a></td>
<td align="left">
GNU Privacy Guard - signature verification tool
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">paperkey</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/paperkey" target="_top">
<code class="literal">paperkey</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=paperkey" target="_top">http://qa.debian.org/popcon.php?package=paperkey</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/paperkey.html" target="_top">88</a></td>
<td align="left">
extract just the secret information out of OpenPGP secret keys
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">cryptsetup</span>(8)</span>, …
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/cryptsetup" target="_top">
<code class="literal">cryptsetup</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=cryptsetup" target="_top">http://qa.debian.org/popcon.php?package=cryptsetup</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/cryptsetup.html" target="_top">648</a></td>
<td align="left">
utilities for <a class="ulink" href="http://en.wikipedia.org/wiki/Dm-crypt" target="_top">dm-crypto</a> block device encryption supporting <a class="ulink" href="http://en.wikipedia.org/wiki/Linux_Unified_Key_Setup" target="_top">LUKS</a>
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">ecryptfs</span>(7)</span>, …
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/ecryptfs-utils" target="_top">
<code class="literal">ecryptfs-utils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=ecryptfs-utils" target="_top">http://qa.debian.org/popcon.php?package=ecryptfs-utils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/e/ecryptfs-utils.html" target="_top">368</a></td>
<td align="left">
utilities for <a class="ulink" href="http://ecryptfs.sourceforge.net/" target="_top">ecryptfs</a> stacked filesystem encryption
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">md5sum</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/coreutils" target="_top">
<code class="literal">coreutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=coreutils" target="_top">http://qa.debian.org/popcon.php?package=coreutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/coreutils.html" target="_top">14088</a></td>
<td align="left">
compute and check MD5 message digest
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">sha1sum</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/coreutils" target="_top">
<code class="literal">coreutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=coreutils" target="_top">http://qa.debian.org/popcon.php?package=coreutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/coreutils.html" target="_top">14088</a></td>
<td align="left">
compute and checks SHA1 message digest
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">openssl</span>(1ssl)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/openssl" target="_top">
<code class="literal">openssl</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=openssl" target="_top">http://qa.debian.org/popcon.php?package=openssl</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/o/openssl.html" target="_top">1079</a></td>
<td align="left">
compute message digest with "<code class="literal">openssl dgst</code>" (OpenSSL)
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>See <a class="xref" href="ch09.en.html#_data_encryption_tips" title="9.4. Data encryption tips">Section 9.4, “Data encryption tips”</a> on <a class="ulink" href="http://en.wikipedia.org/wiki/Dm-crypt" target="_top">dm-crypto</a> and <a class="ulink" href="http://ecryptfs.sourceforge.net/" target="_top">ecryptfs</a> which implement automatic data encryption infrastructure via Linux kernel modules.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_key_management_for_gnupg"></a>10.4.1. Key management for GnuPG</h3></div></div></div>
<p>Here are <a class="ulink" href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard" target="_top">GNU Privacy Guard</a> commands for the basic key management.</p>
<div class="table">
<a name="listofgnuprivacythekeymanagement"></a><p class="title"><b>Table 10.11. List of GNU Privacy Guard commands for the key management</b></p>
<div class="table-contents"><table summary="List of GNU Privacy Guard commands for the key management" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">gpg --gen-key</code>
</td>
<td align="left">
generate a new key
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --gen-revoke my_user_ID</code>
</td>
<td align="left">
generate revoke key for my_user_ID
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --edit-key user_ID</code>
</td>
<td align="left">
edit key interactively, "help" for help
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o file --exports</code>
</td>
<td align="left">
export all keys to file
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --imports file</code>
</td>
<td align="left">
import all keys from file
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --send-keys user_ID</code>
</td>
<td align="left">
send key of user_ID to keyserver
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --recv-keys user_ID</code>
</td>
<td align="left">
recv. key of user_ID from keyserver
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --list-keys user_ID</code>
</td>
<td align="left">
list keys of user_ID
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --list-sigs user_ID</code>
</td>
<td align="left">
list sig. of user_ID
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --check-sigs user_ID</code>
</td>
<td align="left">
check sig. of user_ID
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --fingerprint user_ID</code>
</td>
<td align="left">
check fingerprint of user_ID
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --refresh-keys</code>
</td>
<td align="left">
update local keyring
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>Here is the meaning of the trust code.</p>
<div class="table">
<a name="listofthemeaningofthetrustcode"></a><p class="title"><b>Table 10.12. List of the meaning of the trust code</b></p>
<div class="table-contents"><table summary="List of the meaning of the trust code" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
code
</th>
<th align="left">
description of trust
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">-</code>
</td>
<td align="left">
no owner trust assigned / not yet calculated
</td>
</tr>
<tr>
<td align="left">
<code class="literal">e</code>
</td>
<td align="left">
trust calculation failed
</td>
</tr>
<tr>
<td align="left">
<code class="literal">q</code>
</td>
<td align="left">
not enough information for calculation
</td>
</tr>
<tr>
<td align="left">
<code class="literal">n</code>
</td>
<td align="left">
never trust this key
</td>
</tr>
<tr>
<td align="left">
<code class="literal">m</code>
</td>
<td align="left">
marginally trusted
</td>
</tr>
<tr>
<td align="left">
<code class="literal">f</code>
</td>
<td align="left">
fully trusted
</td>
</tr>
<tr>
<td align="left">
<code class="literal">u</code>
</td>
<td align="left">
ultimately trusted
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>The following uploads my key "<code class="literal">1DD8D791</code>" to the popular keyserver "<code class="literal">hkp://keys.gnupg.net</code>".</p>
<pre class="screen">$ gpg --keyserver hkp://keys.gnupg.net --send-keys 1DD8D791</pre>
<p>A good default keyserver set up in "<code class="literal">~/.gnupg/gpg.conf</code>" (or old location "<code class="literal">~/.gnupg/options</code>") contains the following.</p>
<pre class="screen">keyserver hkp://keys.gnupg.net</pre>
<p>The following obtains unknown keys from the keyserver.</p>
<pre class="screen">$ gpg --list-sigs --with-colons | grep '^sig.*\[User ID not found\]' |\
cut -d ':' -f 5| sort | uniq | xargs gpg --recv-keys</pre>
<p>There was a bug in <a class="ulink" href="http://sourceforge.net/projects/pks/" target="_top">OpenPGP Public Key Server</a> (pre version 0.9.6) which corrupted key with more than 2 sub-keys. The newer <code class="literal">gnupg</code> (&gt;1.2.1-2) package can handle these corrupted subkeys. See <span class="citerefentry"><span class="refentrytitle">gpg</span>(1)</span> under "<code class="literal">--repair-pks-subkey-bug</code>" option.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_using_gnupg_on_files"></a>10.4.2. Using GnuPG on files</h3></div></div></div>
<p>Here are examples for using <a class="ulink" href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard" target="_top">GNU Privacy Guard</a> commands on files.</p>
<div class="table">
<a name="listofgnuprivacydcommandsonfiles"></a><p class="title"><b>Table 10.13. List of GNU Privacy Guard commands on files</b></p>
<div class="table-contents"><table summary="List of GNU Privacy Guard commands on files" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">gpg -a -s file</code>
</td>
<td align="left">
sign file into <a class="ulink" href="http://en.wikipedia.org/wiki/ASCII" target="_top">ASCII</a> armored file.asc
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --armor --sign file</code>
</td>
<td align="left">
, ,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --clearsign file</code>
</td>
<td align="left">
clear-sign message
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --clearsign file|mail foo@example.org</code>
</td>
<td align="left">
mail a clear-signed message to <code class="literal">foo@example.org</code>
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --clearsign --not-dash-escaped patchfile</code>
</td>
<td align="left">
clear-sign patchfile
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --verify file</code>
</td>
<td align="left">
verify clear-signed file
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o file.sig -b file</code>
</td>
<td align="left">
create detached signature
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o file.sig --detach-sig file</code>
</td>
<td align="left">
, ,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg --verify file.sig file</code>
</td>
<td align="left">
verify file with file.sig
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.gpg -r name -e file</code>
</td>
<td align="left">
public-key encryption intended for name from file to binary crypt_file.gpg
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.gpg --recipient name --encrypt file</code>
</td>
<td align="left">
, ,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.asc -a -r name -e file</code>
</td>
<td align="left">
public-key encryption intended for name from file to <a class="ulink" href="http://en.wikipedia.org/wiki/ASCII" target="_top">ASCII</a> armored crypt_file.asc
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.gpg -c file</code>
</td>
<td align="left">
symmetric encryption from file to crypt_file.gpg
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.gpg --symmetric file</code>
</td>
<td align="left">
, ,
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o crypt_file.asc -a -c file</code>
</td>
<td align="left">
symmetric encryption intended for name from file to <a class="ulink" href="http://en.wikipedia.org/wiki/ASCII" target="_top">ASCII</a> armored crypt_file.asc
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o file -d crypt_file.gpg -r name</code>
</td>
<td align="left">
decryption
</td>
</tr>
<tr>
<td align="left">
<code class="literal">gpg -o file --decrypt crypt_file.gpg</code>
</td>
<td align="left">
, ,
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_using_gnupg_with_mutt"></a>10.4.3. Using GnuPG with Mutt</h3></div></div></div>
<p>Add the following to "<code class="literal">~/.muttrc</code>" to keep a slow GnuPG from automatically
starting, while allowing it to be used by typing "<code class="literal">S</code>" at the index menu.</p>
<pre class="screen">macro index S ":toggle pgp_verify_sig\n"
set pgp_verify_sig=no</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_using_gnupg_with_vim"></a>10.4.4. Using GnuPG with Vim</h3></div></div></div>
<p>The <code class="literal">gnupg</code> plugin let you run GnuPG transparently for files with extension "<code class="literal">.gpg</code>", "<code class="literal">.asc</code>", and "<code class="literal">.ppg</code>".</p>
<pre class="screen"># aptitude install vim-scripts vim-addon-manager
$ vim-addons install gnupg</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_md5_sum"></a>10.4.5. The MD5 sum</h3></div></div></div>
<p><span class="citerefentry"><span class="refentrytitle">md5sum</span>(1)</span> provides utility to make a digest file using the method in <a class="ulink" href="http://tools.ietf.org/html/rfc1321" target="_top">rfc1321</a> and verifying each file with it.</p>
<pre class="screen">$ md5sum foo bar &gt;baz.md5
$ cat baz.md5
d3b07384d113edec49eaa6238ad5ff00 foo
c157a79031e1c40f85931829bc5fc552 bar
$ md5sum -c baz.md5
foo: OK
bar: OK</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The computation for the <a class="ulink" href="http://en.wikipedia.org/wiki/MD5" target="_top">MD5</a> sum is less CPU intensive than the one for the cryptographic signature by <a class="ulink" href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard" target="_top">GNU Privacy Guard (GnuPG)</a>. Usually, only the top level digest file is cryptographically signed to ensure data integrity.</p></td></tr>
</table></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_source_code_merge_tools"></a>10.5. Source code merge tools</h2></div></div></div>
<p>There are many merge tools for the source code. Following commands caught my eyes.</p>
<div class="table">
<a name="listofsourcecodemergetools"></a><p class="title"><b>Table 10.14. List of source code merge tools</b></p>
<div class="table-contents"><table summary="List of source code merge tools" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">diff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/diffutils" target="_top">
<code class="literal">diffutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=diffutils" target="_top">http://qa.debian.org/popcon.php?package=diffutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/diffutils.html" target="_top">1118</a></td>
<td align="left">
compare files line by line
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">diff3</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/diffutils" target="_top">
<code class="literal">diffutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=diffutils" target="_top">http://qa.debian.org/popcon.php?package=diffutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/diffutils.html" target="_top">1118</a></td>
<td align="left">
compare and merges three files line by line
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">vimdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/vim" target="_top">
<code class="literal">vim</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=vim" target="_top">http://qa.debian.org/popcon.php?package=vim</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/v/vim.html" target="_top">1873</a></td>
<td align="left">
compare 2 files side by side in vim
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patch" target="_top">
<code class="literal">patch</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patch" target="_top">http://qa.debian.org/popcon.php?package=patch</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patch.html" target="_top">218</a></td>
<td align="left">
apply a diff file to an original
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">dpatch</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dpatch" target="_top">
<code class="literal">dpatch</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dpatch" target="_top">http://qa.debian.org/popcon.php?package=dpatch</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dpatch.html" target="_top">237</a></td>
<td align="left">
manage series of patches for Debian package
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">diffstat</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/diffstat" target="_top">
<code class="literal">diffstat</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=diffstat" target="_top">http://qa.debian.org/popcon.php?package=diffstat</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/diffstat.html" target="_top">45</a></td>
<td align="left">
produce a histogram of changes by the diff
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">combinediff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
create a cumulative patch from two incremental patches
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">dehtmldiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
extract a diff from an HTML page
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">filterdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
extract or excludes diffs from a diff file
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">fixcvsdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
fix diff files created by CVS that <span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span> mis-interprets
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">flipdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
exchange the order of two patches
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">grepdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
show which files are modified by a patch matching a regex
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">interdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
show differences between two unified diff files
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">lsdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
show which files are modified by a patch
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">recountdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
recompute counts and offsets in unified context diffs
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">rediff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
fix offsets and counts of a hand-edited diff
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">splitdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
separate out incremental patches
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">unwrapdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/patchutils" target="_top">
<code class="literal">patchutils</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=patchutils" target="_top">http://qa.debian.org/popcon.php?package=patchutils</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/p/patchutils.html" target="_top">221</a></td>
<td align="left">
demangle patches that have been word-wrapped
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">wiggle</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/wiggle" target="_top">
<code class="literal">wiggle</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=wiggle" target="_top">http://qa.debian.org/popcon.php?package=wiggle</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/w/wiggle.html" target="_top">203</a></td>
<td align="left">
apply rejected patches
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">quilt</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/quilt" target="_top">
<code class="literal">quilt</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=quilt" target="_top">http://qa.debian.org/popcon.php?package=quilt</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/q/quilt.html" target="_top">814</a></td>
<td align="left">
manage series of patches
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">meld</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/meld" target="_top">
<code class="literal">meld</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=meld" target="_top">http://qa.debian.org/popcon.php?package=meld</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/meld.html" target="_top">2023</a></td>
<td align="left">
compare and merge files (GTK)
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">xxdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/xxdiff" target="_top">
<code class="literal">xxdiff</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=xxdiff" target="_top">http://qa.debian.org/popcon.php?package=xxdiff</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/x/xxdiff.html" target="_top">1090</a></td>
<td align="left">
compare and merge files (plain X)
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">dirdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/dirdiff" target="_top">
<code class="literal">dirdiff</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=dirdiff" target="_top">http://qa.debian.org/popcon.php?package=dirdiff</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/dirdiff.html" target="_top">224</a></td>
<td align="left">
display differences and merge changes between directory trees
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">docdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/docdiff" target="_top">
<code class="literal">docdiff</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=docdiff" target="_top">http://qa.debian.org/popcon.php?package=docdiff</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/docdiff.html" target="_top">692</a></td>
<td align="left">
compare two files word by word / char by char
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">imediff2</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/imediff2" target="_top">
<code class="literal">imediff2</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=imediff2" target="_top">http://qa.debian.org/popcon.php?package=imediff2</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/i/imediff2.html" target="_top">76</a></td>
<td align="left">
interactive full screen 2-way merge tool
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">makepatch</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/makepatch" target="_top">
<code class="literal">makepatch</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=makepatch" target="_top">http://qa.debian.org/popcon.php?package=makepatch</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/makepatch.html" target="_top">148</a></td>
<td align="left">
generate extended patch files
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">applypatch</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/makepatch" target="_top">
<code class="literal">makepatch</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=makepatch" target="_top">http://qa.debian.org/popcon.php?package=makepatch</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/makepatch.html" target="_top">148</a></td>
<td align="left">
apply extended patch files
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">wdiff</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/wdiff" target="_top">
<code class="literal">wdiff</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=wdiff" target="_top">http://qa.debian.org/popcon.php?package=wdiff</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/w/wdiff.html" target="_top">900</a></td>
<td align="left">
display word differences between text files
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_extracting_differences_for_source_files"></a>10.5.1. Extracting differences for source files</h3></div></div></div>
<p>One of following procedures extract differences between two source files and create unified diff files "<code class="literal">file.patch0</code>" or "<code class="literal">file.patch1</code>" depending on the file location.</p>
<pre class="screen">$ diff -u file.old file.new &gt; file.patch0
$ diff -u old/file new/file &gt; file.patch1</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_merging_updates_for_source_files"></a>10.5.2. Merging updates for source files</h3></div></div></div>
<p>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.</p>
<pre class="screen">$ patch -p0 file &lt; file.patch0
$ patch -p1 file &lt; file.patch1</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_updating_via_3_way_merge"></a>10.5.3. Updating via 3-way-merge</h3></div></div></div>
<p>If you have three versions of a source code, you can perform 3-way-merge effectively using <span class="citerefentry"><span class="refentrytitle">diff3</span>(1)</span> by the following.</p>
<pre class="screen">$ diff3 -m file.mine file.old file.yours &gt; file</pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_version_control_systems"></a>10.6. Version control systems</h2></div></div></div>
<p>Here is a summary of the <a class="ulink" href="http://en.wikipedia.org/wiki/Revision_control" target="_top">version control systems (VCS)</a> on the Debian system.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>If you are new to VCS systems, you should start learning with <span class="strong"><strong>Git</strong></span>, which is growing fast in popularity.</p></td></tr>
</table></div>
<div class="table">
<a name="list-of-vcs"></a><p class="title"><b>Table 10.15. List of version control system tools</b></p>
<div class="table-contents"><table summary="List of version control system tools" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
tool
</th>
<th align="left">
VCS type
</th>
<th align="left">
comment
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/cssc" target="_top">
<code class="literal">cssc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=cssc" target="_top">http://qa.debian.org/popcon.php?package=cssc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/cssc.html" target="_top">2240</a></td>
<td align="left">
<a class="ulink" href="http://cssc.sourceforge.net/" target="_top">CSSC</a>
</td>
<td align="left">
local
</td>
<td align="left">
clone of the <a class="ulink" href="http://en.wikipedia.org/wiki/Source_Code_Control_System" target="_top">Unix SCCS</a> (deprecated)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/rcs" target="_top">
<code class="literal">rcs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=rcs" target="_top">http://qa.debian.org/popcon.php?package=rcs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/r/rcs.html" target="_top">1101</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Revision_Control_System" target="_top">RCS</a>
</td>
<td align="left">
local
</td>
<td align="left">
"<a class="ulink" href="http://en.wikipedia.org/wiki/Source_Code_Control_System" target="_top">Unix SCCS</a> done right"
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/cvs" target="_top">
<code class="literal">cvs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=cvs" target="_top">http://qa.debian.org/popcon.php?package=cvs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/c/cvs.html" target="_top">4059</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Concurrent_Versions_System" target="_top">CVS</a>
</td>
<td align="left">
remote
</td>
<td align="left">
previous standard remote VCS
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/subversion" target="_top">
<code class="literal">subversion</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=subversion" target="_top">http://qa.debian.org/popcon.php?package=subversion</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/subversion.html" target="_top">4107</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Subversion_(software)" target="_top">Subversion</a>
</td>
<td align="left">
remote
</td>
<td align="left">
"CVS done right", the new de facto standard remote VCS
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git" target="_top">
<code class="literal">git</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git" target="_top">http://qa.debian.org/popcon.php?package=git</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git.html" target="_top">13073</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Git_(software)" target="_top">Git</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
fast DVCS in C (used by the Linux kernel and others)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/mercurial" target="_top">
<code class="literal">mercurial</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=mercurial" target="_top">http://qa.debian.org/popcon.php?package=mercurial</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/mercurial.html" target="_top">369</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Mercurial_(software)" target="_top">Mercurial</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
DVCS in Python and some C
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/bzr" target="_top">
<code class="literal">bzr</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=bzr" target="_top">http://qa.debian.org/popcon.php?package=bzr</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/b/bzr.html" target="_top">65</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Bazaar_(software)" target="_top">Bazaar</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
DVCS influenced by <code class="literal">tla</code> written in Python (used by <a class="ulink" href="http://www.ubuntu.com/" target="_top">Ubuntu</a>)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/darcs" target="_top">
<code class="literal">darcs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=darcs" target="_top">http://qa.debian.org/popcon.php?package=darcs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/darcs.html" target="_top">13347</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Darcs" target="_top">Darcs</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
DVCS with smart algebra of patches (slow)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/tla" target="_top">
<code class="literal">tla</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=tla" target="_top">http://qa.debian.org/popcon.php?package=tla</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/t/tla.html" target="_top">881</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/GNU_arch" target="_top">GNU arch</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
DVCS mainly by Tom Lord (Historic)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/monotone" target="_top">
<code class="literal">monotone</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=monotone" target="_top">http://qa.debian.org/popcon.php?package=monotone</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/m/monotone.html" target="_top">5150</a></td>
<td align="left">
<a class="ulink" href="http://en.wikipedia.org/wiki/Monotone_(software)" target="_top">Monotone</a>
</td>
<td align="left">
distributed
</td>
<td align="left">
DVCS in C++
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/tkcvs" target="_top">
<code class="literal">tkcvs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=tkcvs" target="_top">http://qa.debian.org/popcon.php?package=tkcvs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/t/tkcvs.html" target="_top">2476</a></td>
<td align="left">
CVS, …
</td>
<td align="left">
remote
</td>
<td align="left">
GUI display of VCS (CVS, Subversion, RCS) repository tree
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gitk" target="_top">
<code class="literal">gitk</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gitk" target="_top">http://qa.debian.org/popcon.php?package=gitk</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gitk.html" target="_top">1045</a></td>
<td align="left">
Git
</td>
<td align="left">
distributed
</td>
<td align="left">
GUI display of VCS (Git) repository tree
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>VCS is sometimes known as revision control system (RCS), or software configuration management (SCM).</p>
<p>Distributed VCS such as Git is the tool of choice these days. CVS and Subversion may still be useful to join some existing open source program activities.</p>
<p>Debian provides free VCS services via <a class="ulink" href="http://alioth.debian.org/" target="_top">Debian Alioth service</a>. It supports practically all VCSs. Its documentation can be found at <a class="ulink" href="http://wiki.debian.org/Alioth" target="_top">http://wiki.debian.org/Alioth</a> .</p>
<p>There are few basics for creating a shared access VCS archive.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Use "<code class="literal">umask 002</code>" (see <a class="xref" href="ch01.en.html#_control_of_permissions_for_newly_created_files_umask" title="1.2.4. Control of permissions for newly created files: umask">Section 1.2.4, “Control of permissions for newly created files: umask”</a>)
</p></li>
<li class="listitem"><p>
Make all VCS archive files belonging to a pertinent group
</p></li>
<li class="listitem"><p>
Enable set group ID on all VCS archive directories (BSD-like file creation scheme, see <a class="xref" href="ch01.en.html#_filesystem_permissions" title="1.2.3. Filesystem permissions">Section 1.2.3, “Filesystem permissions”</a>)
</p></li>
<li class="listitem"><p>
Make user sharing the VCS archive belonging to the group
</p></li>
</ul></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_comparison_of_vcs_commands"></a>10.6.1. Comparison of VCS commands</h3></div></div></div>
<p>Here is an oversimplified comparison of native VCS commands to provide the big picture. The typical command sequence may require options and arguments.</p>
<div class="table">
<a name="comparisonofnativevcscommands"></a><p class="title"><b>Table 10.16. Comparison of native VCS commands</b></p>
<div class="table-contents"><table summary="Comparison of native VCS commands" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
CVS
</th>
<th align="left">
Subversion
</th>
<th align="left">
Git
</th>
<th align="left">
function
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">cvs init</code>
</td>
<td align="left">
<code class="literal">svn create</code>
</td>
<td align="left">
<code class="literal">git init</code>
</td>
<td align="left">
create the (local) repository
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs login</code>
</td>
<td align="left">
-
</td>
<td align="left">
-
</td>
<td align="left">
login to the remote repository
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs co</code>
</td>
<td align="left">
<code class="literal">svn co</code>
</td>
<td align="left">
<code class="literal">git clone</code>
</td>
<td align="left">
check out the remote repository as the working tree
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs up</code>
</td>
<td align="left">
<code class="literal">svn up</code>
</td>
<td align="left">
<code class="literal">git pull</code>
</td>
<td align="left">
update the working tree by merging the remote repository
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs add</code>
</td>
<td align="left">
<code class="literal">svn add</code>
</td>
<td align="left">
<code class="literal">git add .</code>
</td>
<td align="left">
add file(s) in the working tree to the VCS
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs rm</code>
</td>
<td align="left">
<code class="literal">svn rm</code>
</td>
<td align="left">
<code class="literal">git rm</code>
</td>
<td align="left">
remove file(s) in working tree from the VCS
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs ci</code>
</td>
<td align="left">
<code class="literal">svn ci</code>
</td>
<td align="left">
-
</td>
<td align="left">
commit changes to the remote repository
</td>
</tr>
<tr>
<td align="left">
-
</td>
<td align="left">
-
</td>
<td align="left">
<code class="literal">git commit -a</code>
</td>
<td align="left">
commit changes to the local repository
</td>
</tr>
<tr>
<td align="left">
-
</td>
<td align="left">
-
</td>
<td align="left">
<code class="literal">git push</code>
</td>
<td align="left">
update the remote repository by the local repository
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs status</code>
</td>
<td align="left">
<code class="literal">svn status</code>
</td>
<td align="left">
<code class="literal">git status</code>
</td>
<td align="left">
display the working tree status from the VCS
</td>
</tr>
<tr>
<td align="left">
<code class="literal">cvs diff</code>
</td>
<td align="left">
<code class="literal">svn diff</code>
</td>
<td align="left">
<code class="literal">git diff</code>
</td>
<td align="left">
diff &lt;reference_repository&gt; &lt;working_tree&gt;
</td>
</tr>
<tr>
<td align="left">
-
</td>
<td align="left">
-
</td>
<td align="left">
<code class="literal">git repack -a -d; git prune</code>
</td>
<td align="left">
repack the local repository into single pack
</td>
</tr>
<tr>
<td align="left">
<code class="literal">tkcvs</code>
</td>
<td align="left">
<code class="literal">tkcvs</code>
</td>
<td align="left">
<code class="literal">gitk</code>
</td>
<td align="left">
GUI display of VCS repository tree
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Caution">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Caution]" src="images/caution.png"></td>
<th align="left">Caution</th>
</tr>
<tr><td align="left" valign="top"><p>Invoking a <code class="literal">git</code> subcommand directly as "<code class="literal">git-xyz</code>" from the command line has been deprecated since early 2006.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>GUI tools such as <span class="citerefentry"><span class="refentrytitle">tkcvs</span>(1)</span> and <span class="citerefentry"><span class="refentrytitle">gitk</span>(1)</span> really help you with tracking revision history of files. The web interface provided by many public archives for browsing their repositories is also quite useful, too.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Git can work directly with different VCS repositories such as ones provided by CVS and Subversion, and provides the local repository for local changes with <code class="literal">git-cvs</code> and <code class="literal">git-svn</code> packages. See <a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/gitcvs-migration.html" target="_top">git for CVS users</a>, and <a class="xref" href="ch10.en.html#_git_for_the_subversion_repository" title="10.9.4. Git for the Subversion repository">Section 10.9.4, “Git for the Subversion repository”</a>.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Git has commands which have no equivalents in CVS and Subversion: "fetch", "rebase", "cherry-pick", …</p></td></tr>
</table></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_cvs"></a>10.7. CVS</h2></div></div></div>
<p>See the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">cvs</span>(1)</span>
</p></li>
<li class="listitem"><p>
"<code class="literal">/usr/share/doc/cvs/html-cvsclient</code>"
</p></li>
<li class="listitem"><p>
"<code class="literal">/usr/share/doc/cvs/html-info</code>"
</p></li>
<li class="listitem"><p>
"<code class="literal">/usr/share/doc/cvsbook</code>"
</p></li>
<li class="listitem"><p>
"<code class="literal">info cvs</code>"
</p></li>
</ul></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_configuration_of_cvs_repository"></a>10.7.1. Configuration of CVS repository</h3></div></div></div>
<p>The following configuration allows commits to the CVS repository only by a member of the "<code class="literal">src</code>" group, and administration of CVS only by a member of the "<code class="literal">staff</code>" group, thus reducing the chance of shooting oneself.</p>
<pre class="screen"># cd /var/lib; umask 002; mkdir cvs
# export CVSROOT=/srv/cvs/project
# cd $CVSROOT
# chown root:src .
# chmod 2775 .
# cvs -d $CVSROOT init
# cd CVSROOT
# chown -R root:staff .
# chmod 2775 .
# touch val-tags
# chmod 664 history val-tags
# chown root:src history val-tags</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You may restrict creation of new project by changing the owner of "<code class="literal">$CVSROOT</code>" directory to "<code class="literal">root:staff</code>" and its permission to "<code class="literal">3775</code>".</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_local_access_to_cvs"></a>10.7.2. Local access to CVS</h3></div></div></div>
<p>The default CVS repository is pointed by "<code class="literal">$CVSROOT</code>". The following sets up "<code class="literal">$CVSROOT</code>" for the local access.</p>
<pre class="screen">$ export CVSROOT=/srv/cvs/project</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_remote_access_to_cvs_with_pserver"></a>10.7.3. Remote access to CVS with pserver</h3></div></div></div>
<p>Many public CVS servers provide read-only remote access to them with account name "<code class="literal">anonymous</code>" via pserver service. For example, Debian web site contents are maintained by <a class="ulink" href="http://alioth.debian.org/projects/webwml/" target="_top">webwml project</a> via CVS at Debian alioth service. The following sets up "<code class="literal">$CVSROOT</code>" for the remote access to this CVS repository.</p>
<pre class="screen">$ export CVSROOT=:pserver:anonymous@cvs.alioth.debian.org:/cvsroot/webwml
$ cvs login</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Since pserver is prone to eavesdropping attack and insecure, write access is usually disable by server administrators.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_remote_access_to_cvs_with_ssh"></a>10.7.4. Remote access to CVS with ssh</h3></div></div></div>
<p>The following sets up "<code class="literal">$CVS_RSH</code>" and "<code class="literal">$CVSROOT</code>" for the remote access to the CVS repository by <a class="ulink" href="http://alioth.debian.org/projects/webwml/" target="_top">webwml project</a> with SSH.</p>
<pre class="screen">$ export CVS_RSH=ssh
$ export CVSROOT=:ext:account@cvs.alioth.debian.org:/cvs/webwml</pre>
<p>You can also use public key authentication for SSH which eliminates the remote password prompt.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_importing_a_new_source_to_cvs"></a>10.7.5. Importing a new source to CVS</h3></div></div></div>
<p>Create a new local source tree location at "<code class="literal">~/path/to/module1</code>" by the following.</p>
<pre class="screen">$ mkdir -p ~/path/to/module1; cd ~/path/to/module1</pre>
<p>Populate a new local source tree under "<code class="literal">~/path/to/module1</code>" with files.</p>
<p>Import it to CVS with the following parameters.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Module name: "<code class="literal">module1</code>"
</p></li>
<li class="listitem"><p>
Vendor tag: "<code class="literal">Main-branch</code>" (tag for the entire branch)
</p></li>
<li class="listitem"><p>
Release tag: "<code class="literal">Release-initial</code>" (tag for a specific release)
</p></li>
</ul></div>
<pre class="screen">$ cd ~/path/to/module1
$ cvs import -m "Start module1" module1 Main-branch Release-initial
$ rm -Rf . # optional</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_file_permissions_in_cvs_repository"></a>10.7.6. File permissions in CVS repository</h3></div></div></div>
<p>CVS does not overwrite the current repository file but replaces it with another one. Thus, write permission to the repository directory is critical. For every new module for "<code class="literal">module1</code>" in repository at "<code class="literal">/srv/cvs/project</code>", run the following to ensure this condition if needed.</p>
<pre class="screen"># cd /srv/cvs/project
# chown -R root:src module1
# chmod -R ug+rwX module1
# chmod 2775 module1</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_work_flow_of_cvs"></a>10.7.7. Work flow of CVS</h3></div></div></div>
<p>Here is an example of typical work flow using CVS.</p>
<p>Check all available modules from CVS project pointed by "<code class="literal">$CVSROOT</code>" by the following.</p>
<pre class="screen">$ cvs rls
CVSROOT
module1
module2
...</pre>
<p>Checkout "<code class="literal">module1</code>" to its default directory "<code class="literal">./module1</code>" by the following.</p>
<pre class="screen">$ cd ~/path/to
$ cvs co module1
$ cd module1</pre>
<p>Make changes to the content as needed.</p>
<p>Check changes by making "<code class="literal">diff -u [repository] [local]</code>" equivalent by the following.</p>
<pre class="screen">$ cvs diff -u</pre>
<p>You find that you broke some file "<code class="literal">file_to_undo</code>" severely but other files are fine.</p>
<p>Overwrite "<code class="literal">file_to_undo</code>" file with the clean copy from CVS by the following.</p>
<pre class="screen">$ cvs up -C file_to_undo</pre>
<p>Save the updated local source tree to CVS by the following.</p>
<pre class="screen">$ cvs ci -m "Describe change"</pre>
<p>Create and add "<code class="literal">file_to_add</code>" file to CVS by the following.</p>
<pre class="screen">$ vi file_to_add
$ cvs add file_to_add
$ cvs ci -m "Added file_to_add"</pre>
<p>Merge the latest version from CVS by the following.</p>
<pre class="screen">$ cvs up -d</pre>
<p>Watch out for lines starting with "<code class="literal">C filename</code>" which indicates conflicting changes.</p>
<p>Look for unmodified code in "<code class="literal">.#filename.version</code>".</p>
<p>Search for "<code class="literal">&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>" and "<code class="literal">&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>" in files for conflicting changes.</p>
<p>Edit files to fix conflicts as needed.</p>
<p>Add a release tag "<code class="literal">Release-1</code>" by the following.</p>
<pre class="screen">$ cvs ci -m "last commit for Release-1"
$ cvs tag Release-1</pre>
<p>Edit further.</p>
<p>Remove the release tag "<code class="literal">Release-1</code>" by the following.</p>
<pre class="screen">$ cvs tag -d Release-1</pre>
<p>Check in changes to CVS by the following.</p>
<pre class="screen">$ cvs ci -m "real last commit for Release-1"</pre>
<p>Re-add the release tag "<code class="literal">Release-1</code>" to updated CVS HEAD of main by the following.</p>
<pre class="screen">$ cvs tag Release-1</pre>
<p>Create a branch with a sticky branch tag "<code class="literal">Release-initial-bugfixes</code>" from the original version pointed by the tag "<code class="literal">Release-initial</code>" and check it out to "<code class="literal">~/path/to/old</code>" directory by the following.</p>
<pre class="screen">$ cvs rtag -b -r Release-initial Release-initial-bugfixes module1
$ cd ~/path/to
$ cvs co -r Release-initial-bugfixes -d old module1
$ cd old</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Use "<code class="literal">-D 2005-12-20</code>" (<a class="ulink" href="http://en.wikipedia.org/wiki/ISO_8601" target="_top">ISO 8601</a> date format) instead of "<code class="literal">-r Release-initial</code>" to specify particular date as the branch point.</p></td></tr>
</table></div>
<p>Work on this local source tree having the sticky tag "<code class="literal">Release-initial-bugfixes</code>" which is based on the original version.</p>
<p>Work on this branch by yourself … until someone else joins to this "<code class="literal">Release-initial-bugfixes</code>" branch.</p>
<p>Sync with files modified by others on this branch while creating new directories as needed by the following.</p>
<pre class="screen">$ cvs up -d</pre>
<p>Edit files to fix conflicts as needed.</p>
<p>Check in changes to CVS by the following.</p>
<pre class="screen">$ cvs ci -m "checked into this branch"</pre>
<p>Update the local tree by HEAD of main while removing sticky tag ("<code class="literal">-A</code>") and without keyword expansion ("<code class="literal">-kk</code>") by the following.</p>
<pre class="screen">$ cvs up -d -kk -A</pre>
<p>Update the local tree (content = HEAD of main) by merging from the "<code class="literal">Release-initial-bugfixes</code>" branch and without keyword expansion by the following.</p>
<pre class="screen">$ cvs up -d -kk -j Release-initial-bugfixes</pre>
<p>Fix conflicts with editor.</p>
<p>Check in changes to CVS by the following.</p>
<pre class="screen">$ cvs ci -m "merged Release-initial-bugfixes"</pre>
<p>Make archive by the following.</p>
<pre class="screen">$ cd ..
$ mv old old-module1-bugfixes
$ tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes
$ rm -rf old-module1-bugfixes</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>"<code class="literal">cvs up</code>" command can take "<code class="literal">-d</code>" option to create new directories and "<code class="literal">-P</code>" option to prune empty directories.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can checkout only a sub directory of "<code class="literal">module1</code>" by providing its name as "<code class="literal">cvs co module1/subdir</code>".</p></td></tr>
</table></div>
<div class="table">
<a name="notableoptionsfotargumentstocvsb"></a><p class="title"><b>Table 10.17. Notable options for CVS commands (use as first argument(s) to <span class="citerefentry"><span class="refentrytitle">cvs</span>(1)</span>)</b></p>
<div class="table-contents"><table summary="Notable options for CVS commands (use as first argument(s) to cvs1)" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
option
</th>
<th align="left">
meaning
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">-n</code>
</td>
<td align="left">
dry run, no effect
</td>
</tr>
<tr>
<td align="left">
<code class="literal">-t</code>
</td>
<td align="left">
display messages showing steps of cvs activity
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_latest_files_from_cvs"></a>10.7.8. Latest files from CVS</h3></div></div></div>
<p>To get the latest files from CVS, use "<code class="literal">tomorrow</code>" by the following.</p>
<pre class="screen">$ cvs ex -D tomorrow module_name</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_administration_of_cvs"></a>10.7.9. Administration of CVS</h3></div></div></div>
<p>Add module alias "<code class="literal">mx</code>" to a CVS project (local server) by the following.</p>
<pre class="screen">$ export CVSROOT=/srv/cvs/project
$ cvs co CVSROOT/modules
$ cd CVSROOT
$ echo "mx -a module1" &gt;&gt;modules
$ cvs ci -m "Now mx is an alias for module1"
$ cvs release -d .</pre>
<p>Now, you can check out "<code class="literal">module1</code>" (alias: "<code class="literal">mx</code>") from CVS to "<code class="literal">new</code>" directory by the following.</p>
<pre class="screen">$ cvs co -d new mx
$ cd new</pre>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>In order to perform above procedure, you should have appropriate file permissions.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_execution_bit_for_cvs_checkout"></a>10.7.10. Execution bit for CVS checkout</h3></div></div></div>
<p>When you checkout files from CVS, their execution permission bit is retained.</p>
<p>Whenever you see execution permission problems in a checked out file, e.g. "<code class="literal">filename</code>", change its permission in the corresponding CVS repository by the following to fix it.</p>
<pre class="screen"># chmod ugo-x filename</pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_subversion"></a>10.8. Subversion</h2></div></div></div>
<p>Subversion is a <span class="strong"><strong>recent-generation</strong></span> version control system replacing older CVS. It has most of CVS's features except tags and branches.</p>
<p>You need to install <code class="literal">subversion</code>, <code class="literal">libapache2-svn</code> and <code class="literal">subversion-tools</code> packages to set up a Subversion server.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_configuration_of_subversion_repository"></a>10.8.1. Configuration of Subversion repository</h3></div></div></div>
<p>Currently, the <code class="literal">subversion</code> package does not set up a repository, so one must set it up manually. One possible location for a repository is in "<code class="literal">/srv/svn/project</code>".</p>
<p>Create a directory by the following.</p>
<pre class="screen"># mkdir -p /srv/svn/project</pre>
<p>Create the repository database by the following.</p>
<pre class="screen"># svnadmin create /srv/svn/project</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_access_to_subversion_via_apache2_server"></a>10.8.2. Access to Subversion via Apache2 server</h3></div></div></div>
<p>If you only access Subversion repository via Apache2 server, you just need to make the repository only writable by the WWW server by the following.</p>
<pre class="screen"># chown -R www-data:www-data /srv/svn/project</pre>
<p>Add (or uncomment) the following in "<code class="literal">/etc/apache2/mods-available/dav_svn.conf</code>" to allow access to the repository via user authentication.</p>
<pre class="screen">&lt;Location /project&gt;
DAV svn
SVNPath /srv/svn/project
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/subversion/passwd
&lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;
Require valid-user
&lt;/LimitExcept&gt;
&lt;/Location&gt;</pre>
<p>Create a user authentication file with the command by the following.</p>
<pre class="screen"># htpasswd2 -c /etc/subversion/passwd some-username</pre>
<p>Restart Apache2.</p>
<p>Your new Subversion repository is accessible at URL "<code class="literal">http://localhost/project</code>" and "<code class="literal">http://example.com/project</code>" from <span class="citerefentry"><span class="refentrytitle">svn</span>(1)</span> (assuming your URL of web server is "<code class="literal">http://example.com/</code>").</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_local_access_to_subversion_by_group"></a>10.8.3. Local access to Subversion by group</h3></div></div></div>
<p>The following sets up Subversion repository for the local access by a group, e.g. <code class="literal">project</code>.</p>
<pre class="screen"># chmod 2775 /srv/svn/project
# chown -R root:src /srv/svn/project
# chmod -R ug+rwX /srv/svn/project</pre>
<p>Your new Subversion repository is group accessible at URL "<code class="literal">file:///localhost/srv/svn/project</code>" or "<code class="literal">file:///srv/svn/project</code>" from <span class="citerefentry"><span class="refentrytitle">svn</span>(1)</span> for local users belonging to <code class="literal">project</code> group. You must run commands, such as <code class="literal">svn</code>, <code class="literal">svnserve</code>, <code class="literal">svnlook</code>, and <code class="literal">svnadmin</code> under "<code class="literal">umask 002</code>" to ensure group access.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_remote_access_to_subversion_via_ssh"></a>10.8.4. Remote access to Subversion via SSH</h3></div></div></div>
<p>A group accessible Subversion repository is at URL "<code class="literal">example.com:/srv/svn/project</code>" for SSH, you can access it from <span class="citerefentry"><span class="refentrytitle">svn</span>(1)</span> at URL "<code class="literal">svn+ssh://example.com:/srv/svn/project</code>".</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_subversion_directory_structure"></a>10.8.5. Subversion directory structure</h3></div></div></div>
<p>Many projects uses directory tree similar to the following for Subversion to compensate its lack of branches and tags.</p>
<pre class="screen"> ----- module1
| |-- branches
| |-- tags
| | |-- release-1.0
| | `-- release-2.0
| |
| `-- trunk
| |-- file1
| |-- file2
| `-- file3
|
`-- module2</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You must use "<code class="literal">svn copy …</code>" command to mark branches and tags. This ensures Subversion to record modification history of files properly and saves storage spaces.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_importing_a_new_source_to_subversion"></a>10.8.6. Importing a new source to Subversion</h3></div></div></div>
<p>Create a new local source tree location at "<code class="literal">~/path/to/module1</code>" by the following.</p>
<pre class="screen">$ mkdir -p ~/path/to/module1; cd ~/path/to/module1</pre>
<p>Populate a new local source tree under "<code class="literal">~/path/to/module1</code>" with files.</p>
<p>Import it to Subversion with the following parameters.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Module name: "<code class="literal">module1</code>"
</p></li>
<li class="listitem"><p>
Subversion site URL: "<code class="literal">file:///srv/svn/project</code>"
</p></li>
<li class="listitem"><p>
Subversion directory: "<code class="literal">module1/trunk</code>"
</p></li>
<li class="listitem"><p>
Subversion tag: "<code class="literal">module1/tags/Release-initial</code>"
</p></li>
</ul></div>
<pre class="screen">$ cd ~/path/to/module1
$ svn import file:///srv/svn/project/module1/trunk -m "Start module1"
$ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-initial</pre>
<p>Alternatively, by the following.</p>
<pre class="screen">$ svn import ~/path/to/module1 file:///srv/svn/project/module1/trunk -m "Start module1"
$ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-initial</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can replace URLs such as "<code class="literal">file:///…</code>" by any other URL formats such as "<code class="literal">http://…</code>" and "<code class="literal">svn+ssh://…</code>".</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_work_flow_of_subversion"></a>10.8.7. Work flow of Subversion</h3></div></div></div>
<p>Here is an example of typical work flow using Subversion with its native client.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Client commands offered by the <code class="literal">git-svn</code> package may offer alternative work flow of Subversion using the <code class="literal">git</code> command. See <a class="xref" href="ch10.en.html#_git_for_the_subversion_repository" title="10.9.4. Git for the Subversion repository">Section 10.9.4, “Git for the Subversion repository”</a>.</p></td></tr>
</table></div>
<p>Check all available modules from Subversion project pointed by URL "<code class="literal">file:///srv/svn/project</code>" by the following.</p>
<pre class="screen">$ svn list file:///srv/svn/project
module1
module2
...</pre>
<p>Checkout "<code class="literal">module1/trunk</code>" to a directory "<code class="literal">module1</code>" by the following.</p>
<pre class="screen">$ cd ~/path/to
$ svn co file:///srv/svn/project/module1/trunk module1
$ cd module1</pre>
<p>Make changes to the content as needed.</p>
<p>Check changes by making "<code class="literal">diff -u [repository] [local]</code>" equivalent by the following.</p>
<pre class="screen">$ svn diff</pre>
<p>You find that you broke some file "<code class="literal">file_to_undo</code>" severely but other files are fine.</p>
<p>Overwrite "<code class="literal">file_to_undo</code>" file with the clean copy from Subversion by the following.</p>
<pre class="screen">$ svn revert file_to_undo</pre>
<p>Save the updated local source tree to Subversion by the following.</p>
<pre class="screen">$ svn ci -m "Describe change"</pre>
<p>Create and add "<code class="literal">file_to_add</code>" file to Subversion by the following.</p>
<pre class="screen">$ vi file_to_add
$ svn add file_to_add
$ svn ci -m "Added file_to_add"</pre>
<p>Merge the latest version from Subversion by the following.</p>
<pre class="screen">$ svn up</pre>
<p>Watch out for lines starting with "<code class="literal">C filename</code>" which indicates conflicting changes.</p>
<p>Look for unmodified code in, e.g., "<code class="literal">filename.r6</code>", "<code class="literal">filename.r9</code>", and "<code class="literal">filename.mine</code>".</p>
<p>Search for "<code class="literal">&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code>" and "<code class="literal">&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>" in files for conflicting changes.</p>
<p>Edit files to fix conflicts as needed.</p>
<p>Add a release tag "<code class="literal">Release-1</code>" by the following.</p>
<pre class="screen">$ svn ci -m "last commit for Release-1"
$ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1</pre>
<p>Edit further.</p>
<p>Remove the release tag "<code class="literal">Release-1</code>" by the following.</p>
<pre class="screen">$ svn rm file:///srv/svn/project/module1/tags/Release-1</pre>
<p>Check in changes to Subversion by the following.</p>
<pre class="screen">$ svn ci -m "real last commit for Release-1"</pre>
<p>Re-add the release tag "<code class="literal">Release-1</code>" from updated Subversion HEAD of trunk by the following.</p>
<pre class="screen">$ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1</pre>
<p>Create a branch with a path "<code class="literal">module1/branches/Release-initial-bugfixes</code>" from the original version pointed by the path "<code class="literal">module1/tags/Release-initial</code>" and check it out to "<code class="literal">~/path/to/old</code>" directory by the following.</p>
<pre class="screen">$ svn cp file:///srv/svn/project/module1/tags/Release-initial file:///srv/svn/project/module1/branches/Release-initial-bugfixes
$ cd ~/path/to
$ svn co file:///srv/svn/project/module1/branches/Release-initial-bugfixes old
$ cd old</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>Use "<code class="literal">module1/trunk@{2005-12-20}</code>" (<a class="ulink" href="http://en.wikipedia.org/wiki/ISO_8601" target="_top">ISO 8601</a> date format) instead of "<code class="literal">module1/tags/Release-initial</code>" to specify particular date as the branch point.</p></td></tr>
</table></div>
<p>Work on this local source tree pointing to branch "<code class="literal">Release-initial-bugfixes</code>" which is based on the original version.</p>
<p>Work on this branch by yourself … until someone else joins to this "<code class="literal">Release-initial-bugfixes</code>" branch.</p>
<p>Sync with files modified by others on this branch by the following.</p>
<pre class="screen">$ svn up</pre>
<p>Edit files to fix conflicts as needed.</p>
<p>Check in changes to Subversion by the following.</p>
<pre class="screen">$ svn ci -m "checked into this branch"</pre>
<p>Update the local tree with HEAD of trunk by the following.</p>
<pre class="screen">$ svn switch file:///srv/svn/project/module1/trunk</pre>
<p>Update the local tree (content = HEAD of trunk) by merging from the "<code class="literal">Release-initial-bugfixes</code>" branch by the following.</p>
<pre class="screen">$ svn merge file:///srv/svn/project/module1/branches/Release-initial-bugfixes</pre>
<p>Fix conflicts with editor.</p>
<p>Check in changes to Subversion by the following.</p>
<pre class="screen">$ svn ci -m "merged Release-initial-bugfixes"</pre>
<p>Make archive by the following.</p>
<pre class="screen">$ cd ..
$ mv old old-module1-bugfixes
$ tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes
$ rm -rf old-module1-bugfixes</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can replace URLs such as "<code class="literal">file:///…</code>" by any other URL formats such as "<code class="literal">http://…</code>" and "<code class="literal">svn+ssh://…</code>".</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>You can checkout only a sub directory of "<code class="literal">module1</code>" by providing its name as "<code class="literal">svn co file:///srv/svn/project/module1/trunk/subdir module1/subdir</code>", etc.</p></td></tr>
</table></div>
<div class="table">
<a name="notableoptionsfotargumentstosvnb"></a><p class="title"><b>Table 10.18. Notable options for Subversion commands (use as first argument(s) to <span class="citerefentry"><span class="refentrytitle">svn</span>(1)</span>)</b></p>
<div class="table-contents"><table summary="Notable options for Subversion commands (use as first argument(s) to svn1)" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
option
</th>
<th align="left">
meaning
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">--dry-run</code>
</td>
<td align="left">
dry run, no effect
</td>
</tr>
<tr>
<td align="left">
<code class="literal">-v</code>
</td>
<td align="left">
display detail messages of svn activity
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_git"></a>10.9. Git</h2></div></div></div>
<p>Git can do everything for both local and remote source code management. This means that you can record the source code changes without needing network connectivity to the remote repository.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_configuration_of_git_client"></a>10.9.1. Configuration of Git client</h3></div></div></div>
<p>You may wish to set several global configuration in "<code class="literal">~/.gitconfig</code>" such as your name and email address used by Git by the following.</p>
<pre class="screen">$ git config --global user.name "Name Surname"
$ git config --global user.email yourname@example.com</pre>
<p>If you are too used to CVS or Subversion commands, you may wish to set several command aliases by the following.</p>
<pre class="screen">$ git config --global alias.ci "commit -a"
$ git config --global alias.co checkout</pre>
<p>You can check your global configuration by the following.</p>
<pre class="screen">$ git config --global --list</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_git_references"></a>10.9.2. Git references</h3></div></div></div>
<p>See the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/git.html" target="_top">manpage: git(1)</a> (<code class="literal">/usr/share/doc/git-doc/git.html</code>)
</p></li>
<li class="listitem"><p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/user-manual.html" target="_top">Git User's Manual</a> (<code class="literal">/usr/share/doc/git-doc/user-manual.html</code>)
</p></li>
<li class="listitem"><p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html" target="_top">A tutorial introduction to git</a> (<code class="literal">/usr/share/doc/git-doc/gittutorial.html</code>)
</p></li>
<li class="listitem"><p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html" target="_top">A tutorial introduction to git: part two</a> (<code class="literal">/usr/share/doc/git-doc/gittutorial-2.html</code>)
</p></li>
<li class="listitem"><p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/everyday.html" target="_top">Everyday GIT With 20 Commands Or So</a> (<code class="literal">/usr/share/doc/git-doc/everyday.html</code>)
</p></li>
<li class="listitem">
<p><a class="ulink" href="http://www.kernel.org/pub/software/scm/git/docs/gitcvs-migration.html" target="_top">git for CVS users</a> (<code class="literal">/usr/share/doc/git-doc/gitcvs-migration.html</code>)
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>
This also describes how to set up server like CVS and extract old data from CVS into Git.
</p></li></ul></div>
</li>
<li class="listitem">
<p>
<a class="ulink" href="http://git-scm.com/documentation" target="_top">Other git resources available on the web</a>
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem"><p>
<a class="ulink" href="http://git-scm.com/course/svn.html" target="_top">Git - SVN Crash Course</a>
</p></li>
<li class="listitem"><p><a class="ulink" href="http://www-cs-students.stanford.edu/~blynn/gitmagic/" target="_top">Git Magic</a> (<code class="literal">/usr/share/doc/gitmagic/html/index.html</code>)
</p></li>
</ul></div>
</li>
</ul></div>
<p><span class="citerefentry"><span class="refentrytitle">git-gui</span>(1)</span> and <span class="citerefentry"><span class="refentrytitle">gitk</span>(1)</span> commands make using Git very easy.</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>Do not use the tag string with spaces in it even if some tools such as <span class="citerefentry"><span class="refentrytitle">gitk</span>(1)</span> allow you to use it. It may choke some other <code class="literal">git</code> commands.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_git_commands"></a>10.9.3. Git commands</h3></div></div></div>
<p>Even if your upstream uses different VCS, it may be good idea to use <span class="citerefentry"><span class="refentrytitle">git</span>(1)</span> for local activity since you can manage your local copy of source tree without the network connection to the upstream. Here are some packages and commands used with <span class="citerefentry"><span class="refentrytitle">git</span>(1)</span>.</p>
<div class="table">
<a name="listofgitrelatedkagesandcommands"></a><p class="title"><b>Table 10.19. List of git related packages and commands</b></p>
<div class="table-contents"><table summary="List of git related packages and commands" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
N/A
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-doc" target="_top">
<code class="literal">git-doc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-doc" target="_top">http://qa.debian.org/popcon.php?package=git-doc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-doc.html" target="_top">8398</a></td>
<td align="left">
official documentation for Git
</td>
</tr>
<tr>
<td align="left">
N/A
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gitmagic" target="_top">
<code class="literal">gitmagic</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gitmagic" target="_top">http://qa.debian.org/popcon.php?package=gitmagic</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gitmagic.html" target="_top">924</a></td>
<td align="left">
"Git Magic", easier to understand guide for Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git</span>(7)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git" target="_top">
<code class="literal">git</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git" target="_top">http://qa.debian.org/popcon.php?package=git</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git.html" target="_top">13073</a></td>
<td align="left">
Git, the fast, scalable, distributed revision control system
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">gitk</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/gitk" target="_top">
<code class="literal">gitk</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=gitk" target="_top">http://qa.debian.org/popcon.php?package=gitk</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/gitk.html" target="_top">1045</a></td>
<td align="left">
GUI Git repository browser with history
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-gui</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-gui" target="_top">
<code class="literal">git-gui</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-gui" target="_top">http://qa.debian.org/popcon.php?package=git-gui</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-gui.html" target="_top">1666</a></td>
<td align="left">
GUI for Git (No history)
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-svnimport</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-svn" target="_top">
<code class="literal">git-svn</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-svn" target="_top">http://qa.debian.org/popcon.php?package=git-svn</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-svn.html" target="_top">686</a></td>
<td align="left">
import the data out of Subversion into Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-svn</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-svn" target="_top">
<code class="literal">git-svn</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-svn" target="_top">http://qa.debian.org/popcon.php?package=git-svn</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-svn.html" target="_top">686</a></td>
<td align="left">
provide bidirectional operation between the Subversion and Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-cvsimport</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-cvs" target="_top">
<code class="literal">git-cvs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-cvs" target="_top">http://qa.debian.org/popcon.php?package=git-cvs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-cvs.html" target="_top">779</a></td>
<td align="left">
import the data out of CVS into Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-cvsexportcommit</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-cvs" target="_top">
<code class="literal">git-cvs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-cvs" target="_top">http://qa.debian.org/popcon.php?package=git-cvs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-cvs.html" target="_top">779</a></td>
<td align="left">
export a commit to a CVS checkout from Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-cvsserver</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-cvs" target="_top">
<code class="literal">git-cvs</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-cvs" target="_top">http://qa.debian.org/popcon.php?package=git-cvs</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-cvs.html" target="_top">779</a></td>
<td align="left">
CVS server emulator for Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-send-email</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-email" target="_top">
<code class="literal">git-email</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-email" target="_top">http://qa.debian.org/popcon.php?package=git-email</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-email.html" target="_top">529</a></td>
<td align="left">
send a collection of patches as email from the Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">stg</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/stgit" target="_top">
<code class="literal">stgit</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=stgit" target="_top">http://qa.debian.org/popcon.php?package=stgit</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/s/stgit.html" target="_top">1628</a></td>
<td align="left">
quilt on top of git (Python)
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">git-buildpackage</span>(1)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/git-buildpackage" target="_top">
<code class="literal">git-buildpackage</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=git-buildpackage" target="_top">http://qa.debian.org/popcon.php?package=git-buildpackage</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/git-buildpackage.html" target="_top">2219</a></td>
<td align="left">
automate the Debian packaging with the Git
</td>
</tr>
<tr>
<td align="left">
<span class="citerefentry"><span class="refentrytitle">guilt</span>(7)</span>
</td>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/guilt" target="_top">
<code class="literal">guilt</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=guilt" target="_top">http://qa.debian.org/popcon.php?package=guilt</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/guilt.html" target="_top">360</a></td>
<td align="left">
quilt on top of git (SH/AWK/SED/…)
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>With <span class="citerefentry"><span class="refentrytitle">git</span>(1)</span>, you work on a local branch with many commits and use something like "<code class="literal">git rebase -i master</code>" to reorganize change history later. This enables you to make clean change history. See <span class="citerefentry"><span class="refentrytitle">git-rebase</span>(1)</span> and <span class="citerefentry"><span class="refentrytitle">git-cherry-pick</span>(1)</span>.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>When you want to go back to a clean working directory without loosing the current state of the working directory, you can use "<code class="literal">git stash</code>". See <span class="citerefentry"><span class="refentrytitle">git-stash</span>(1)</span>.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_git_for_the_subversion_repository"></a>10.9.4. Git for the Subversion repository</h3></div></div></div>
<p>You can check out a Subversion repository at "<code class="literal">svn+ssh://svn.example.org/project/module/trunk</code>" to a local Git repository at "<code class="literal">./dest</code>" and commit back to the Subversion repository. E.g.:</p>
<pre class="screen">$ git svn clone -s -rHEAD svn+ssh://svn.example.org/project dest
$ cd dest
... make changes
$ git commit -a
... keep working locally with git
$ git svn dcommit</pre>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>The use of "<code class="literal">-rHEAD</code>" enables us to avoid cloning entire historical contents from the Subversion repository.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_git_for_recording_configuration_history"></a>10.9.5. Git for recording configuration history</h3></div></div></div>
<p>You can manually record chronological history of configuration using <a class="ulink" href="http://en.wikipedia.org/wiki/Git_(software)" target="_top">Git</a> tools. Here is a simple example for your practice to record "<code class="literal">/etc/apt/</code>" contents.</p>
<pre class="screen">$ cd /etc/apt/
$ sudo git init
$ sudo chmod 700 .git
$ sudo git add .
$ sudo git commit -a</pre>
<p>Commit configuration with description.</p>
<p>Make modification to the configuration files.</p>
<pre class="screen">$ cd /etc/apt/
$ sudo git commit -a</pre>
<p>Commit configuration with description and continue your life.</p>
<pre class="screen">$ cd /etc/apt/
$ sudo gitk --all</pre>
<p>You have full configuration history with you.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p><span class="citerefentry"><span class="refentrytitle">sudo</span>(8)</span> is needed to work with any file permissions of configuration data. For user configuration data, you may skip <code class="literal">sudo</code>.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The "<code class="literal">chmod 700 .git</code>" command in the above example is needed to protect archive data from unauthorized read access.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>For more complete setup for recording configuration history, please look for the <code class="literal">etckeeper</code> package: <a class="xref" href="ch09.en.html#_recording_changes_in_configuration_files" title="9.2.10. Recording changes in configuration files">Section 9.2.10, “Recording changes in configuration files”</a>.</p></td></tr>
</table></div>
</div>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="ch09.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="ch11.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 9. System tips </td>
<td width="20%" align="center"><a accesskey="h" href="index.en.html"><img src="images/home.gif" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Chapter 11. Data conversion</td>
</tr>
</table>
</div>
</body>
</html>