CINXE.COM

Chapter 9. System tips

<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Chapter 9. System tips</title> <link rel="stylesheet" type="text/css" href="debian-reference.css"/> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <link rel="home" href="index.en.html" title="Debian Reference"/> <link rel="up" href="index.en.html" title="Debian Reference"/> <link rel="prev" href="ch08.en.html" title="Chapter 8. I18N and L10N"/> <link rel="next" href="ch10.en.html" title="Chapter 10. Data management"/> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">Chapter 9. System tips</th> </tr> <tr> <td align="left"><a accesskey="p" href="ch08.en.html"><img src="images/prev.png" alt="Prev"/></a> </td> <th width="60%" align="center"> </th> <td align="right"> <a accesskey="n" href="ch10.en.html"><img src="images/next.png" alt="Next"/></a></td> </tr> </table> <hr/> </div> <div class="chapter"> <div class="titlepage"> <div> <div> <h1 class="title"><a id="_system_tips"/>Chapter 9. System tips</h1> </div> </div> </div> <div class="toc"> <p> <strong>Table of Contents</strong> </p> <dl class="toc"> <dt> <span class="section"> <a href="ch09.en.html#_the_console_tips">9.1. The console tips</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_recording_the_shell_activities_cleanly">9.1.1. Recording the shell activities cleanly</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_screen_program">9.1.2. The screen program</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_navigating_around_directories">9.1.3. Navigating around directories</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_readline_wrapper">9.1.4. Readline wrapper</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_scanning_the_source_code_tree">9.1.5. Scanning the source code tree</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_customizing_vim">9.2. Customizing vim</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_customizing_vim_with internal_features">9.2.1. Customizing vim with internal features</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_customizing_vim_with_external_packages">9.2.2. Customizing vim with external packages</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_data_recording_and_presentation">9.3. Data recording and presentation</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_the_log_daemon">9.3.1. The log daemon</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_log_analyzer">9.3.2. Log analyzer</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_customized_display_of_text_data">9.3.3. Customized display of text data</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_customized_display_of_time_and_date">9.3.4. Customized display of time and date</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_colorized_shell_echo">9.3.5. Colorized shell echo</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_colorized_commands">9.3.6. Colorized commands</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_recording_the_editor_activities_for_complex_repeats">9.3.7. Recording the editor activities for complex repeats</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_recording_the_graphic_image_of_an_x_application">9.3.8. Recording the graphics image of an X application</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_recording_changes_in_configuration_files">9.3.9. Recording changes in configuration files</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_monitoring_controlling_and_starting_program_activities">9.4. Monitoring, controlling, and starting program activities</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_timing_a_process">9.4.1. Timing a process</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_scheduling_priority">9.4.2. The scheduling priority</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_ps_command">9.4.3. The ps command</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_top_command">9.4.4. The top command</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_listing_files_opened_by_a_process">9.4.5. Listing files opened by a process</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_tracing_program_activities">9.4.6. Tracing program activities</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_identification_of_processes_using_files_or_sockets">9.4.7. Identification of processes using files or sockets</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_repeating_a_command_with_a_constant_interval">9.4.8. Repeating a command with a constant interval</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_repeating_a_command_looping_over_files">9.4.9. Repeating a command looping over files</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_starting_a_program_from_gui">9.4.10. Starting a program from GUI</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_customizing_program_to_be_started">9.4.11. Customizing program to be started</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_killing_a_process">9.4.12. Killing a process</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_scheduling_tasks_once">9.4.13. Scheduling tasks once</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_scheduling_tasks_regularly">9.4.14. Scheduling tasks regularly</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_scheduling_tasks_on_event">9.4.15. Scheduling tasks on event</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_alt_sysrq_key">9.4.16. Alt-SysRq key</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_system_maintenance_tips">9.5. System maintenance tips</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_who_is_on_the_system">9.5.1. Who is on the system?</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_warning_everyone">9.5.2. Warning everyone</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_hardware_identification">9.5.3. Hardware identification</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_hardware_configuration">9.5.4. Hardware configuration</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_system_and_hardware_time">9.5.5. System and hardware time</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_terminal_configuration">9.5.6. The terminal configuration</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_the_sound_infrastructure">9.5.7. The sound infrastructure</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_disabling_the_screen_saver">9.5.8. Disabling the screen saver</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_disabling_beep_sounds">9.5.9. Disabling beep sounds</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_memory_usage">9.5.10. Memory usage</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_system_security_and_integrity_check">9.5.11. System security and integrity check</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_data_storage_tips">9.6. Data storage tips</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_disk_space_usage">9.6.1. Disk space usage</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_disk_partition_configuration">9.6.2. Disk partition configuration</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_accessing_partition_using_uuid">9.6.3. Accessing partition using UUID</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_lvm2">9.6.4. LVM2</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_filesystem_configuration">9.6.5. Filesystem configuration</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_filesystem_creation_and_integrity_check">9.6.6. Filesystem creation and integrity check</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_optimization_of_filesystem_by_mount_options">9.6.7. Optimization of filesystem by mount options</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_optimization_of_filesystem_via_superblock">9.6.8. Optimization of filesystem via superblock</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_optimization_of_hard_disk">9.6.9. Optimization of hard disk</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_optimization_of_solid_state_drive">9.6.10. Optimization of solid state drive</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_using_smart_to_predict_hard_disk_failure">9.6.11. Using SMART to predict hard disk failure</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_specify_temporary_storage_directory_via_tmpdir">9.6.12. Specify temporary storage directory via $TMPDIR</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_expansion_of_usable_storage_space_via_lvm">9.6.13. Expansion of usable storage space via LVM</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_expansion_of_usable_storage_space_by_mounting_another_partition">9.6.14. Expansion of usable storage space by mounting another partition</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_expansion_of_usable_storage_space_by_bind_mounting_another_directory">9.6.15. Expansion of usable storage space by bind-mounting another directory</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_expansion_of_usable_storage_space_by_overlay_mounting_another_directory">9.6.16. Expansion of usable storage space by overlay-mounting another directory</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_expansion_of_usable_storage_space_using_symlink">9.6.17. Expansion of usable storage space using symlink</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_the_disk_image">9.7. The disk image</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_making_the_disk_image_file">9.7.1. Making the disk image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_writing_directly_to_the_disk">9.7.2. Writing directly to the disk</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_mounting_the_disk_image_file">9.7.3. Mounting the disk image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_cleaning_a_disk_image_file">9.7.4. Cleaning a disk image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_making_the_empty_disk_image_file">9.7.5. Making the empty disk image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_making_the_iso9660_image_file">9.7.6. Making the ISO9660 image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_writing_directly_to_the_cd_dvd_r_rw">9.7.7. Writing directly to the CD/DVD-R/RW</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_mounting_the_iso9660_image_file">9.7.8. Mounting the ISO9660 image file</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_the_binary_data">9.8. The binary data</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_viewing_and_editing_binary_data">9.8.1. Viewing and editing binary data</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_manipulating_files_without_mounting_disk">9.8.2. Manipulating files without mounting disk</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_data_redundancy">9.8.3. Data redundancy</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_data_file_recovery_and_forensic_analysis">9.8.4. Data file recovery and forensic analysis</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_splitting_a_large_file_into_small_files">9.8.5. Splitting a large file into small files</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_clearing_file_contents">9.8.6. Clearing file contents</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_dummy_files">9.8.7. Dummy files</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_erasing_an_entire_hard_disk">9.8.8. Erasing an entire hard disk</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_erasing_unused_area_of_an_hard_disk">9.8.9. Erasing unused area of an hard disk</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_undeleting_deleted_but_still_open_files">9.8.10. Undeleting deleted but still open files</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_searching_all_hardlinks">9.8.11. Searching all hardlinks</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_invisible_disk_space_consumption">9.8.12. Invisible disk space consumption</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_data_encryption_tips">9.9. Data encryption tips</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_removable_disk_encryption_with_dm_crypt_luks">9.9.1. Removable disk encryption with dm-crypt/LUKS</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_mounting_encrypted_disk_with_dm_crypt_luks">9.9.2. Mounting encrypted disk with dm-crypt/LUKS</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_the_kernel">9.10. The kernel</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_kernel_parameters">9.10.1. Kernel parameters</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_kernel_headers">9.10.2. Kernel headers</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_compiling_the_kernel_and_related_modules">9.10.3. Compiling the kernel and related modules</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_compiling_the_kernel_source_debian_kernel_team_recommendation">9.10.4. Compiling the kernel source: Debian Kernel Team recommendation</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_hardware_drivers_and_firmware">9.10.5. Hardware drivers and firmware</a> </span> </dt> </dl> </dd> <dt> <span class="section"> <a href="ch09.en.html#_virtualized_system">9.11. Virtualized system</a> </span> </dt> <dd> <dl> <dt> <span class="section"> <a href="ch09.en.html#_virtualization_tools">9.11.1. Virtualization and emulation tools</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_virtualization_work_flow">9.11.2. Virtualization work flow</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_mounting_the_virtual_disk_image_file">9.11.3. Mounting the virtual disk image file</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_chroot_system">9.11.4. Chroot system</a> </span> </dt> <dt> <span class="section"> <a href="ch09.en.html#_multiple_desktop_systems">9.11.5. Multiple desktop systems</a> </span> </dt> </dl> </dd> </dl> </div> <p>Here, I describe basic tips to configure and manage systems, mostly from the console.</p> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_the_console_tips"/>9.1. The console tips</h2> </div> </div> </div> <p>There are some utility programs to help your console activities.</p> <div class="table"> <a id="listofprogramstoonsoleactivities"/> <p class="title"> <strong>Table 9.1. List of programs to support console activities</strong> </p> <div class="table-contents"> <table class="table" summary="List of programs to support console activities" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/mc"> <code class="literal">mc</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=mc">V:50, I:209</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/mc">1542</a> </td> <td style="text-align: left"> See <a class="xref" href="ch01.en.html#_midnight_commander_mc" title="1.3. Midnight Commander (MC)">Section 1.3, “Midnight Commander (MC)”</a> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bsdutils"> <code class="literal">bsdutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bsdutils">V:519, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bsdutils">356</a> </td> <td style="text-align: left"> <code class="literal">script</code>(1) command to make a record of terminal session </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/screen"> <code class="literal">screen</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=screen">V:71, I:230</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/screen">1003</a> </td> <td style="text-align: left"> terminal multiplexer with VT100/ANSI terminal emulation </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/tmux"> <code class="literal">tmux</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=tmux">V:43, I:146</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/tmux">1180</a> </td> <td style="text-align: left"> terminal multiplexer alternative (Use "Control-B" instead) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fzf"> <code class="literal">fzf</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fzf">V:4, I:16</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fzf">3648</a> </td> <td style="text-align: left"> fuzzy text finder </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fzy"> <code class="literal">fzy</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fzy">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fzy">54</a> </td> <td style="text-align: left"> fuzzy text finder </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/rlwrap"> <code class="literal">rlwrap</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=rlwrap">V:1, I:15</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/rlwrap">330</a> </td> <td style="text-align: left"> readline feature command line wrapper </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ledit"> <code class="literal">ledit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ledit">V:0, I:11</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ledit">331</a> </td> <td style="text-align: left"> readline feature command line wrapper </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/rlfe"> <code class="literal">rlfe</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=rlfe">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/rlfe">45</a> </td> <td style="text-align: left"> readline feature command line wrapper </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ripgrep"> <code class="literal">ripgrep</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ripgrep">V:5, I:19</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ripgrep">5152</a> </td> <td style="text-align: left"> fast recursive string search in the source code tree with automatic filtering </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_recording_the_shell_activities_cleanly"/>9.1.1. Recording the shell activities cleanly</h3> </div> </div> </div> <p>The simple use of <code class="literal">script</code>(1) (see <a class="xref" href="ch01.en.html#_recording_the_shell_activities" title="1.4.9. Recording the shell activities">Section 1.4.9, “Recording the shell activities”</a>) to record shell activity produces a file with control characters. This can be avoided by using <code class="literal">col</code>(1) as the following.</p> <pre class="screen">$ script Script started, file is typescript</pre> <p>Do whatever … and press <code class="literal">Ctrl-D</code> to exit <code class="literal">script</code>.</p> <pre class="screen">$ col -bx &lt; typescript &gt; cleanedfile $ vim cleanedfile</pre> <p>There are alternative methods to record the shell activities:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Use <code class="literal">tee</code> (usable during the boot process in the initramfs): </p> <pre class="screen">$ sh -i 2&gt;&amp;1 | tee typescript</pre> </li> <li class="listitem"> <p> Use <code class="literal">gnome-terminal</code> with the extend line buffer for scrollback. </p> </li> <li class="listitem"> <p>Use <code class="literal">screen</code> with "<code class="literal">^A H</code>" (see <a class="xref" href="ch09.en.html#_the_screen_program" title="9.1.2. The screen program">Section 9.1.2, “The screen program”</a>) to perform recording of console.</p> </li> <li class="listitem"> <p>Use <code class="literal">vim</code> with "<code class="literal">:terminal</code>" to enter the terminal mode. Use "<code class="literal">Ctrl-W N</code>" to exit from terminal mode to normal mode. Use "<code class="literal">:w typescript</code>" to write the buffer to a file.</p> </li> <li class="listitem"> <p>Use <code class="literal">emacs</code> with "<code class="literal">M-x shell</code>", "<code class="literal">M-x eshell</code>", or "<code class="literal">M-x term</code>" to enter recording console. Use "<code class="literal">C-x C-w</code>" to write the buffer to a file.</p> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_screen_program"/>9.1.2. The screen program</h3> </div> </div> </div> <p><code class="literal">screen</code>(1) not only allows one terminal window to work with multiple processes, but also allows <span class="strong"><strong>remote shell process to survive interrupted connections</strong></span>. Here is a typical use scenario of <code class="literal">screen</code>(1).</p> <div class="orderedlist"> <ol class="orderedlist"> <li class="listitem"> <p> You login to a remote machine. </p> </li> <li class="listitem"> <p> You start <code class="literal">screen</code> on a single console. </p> </li> <li class="listitem"> <p> You execute multiple programs in <code class="literal">screen</code> windows created with <code class="literal">^A c</code> ("Control-A" followed by "c"). </p> </li> <li class="listitem"> <p> You switch among the multiple <code class="literal">screen</code> windows by <code class="literal">^A n</code> ("Control-A" followed by "n"). </p> </li> <li class="listitem"> <p> Suddenly you need to leave your terminal, but you don't want to lose your active work by keeping the connection. </p> </li> <li class="listitem"> <p> You may <span class="strong"><strong>detach</strong></span> the <code class="literal">screen</code> session by any methods. </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Brutally unplug your network connection </p> </li> <li class="listitem"> <p> Type <code class="literal">^A d</code> ("Control-A" followed by "d") and manually logging out from the remote connection </p> </li> <li class="listitem"> <p> Type <code class="literal">^A DD</code> ("Control-A" followed by "DD") to have <code class="literal">screen</code> detach and log you out </p> </li> </ul> </div> </li> <li class="listitem"> <p> You log in again to the same remote machine (even from a different terminal). </p> </li> <li class="listitem"> <p> You start <code class="literal">screen</code> as "<code class="literal">screen -r</code>". </p> </li> <li class="listitem"> <p><code class="literal">screen</code> magically <span class="strong"><strong>reattaches</strong></span> all previous <code class="literal">screen</code> windows with all actively running programs. </p> </li> </ol> </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can save connection fees with <code class="literal">screen</code> for metered network connections such as dial-up and packet ones, because you can leave a process active while disconnected, and then re-attach it later when you connect again.</p> </td> </tr> </table> </div> <p>In a <code class="literal">screen</code> session, all keyboard inputs are sent to your current window except for the command keystroke. All <code class="literal">screen</code> command keystrokes are entered by typing <code class="literal">^A</code> ("Control-A") plus a single key [plus any parameters]. Here are important ones to remember.</p> <div class="table"> <a id="listofkeybindingsforscreen"/> <p class="title"> <strong>Table 9.2. List of key bindings for screen</strong> </p> <div class="table-contents"> <table class="table" summary="List of key bindings for screen" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> key binding </th> <th style="text-align: left"> meaning </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <code class="literal">^A ?</code> </td> <td style="text-align: left"> show a help screen (display key bindings) </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A c</code> </td> <td style="text-align: left"> create a new window and switch to it </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A n</code> </td> <td style="text-align: left"> go to next window </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A p</code> </td> <td style="text-align: left"> go to previous window </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A 0</code> </td> <td style="text-align: left"> go to window number 0 </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A 1</code> </td> <td style="text-align: left"> go to window number 1 </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A w</code> </td> <td style="text-align: left"> show a list of windows </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A a</code> </td> <td style="text-align: left"> send a Ctrl-A to current window as keyboard input </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A h</code> </td> <td style="text-align: left"> write a hardcopy of current window to file </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A H</code> </td> <td style="text-align: left"> begin/end logging current window to file </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A ^X</code> </td> <td style="text-align: left"> lock the terminal (password protected) </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A d</code> </td> <td style="text-align: left"> detach screen session from the terminal </td> </tr> <tr> <td style="text-align: left"> <code class="literal">^A DD</code> </td> <td style="text-align: left"> detach screen session and log out </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>See <code class="literal">screen</code>(1) for details.</p> <p>See <code class="literal">tmux</code>(1) for functionalities of the alternative command.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_navigating_around_directories"/>9.1.3. Navigating around directories</h3> </div> </div> </div> <p>In <a class="xref" href="ch01.en.html#_customizing_bash" title="1.4.2. Customizing bash">Section 1.4.2, “Customizing bash”</a>, 2 tips to allow quick navigation around directories are described: <code class="literal">$CDPATH</code> and <code class="literal">mc</code>. </p> <p>If you use fuzzy text filter program, you can do without typing the exact path. For <code class="literal">fzf</code>, include following in <code class="literal">~/.bashrc</code>. </p> <pre class="screen">FZF_KEYBINDINGS_PATH=/usr/share/doc/fzf/examples/key-bindings.bash if [ -f $FZF_KEYBINDINGS_PATH ]; then . $FZF_KEYBINDINGS_PATH fi</pre> <p>For example:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p>You can jump to a very deep subdirectory with minimal efforts. You first type "<code class="literal">cd **</code>" and press <code class="literal">Tab</code>. Then you will be prompted with candidate paths. Typing in partial path strings, e.g., <code class="literal">s/d/b foo</code>, will narrow down candidate paths. You select the path to be used by <code class="literal">cd</code> with cursor and return keys.</p> </li> <li class="listitem"> <p>You can select a command from the command history more efficiently with minimal efforts. You press <code class="literal">Ctrl-R</code> at the command prompt. Then you will be prompted with candidate commands. Typing in partial command strings, e.g., <code class="literal">vim d</code>, will narrow down candidates. You select the one to be used with cursor and return keys.</p> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_readline_wrapper"/>9.1.4. Readline wrapper</h3> </div> </div> </div> <p>Some commands such as <code class="literal">/usr/bin/dash</code> which lacks command line history editing capability can add such functionality transparently by running under <code class="literal">rlwrap</code> or its equivalents.</p> <pre class="screen"> $ rlwrap dash -i</pre> <p>This provides convenient platform to test subtle points for <code class="literal">dash</code> with friendly <code class="literal">bash</code>-like environment. </p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_scanning_the_source_code_tree"/>9.1.5. Scanning the source code tree</h3> </div> </div> </div> <p>The <code class="literal">rg</code>(1) command in the <code class="literal">ripgrep</code> package offers a faster alternative to the <code class="literal">grep</code>(1) command for scanning the source code tree for typical situation. It takes advantage of modern multi-core CPUs and automatically applies reasonable filters to skip some files. </p> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_customizing_vim"/>9.2. Customizing vim</h2> </div> </div> </div> <p> After you learn basics of <code class="literal">vim</code>(1) through <a class="xref" href="ch01.en.html#_using_vim" title="1.4.8. Using vim">Section 1.4.8, “Using vim”</a>, please read Bram Moolenaar's "<a class="ulink" href="https://www.moolenaar.net/habits.html">Seven habits of effective text editing (2000)</a>" to understand how <code class="literal">vim</code> should be used. </p> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_customizing_vim_with internal_features"/>9.2.1. Customizing vim with internal features</h3> </div> </div> </div> <p>The behavior of <code class="literal">vim</code> can be changed significantly by enabling its internal features through the <code class="literal">Ex</code>-mode commands such as "<code class="literal">set ...</code>" to set vim options.</p> <p>These <code class="literal">Ex</code>-mode commands can be included in user's vimrc file, traditional "<code class="literal">~/.vimrc</code>" or git-friendly "<code class="literal">~/.vim/vimrc</code>". Here is a very simple example <a href="#ftn.idm14510" class="footnote" id="idm14510"><sup class="footnote">[2]</sup></a>: </p> <pre class="screen">""" Generic baseline Vim and Neovim configuration (~/.vimrc) """ - For NeoVim, use "nvim -u ~/.vimrc [filename]" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = ' ' " :h mapleader """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible " :h 'cp -- sensible (n)vim mode syntax on " :h :syn-on filetype plugin indent on " :h :filetype-overview set encoding=utf-8 " :h 'enc (default: latin1) -- sensible encoding """ current vim option value can be verified by :set encoding? set backspace=indent,eol,start " :h 'bs (default: nobs) -- sensible BS set statusline=%&lt;%f%m%r%h%w%=%y[U+%04B]%2l/%2L=%P,%2c%V set listchars=eol:¶,tab:⇄\ ,extends:↦,precedes:↤,nbsp:␣ set viminfo=!,'100,&lt;5000,s100,h " :h 'vi -- bigger copy buffer etc. """ Pick "colorscheme" from blue darkblue default delek desert elflord evening """ habamax industry koehler lunaperche morning murphy pablo peachpuff quiet ron """ shine slate torte zellner colorscheme industry """ don't pick "colorscheme" as "default" which may kill SpellUnderline settings set scrolloff=5 " :h 'scr -- show 5 lines around cursor set laststatus=2 " :h 'ls (default 1) k """ boolean options can be unset by prefixing "no" set ignorecase " :h 'ic set smartcase " :h 'scs set autoindent " :h 'ai set smartindent " :h 'si set nowrap " :h 'wrap "set list " :h 'list (default nolist) set noerrorbells " :h 'eb set novisualbell " :h 'vb set t_vb= " :h 't_vb -- termcap visual bell set spell " :h 'spell set spelllang=en_us,cjk " :h 'spl -- english spell, ignore CJK set clipboard=unnamedplus " :h 'cb -- cut/copy/paste with other app set hidden " :h 'hid set autowrite " :h 'aw set timeoutlen=300 " :h 'tm</pre> <p>The keymap of <code class="literal">vim</code> can be changed in user's vimrc file. E.g.:</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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>Don't try to change the default key bindings without very good reasons.</p> </td> </tr> </table> </div> <pre class="screen">""" Popular mappings (imitating LazyVim etc.) """ Window moves without using CTRL-W which is dangerous in INSERT mode nnoremap &lt;C-H&gt; &lt;C-W&gt;h nnoremap &lt;C-J&gt; &lt;C-W&gt;j nnoremap &lt;C-K&gt; &lt;C-W&gt;k silent! nnoremap &lt;C-L&gt; &lt;C-W&gt;l """ Window resize nnoremap &lt;C-LEFT&gt; &lt;CMD&gt;vertical resize -2&lt;CR&gt; nnoremap &lt;C-DOWN&gt; &lt;CMD&gt;resize -2&lt;CR&gt; nnoremap &lt;C-UP&gt; &lt;CMD&gt;resize +2&lt;CR&gt; nnoremap &lt;C-RIGHT&gt; &lt;CMD&gt;vertical resize +2&lt;CR&gt; """ Clear hlsearch with &lt;ESC&gt; (&lt;C-L&gt; is mapped as above) nnoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt; inoremap &lt;ESC&gt; &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt; """ center after jump next nnoremap n nzz nnoremap N Nzz """ fast "jk" to get out of INSERT mode (&lt;ESC&gt;) inoremap jk &lt;CMD&gt;noh&lt;CR&gt;&lt;ESC&gt; """ fast "&lt;ESC&gt;&lt;ESC&gt;" to get out of TERM mode (CTRL-\ CTRL-N) tnoremap &lt;ESC&gt;&lt;ESC&gt; &lt;C-\&gt;&lt;C-N&gt; """ fast "jk" to get out of TERM mode (CTRL-\ CTRL-N) tnoremap jk &lt;C-\&gt;&lt;C-N&gt; """ previous/next trouble/quickfix item nnoremap [q &lt;CMD&gt;cprevious&lt;CR&gt; nnoremap ]q &lt;CMD&gt;cnext&lt;CR&gt; """ buffers nnoremap &lt;S-H&gt; &lt;CMD&gt;bprevious&lt;CR&gt; nnoremap &lt;S-L&gt; &lt;CMD&gt;bnext&lt;CR&gt; nnoremap [b &lt;CMD&gt;bprevious&lt;CR&gt; nnoremap ]b &lt;CMD&gt;bnext&lt;CR&gt; """ Add undo break-points inoremap , ,&lt;C-G&gt;u inoremap . .&lt;C-G&gt;u inoremap ; ;&lt;C-G&gt;u """ save file inoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt; xnoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt; nnoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt; snoremap &lt;C-S&gt; &lt;CMD&gt;w&lt;CR&gt;&lt;ESC&gt; """ better indenting vnoremap &lt; &lt;gv vnoremap &gt; &gt;gv """ terminal (Somehow under Linux, &lt;C-/&gt; becomes &lt;C-_&gt; in Vim) nnoremap &lt;C-_&gt; &lt;CMD&gt;terminal&lt;CR&gt; "nnoremap &lt;C-/&gt; &lt;CMD&gt;terminal&lt;CR&gt; """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if ! has('nvim') """ Toggle paste mode with &lt;SPACE&gt;p for Vim (no need for Nvim) set pastetoggle=&lt;leader&gt;p """ nvim default mappings for Vim. See :h default-mappings in nvim """ copy to EOL (no delete) like D for d noremap Y y$ """ sets a new undo point before deleting inoremap &lt;C-U&gt; &lt;C-G&gt;u&lt;C-U&gt; inoremap &lt;C-W&gt; &lt;C-G&gt;u&lt;C-W&gt; """ &lt;C-L&gt; is re-purposed as above """ execute the previous macro recorded with Q nnoremap Q @@ """ repeat last substitute and *KEEP* flags nnoremap &amp; :&amp;&amp;&lt;CR&gt; """ search visual selected string for visual mode xnoremap * y/\V&lt;C-R&gt;"&lt;CR&gt; xnoremap # y?\V&lt;C-R&gt;"&lt;CR&gt; endif</pre> <p>In order for the above keybindings to function properly, the terminal program needs to be configured to generate "ASCII DEL" for <code class="literal">Backspace</code>-key and "Escape sequence" for <code class="literal">Delete</code>-key.</p> <p>Other miscellaneous configuration can be changed in user's vimrc file. E.g.:</p> <pre class="screen">""" Use faster 'rg' (ripgrep package) for :grep if executable("rg") set grepprg=rg\ --vimgrep\ --smart-case set grepformat=%f:%l:%c:%m endif """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """ Retain last cursor position :h '" augroup RetainLastCursorPosition autocmd! autocmd BufReadPost * \ if line("'\"") &gt; 0 &amp;&amp; line ("'\"") &lt;= line("$") | \ exe "normal! g'\"" | \ endif augroup END """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """ Force to use underline for spell check results augroup SpellUnderline autocmd! autocmd ColorScheme * highlight SpellBad term=Underline gui=Undercurl autocmd ColorScheme * highlight SpellCap term=Underline gui=Undercurl autocmd ColorScheme * highlight SpellLocal term=Underline gui=Undercurl autocmd ColorScheme * highlight SpellRare term=Underline gui=Undercurl augroup END """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """ highlight tailing spaces except when typing as red (set after colorscheme) highlight TailingWhitespaces ctermbg=red guibg=red """ \s\+ 1 or more whitespace character: &lt;Space&gt; and &lt;Tab&gt; """ \%#\@&lt;! Matches with zero width if the cursor position does NOT match. match TailingWhitespaces /\s\+\%#\@&lt;!$/</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_customizing_vim_with_external_packages"/>9.2.2. Customizing vim with external packages</h3> </div> </div> </div> <p>Interesting external plugin packages can be found:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> <a class="ulink" href="https://www.vim.org/"> Vim - the ubiquitous text editor </a> -- The official upstream site of Vim and vim scripts </p> </li> <li class="listitem"> <p> <a class="ulink" href="https://vimawesome.com/"> VimAwsome </a> -- The listing of Vim plugins </p> </li> <li class="listitem"> <p> <a class="ulink" href="https://packages.debian.org/unstable/vim-scripts">vim-scripts</a> -- Debian package: a collection of vim scripts </p> </li> </ul> </div> <p>Plugin packages in the <a class="ulink" href="https://packages.debian.org/unstable/vim-scripts">vim-scripts</a> package can be enabled using user's vimrc file. E.g.:</p> <pre class="screen">packadd! secure-modelines packadd! winmanager " IDE-like UI for files and buffers with &lt;space&gt;w nnoremap &lt;leader&gt;w :WMToggle&lt;CR&gt;</pre> <p>The new native Vim package system works nicely with "<code class="literal">git</code>" and "<code class="literal">git submodule</code>". One such example configuration can be found at <a class="ulink" href="https://github.com/osamuaoki/dot-vim/tree/old">my git repository: dot-vim</a>. This does essentially:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p>By using "<code class="literal">git</code>" and "<code class="literal">git submodule</code>", latest external packages, such as "<code class="literal"><span class="emphasis"><em>name</em></span></code>", are placed into <code class="literal">~/.vim/pack/*/opt/<span class="emphasis"><em>name</em></span></code> and similar.</p> </li> <li class="listitem"> <p>By adding <code class="literal">:packadd! <span class="emphasis"><em>name</em></span></code> line to user's vimrc file, these packages are placed on <code class="literal">runtimepath</code>.</p> </li> <li class="listitem"> <p>Vim loads these packages on <code class="literal">runtimepath</code> during its initialization.</p> </li> <li class="listitem"> <p>At the end of its initialization, tags for the installed documents are updated with "<code class="literal">helptags ALL</code>".</p> </li> </ul> </div> <p>For more, please start <code class="literal">vim</code> with "<code class="literal">vim --startuptime vimstart.log</code>" to check actual execution sequence and time spent for each step.</p> <p>It is quite confusing to see too many ways<a href="#ftn.idm14569" class="footnote" id="idm14569"><sup class="footnote">[3]</sup></a> to manage and load these external packages to <code class="literal">vim</code>. Checking the original information is the best cure.</p> <div class="table"> <a id="informationonthetializationofvim"/> <p class="title"> <strong>Table 9.3. Information on the initialization of <code class="literal">vim</code></strong> </p> <div class="table-contents"> <table class="table" summary="Information on the initialization of vim" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> key strokes </th> <th style="text-align: left"> information </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <code class="literal">:help package</code> </td> <td style="text-align: left"> explanation on the vim package mechanism </td> </tr> <tr> <td style="text-align: left"> <code class="literal">:help runtimepath</code> </td> <td style="text-align: left"> explanation on the <code class="literal">runtimepath</code> mechanism </td> </tr> <tr> <td style="text-align: left"> <code class="literal">:version</code> </td> <td style="text-align: left"> internal states including candidates for the vimrc file </td> </tr> <tr> <td style="text-align: left"> <code class="literal">:echo $VIM</code> </td> <td style="text-align: left"> the environment variable "<code class="literal">$VIM</code>" used to locate the vimrc file</td> </tr> <tr> <td style="text-align: left"> <code class="literal">:set runtimepath?</code> </td> <td style="text-align: left"> list of directories which will be searched for all runtime support files </td> </tr> <tr> <td style="text-align: left"> <code class="literal">:echo $VIMRUNTIME</code> </td> <td style="text-align: left"> the environment variable "<code class="literal">$VIMRUNTIME</code>" used to locate various system provided runtime support files </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_data_recording_and_presentation"/>9.3. Data recording and presentation</h2> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_log_daemon"/>9.3.1. The log daemon</h3> </div> </div> </div> <p>Many traditional programs record their activities in the text file format under the "<code class="literal">/var/log/</code>" directory.</p> <p><code class="literal">logrotate</code>(8) is used to simplify the administration of log files on a system which generates a lot of log files.</p> <p>Many new programs record their activities in the binary file format using <code class="literal">systemd-journald</code>(8) Journal service under the "<code class="literal">/var/log/journal</code>" directory.</p> <p>You can log data to the <code class="literal">systemd-journald</code>(8) Journal from a shell script by using the <code class="literal">systemd-cat</code>(1) command.</p> <p>See <a class="xref" href="ch03.en.html#_the_system_message" title="3.4. The system message">Section 3.4, “The system message”</a> and <a class="xref" href="ch03.en.html#_the_kernel_message" title="3.3. The kernel message">Section 3.3, “The kernel message”</a>.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_log_analyzer"/>9.3.2. Log analyzer</h3> </div> </div> </div> <p>Here are notable log analyzers ("<code class="literal">~Gsecurity::log-analyzer</code>" in <code class="literal">aptitude</code>(8)).</p> <div class="table"> <a id="listofsystemloganalyzers"/> <p class="title"> <strong>Table 9.4. List of system log analyzers</strong> </p> <div class="table-contents"> <table class="table" summary="List of system log analyzers" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/logwatch"> <code class="literal">logwatch</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=logwatch">V:11, I:13</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/logwatch">2328</a> </td> <td style="text-align: left"> log analyzer with nice output written in Perl </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fail2ban"> <code class="literal">fail2ban</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fail2ban">V:98, I:111</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fail2ban">2126</a> </td> <td style="text-align: left"> ban IPs that cause multiple authentication errors </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/analog"> <code class="literal">analog</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=analog">V:3, I:96</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/analog">3739</a> </td> <td style="text-align: left"> web server log analyzer </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/awstats"> <code class="literal">awstats</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=awstats">V:6, I:10</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/awstats">6928</a> </td> <td style="text-align: left"> powerful and featureful web server log analyzer </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/sarg"> <code class="literal">sarg</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=sarg">V:1, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/sarg">845</a> </td> <td style="text-align: left"> squid analysis report generator </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pflogsumm"> <code class="literal">pflogsumm</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pflogsumm">V:1, I:4</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pflogsumm">109</a> </td> <td style="text-align: left"> Postfix log entry summarizer </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fwlogwatch"> <code class="literal">fwlogwatch</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fwlogwatch">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fwlogwatch">481</a> </td> <td style="text-align: left"> firewall log analyzer </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/squidview"> <code class="literal">squidview</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=squidview">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/squidview">189</a> </td> <td style="text-align: left"> monitor and analyze squid access.log files </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/swatch"> <code class="literal">swatch</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=swatch">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/swatch">99</a> </td> <td style="text-align: left"> log file viewer with regexp matching, highlighting, and hooks </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/crm114"> <code class="literal">crm114</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=crm114">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/crm114">1119</a> </td> <td style="text-align: left"> Controllable Regex Mutilator and Spam Filter (CRM114) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/icmpinfo"> <code class="literal">icmpinfo</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=icmpinfo">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/icmpinfo">44</a> </td> <td style="text-align: left"> interpret ICMP messages </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <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"> <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="https://en.wikipedia.org/wiki/CRM114_(program)">CRM114</a> provides language infrastructure to write <span class="strong"><strong>fuzzy</strong></span> filters with the <a class="ulink" href="https://github.com/laurikari/tre/">TRE regex library</a>. Its popular use is spam mail filter but it can be used as log analyzer.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_customized_display_of_text_data"/>9.3.3. Customized display of text data</h3> </div> </div> </div> <p>Although pager tools such as <code class="literal">more</code>(1) and <code class="literal">less</code>(1) (see <a class="xref" href="ch01.en.html#_the_pager" title="1.4.5. The pager">Section 1.4.5, “The pager”</a>) and custom tools for highlighting and formatting (see <a class="xref" href="ch11.en.html#_highlighting_and_formatting_plain_text_data" title="11.1.8. Highlighting and formatting plain text data">Section 11.1.8, “Highlighting and formatting plain text data”</a>) can display text data nicely, general purpose editors (see <a class="xref" href="ch01.en.html#_the_text_editor" title="1.4.6. The text editor">Section 1.4.6, “The text editor”</a>) are most versatile and customizable.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>For <code class="literal">vim</code>(1) and its pager mode alias <code class="literal">view</code>(1), "<code class="literal">:set hls</code>" enables highlighted search.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_customized_display_of_time_and_date"/>9.3.4. Customized display of time and date</h3> </div> </div> </div> <p>The default display format of time and date by the "<code class="literal">ls -l</code>" command depends on the <span class="strong"><strong>locale</strong></span> (see <a class="xref" href="ch01.en.html#_timestamps" title="1.2.6. Timestamps">Section 1.2.6, “Timestamps”</a> for value). The "<code class="literal">$LANG</code>" variable is referred first and it can be overridden by the "<code class="literal">$LC_TIME</code>" or "<code class="literal">$LC_ALL</code>" exported environment variables.</p> <p>The actual default display format for each locale depends on the version of the standard C library (the <code class="literal">libc6</code> package) used. I.e., different releases of Debian had different defaults. For iso-formats, see <a class="ulink" href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>.</p> <p>If you really wish to customize this display format of time and date beyond the <span class="strong"><strong>locale</strong></span>, you should set the <span class="strong"><strong>time style value</strong></span> by the "<code class="literal">--time-style</code>" argument or by the "<code class="literal">$TIME_STYLE</code>" value (see <code class="literal">ls</code>(1), <code class="literal">date</code>(1), "<code class="literal">info coreutils 'ls invocation'</code>").</p> <div class="table"> <a id="displayexamplesohetimestylevalue"/> <p class="title"> <strong>Table 9.5. Display examples of time and date for the "<code class="literal">ls -l</code>" command with the <span class="strong">time style value</span></strong> </p> <div class="table-contents"> <table class="table" summary="Display examples of time and date for the &quot;ls -l&quot; command with the time style value" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> time style value </th> <th style="text-align: left"> locale </th> <th style="text-align: left"> display of time and date </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <code class="literal">iso</code> </td> <td style="text-align: left"> any </td> <td style="text-align: left"> <code class="literal">01-19 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">long-iso</code> </td> <td style="text-align: left"> any </td> <td style="text-align: left"> <code class="literal">2009-01-19 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">full-iso</code> </td> <td style="text-align: left"> any </td> <td style="text-align: left"> <code class="literal">2009-01-19 00:15:16.000000000 +0900</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">locale</code> </td> <td style="text-align: left"> <code class="literal">C</code> </td> <td style="text-align: left"> <code class="literal">Jan 19 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">locale</code> </td> <td style="text-align: left"> <code class="literal">en_US.UTF-8</code> </td> <td style="text-align: left"> <code class="literal">Jan 19 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">locale</code> </td> <td style="text-align: left"> <code class="literal">es_ES.UTF-8</code> </td> <td style="text-align: left"> <code class="literal">ene 19 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">+%d.%m.%y %H:%M</code> </td> <td style="text-align: left"> any </td> <td style="text-align: left"> <code class="literal">19.01.09 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">+%d.%b.%y %H:%M</code> </td> <td style="text-align: left"> <code class="literal">C</code> or <code class="literal">en_US.UTF-8</code> </td> <td style="text-align: left"> <code class="literal">19.Jan.09 00:15</code> </td> </tr> <tr> <td style="text-align: left"> <code class="literal">+%d.%b.%y %H:%M</code> </td> <td style="text-align: left"> <code class="literal">es_ES.UTF-8</code> </td> <td style="text-align: left"> <code class="literal">19.ene.09 00:15</code> </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can eliminate typing long option on commandline using command alias (see <a class="xref" href="ch01.en.html#_command_alias" title="1.5.9. Command alias">Section 1.5.9, “Command alias”</a>):</p> <pre class="screen">alias ls='ls --time-style=+%d.%m.%y %H:%M'</pre> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_colorized_shell_echo"/>9.3.5. Colorized shell echo</h3> </div> </div> </div> <p>Shell echo to most modern terminals can be colorized using <a class="ulink" href="https://en.wikipedia.org/wiki/ANSI_escape_code">ANSI escape code</a> (see "<code class="literal">/usr/share/doc/xterm/ctlseqs.txt.gz</code>").</p> <p>For example, try the following</p> <pre class="screen">$ RED=$(printf "\x1b[31m") $ NORMAL=$(printf "\x1b[0m") $ REVERSE=$(printf "\x1b[7m") $ echo "${RED}RED-TEXT${NORMAL} ${REVERSE}REVERSE-TEXT${NORMAL}"</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_colorized_commands"/>9.3.6. Colorized commands</h3> </div> </div> </div> <p>Colorized commands are handy for inspecting their output in the interactive environment. I include the following in my "<code class="literal">~/.bashrc</code>".</p> <pre class="screen">if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=always' alias ll='ls --color=always -l' alias la='ls --color=always -A' alias less='less -R' alias ls='ls --color=always' alias grep='grep --color=always' alias egrep='egrep --color=always' alias fgrep='fgrep --color=always' alias zgrep='zgrep --color=always' else alias ll='ls -l' alias la='ls -A' fi</pre> <p>The use of alias limits color effects to the interactive command usage. It has advantage over exporting environment variable "<code class="literal">export GREP_OPTIONS='--color=auto'</code>" since color can be seen under pager programs such as <code class="literal">less</code>(1). If you wish to suppress color when piping to other programs, use "<code class="literal">--color=auto</code>" instead in the above example for "<code class="literal">~/.bashrc</code>".</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can turn off these colorizing aliases in the interactive environment by invoking shell with "<code class="literal">TERM=dumb bash</code>".</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_recording_the_editor_activities_for_complex_repeats"/>9.3.7. Recording the editor activities for complex repeats</h3> </div> </div> </div> <p>You can record the editor activities for complex repeats.</p> <p>For <a class="ulink" href="https://en.wikipedia.org/wiki/Vim_(text_editor)">Vim</a>, as follows.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> "<code class="literal">qa</code>": start recording typed characters into named register "<code class="literal">a</code>". </p> </li> <li class="listitem"> <p> … editor activities </p> </li> <li class="listitem"> <p> "<code class="literal">q</code>": end recording typed characters. </p> </li> <li class="listitem"> <p> "<code class="literal">@a</code>": execute the contents of register "<code class="literal">a</code>". </p> </li> </ul> </div> <p>For <a class="ulink" href="https://en.wikipedia.org/wiki/Emacs">Emacs</a>, as follows.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> "<code class="literal">C-x (</code>": start defining a keyboard macro. </p> </li> <li class="listitem"> <p> … editor activities </p> </li> <li class="listitem"> <p> "<code class="literal">C-x )</code>": end defining a keyboard macro. </p> </li> <li class="listitem"> <p> "<code class="literal">C-x e</code>": execute a keyboard macro. </p> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_recording_the_graphic_image_of_an_x_application"/>9.3.8. Recording the graphics image of an X application</h3> </div> </div> </div> <p>There are few ways to record the graphics image of an X application, including an <code class="literal">xterm</code> display.</p> <div class="table"> <a id="listofgraphicsimanipulationtools"/> <p class="title"> <strong>Table 9.6. List of graphics image manipulation tools</strong> </p> <div class="table-contents"> <table class="table" summary="List of graphics image manipulation tools" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> screen </th> <th> command </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gnome-screenshot"> <code class="literal">gnome-screenshot</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gnome-screenshot">V:18, I:173</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gnome-screenshot">1134</a> </td> <td style="text-align: left"> Wayland </td> <td> screenshot application for GNOME </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/flameshot"> <code class="literal">flameshot</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=flameshot">V:7, I:15</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/flameshot">3364</a> </td> <td style="text-align: left"> Wayland </td> <td> screenshot application on steroid </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gimp"> <code class="literal">gimp</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gimp">V:50, I:252</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gimp">19304</a> </td> <td style="text-align: left"> Wayland + X </td> <td> screenshot in GUI menu </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/x11-apps"> <code class="literal">x11-apps</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=x11-apps">V:31, I:463</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/x11-apps">2460</a> </td> <td style="text-align: left"> X </td> <td> <code class="literal">xwd</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/imagemagick"> <code class="literal">imagemagick</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=imagemagick">I:317</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/imagemagick">74</a> </td> <td style="text-align: left"> X </td> <td> <code class="literal">import</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/scrot"> <code class="literal">scrot</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=scrot">V:5, I:63</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/scrot">131</a> </td> <td style="text-align: left"> X </td> <td> <code class="literal">scrot</code>(1) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_recording_changes_in_configuration_files"/>9.3.9. Recording changes in configuration files</h3> </div> </div> </div> <p>There are specialized tools to record changes in configuration files with help of DVCS and to make system snapshots on <a class="ulink" href="https://en.wikipedia.org/wiki/Btrfs">Btrfs</a>.</p> <div class="table"> <a id="listofpackageswhigurationhistory"/> <p class="title"> <strong>Table 9.7. List of packages which can record configuration history</strong> </p> <div class="table-contents"> <table class="table" summary="List of packages which can record configuration history" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/etckeeper"> <code class="literal">etckeeper</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=etckeeper">V:26, I:30</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/etckeeper">168</a> </td> <td style="text-align: left"> store configuration files and their metadata with <a class="ulink" href="https://en.wikipedia.org/wiki/Git_(software)">Git</a> (default), <a class="ulink" href="https://en.wikipedia.org/wiki/Mercurial_(software)">Mercurial</a>, or <a class="ulink" href="https://en.wikipedia.org/wiki/GNU_Bazaar">GNU Bazaar</a> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/timeshift"> <code class="literal">timeshift</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=timeshift">V:5, I:10</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/timeshift">3506</a> </td> <td style="text-align: left"> system restore utility using rsync or BTRFS snapshots </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/snapper"> <code class="literal">snapper</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=snapper">V:4, I:5</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/snapper">2392</a> </td> <td style="text-align: left"> Linux filesystem snapshot management tool </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>You may also think about local script <a class="xref" href="ch10.en.html#_backup_tips" title="10.2.3. Backup tips">Section 10.2.3, “Backup tips”</a> approach.</p> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_monitoring_controlling_and_starting_program_activities"/>9.4. Monitoring, controlling, and starting program activities</h2> </div> </div> </div> <p>Program activities can be monitored and controlled using specialized tools.</p> <div class="table"> <a id="listoftoolsformorogramactivities"/> <p class="title"> <strong>Table 9.8. List of tools for monitoring and controlling program activities</strong> </p> <div class="table-contents"> <table class="table" summary="List of tools for monitoring and controlling program activities" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/coreutils"> <code class="literal">coreutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=coreutils">V:880, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/coreutils">18307</a> </td> <td style="text-align: left"><code class="literal">nice</code>(1): run a program with modified scheduling priority </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bsdutils"> <code class="literal">bsdutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bsdutils">V:519, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bsdutils">356</a> </td> <td style="text-align: left"><code class="literal">renice</code>(1): modify the scheduling priority of a running process </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/procps"> <code class="literal">procps</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=procps">V:766, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/procps">2389</a> </td> <td style="text-align: left"> "<code class="literal">/proc</code>" filesystem utilities: <code class="literal">ps</code>(1), <code class="literal">top</code>(1), <code class="literal">kill</code>(1), <code class="literal">watch</code>(1), … </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/psmisc"> <code class="literal">psmisc</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=psmisc">V:420, I:775</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/psmisc">908</a> </td> <td style="text-align: left"> "<code class="literal">/proc</code>" filesystem utilities: <code class="literal">killall</code>(1), <code class="literal">fuser</code>(1), <code class="literal">peekfd</code>(1), <code class="literal">pstree</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/time"> <code class="literal">time</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=time">V:7, I:132</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/time">129</a> </td> <td style="text-align: left"> <code class="literal">time</code>(1): run a program to report system resource usages with respect to time </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/sysstat"> <code class="literal">sysstat</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=sysstat">V:148, I:170</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/sysstat">1904</a> </td> <td style="text-align: left"> <code class="literal">sar</code>(1), <code class="literal">iostat</code>(1), <code class="literal">mpstat</code>(1), …: system performance tools for Linux </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/isag"> <code class="literal">isag</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=isag">V:0, I:3</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/isag">109</a> </td> <td style="text-align: left"> Interactive System Activity Grapher for sysstat </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/lsof"> <code class="literal">lsof</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=lsof">V:422, I:945</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/lsof">482</a> </td> <td style="text-align: left"> <code class="literal">lsof</code>(8): list files opened by a running process using "<code class="literal">-p</code>" option </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/strace"> <code class="literal">strace</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=strace">V:12, I:119</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/strace">2897</a> </td> <td style="text-align: left"> <code class="literal">strace</code>(1): trace system calls and signals </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ltrace"> <code class="literal">ltrace</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ltrace">V:0, I:16</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ltrace">330</a> </td> <td style="text-align: left"> <code class="literal">ltrace</code>(1): trace library calls </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/xtrace"> <code class="literal">xtrace</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=xtrace">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/xtrace">353</a> </td> <td style="text-align: left"> <code class="literal">xtrace</code>(1): trace communication between X11 client and server </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/powertop"> <code class="literal">powertop</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=powertop">V:18, I:217</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/powertop">677</a> </td> <td style="text-align: left"> <code class="literal">powertop</code>(1): information about system power use </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cron"> <code class="literal">cron</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cron">V:872, I:995</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cron">244</a> </td> <td style="text-align: left"> run processes according to a schedule in background from <code class="literal">cron</code>(8) daemon </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/anacron"> <code class="literal">anacron</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=anacron">V:396, I:479</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/anacron">93</a> </td> <td style="text-align: left"> cron-like command scheduler for systems that don't run 24 hours a day </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/at"> <code class="literal">at</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=at">V:101, I:154</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/at">158</a> </td> <td style="text-align: left"> <code class="literal">at</code>(1) or <code class="literal">batch</code>(1): run a job at a specified time or below certain load level </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="literal">procps</code> packages provide very basics of monitoring, controlling, and starting program activities. You should learn all of them.</p> </td> </tr> </table> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_timing_a_process"/>9.4.1. Timing a process</h3> </div> </div> </div> <p>Display time used by the process invoked by the command.</p> <pre class="screen"># time some_command &gt;/dev/null real 0m0.035s # time on wall clock (elapsed real time) user 0m0.000s # time in user mode sys 0m0.020s # time in kernel mode</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_scheduling_priority"/>9.4.2. The scheduling priority</h3> </div> </div> </div> <p>A nice value is used to control the scheduling priority for the process.</p> <div class="table"> <a id="listofnicevalueshedulingpriority"/> <p class="title"> <strong>Table 9.9. List of nice values for the scheduling priority</strong> </p> <div class="table-contents"> <table class="table" summary="List of nice values for the scheduling priority" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> nice value </th> <th style="text-align: left"> scheduling priority </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> 19 </td> <td style="text-align: left"> lowest priority process (nice) </td> </tr> <tr> <td style="text-align: left"> 0 </td> <td style="text-align: left"> very high priority process for user </td> </tr> <tr> <td style="text-align: left"> -20 </td> <td style="text-align: left"> very high priority process for root (not-nice) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <pre class="screen"># nice -19 top # very nice # nice --20 wodim -v -eject speed=2 dev=0,0 disk.img # very fast</pre> <p>Sometimes an extreme nice value does more harm than good to the system. Use this command carefully.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_ps_command"/>9.4.3. The ps command</h3> </div> </div> </div> <p>The <code class="literal">ps</code>(1) command on a Debian system support both BSD and SystemV features and helps to identify the process activity statically.</p> <div class="table"> <a id="listofpscommandstyles"/> <p class="title"> <strong>Table 9.10. List of ps command styles</strong> </p> <div class="table-contents"> <table class="table" summary="List of ps command styles" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> style </th> <th style="text-align: left"> typical command </th> <th style="text-align: left"> feature </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> BSD </td> <td style="text-align: left"> <code class="literal">ps aux</code> </td> <td style="text-align: left"> display %CPU %MEM </td> </tr> <tr> <td style="text-align: left"> System V </td> <td style="text-align: left"> <code class="literal">ps -efH</code> </td> <td style="text-align: left"> display PPID </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>For the zombie (defunct) children process, you can kill them by the parent process ID identified in the "<code class="literal">PPID</code>" field.</p> <p>The <code class="literal">pstree</code>(1) command display a tree of processes.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_top_command"/>9.4.4. The top command</h3> </div> </div> </div> <p><code class="literal">top</code>(1) on the Debian system has rich features and helps to identify what process is acting funny dynamically.</p> <p>It is an interactive full screen program. You can get its usage help press by pressing the "h"-key and terminate it by pressing the "q"-key.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_listing_files_opened_by_a_process"/>9.4.5. Listing files opened by a process</h3> </div> </div> </div> <p>You can list all files opened by a process with a process ID (PID), e.g. 1, by the following.</p> <pre class="screen">$ sudo lsof -p 1</pre> <p>PID=1 is usually the <code class="literal">init</code> program.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_tracing_program_activities"/>9.4.6. Tracing program activities</h3> </div> </div> </div> <p>You can trace program activity with <code class="literal">strace</code>(1), <code class="literal">ltrace</code>(1), or <code class="literal">xtrace</code>(1) for system calls and signals, library calls, or communication between X11 client and server.</p> <p>You can trace system calls of the <code class="literal">ls</code> command as the following.</p> <pre class="screen">$ sudo strace ls</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p> Use <span class="strong"><strong>strace-graph</strong></span> script found in <span class="strong"><strong>/usr/share/doc/strace/examples/</strong></span> to make a nice tree view </p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_identification_of_processes_using_files_or_sockets"/>9.4.7. Identification of processes using files or sockets</h3> </div> </div> </div> <p>You can also identify processes using files by <code class="literal">fuser</code>(1), e.g. for "<code class="literal">/var/log/mail.log</code>" by the following.</p> <pre class="screen">$ sudo fuser -v /var/log/mail.log USER PID ACCESS COMMAND /var/log/mail.log: root 2946 F.... rsyslogd</pre> <p>You see that file "<code class="literal">/var/log/mail.log</code>" is open for writing by the <code class="literal">rsyslogd</code>(8) command.</p> <p>You can also identify processes using sockets by <code class="literal">fuser</code>(1), e.g. for "<code class="literal">smtp/tcp</code>" by the following.</p> <pre class="screen">$ sudo fuser -v smtp/tcp USER PID ACCESS COMMAND smtp/tcp: Debian-exim 3379 F.... exim4</pre> <p>Now you know your system runs <code class="literal">exim4</code>(8) to handle <a class="ulink" href="https://en.wikipedia.org/wiki/Transmission_Control_Protocol">TCP</a> connections to <a class="ulink" href="https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol">SMTP</a> port (25).</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_repeating_a_command_with_a_constant_interval"/>9.4.8. Repeating a command with a constant interval</h3> </div> </div> </div> <p><code class="literal">watch</code>(1) executes a program repeatedly with a constant interval while showing its output in fullscreen.</p> <pre class="screen">$ watch w</pre> <p>This displays who is logged on to the system updated every 2 seconds.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_repeating_a_command_looping_over_files"/>9.4.9. Repeating a command looping over files</h3> </div> </div> </div> <p>There are several ways to repeat a command looping over files matching some condition, e.g. matching glob pattern "<code class="literal">*.ext</code>".</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Shell for-loop method (see <a class="xref" href="ch12.en.html#_shell_loops" title="12.1.4. Shell loops">Section 12.1.4, “Shell loops”</a>): </p> </li> </ul> </div> <pre class="screen">for x in *.ext; do if [ -f "$x"]; then command "$x" ; fi; done</pre> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">find</code>(1) and <code class="literal">xargs</code>(1) combination: </p> </li> </ul> </div> <pre class="screen">find . -type f -maxdepth 1 -name '*.ext' -print0 | xargs -0 -n 1 command</pre> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">find</code>(1) with "<code class="literal">-exec</code>" option with a command: </p> </li> </ul> </div> <pre class="screen">find . -type f -maxdepth 1 -name '*.ext' -exec command '{}' \;</pre> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">find</code>(1) with "<code class="literal">-exec</code>" option with a short shell script: </p> </li> </ul> </div> <pre class="screen">find . -type f -maxdepth 1 -name '*.ext' -exec sh -c "command '{}' &amp;&amp; echo 'successful'" \;</pre> <p>The above examples are written to ensure proper handling of funny file names such as ones containing spaces. 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> for more advance uses of <code class="literal">find</code>(1).</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_starting_a_program_from_gui"/>9.4.10. Starting a program from GUI</h3> </div> </div> </div> <p>For the <a class="ulink" href="https://en.wikipedia.org/wiki/Command-line_interface">command-line interface (CLI)</a>, the first program with the matching name found in the directories specified in the <code class="literal">$PATH</code> environment variable is executed. See <a class="xref" href="ch01.en.html#_the_literal_path_literal_variable" title="1.5.3. The &quot;$PATH&quot; variable">Section 1.5.3, “The "<code class="literal">$PATH</code>" variable”</a>.</p> <p>For the <a class="ulink" href="https://en.wikipedia.org/wiki/Graphical_user_interface">graphical user interface (GUI)</a> compliant to the <a class="ulink" href="https://www.freedesktop.org/wiki/">freedesktop.org</a> standards, the <code class="literal">*.desktop</code> files in the <code class="literal">/usr/share/applications/</code> directory provide necessary attributes for the GUI menu display of each program. Each package which is compliant to Freedesktop.org's xdg menu system installs its menu data provided by "*.desktop" under "/usr/share/applications/". Modern desktop environments which are compliant to Freedesktop.org standard use these data to generate their menu using the xdg-utils package. See "/usr/share/doc/xdg-utils/README". </p> <p>For example, the <code class="literal">chromium.desktop</code> file defines attributes for the "Chromium Web Browser" such as "Name" for the program name, "Exec" for the program execution path and arguments, "Icon" for the icon used, etc. (see the <a class="ulink" href="https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html">Desktop Entry Specification</a>) as follows:</p> <pre class="screen">[Desktop Entry] Version=1.0 Name=Chromium Web Browser GenericName=Web Browser Comment=Access the Internet Comment[fr]=Explorer le Web Exec=/usr/bin/chromium %U Terminal=false X-MultipleArgs=false Type=Application Icon=chromium Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml_xml;x-scheme-handler/http;x-scheme-handler/https; StartupWMClass=Chromium StartupNotify=true</pre> <p>This is an oversimplified description. The <code class="literal">*.desktop</code> files are scanned as follows.</p> <p>The desktop environment sets <code class="literal">$XDG_DATA_HOME</code> and <code class="literal">$XDG_DATA_DIR</code> environment variables. For example, under the GNOME 3:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">$XDG_DATA_HOME</code> is unset. (The default value of <code class="literal">$HOME/.local/share</code> is used.) </p> </li> <li class="listitem"> <p><code class="literal">$XDG_DATA_DIRS</code> is set to <code class="literal">/usr/share/gnome:/usr/local/share/:/usr/share/</code>. </p> </li> </ul> </div> <p>So the base directories (see <a class="ulink" href="https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html">XDG Base Directory Specification</a>) and the <code class="literal">applications</code> directories are as follows.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">$HOME/.local/share/</code> → <code class="literal">$HOME/.local/share/applications/</code> </p> </li> <li class="listitem"> <p><code class="literal">/usr/share/gnome/</code> → <code class="literal">/usr/share/gnome/applications/</code> </p> </li> <li class="listitem"> <p><code class="literal">/usr/local/share/</code> → <code class="literal">/usr/local/share/applications/</code> </p> </li> <li class="listitem"> <p><code class="literal">/usr/share/</code> → <code class="literal">/usr/share/applications/</code> </p> </li> </ul> </div> <p>The <code class="literal">*.desktop</code> files are scanned in these <code class="literal">applications</code> directories in this order.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>A user custom GUI menu entry can be created by adding a <code class="literal">*.desktop</code> file in the <code class="literal">$HOME/.local/share/applications/</code> directory.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The "<code class="literal">Exec=...</code>" line isn't parsed by the shell. Use the <code class="literal">env</code>(1) command if environment variables need to be set.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Similarly, if a <code class="literal">*.desktop</code> file is created in the <code class="literal">autostart</code> directory under these base directories, the specified program in the <code class="literal">*.desktop</code> file is executed automatically when the desktop environment is started. See <a class="ulink" href="https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html">Desktop Application Autostart Specification</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Similarly, if a <code class="literal">*.desktop</code> file is created in the <code class="literal">$HOME/Desktop</code> directory and the Desktop environment is configured to support the desktop icon launcher feature, the specified program in it is executed upon clicking the icon. Please note that the actual name of the <code class="literal">$HOME/Desktop</code> directory is locale dependent. See <code class="literal">xdg-user-dirs-update</code>(1).</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_customizing_program_to_be_started"/>9.4.11. Customizing program to be started</h3> </div> </div> </div> <p>Some programs start another program automatically. Here are check points for customizing this process.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Application configuration menu: </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> GNOME3 desktop: "Settings" → "System" → "Details" → "Default Applications" </p> </li> <li class="listitem"> <p> KDE desktop: "K" → "Control Center" → "KDE Components" → "Component Chooser" </p> </li> <li class="listitem"> <p> Iceweasel browser: "Edit" → "Preferences" → "Applications" </p> </li> <li class="listitem"> <p><code class="literal">mc</code>(1): "<code class="literal">/etc/mc/mc.ext</code>" </p> </li> </ul> </div> </li> <li class="listitem"> <p> Environment variables such as "<code class="literal">$BROWSER</code>", "<code class="literal">$EDITOR</code>", "<code class="literal">$VISUAL</code>", and "<code class="literal">$PAGER</code>" (see <code class="literal">environ</code>(7)) </p> </li> <li class="listitem"> <p> The <code class="literal">update-alternatives</code>(1) system for programs such as "<code class="literal">editor</code>", "<code class="literal">view</code>", "<code class="literal">x-www-browser</code>", "<code class="literal">gnome-www-browser</code>", and "<code class="literal">www-browser</code>" (see <a class="xref" href="ch01.en.html#_setting_a_default_text_editor" title="1.4.7. Setting a default text editor">Section 1.4.7, “Setting a default text editor”</a>) </p> </li> <li class="listitem"> <p> the "<code class="literal">~/.mailcap</code>" and "<code class="literal">/etc/mailcap</code>" file contents which associate <a class="ulink" href="https://en.wikipedia.org/wiki/MIME">MIME</a> type with program (see <code class="literal">mailcap</code>(5)) </p> </li> <li class="listitem"> <p> The "<code class="literal">~/.mime.types</code>" and "<code class="literal">/etc/mime.types</code>" file contents which associate file name extension with <a class="ulink" href="https://en.wikipedia.org/wiki/MIME">MIME</a> type (see <code class="literal">run-mailcap</code>(1)) </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p><code class="literal">update-mime</code>(8) updates the "<code class="literal">/etc/mailcap</code>" file using "<code class="literal">/etc/mailcap.order</code>" file (see <code class="literal">mailcap.order</code>(5)).</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="literal">debianutils</code> package provides <code class="literal">sensible-browser</code>(1), <code class="literal">sensible-editor</code>(1), and <code class="literal">sensible-pager</code>(1) which make sensible decisions on which editor, pager, and web browser to call, respectively. I recommend you to read these shell scripts.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>In order to run a console application such as <code class="literal">mutt</code> under GUI as your preferred application, you should create an GUI application as following and set "<code class="literal">/usr/local/bin/mutt-term</code>" as your preferred application to be started as described.</p> <pre class="screen"># cat /usr/local/bin/mutt-term &lt;&lt;EOF #!/bin/sh gnome-terminal -e "mutt \$@" EOF # chmod 755 /usr/local/bin/mutt-term</pre> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_killing_a_process"/>9.4.12. Killing a process</h3> </div> </div> </div> <p>Use <code class="literal">kill</code>(1) to kill (or send a signal to) a process by the process ID.</p> <p>Use <code class="literal">killall</code>(1) or <code class="literal">pkill</code>(1) to do the same by the process command name and other attributes.</p> <div class="table"> <a id="listoffrequentlylsforkillcommand"/> <p class="title"> <strong>Table 9.11. List of frequently used signals for kill command</strong> </p> <div class="table-contents"> <table class="table" summary="List of frequently used signals for kill command" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> signal value </th> <th style="text-align: left"> signal name </th> <th style="text-align: left"> action </th> <th style="text-align: left"> note </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> 0 </td> <td style="text-align: left"> --- </td> <td style="text-align: left"> no signal is sent (see <code class="literal">kill</code>(2)) </td> <td style="text-align: left"> check if process is running </td> </tr> <tr> <td style="text-align: left"> 1 </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/SIGHUP">SIGHUP</a> </td> <td style="text-align: left"> terminate the process </td> <td style="text-align: left"> disconnected terminal (signal hang up) </td> </tr> <tr> <td style="text-align: left"> 2 </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Signals_intelligence">SIGINT</a> </td> <td style="text-align: left"> terminate the process </td> <td style="text-align: left"> interrupt from keyboard (<code class="literal">CTRL-C</code>) </td> </tr> <tr> <td style="text-align: left"> 3 </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGQUIT">SIGQUIT</a> </td> <td style="text-align: left"> terminate the process and <a class="ulink" href="https://en.wikipedia.org/wiki/Core_dump">dump core</a> </td> <td style="text-align: left"> quit from keyboard (<code class="literal">CTRL-\</code>) </td> </tr> <tr> <td style="text-align: left"> 9 </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL">SIGKILL</a> </td> <td style="text-align: left"> terminate the process </td> <td style="text-align: left"> unblockable kill signal </td> </tr> <tr> <td style="text-align: left"> 15 </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM">SIGTERM</a> </td> <td style="text-align: left"> terminate the process </td> <td style="text-align: left"> blockable termination signal </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_scheduling_tasks_once"/>9.4.13. Scheduling tasks once</h3> </div> </div> </div> <p>Run the <code class="literal">at</code>(1) command to schedule a one-time job by the following.</p> <pre class="screen">$ echo 'command -args'| at 3:40 monday</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_scheduling_tasks_regularly"/>9.4.14. Scheduling tasks regularly</h3> </div> </div> </div> <p>Use <code class="literal">cron</code>(8) to schedule tasks regularly. See <code class="literal">crontab</code>(1) and <code class="literal">crontab</code>(5).</p> <p>You can schedule to run processes as a normal user, e.g. <code class="literal">foo</code> by creating a <code class="literal">crontab</code>(5) file as "<code class="literal">/var/spool/cron/crontabs/foo</code>" with "<code class="literal">crontab -e</code>" command.</p> <p>Here is an example of a <code class="literal">crontab</code>(5) file.</p> <pre class="screen"># use /usr/bin/sh to run commands, no matter what /etc/passwd says SHELL=/bin/sh # mail any output to paul, no matter whose crontab this is MAILTO=paul # Min Hour DayOfMonth Month DayOfWeek command (Day... are OR'ed) # run at 00:05, every day 5 0 * * * $HOME/bin/daily.job &gt;&gt; $HOME/tmp/out 2&gt;&amp;1 # run at 14:15 on the first of every month -- output mailed to paul 15 14 1 * * $HOME/bin/monthly # run at 22:00 on weekdays(1-5), annoy Joe. % for newline, last % for cc: 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%.%% 23 */2 1 2 * echo "run 23 minutes after 0am, 2am, 4am ..., on Feb 1" 5 4 * * sun echo "run at 04:05 every Sunday" # run at 03:40 on the first Monday of each month 40 3 1-7 * * [ "$(date +%a)" == "Mon" ] &amp;&amp; command -args</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>For the system not running continuously, install the <code class="literal">anacron</code> package to schedule periodic commands at the specified intervals as closely as machine-uptime permits. See <code class="literal">anacron</code>(8) and <code class="literal">anacrontab</code>(5).</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>For scheduled system maintenance scripts, you can run them periodically from root account by placing such scripts in "<code class="literal">/etc/cron.hourly/</code>", "<code class="literal">/etc/cron.daily/</code>", "<code class="literal">/etc/cron.weekly/</code>", or "<code class="literal">/etc/cron.monthly/</code>". Execution timings of these scripts can be customized by "<code class="literal">/etc/crontab</code>" and "<code class="literal">/etc/anacrontab</code>".</p> </td> </tr> </table> </div> <p> <a class="ulink" href="https://en.wikipedia.org/wiki/Systemd">Systemd</a> has low level capability to schedule programs to run without <code class="literal">cron</code> daemon. For example, <code class="literal">/lib/systemd/system/apt-daily.timer</code> and <code class="literal">/lib/systemd/system/apt-daily.service</code> set up daily apt download activities. See <code class="literal">systemd.timer</code>(5) .</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_scheduling_tasks_on_event"/>9.4.15. Scheduling tasks on event</h3> </div> </div> </div> <p> <a class="ulink" href="https://en.wikipedia.org/wiki/Systemd">Systemd</a> can schedule program not only on the timer event but also on the mount event. See <a class="xref" href="ch10.en.html#_timer_event_triggered_backup" title="10.2.3.3. Timer event triggered backup">Section 10.2.3.3, “Timer event triggered backup”</a> and <a class="xref" href="ch10.en.html#_mount_event_triggered_backup" title="10.2.3.2. Mount event triggered backup">Section 10.2.3.2, “Mount event triggered backup”</a> for examples. </p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_alt_sysrq_key"/>9.4.16. Alt-SysRq key</h3> </div> </div> </div> <p>Pressing Alt-SysRq (PrtScr) followed by one keys does the magic of rescuing control of the system.</p> <div class="table"> <a id="listofnotablesakcommandkeys"/> <p class="title"> <strong>Table 9.12. List of notable SAK command keys</strong> </p> <div class="table-contents"> <table class="table" summary="List of notable SAK command keys" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> key following Alt-SysRq </th> <th style="text-align: left"> description of action </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <code class="literal">k</code> </td> <td style="text-align: left"><span class="strong"><strong>k</strong></span>ill all processes on the <span class="strong"><strong>current virtual console</strong></span> (<a class="ulink" href="https://en.wikipedia.org/wiki/Secure_attention_key">SAK</a>) </td> </tr> <tr> <td style="text-align: left"> <code class="literal">s</code> </td> <td style="text-align: left"><span class="strong"><strong>s</strong></span>ync all mounted filesystems to avoid data corruption </td> </tr> <tr> <td style="text-align: left"> <code class="literal">u</code> </td> <td style="text-align: left"> remount all mounted filesystems read-only (<span class="strong"><strong>u</strong></span>mount) </td> </tr> <tr> <td style="text-align: left"> <code class="literal">r</code> </td> <td style="text-align: left"> restore the keyboard from <span class="strong"><strong>r</strong></span>aw mode after X crashes </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>See more on <a class="ulink" href="https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html">Linux kernel user’s and administrator’s guide » Linux Magic System Request Key Hacks</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>From SSH terminal etc., you can use the Alt-SysRq feature by writing to the "<code class="literal">/proc/sysrq-trigger</code>". For example, "<code class="literal">echo s &gt; /proc/sysrq-trigger; echo u &gt; /proc/sysrq-trigger</code>" from the root shell prompt <span class="strong"><strong>s</strong></span>yncs and <span class="strong"><strong>u</strong></span>mounts all mounted filesystems.</p> </td> </tr> </table> </div> <p>The current (2021) Debian amd64 Linux kernel has <code class="literal">/proc/sys/kernel/sysrq=438=0b110110110</code>:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p>2 = 0x2 - enable control of console logging level (ON)</p> </li> <li class="listitem"> <p>4 = 0x4 - enable control of keyboard (SAK, unraw) (ON)</p> </li> <li class="listitem"> <p>8 = 0x8 - enable debugging dumps of processes etc. (OFF)</p> </li> <li class="listitem"> <p>16 = 0x10 - enable sync command (ON)</p> </li> <li class="listitem"> <p>32 = 0x20 - enable remount read-only (ON)</p> </li> <li class="listitem"> <p>64 = 0x40 - enable signaling of processes (term, kill, oom-kill) (OFF)</p> </li> <li class="listitem"> <p>128 = 0x80 - allow reboot/poweroff (ON)</p> </li> <li class="listitem"> <p>256 = 0x100 - allow nicing of all RT tasks (ON)</p> </li> </ul> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_system_maintenance_tips"/>9.5. System maintenance tips</h2> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_who_is_on_the_system"/>9.5.1. Who is on the system?</h3> </div> </div> </div> <p>You can check who is on the system by the following.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">who</code>(1) shows who is logged on. </p> </li> <li class="listitem"> <p><code class="literal">w</code>(1) shows who is logged on and what they are doing. </p> </li> <li class="listitem"> <p><code class="literal">last</code>(1) shows listing of last logged in user. </p> </li> <li class="listitem"> <p><code class="literal">lastb</code>(1) shows listing of last bad logged in users. </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>"<code class="literal">/var/run/utmp</code>", and "<code class="literal">/var/log/wtmp</code>" hold such user information. See <code class="literal">login</code>(1) and <code class="literal">utmp</code>(5).</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_warning_everyone"/>9.5.2. Warning everyone</h3> </div> </div> </div> <p>You can send message to everyone who is logged on to the system with <code class="literal">wall</code>(1) by the following.</p> <pre class="screen">$ echo "We are shutting down in 1 hour" | wall</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_hardware_identification"/>9.5.3. Hardware identification</h3> </div> </div> </div> <p>For the <a class="ulink" href="https://en.wikipedia.org/wiki/Peripheral_Component_Interconnect">PCI</a>-like devices (<a class="ulink" href="https://en.wikipedia.org/wiki/Accelerated_Graphics_Port">AGP</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/PCI_Express">PCI-Express</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/PC_Card#CardBus">CardBus</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/ExpressCard">ExpressCard</a>, etc.), <code class="literal">lspci</code>(8) (probably with "<code class="literal">-nn</code>" option) is a good start for the hardware identification.</p> <p>Alternatively, you can identify the hardware by reading contents of "<code class="literal">/proc/bus/pci/devices</code>" or browsing directory tree under "<code class="literal">/sys/bus/pci</code>" (see <a class="xref" href="ch01.en.html#_procfs_and_sysfs" title="1.2.12. procfs and sysfs">Section 1.2.12, “procfs and sysfs”</a>).</p> <div class="table"> <a id="listofhardwareidntificationtools"/> <p class="title"> <strong>Table 9.13. List of hardware identification tools</strong> </p> <div class="table-contents"> <table class="table" summary="List of hardware identification tools" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pciutils"> <code class="literal">pciutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pciutils">V:249, I:991</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pciutils">213</a> </td> <td style="text-align: left"> Linux PCI Utilities: <code class="literal">lspci</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/usbutils"> <code class="literal">usbutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=usbutils">V:68, I:869</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/usbutils">325</a> </td> <td style="text-align: left"> Linux USB utilities: <code class="literal">lsusb</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/nvme-cli"> <code class="literal">nvme-cli</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=nvme-cli">V:15, I:22</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/nvme-cli">1642</a> </td> <td style="text-align: left"> NVMe utilities for Linux: <code class="literal">nvme</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pcmciautils"> <code class="literal">pcmciautils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pcmciautils">V:6, I:10</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pcmciautils">91</a> </td> <td style="text-align: left"> PCMCIA utilities for Linux: <code class="literal">pccardctl</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/scsitools"> <code class="literal">scsitools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=scsitools">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/scsitools">346</a> </td> <td style="text-align: left"> collection of tools for SCSI hardware management: <code class="literal">lsscsi</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/procinfo"> <code class="literal">procinfo</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=procinfo">V:0, I:9</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/procinfo">132</a> </td> <td style="text-align: left"> system information obtained from "<code class="literal">/proc</code>": <code class="literal">lsdev</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/lshw"> <code class="literal">lshw</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=lshw">V:13, I:89</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/lshw">919</a> </td> <td style="text-align: left"> information about hardware configuration: <code class="literal">lshw</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/discover"> <code class="literal">discover</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=discover">V:40, I:958</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/discover">98</a> </td> <td style="text-align: left"> hardware identification system: <code class="literal">discover</code>(8) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_hardware_configuration"/>9.5.4. Hardware configuration</h3> </div> </div> </div> <p>Although most of the hardware configuration on modern GUI desktop systems such as GNOME and KDE can be managed through accompanying GUI configuration tools, it is a good idea to know some basics methods to configure them.</p> <div class="table"> <a id="listofhardwareconfigurationtools"/> <p class="title"> <strong>Table 9.14. List of hardware configuration tools</strong> </p> <div class="table-contents"> <table class="table" summary="List of hardware configuration tools" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/console-setup"> <code class="literal">console-setup</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=console-setup">V:88, I:967</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/console-setup">428</a> </td> <td style="text-align: left"> Linux console font and keytable utilities </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/x11-xserver-utils"> <code class="literal">x11-xserver-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=x11-xserver-utils">V:302, I:528</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/x11-xserver-utils">568</a> </td> <td style="text-align: left"> X server utilities: <code class="literal">xset</code>(1), <code class="literal">xmodmap</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/acpid"> <code class="literal">acpid</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=acpid">V:84, I:148</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/acpid">158</a> </td> <td style="text-align: left"> daemon to manage events delivered by the Advanced Configuration and Power Interface (ACPI) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/acpi"> <code class="literal">acpi</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=acpi">V:9, I:136</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/acpi">47</a> </td> <td style="text-align: left"> utility to display information on ACPI devices </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/sleepd"> <code class="literal">sleepd</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=sleepd">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/sleepd">86</a> </td> <td style="text-align: left"> daemon to put a laptop to sleep during inactivity </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/hdparm"> <code class="literal">hdparm</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=hdparm">V:178, I:335</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/hdparm">256</a> </td> <td style="text-align: left"> hard disk access optimization (see <a class="xref" href="ch09.en.html#_optimization_of_hard_disk" title="9.6.9. Optimization of hard disk">Section 9.6.9, “Optimization of hard disk”</a>) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/smartmontools"> <code class="literal">smartmontools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=smartmontools">V:207, I:250</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/smartmontools">2358</a> </td> <td style="text-align: left"> control and monitor storage systems using <a class="ulink" href="https://en.wikipedia.org/wiki/S.M.A.R.T.">S.M.A.R.T.</a> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/setserial"> <code class="literal">setserial</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=setserial">V:4, I:6</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/setserial">103</a> </td> <td style="text-align: left"> collection of tools for serial port management </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/memtest86+"> <code class="literal">memtest86+</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=memtest86+">V:1, I:21</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/memtest86+">12711</a> </td> <td style="text-align: left"> collection of tools for memory hardware management </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/scsitools"> <code class="literal">scsitools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=scsitools">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/scsitools">346</a> </td> <td style="text-align: left"> collection of tools for <a class="ulink" href="https://en.wikipedia.org/wiki/SCSI">SCSI</a> hardware management </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/setcd"> <code class="literal">setcd</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=setcd">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/setcd">37</a> </td> <td style="text-align: left"> compact disc drive access optimization </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/big-cursor"> <code class="literal">big-cursor</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=big-cursor">I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/big-cursor">26</a> </td> <td style="text-align: left"> larger mouse cursors for X </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>Here, <a class="ulink" href="https://en.wikipedia.org/wiki/Advanced_Configuration_and_Power_Interface">ACPI</a> is a newer framework for the power management system than <a class="ulink" href="https://en.wikipedia.org/wiki/Advanced_Power_Management">APM</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>CPU frequency scaling on modern system is governed by kernel modules such as <code class="literal">acpi_cpufreq</code>.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_system_and_hardware_time"/>9.5.5. System and hardware time</h3> </div> </div> </div> <p>The following sets system and hardware time to MM/DD hh:mm, CCYY.</p> <pre class="screen"># date MMDDhhmmCCYY # hwclock --utc --systohc # hwclock --show</pre> <p>Times are normally displayed in the local time on the Debian system but the hardware and system time usually use <a class="ulink" href="https://en.wikipedia.org/wiki/UTC">UTC(GMT)</a>.</p> <p>If the hardware time is set to UTC, change the setting to "<code class="literal">UTC=yes</code>" in the "<code class="literal">/etc/default/rcS</code>".</p> <p>The following reconfigure the timezone used by the Debian system.</p> <pre class="screen"># dpkg-reconfigure tzdata</pre> <p>If you wish to update system time via network, consider to use the <a class="ulink" href="https://en.wikipedia.org/wiki/Network_Time_Protocol">NTP</a> service with the packages such as <code class="literal">ntp</code>, <code class="literal">ntpdate</code>, and <code class="literal">chrony</code>.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Under <a class="ulink" href="https://en.wikipedia.org/wiki/Systemd">systemd</a>, use <code class="literal">systemd-timesyncd</code> for the network time synchronization instead. See <code class="literal">systemd-timesyncd</code>(8).</p> </td> </tr> </table> </div> <p>See the following.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> <a class="ulink" href="https://tldp.org/HOWTO/TimePrecision-HOWTO/index.html">Managing Accurate Date and Time HOWTO</a> </p> </li> <li class="listitem"> <p> <a class="ulink" href="https://www.ntp.org/">NTP Public Services Project</a> </p> </li> <li class="listitem"> <p> The <code class="literal">ntp-doc</code> package </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p><code class="literal">ntptrace</code>(8) in the <code class="literal">ntp</code> package can trace a chain of NTP servers back to the primary source.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_terminal_configuration"/>9.5.6. The terminal configuration</h3> </div> </div> </div> <p>There are several components to configure character console and <code class="literal">ncurses</code>(3) system features.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> The "<code class="literal">/etc/terminfo/*/*</code>" file (<code class="literal">terminfo</code>(5)) </p> </li> <li class="listitem"> <p> The "<code class="literal">$TERM</code>" environment variable (<code class="literal">term</code>(7)) </p> </li> <li class="listitem"> <p><code class="literal">setterm</code>(1), <code class="literal">stty</code>(1), <code class="literal">tic</code>(1), and <code class="literal">toe</code>(1) </p> </li> </ul> </div> <p>If the <code class="literal">terminfo</code> entry for <code class="literal">xterm</code> doesn't work with a non-Debian <code class="literal">xterm</code>, change your terminal type, "<code class="literal">$TERM</code>", from "<code class="literal">xterm</code>" to one of the feature-limited versions such as "<code class="literal">xterm-r6</code>" when you log in to a Debian system remotely. See "<code class="literal">/usr/share/doc/libncurses5/FAQ</code>" for more. "<code class="literal">dumb</code>" is the lowest common denominator for "<code class="literal">$TERM</code>".</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_the_sound_infrastructure"/>9.5.7. The sound infrastructure</h3> </div> </div> </div> <p>Device drivers for sound cards for current Linux are provided by <a class="ulink" href="https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture">Advanced Linux Sound Architecture (ALSA)</a>. ALSA provides emulation mode for previous <a class="ulink" href="https://en.wikipedia.org/wiki/Open_Sound_System">Open Sound System (OSS)</a> for compatibility.</p> <p>Application softwares may be configured not only to access sound devices directly but also to access them via some standardized sound server system. Currently, PulseAudio, JACK, and PipeWire are used as sound server system. See <a class="ulink" href="https://wiki.debian.org/Sound">Debian wiki page on Sound</a> for the latest situation.</p> <p>There is usually a common sound engine for each popular desktop environment. Each sound engine used by the application can choose to connect to different sound servers.</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"> <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">cat /dev/urandom &gt; /dev/audio</code>" or <code class="literal">speaker-test</code>(1) to test speaker (^C to stop).</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>If you can not get sound, your speaker may be connected to a muted output. Modern sound system has many outputs. <code class="literal">alsamixer</code>(1) in the <code class="literal">alsa-utils</code> package is useful to configure volume and mute settings.</p> </td> </tr> </table> </div> <div class="table"> <a id="listofsoundpackages"/> <p class="title"> <strong>Table 9.15. List of sound packages</strong> </p> <div class="table-contents"> <table class="table" summary="List of sound packages" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/alsa-utils"> <code class="literal">alsa-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=alsa-utils">V:330, I:466</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/alsa-utils">2605</a> </td> <td style="text-align: left"> utilities for configuring and using ALSA </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/oss-compat"> <code class="literal">oss-compat</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=oss-compat">V:1, I:17</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/oss-compat">18</a> </td> <td style="text-align: left"> OSS compatibility under ALSA preventing "<code class="literal">/dev/dsp not found</code>" errors </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pipewire"> <code class="literal">pipewire</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pipewire">V:265, I:319</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pipewire">120</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</a> - metapackage </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pipewire-bin"> <code class="literal">pipewire-bin</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pipewire-bin">V:274, I:319</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pipewire-bin">1631</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</a> - audio server and CLI programs </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pipewire-alsa"> <code class="literal">pipewire-alsa</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pipewire-alsa">V:105, I:157</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pipewire-alsa">206</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</a> - audio server to replace ALSA </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pipewire-pulse"> <code class="literal">pipewire-pulse</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pipewire-pulse">V:160, I:214</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pipewire-pulse">50</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PipeWire">audio and video processing engine multimedia server</a> - audio server to replace PulseAudio </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pulseaudio"> <code class="literal">pulseaudio</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pulseaudio">V:256, I:308</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pulseaudio">6472</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PulseAudio">PulseAudio</a> server </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libpulse0"> <code class="literal">libpulse0</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libpulse0">V:413, I:580</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libpulse0">975</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/PulseAudio">PulseAudio</a> client library </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/jackd"> <code class="literal">jackd</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=jackd">V:2, I:18</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/jackd">9</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit">JACK Audio Connection Kit. (JACK)</a> server (low latency) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libjack0"> <code class="literal">libjack0</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libjack0">V:1, I:9</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libjack0">326</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/JACK_Audio_Connection_Kit">JACK Audio Connection Kit. (JACK)</a> library (low latency) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libgstreamer1.0-0"> <code class="literal">libgstreamer1.0-0</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libgstreamer1.0-0">V:429, I:597</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libgstreamer1.0-0">4455</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/GStreamer">GStreamer</a>: GNOME sound engine </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libphonon4qt5-4"> <code class="literal">libphonon4qt5-4</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libphonon4qt5-4">V:72, I:162</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libphonon4qt5-4">594</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/Phonon_(KDE)">Phonon</a>: KDE sound engine </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_disabling_the_screen_saver"/>9.5.8. Disabling the screen saver</h3> </div> </div> </div> <p>For disabling the screen saver, use following commands.</p> <div class="table"> <a id="listofcommandsfongthescreensaver"/> <p class="title"> <strong>Table 9.16. List of commands for disabling the screen saver</strong> </p> <div class="table-contents"> <table class="table" summary="List of commands for disabling the screen saver" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> environment </th> <th style="text-align: left"> command </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> The Linux console </td> <td style="text-align: left"> <code class="literal">setterm -powersave off</code> </td> </tr> <tr> <td style="text-align: left"> The X Window (turning off screensaver) </td> <td style="text-align: left"> <code class="literal">xset s off</code> </td> </tr> <tr> <td style="text-align: left"> The X Window (disabling dpms) </td> <td style="text-align: left"> <code class="literal">xset -dpms</code> </td> </tr> <tr> <td style="text-align: left"> The X Window (GUI configuration of screen saver) </td> <td style="text-align: left"> <code class="literal">xscreensaver-command -prefs</code> </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_disabling_beep_sounds"/>9.5.9. Disabling beep sounds</h3> </div> </div> </div> <p>One can always unplug the PC speaker to disable beep sounds. Removing <code class="literal">pcspkr</code> kernel module does this for you.</p> <p>The following prevents the <code class="literal">readline</code>(3) program used by <code class="literal">bash</code>(1) to beep when encountering an alert character (ASCII=7).</p> <pre class="screen">$ echo "set bell-style none"&gt;&gt; ~/.inputrc</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_memory_usage"/>9.5.10. Memory usage</h3> </div> </div> </div> <p>There are 2 resources available for you to get the memory usage situation.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> The kernel boot message in the "<code class="literal">/var/log/dmesg</code>" contains the total exact size of available memory. </p> </li> <li class="listitem"> <p><code class="literal">free</code>(1) and <code class="literal">top</code>(1) display information on memory resources on the running system. </p> </li> </ul> </div> <p>Here is an example.</p> <pre class="screen"># grep '\] Memory' /var/log/dmesg [ 0.004000] Memory: 990528k/1016784k available (1975k kernel code, 25868k reserved, 931k data, 296k init) $ free -k total used free shared buffers cached Mem: 997184 976928 20256 0 129592 171932 -/+ buffers/cache: 675404 321780 Swap: 4545576 4 4545572</pre> <p>You may be wondering "dmesg tells me a free of 990 MB, and free -k says 320 MB is free. More than 600 MB missing …".</p> <p>Do not worry about the large size of "<code class="literal">used</code>" and the small size of "<code class="literal">free</code>" in the "<code class="literal">Mem:</code>" line, but read the one under them (675404 and 321780 in the example above) and relax.</p> <p>For my MacBook with 1GB=1048576k DRAM (video system steals some of this), I see the following.</p> <div class="table"> <a id="listofmemorysizesreported"/> <p class="title"> <strong>Table 9.17. List of memory sizes reported</strong> </p> <div class="table-contents"> <table class="table" summary="List of memory sizes reported" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> report </th> <th style="text-align: left"> size </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> Total size in dmesg </td> <td style="text-align: left"> 1016784k = 1GB - 31792k </td> </tr> <tr> <td style="text-align: left"> Free in dmesg </td> <td style="text-align: left"> 990528k </td> </tr> <tr> <td style="text-align: left"> Total under shell </td> <td style="text-align: left"> 997184k </td> </tr> <tr> <td style="text-align: left"> Free under shell </td> <td style="text-align: left"> 20256k (but effectively 321780k) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_system_security_and_integrity_check"/>9.5.11. System security and integrity check</h3> </div> </div> </div> <p>Poor system maintenance may expose your system to external exploitation.</p> <p>For system security and integrity check, you should start with the following.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> The <code class="literal">debsums</code> package, see <code class="literal">debsums</code>(1) and <a class="xref" href="ch02.en.html#_top_level_release_file_and_authenticity" title="2.5.2. Top level &quot;Release&quot; file and authenticity">Section 2.5.2, “Top level "Release" file and authenticity”</a>. </p> </li> <li class="listitem"> <p> The <code class="literal">chkrootkit</code> package, see <code class="literal">chkrootkit</code>(1). </p> </li> <li class="listitem"> <p> The <code class="literal">clamav</code> package family, see <code class="literal">clamscan</code>(1) and <code class="literal">freshclam</code>(1). </p> </li> <li class="listitem"> <p><a class="ulink" href="https://www.debian.org/security/faq">Debian security FAQ</a>. </p> </li> <li class="listitem"> <p><a class="ulink" href="https://www.debian.org/doc/manuals/securing-debian-manual/">Securing Debian Manual</a>. </p> </li> </ul> </div> <div class="table"> <a id="listoftoolsforsyndintegritycheck"/> <p class="title"> <strong>Table 9.18. List of tools for system security and integrity check</strong> </p> <div class="table-contents"> <table class="table" summary="List of tools for system security and integrity check" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/logcheck"> <code class="literal">logcheck</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=logcheck">V:6, I:7</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/logcheck">110</a> </td> <td style="text-align: left"> daemon to mail anomalies in the system logfiles to the administrator </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/debsums"> <code class="literal">debsums</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=debsums">V:5, I:35</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/debsums">98</a> </td> <td style="text-align: left"> utility to verify installed package files against MD5 checksums </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/chkrootkit"> <code class="literal">chkrootkit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=chkrootkit">V:8, I:17</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/chkrootkit">925</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/Rootkit">rootkit</a> detector </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/clamav"> <code class="literal">clamav</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=clamav">V:9, I:45</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/clamav">27455</a> </td> <td style="text-align: left"> anti-virus utility for Unix - command-line interface </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/tiger"> <code class="literal">tiger</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=tiger">V:1, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/tiger">7800</a> </td> <td style="text-align: left"> report system security vulnerabilities </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/tripwire"> <code class="literal">tripwire</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=tripwire">V:1, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/tripwire">5016</a> </td> <td style="text-align: left"> file and directory integrity checker </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/john"> <code class="literal">john</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=john">V:1, I:9</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/john">471</a> </td> <td style="text-align: left"> active password cracking tool </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/aide"> <code class="literal">aide</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=aide">V:1, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/aide">293</a> </td> <td style="text-align: left"> Advanced Intrusion Detection Environment - static binary </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/integrit"> <code class="literal">integrit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=integrit">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/integrit">2659</a> </td> <td style="text-align: left"> file integrity verification program </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/crack"> <code class="literal">crack</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=crack">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/crack">149</a> </td> <td style="text-align: left"> password guessing program </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>Here is a simple script to check for typical world writable incorrect file permissions.</p> <pre class="screen"># find / -perm 777 -a \! -type s -a \! -type l -a \! \( -type d -a -perm 1777 \)</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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>Since the <code class="literal">debsums</code> package uses <a class="ulink" href="https://en.wikipedia.org/wiki/MD5">MD5</a> checksums stored locally, it can not be fully trusted as the system security audit tool against malicious attacks.</p> </td> </tr> </table> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_data_storage_tips"/>9.6. Data storage tips</h2> </div> </div> </div> <p>Booting your system with Linux <a class="ulink" href="https://en.wikipedia.org/wiki/Live_CD">live CDs</a> or <a class="ulink" href="https://www.debian.org/releases/stable/debian-installer/">debian-installer CDs</a> in rescue mode makes it easy for you to reconfigure data storage on your boot device.</p> <p>You may need to <code class="literal">umount</code>(8) some devices manually from the command line before operating on them if they are automatically mounted by the GUI desktop system.</p> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_disk_space_usage"/>9.6.1. Disk space usage</h3> </div> </div> </div> <p>The disk space usage can be evaluated by programs provided by the <code class="literal">mount</code>, <code class="literal">coreutils</code>, and <code class="literal">xdu</code> packages:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">mount</code>(8) reports all mounted filesystems (= disks). </p> </li> <li class="listitem"> <p><code class="literal">df</code>(1) reports the disk space usage for the file system. </p> </li> <li class="listitem"> <p><code class="literal">du</code>(1) reports the disk space usage for the directory tree. </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can feed the output of <code class="literal">du</code>(8) to <code class="literal">xdu</code>(1x) to produce its graphical and interactive presentation with "<code class="literal">du -k . |xdu</code>", "<code class="literal">sudo du -k -x / |xdu</code>", etc.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_disk_partition_configuration"/>9.6.2. Disk partition configuration</h3> </div> </div> </div> <p>For <a class="ulink" href="https://en.wikipedia.org/wiki/Disk_partitioning">disk partition</a> configuration, although <code class="literal">fdisk</code>(8) has been considered standard, <code class="literal">parted</code>(8) deserves some attention. "Disk partitioning data", "partition table", "partition map", and "disk label" are all synonyms.</p> <p>Older PCs use the classic <a class="ulink" href="https://en.wikipedia.org/wiki/Master_boot_record">Master Boot Record (MBR)</a> scheme to hold <a class="ulink" href="https://en.wikipedia.org/wiki/Disk_partitioning">disk partitioning</a> data in the first sector, i.e., <a class="ulink" href="https://en.wikipedia.org/wiki/Logical_block_addressing">LBA</a> sector 0 (512 bytes).</p> <p>Recent PCs with <a class="ulink" href="https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface">Unified Extensible Firmware Interface (UEFI)</a>, including Intel-based Macs, use <a class="ulink" href="https://en.wikipedia.org/wiki/GUID_Partition_Table">GUID Partition Table (GPT)</a> scheme to hold <a class="ulink" href="https://en.wikipedia.org/wiki/Disk_partitioning">disk partitioning</a> data not in the first sector.</p> <p>Although <code class="literal">fdisk</code>(8) has been standard for the disk partitioning tool, <code class="literal">parted</code>(8) is replacing it.</p> <div class="table"> <a id="listofdiskpartitnagementpackages"/> <p class="title"> <strong>Table 9.19. List of disk partition management packages</strong> </p> <div class="table-contents"> <table class="table" summary="List of disk partition management packages" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/util-linux"> <code class="literal">util-linux</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=util-linux">V:881, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/util-linux">5283</a> </td> <td style="text-align: left"> miscellaneous system utilities including <code class="literal">fdisk</code>(8) and <code class="literal">cfdisk</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/parted"> <code class="literal">parted</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=parted">V:417, I:568</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/parted">122</a> </td> <td style="text-align: left"> GNU Parted disk partition resizing program </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gparted"> <code class="literal">gparted</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gparted">V:15, I:102</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gparted">2175</a> </td> <td style="text-align: left"> GNOME partition editor based on <code class="literal">libparted</code> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gdisk"> <code class="literal">gdisk</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gdisk">V:338, I:511</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gdisk">885</a> </td> <td style="text-align: left"> partition editor for the GPT/MBR hybrid disk </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/kpartx"> <code class="literal">kpartx</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=kpartx">V:22, I:33</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/kpartx">77</a> </td> <td style="text-align: left"> program to create device mappings for partitions </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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>Although <code class="literal">parted</code>(8) claims to create and to resize filesystem too, it is safer to do such things using best maintained specialized tools such as <code class="literal">mkfs</code>(8) (<code class="literal">mkfs.msdos</code>(8), <code class="literal">mkfs.ext2</code>(8), <code class="literal">mkfs.ext3</code>(8), <code class="literal">mkfs.ext4</code>(8), …) and <code class="literal">resize2fs</code>(8).</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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>In order to switch between <a class="ulink" href="https://en.wikipedia.org/wiki/GUID_Partition_Table">GPT</a> and <a class="ulink" href="https://en.wikipedia.org/wiki/Master_boot_record">MBR</a>, you need to erase first few blocks of disk contents directly (see <a class="xref" href="ch09.en.html#_clearing_file_contents" title="9.8.6. Clearing file contents">Section 9.8.6, “Clearing file contents”</a>) and use "<code class="literal">parted /dev/sdx mklabel gpt</code>" or "<code class="literal">parted /dev/sdx mklabel msdos</code>" to set it. Please note "<code class="literal">msdos</code>" is use here for <a class="ulink" href="https://en.wikipedia.org/wiki/Master_boot_record">MBR</a>.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_accessing_partition_using_uuid"/>9.6.3. Accessing partition using UUID</h3> </div> </div> </div> <p>Although reconfiguration of your partition or activation order of removable storage media may yield different names for partitions, you can access them consistently. This is also helpful if you have multiple disks and your BIOS/UEFI doesn't give them consistent device names.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">mount</code>(8) with "<code class="literal">-U</code>" option can mount a block device using <a class="ulink" href="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a>, instead of using its file name such as "<code class="literal">/dev/sda3</code>". </p> </li> <li class="listitem"> <p> "<code class="literal">/etc/fstab</code>" (see <code class="literal">fstab</code>(5)) can use <a class="ulink" href="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a>. </p> </li> <li class="listitem"> <p> Boot loaders (<a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.1.2. Stage 2: the boot loader">Section 3.1.2, “Stage 2: the boot loader”</a>) may use <a class="ulink" href="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a> too. </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can probe <a class="ulink" href="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a> of a block special device with <code class="literal">blkid</code>(8).</p> <p>You can also probe UUID and other information with "<code class="literal">lsblk -f</code>".</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_lvm2"/>9.6.4. LVM2</h3> </div> </div> </div> <p>LVM2 is a <a class="ulink" href="https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">logical volume manager</a> for the Linux kernel. With LVM2, disk partitions can be created on logical volumes instead of the physical harddisks.</p> <p>LVM requires the following.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> device-mapper support in the Linux kernel (default for Debian kernels) </p> </li> <li class="listitem"> <p> the userspace device-mapper support library (<code class="literal">libdevmapper*</code> package) </p> </li> <li class="listitem"> <p> the userspace LVM2 tools (<code class="literal">lvm2</code> package) </p> </li> </ul> </div> <p>Please start learning LVM2 from the following manpages.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">lvm</code>(8): Basics of LVM2 mechanism (list of all LVM2 commands) </p> </li> <li class="listitem"> <p><code class="literal">lvm.conf</code>(5): Configuration file for LVM2 </p> </li> <li class="listitem"> <p><code class="literal">lvs</code>(8): Report information about logical volumes </p> </li> <li class="listitem"> <p><code class="literal">vgs</code>(8): Report information about volume groups </p> </li> <li class="listitem"> <p><code class="literal">pvs</code>(8): Report information about physical volumes </p> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_filesystem_configuration"/>9.6.5. Filesystem configuration</h3> </div> </div> </div> <p>For <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem, the <code class="literal">e2fsprogs</code> package provides the following.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><code class="literal">mkfs.ext4</code>(8) to create new <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem </p> </li> <li class="listitem"> <p><code class="literal">fsck.ext4</code>(8) to check and to repair existing <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem </p> </li> <li class="listitem"> <p><code class="literal">tune2fs</code>(8) to configure superblock of <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem </p> </li> <li class="listitem"> <p><code class="literal">debugfs</code>(8) to debug <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem interactively. (It has <code class="literal">undel</code> command to recover deleted files.) </p> </li> </ul> </div> <p>The <code class="literal">mkfs</code>(8) and <code class="literal">fsck</code>(8) commands are provided by the <code class="literal">e2fsprogs</code> package as front-ends to various filesystem dependent programs (<code class="literal">mkfs.fstype</code> and <code class="literal">fsck.fstype</code>). For <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystem, they are <code class="literal">mkfs.ext4</code>(8) and <code class="literal">fsck.ext4</code>(8) (they are symlinked to <code class="literal">mke2fs</code>(8) and <code class="literal">e2fsck</code>(8)).</p> <p>Similar commands are available for each filesystem supported by Linux.</p> <div class="table"> <a id="listoffilesystemnagementpackages"/> <p class="title"> <strong>Table 9.20. List of filesystem management packages</strong> </p> <div class="table-contents"> <table class="table" summary="List of filesystem management packages" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/e2fsprogs"> <code class="literal">e2fsprogs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=e2fsprogs">V:767, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/e2fsprogs">1499</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/Ext2">ext2</a>/<a class="ulink" href="https://en.wikipedia.org/wiki/Ext3">ext3</a>/<a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystems </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/btrfs-progs"> <code class="literal">btrfs-progs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=btrfs-progs">V:44, I:72</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/btrfs-progs">5078</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/Btrfs">Btrfs</a> filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/reiserfsprogs"> <code class="literal">reiserfsprogs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=reiserfsprogs">V:12, I:25</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/reiserfsprogs">473</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/Reiserfs">Reiserfs</a> filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/zfsutils-linux"> <code class="literal">zfsutils-linux</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=zfsutils-linux">V:29, I:30</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/zfsutils-linux">1762</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/OpenZFS">OpenZFS</a> filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dosfstools"> <code class="literal">dosfstools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dosfstools">V:196, I:541</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dosfstools">315</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/File_Allocation_Table">FAT</a> filesystem. (Microsoft: MS-DOS, Windows) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/exfatprogs"> <code class="literal">exfatprogs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=exfatprogs">V:29, I:371</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/exfatprogs">301</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/ExFAT">exFAT</a> filesystem maintained by Samsung. </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/exfat-fuse"> <code class="literal">exfat-fuse</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=exfat-fuse">V:5, I:120</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/exfat-fuse">73</a> </td> <td style="text-align: left"> read/write <a class="ulink" href="https://en.wikipedia.org/wiki/ExFAT">exFAT</a> filesystem (Microsoft) driver for FUSE. </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/exfat-utils"> <code class="literal">exfat-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=exfat-utils">V:4, I:106</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/exfat-utils">231</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/ExFAT">exFAT</a> filesystem maintained by the exfat-fuse author. </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/xfsprogs"> <code class="literal">xfsprogs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=xfsprogs">V:21, I:95</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/xfsprogs">3476</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/XFS">XFS</a> filesystem. (SGI: IRIX) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ntfs-3g"> <code class="literal">ntfs-3g</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ntfs-3g">V:197, I:513</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ntfs-3g">1474</a> </td> <td style="text-align: left"> read/write <a class="ulink" href="https://en.wikipedia.org/wiki/NTFS">NTFS</a> filesystem (Microsoft: Windows NT, …) driver for FUSE. </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/jfsutils"> <code class="literal">jfsutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=jfsutils">V:0, I:8</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/jfsutils">1577</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/JFS_(file_system)">JFS</a> filesystem. (IBM: AIX, OS/2) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/reiser4progs"> <code class="literal">reiser4progs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=reiser4progs">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/reiser4progs">1367</a> </td> <td style="text-align: left"> utilities for the <a class="ulink" href="https://en.wikipedia.org/wiki/Reiser4">Reiser4</a> filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/hfsprogs"> <code class="literal">hfsprogs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=hfsprogs">V:0, I:4</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/hfsprogs">394</a> </td> <td style="text-align: left"> utilities for <a class="ulink" href="https://en.wikipedia.org/wiki/Hierarchical_File_System">HFS</a> and <a class="ulink" href="https://en.wikipedia.org/wiki/HFS_Plus">HFS Plus</a> filesystem. (Apple: Mac OS) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/zerofree"> <code class="literal">zerofree</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=zerofree">V:5, I:131</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/zerofree">25</a> </td> <td style="text-align: left"> program to zero free blocks from ext2/3/4 filesystems </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">Ext4</a> filesystem is the default filesystem for the Linux system and strongly recommended to use it unless you have some specific reasons not to.</p> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Btrfs">Btrfs</a> status can be found at <a class="ulink" href="https://wiki.debian.org/Btrfs">Debian wiki on btrfs</a> and <a class="ulink" href="https://btrfs.wiki.kernel.org/index.php/Status">kernel.org wiki on btrfs</a>. It is expected to be the next default filesystem after the ext4 filesystem.</p> <p>Some tools allow access to filesystem without Linux kernel support (see <a class="xref" href="ch09.en.html#_manipulating_files_without_mounting_disk" title="9.8.2. Manipulating files without mounting disk">Section 9.8.2, “Manipulating files without mounting disk”</a>).</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_filesystem_creation_and_integrity_check"/>9.6.6. Filesystem creation and integrity check</h3> </div> </div> </div> <p>The <code class="literal">mkfs</code>(8) command creates the filesystem on a Linux system. The <code class="literal">fsck</code>(8) command provides the filesystem integrity check and repair on a Linux system.</p> <p>Debian now defaults to no periodic <code class="literal">fsck</code> after filesystem creation.</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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>It is generally not safe to run <code class="literal">fsck</code> on <span class="strong"><strong>mounted filesystems</strong></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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can run the <code class="literal">fsck</code>(8) command safely on all filesystems including root filesystem on reboot by setting "<code class="literal">enable_periodic_fsck</code>" in "<code class="literal">/etc/mke2fs.conf</code>" and the max mount count to 0 using "<code class="literal">tune2fs -c0 /dev/<span class="emphasis"><em>partition_name</em></span></code>". See <code class="literal">mke2fs.conf</code>(5) and <code class="literal">tune2fs</code>(8).</p> <p>Check files in "<code class="literal">/var/log/fsck/</code>" for the result of the <code class="literal">fsck</code>(8) command run from the boot script.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_optimization_of_filesystem_by_mount_options"/>9.6.7. Optimization of filesystem by mount options</h3> </div> </div> </div> <p>The basic static filesystem configuration is given by "<code class="literal">/etc/fstab</code>". For example,</p> <pre class="screen">«file system» «mount point» «type» «options» «dump» «pass» proc /proc proc defaults 0 0 UUID=709cbe4c-80c1-56db-8ab1-dbce3146d2f7 / ext4 errors=remount-ro 0 1 UUID=817bae6b-45d2-5aca-4d2a-1267ab46ac23 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Universally_Unique_Identifier">UUID</a> (see <a class="xref" href="ch09.en.html#_accessing_partition_using_uuid" title="9.6.3. Accessing partition using UUID">Section 9.6.3, “Accessing partition using UUID”</a>) may be used to identify a block device instead of normal block device names such as "<code class="literal">/dev/sda1</code>", "<code class="literal">/dev/sda2</code>", …</p> </td> </tr> </table> </div> <p>Since Linux 2.6.30, the kernel defaults to the behavior provided by "<code class="literal">relatime</code>" option. </p> <p>See <code class="literal">fstab</code>(5) and <code class="literal">mount</code>(8).</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_optimization_of_filesystem_via_superblock"/>9.6.8. Optimization of filesystem via superblock</h3> </div> </div> </div> <p>Characteristics of a filesystem can be optimized via its superblock using the <code class="literal">tune2fs</code>(8) command.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Execution of "<code class="literal">sudo tune2fs -l /dev/hda1</code>" displays the contents of the filesystem superblock on "<code class="literal">/dev/hda1</code>". </p> </li> <li class="listitem"> <p> Execution of "<code class="literal">sudo tune2fs -c 50 /dev/hda1</code>" changes frequency of filesystem checks (<code class="literal">fsck</code> execution during boot-up) to every 50 boots on "<code class="literal">/dev/hda1</code>". </p> </li> <li class="listitem"> <p> Execution of "<code class="literal">sudo tune2fs -j /dev/hda1</code>" adds journaling capability to the filesystem, i.e. filesystem conversion from <a class="ulink" href="https://en.wikipedia.org/wiki/Ext2">ext2</a> to <a class="ulink" href="https://en.wikipedia.org/wiki/Ext3">ext3</a> on "<code class="literal">/dev/hda1</code>". (Do this on the unmounted filesystem.) </p> </li> <li class="listitem"> <p> Execution of "<code class="literal">sudo tune2fs -O extents,uninit_bg,dir_index /dev/hda1 &amp;&amp; fsck -pf /dev/hda1</code>" converts it from <a class="ulink" href="https://en.wikipedia.org/wiki/Ext3">ext3</a> to <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> on "<code class="literal">/dev/hda1</code>". (Do this on the unmounted 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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Despite its name, <code class="literal">tune2fs</code>(8) works not only on the <a class="ulink" href="https://en.wikipedia.org/wiki/Ext2">ext2</a> filesystem but also on the <a class="ulink" href="https://en.wikipedia.org/wiki/Ext3">ext3</a> and <a class="ulink" href="https://en.wikipedia.org/wiki/Ext4">ext4</a> filesystems.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_optimization_of_hard_disk"/>9.6.9. Optimization of hard disk</h3> </div> </div> </div> <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"> <img alt="[Warning]" src="images/warning.png"/> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p>Please check your hardware and read manpage of <code class="literal">hdparm</code>(8) before playing with hard disk configuration because this may be quite dangerous for the data integrity.</p> </td> </tr> </table> </div> <p>You can test disk access speed of a hard disk, e.g. "<code class="literal">/dev/hda</code>", by "<code class="literal">hdparm -tT /dev/hda</code>". For some hard disk connected with (E)IDE, you can speed it up with "<code class="literal">hdparm -q -c3 -d1 -u1 -m16 /dev/hda</code>" by enabling the "(E)IDE 32-bit I/O support", enabling the "using_dma flag", setting "interrupt-unmask flag", and setting the "multiple 16 sector I/O" (dangerous!).</p> <p>You can test write cache feature of a hard disk, e.g. "<code class="literal">/dev/sda</code>", by "<code class="literal">hdparm -W /dev/sda</code>". You can disable its write cache feature with "<code class="literal">hdparm -W 0 /dev/sda</code>".</p> <p>You may be able to read badly pressed CDROMs on modern high speed CD-ROM drive by slowing it down with "<code class="literal">setcd -x 2</code>".</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_optimization_of_solid_state_drive"/>9.6.10. Optimization of solid state drive</h3> </div> </div> </div> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Solid-state_drive">Solid state drive (SSD)</a> is auto detected now.</p> <p>Reduce unnecessary disk accesses to prevent disk wear out by mounting "<code class="literal">tmpfs</code>" on volatile data path in <code class="literal">/etc/fstab</code>. </p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_using_smart_to_predict_hard_disk_failure"/>9.6.11. Using SMART to predict hard disk failure</h3> </div> </div> </div> <p>You can monitor and log your hard disk which is compliant to <a class="ulink" href="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</a> with the <code class="literal">smartd</code>(8) daemon.</p> <div class="orderedlist"> <ol class="orderedlist"> <li class="listitem"> <p> Enable <a class="ulink" href="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</a> feature in <a class="ulink" href="https://en.wikipedia.org/wiki/BIOS">BIOS</a>. </p> </li> <li class="listitem"> <p> Install the <code class="literal">smartmontools</code> package. </p> </li> <li class="listitem"> <p> Identify your hard disk drives by listing them with <code class="literal">df</code>(1). </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Let's assume a hard disk drive to be monitored as "<code class="literal">/dev/hda</code>". </p> </li> </ul> </div> </li> <li class="listitem"> <p> Check the output of "<code class="literal">smartctl -a /dev/hda</code>" to see if <a class="ulink" href="https://en.wikipedia.org/wiki/S.M.A.R.T.">SMART</a> feature is actually enabled. </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> If not, enable it by "<code class="literal">smartctl -s on -a /dev/hda</code>". </p> </li> </ul> </div> </li> <li class="listitem"> <p> Enable <code class="literal">smartd</code>(8) daemon to run by the following. </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> uncomment "<code class="literal">start_smartd=yes</code>" in the "<code class="literal">/etc/default/smartmontools</code>" file. </p> </li> <li class="listitem"> <p> restart the <code class="literal">smartd</code>(8) daemon by "<code class="literal">sudo systemctl restart smartmontools</code>". </p> </li> </ul> </div> </li> </ol> </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="literal">smartd</code>(8) daemon can be customized with the <code class="literal">/etc/smartd.conf</code> file including how to be notified of warnings.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_specify_temporary_storage_directory_via_tmpdir"/>9.6.12. Specify temporary storage directory via $TMPDIR</h3> </div> </div> </div> <p>Applications create temporary files normally under the temporary storage directory "<code class="literal">/tmp</code>". If "<code class="literal">/tmp</code>" does not provide enough space, you can specify such temporary storage directory via the <code class="literal">$TMPDIR</code> variable for well-behaving programs.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_expansion_of_usable_storage_space_via_lvm"/>9.6.13. Expansion of usable storage space via LVM</h3> </div> </div> </div> <p>For partitions created on <a class="ulink" href="https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">Logical Volume Manager (LVM)</a> (Linux feature) at install time, they can be resized easily by concatenating extents onto them or truncating extents from them over multiple storage devices without major system reconfiguration.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_expansion_of_usable_storage_space_by_mounting_another_partition"/>9.6.14. Expansion of usable storage space by mounting another partition</h3> </div> </div> </div> <p>If you have an empty partition (e.g., "<code class="literal">/dev/sdx</code>"), you can format it with <code class="literal">mkfs.ext4</code>(1) and <code class="literal">mount</code>(8) it to a directory where you need more space. (You need to copy original data contents.)</p> <pre class="screen">$ sudo mv work-dir old-dir $ sudo mkfs.ext4 /dev/sdx $ sudo mount -t ext4 /dev/sdx work-dir $ sudo cp -a old-dir/* work-dir $ sudo rm -rf old-dir</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You may alternatively mount an empty disk image file (see <a class="xref" href="ch09.en.html#_making_the_empty_disk_image_file" title="9.7.5. Making the empty disk image file">Section 9.7.5, “Making the empty disk image file”</a>) as a loop device (see <a class="xref" href="ch09.en.html#_mounting_the_disk_image_file" title="9.7.3. Mounting the disk image file">Section 9.7.3, “Mounting the disk image file”</a>). The actual disk usage grows with the actual data stored.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_expansion_of_usable_storage_space_by_bind_mounting_another_directory"/>9.6.15. Expansion of usable storage space by bind-mounting another directory</h3> </div> </div> </div> <p>If you have an empty directory (e.g., "<code class="literal">/path/to/emp-dir</code>") on another partition with usable space, you can mount(8) it with "<code class="literal">--bind</code>" option to a directory (e.g., "<code class="literal">work-dir</code>") where you need more space.</p> <pre class="screen">$ sudo mount --bind /path/to/emp-dir work-dir</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_expansion_of_usable_storage_space_by_overlay_mounting_another_directory"/>9.6.16. Expansion of usable storage space by overlay-mounting another directory</h3> </div> </div> </div> <p>If you have usable space in another partition (e.g., "<code class="literal">/path/to/empty</code>" and "<code class="literal">/path/to/work</code>"), you can create a directory in it and stack that on to an old directory (e.g., "<code class="literal">/path/to/old</code>") where you need space using the <a class="ulink" href="https://en.wikipedia.org/wiki/OverlayFS">OverlayFS</a> for Linux kernel 3.18 or newer (Debian Stretch 9.0 or newer).</p> <pre class="screen">$ sudo mount -t overlay overlay \ -olowerdir=/path/to/old-dir,upperdir=/path/to/empty,workdir=/path/to/work</pre> <p>Here, "<code class="literal">/path/to/empty</code>" and "<code class="literal">/path/to/work</code>" should be on the RW-enabled partition to write on "<code class="literal">/path/to/old</code>".</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_expansion_of_usable_storage_space_using_symlink"/>9.6.17. Expansion of usable storage space using symlink</h3> </div> </div> </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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>This is a deprecated method. Some software may not function well with "symlink to a directory". Instead, use the "mounting" approaches described in the above.</p> </td> </tr> </table> </div> <p>If you have an empty directory (e.g., "<code class="literal">/path/to/emp-dir</code>") in another partition with usable space, you can create a symlink to the directory with <code class="literal">ln</code>(8).</p> <pre class="screen">$ sudo mv work-dir old-dir $ sudo mkdir -p /path/to/emp-dir $ sudo ln -sf /path/to/emp-dir work-dir $ sudo cp -a old-dir/* work-dir $ sudo rm -rf old-dir</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"> <img alt="[Warning]" src="images/warning.png"/> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p>Do not use "symlink to a directory" for directories managed by the system such as "<code class="literal">/opt</code>". Such a symlink may be overwritten when the system is upgraded.</p> </td> </tr> </table> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_the_disk_image"/>9.7. The disk image</h2> </div> </div> </div> <p>Here, we discuss manipulations of the disk image.</p> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_making_the_disk_image_file"/>9.7.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 or serial ATA drive "<code class="literal">/dev/sdb</code>", can be made using <code class="literal">cp</code>(1) or <code class="literal">dd</code>(1) 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="https://en.wikipedia.org/wiki/Master_boot_record">master boot record (MBR)</a> (see <a class="xref" href="ch09.en.html#_disk_partition_configuration" title="9.6.2. Disk partition configuration">Section 9.6.2, “Disk partition configuration”</a>) which reside on the first sector on the primary IDE disk can be made by using <code class="literal">dd</code>(1) 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"> <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">mbr-part.img</code>": The partition table of the MBR only </p> </li> </ul> </div> <p>If you have an SCSI or serial ATA device 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 id="_writing_directly_to_the_disk"/>9.7.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 id="_mounting_the_disk_image_file"/>9.7.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="https://en.wikipedia.org/wiki/Loop_device">loop device</a> as follows.</p> <pre class="screen"># losetup --show -f partition.img /dev/loop0 # mkdir -p /mnt/loop0 # mount -t auto /dev/loop0 /mnt/loop0 ...hack...hack...hack # umount /dev/loop0 # losetup -d /dev/loop0</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="https://en.wikipedia.org/wiki/Loop_device">loop device</a>.</p> <pre class="screen"># losetup --show -f -P disk.img /dev/loop0 # ls -l /dev/loop0* brw-rw---- 1 root disk 7, 0 Apr 2 22:51 /dev/loop0 brw-rw---- 1 root disk 259, 12 Apr 2 22:51 /dev/loop0p1 brw-rw---- 1 root disk 259, 13 Apr 2 22:51 /dev/loop0p14 brw-rw---- 1 root disk 259, 14 Apr 2 22:51 /dev/loop0p15 # fdisk -l /dev/loop0 Disk /dev/loop0: 2 GiB, 2147483648 bytes, 4194304 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 6A1D9E28-C48C-2144-91F7-968B3CBC9BD1 Device Start End Sectors Size Type /dev/loop0p1 262144 4192255 3930112 1.9G Linux root (x86-64) /dev/loop0p14 2048 8191 6144 3M BIOS boot /dev/loop0p15 8192 262143 253952 124M EFI System Partition table entries are not in disk order. # mkdir -p /mnt/loop0p1 # mkdir -p /mnt/loop0p15 # mount -t auto /dev/loop0p1 /mnt/loop0p1 # mount -t auto /dev/loop0p15 /mnt/loop0p15 # mount |grep loop /dev/loop0p1 on /mnt/loop0p1 type ext4 (rw,relatime) /dev/loop0p15 on /mnt/loop0p15 type vfat (rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro) ...hack...hack...hack # umount /dev/loop0p1 # umount /dev/loop0p15 # losetup -d /dev/loop0</pre> <p>Alternatively, similar effects can be done by using the <a class="ulink" href="https://en.wikipedia.org/wiki/Device_mapper">device mapper</a> devices created by <code class="literal">kpartx</code>(8) from the <code class="literal">kpartx</code> package as follows.</p> <pre class="screen"># kpartx -a -v disk.img add map loop0p1 (253:0): 0 3930112 linear 7:0 262144 add map loop0p14 (253:1): 0 6144 linear 7:0 2048 add map loop0p15 (253:2): 0 253952 linear 7:0 8192 # fdisk -l /dev/loop0 Disk /dev/loop0: 2 GiB, 2147483648 bytes, 4194304 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 6A1D9E28-C48C-2144-91F7-968B3CBC9BD1 Device Start End Sectors Size Type /dev/loop0p1 262144 4192255 3930112 1.9G Linux root (x86-64) /dev/loop0p14 2048 8191 6144 3M BIOS boot /dev/loop0p15 8192 262143 253952 124M EFI System Partition table entries are not in disk order. # ls -l /dev/mapper/ total 0 crw------- 1 root root 10, 236 Apr 2 22:45 control lrwxrwxrwx 1 root root 7 Apr 2 23:19 loop0p1 -&gt; ../dm-0 lrwxrwxrwx 1 root root 7 Apr 2 23:19 loop0p14 -&gt; ../dm-1 lrwxrwxrwx 1 root root 7 Apr 2 23:19 loop0p15 -&gt; ../dm-2 # mkdir -p /mnt/loop0p1 # mkdir -p /mnt/loop0p15 # mount -t auto /dev/mapper/loop0p1 /mnt/loop0p1 # mount -t auto /dev/mapper/loop0p15 /mnt/loop0p15 # mount |grep loop /dev/loop0p1 on /mnt/loop0p1 type ext4 (rw,relatime) /dev/loop0p15 on /mnt/loop0p15 type vfat (rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro) ...hack...hack...hack # umount /dev/mapper/loop0p1 # umount /dev/mapper/loop0p15 # kpartx -d disk.img</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_cleaning_a_disk_image_file"/>9.7.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, ext3 or ext4, you can also use <code class="literal">zerofree</code>(8) from the <code class="literal">zerofree</code> package as follows.</p> <pre class="screen"># losetup --show -f disk.img /dev/loop0 # zerofree /dev/loop0 # cp --sparse=always disk.img new.img # losetup -d /dev/loop0</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_making_the_empty_disk_image_file"/>9.7.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 <code class="literal">dd</code>(1) as follows.</p> <pre class="screen">$ dd bs=1 count=0 if=/dev/zero of=disk.img seek=5G</pre> <p>Instead of using <code class="literal">dd</code>(1), specialized <code class="literal">fallocate</code>(8) may be used here.</p> <p>You can create an ext4 filesystem on this disk image "<code class="literal">disk.img</code>" using the <a class="ulink" href="https://en.wikipedia.org/wiki/Loop_device">loop device</a> as follows.</p> <pre class="screen"># losetup --show -f disk.img /dev/loop0 # mkfs.ext4 /dev/loop0 ...hack...hack...hack # losetup -d /dev/loop0 $ du --apparent-size -h disk.img 5.0G disk.img $ du -h disk.img 83M disk.img</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="https://en.wikipedia.org/wiki/Ext4">ext4</a> can hold <a class="ulink" href="https://en.wikipedia.org/wiki/Sparse_file">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"> <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="https://en.wikipedia.org/wiki/Sparse_file">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="https://en.wikipedia.org/wiki/Loop_device">loop device</a> or the <a class="ulink" href="https://en.wikipedia.org/wiki/Device_mapper">device mapper</a> devices as <a class="xref" href="ch09.en.html#_mounting_the_disk_image_file" title="9.7.3. Mounting the disk image file">Section 9.7.3, “Mounting the disk image file”</a>, you can partition this disk image "<code class="literal">disk.img</code>" using <code class="literal">parted</code>(8) or <code class="literal">fdisk</code>(8), and can create filesystem on it using <code class="literal">mkfs.ext4</code>(8), <code class="literal">mkswap</code>(8), etc.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_making_the_iso9660_image_file"/>9.7.6. Making the ISO9660 image file</h3> </div> </div> </div> <p>The <a class="ulink" href="https://en.wikipedia.org/wiki/ISO_9660">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 <code class="literal">genisoimage</code>(1) provided by <a class="ulink" href="https://en.wikipedia.org/wiki/Cdrkit">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="https://en.wikipedia.org/wiki/SYSLINUX">Isolinux boot loader</a> (see <a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.1.2. Stage 2: the boot loader">Section 3.1.2, “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"> <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 id="_writing_directly_to_the_cd_dvd_r_rw"/>9.7.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"> <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 <code class="literal">wodim</code>(1) provided by <a class="ulink" href="https://en.wikipedia.org/wiki/Cdrkit">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 <code class="literal">wodim</code>(1) 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"> <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 CDs automatically, unmount it by "<code class="literal">sudo umount /dev/hda</code>" from console before using <code class="literal">wodim</code>(1).</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_mounting_the_iso9660_image_file"/>9.7.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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Modern desktop system may mount removable media such as ISO9660 formatted CD automatically (see <a class="xref" href="ch10.en.html#_removable_storage_device" title="10.1.7. Removable storage device">Section 10.1.7, “Removable storage device”</a>).</p> </td> </tr> </table> </div> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_the_binary_data"/>9.8. The binary data</h2> </div> </div> </div> <p>Here, we discuss direct manipulations of the binary data on storage media.</p> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_viewing_and_editing_binary_data"/>9.8.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 id="listofpackageswhndeditbinarydata"/> <p class="title"> <strong>Table 9.21. List of packages which view and edit binary data</strong> </p> <div class="table-contents"> <table class="table" summary="List of packages which view and edit binary data" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/coreutils"> <code class="literal">coreutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=coreutils">V:880, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/coreutils">18307</a> </td> <td style="text-align: left"> basic package which has <code class="literal">od</code>(1) to dump files (HEX, ASCII, OCTAL, …) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bsdmainutils"> <code class="literal">bsdmainutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bsdmainutils">V:11, I:315</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bsdmainutils">17</a> </td> <td style="text-align: left"> utility package which has <code class="literal">hd</code>(1) to dump files (HEX, ASCII, OCTAL, …) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/hexedit"> <code class="literal">hexedit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=hexedit">V:0, I:9</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/hexedit">73</a> </td> <td style="text-align: left"> binary editor and viewer (HEX, ASCII) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bless"> <code class="literal">bless</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bless">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bless">924</a> </td> <td style="text-align: left"> full featured hexadecimal editor (GNOME) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/okteta"> <code class="literal">okteta</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=okteta">V:1, I:12</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/okteta">1585</a> </td> <td style="text-align: left"> full featured hexadecimal editor (KDE4) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ncurses-hexedit"> <code class="literal">ncurses-hexedit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ncurses-hexedit">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ncurses-hexedit">130</a> </td> <td style="text-align: left"> binary editor and viewer (HEX, ASCII, EBCDIC) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/beav"> <code class="literal">beav</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=beav">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/beav">137</a> </td> <td style="text-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"> <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="https://en.wikipedia.org/wiki/Hexadecimal">hexadecimal</a> format with <a class="ulink" href="https://en.wikipedia.org/wiki/Radix">radix</a> 16. OCTAL is for <a class="ulink" href="https://en.wikipedia.org/wiki/Octal">octal</a> format with <a class="ulink" href="https://en.wikipedia.org/wiki/Radix">radix</a> 8. ASCII is for <a class="ulink" href="https://en.wikipedia.org/wiki/ASCII">American Standard Code for Information Interchange</a>, i.e., normal English text code. EBCDIC is for <a class="ulink" href="https://en.wikipedia.org/wiki/Extended_Binary_Coded_Decimal_Interchange_Code">Extended Binary Coded Decimal Interchange Code</a> used on <a class="ulink" href="https://en.wikipedia.org/wiki/IBM_mainframe">IBM mainframe</a> operating systems.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_manipulating_files_without_mounting_disk"/>9.8.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 id="listofpackagestohoutmountingdisk"/> <p class="title"> <strong>Table 9.22. List of packages to manipulate files without mounting disk</strong> </p> <div class="table-contents"> <table class="table" summary="List of packages to manipulate files without mounting disk" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/mtools"> <code class="literal">mtools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=mtools">V:8, I:63</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/mtools">390</a> </td> <td style="text-align: left"> utilities for MSDOS files without mounting them </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/hfsutils"> <code class="literal">hfsutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=hfsutils">V:0, I:5</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/hfsutils">184</a> </td> <td style="text-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 id="_data_redundancy"/>9.8.3. Data redundancy</h3> </div> </div> </div> <p>Software <a class="ulink" href="https://en.wikipedia.org/wiki/RAID">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 id="listoftoolstoaddedundancytofiles"/> <p class="title"> <strong>Table 9.23. List of tools to add data redundancy to files</strong> </p> <div class="table-contents"> <table class="table" summary="List of tools to add data redundancy to files" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/par2"> <code class="literal">par2</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=par2">V:9, I:94</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/par2">268</a> </td> <td style="text-align: left"> Parity Archive Volume Set, for checking and repair of files </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dvdisaster"> <code class="literal">dvdisaster</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dvdisaster">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dvdisaster">1422</a> </td> <td style="text-align: left"> data loss/scratch/aging protection for CD/DVD media </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dvbackup"> <code class="literal">dvbackup</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dvbackup">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dvbackup">413</a> </td> <td style="text-align: left"> backup tool using MiniDV camcorders (providing <code class="literal">rsbep</code>(1)) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_data_file_recovery_and_forensic_analysis"/>9.8.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 id="listofpackagesfoforensicanalysis"/> <p class="title"> <strong>Table 9.24. List of packages for data file recovery and forensic analysis</strong> </p> <div class="table-contents"> <table class="table" summary="List of packages for data file recovery and forensic analysis" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/testdisk"> <code class="literal">testdisk</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=testdisk">V:2, I:28</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/testdisk">1413</a> </td> <td style="text-align: left"> utilities for partition scan and disk recovery </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/magicrescue"> <code class="literal">magicrescue</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=magicrescue">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/magicrescue">255</a> </td> <td style="text-align: left"> utility to recover files by looking for magic bytes </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/scalpel"> <code class="literal">scalpel</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=scalpel">V:0, I:3</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/scalpel">89</a> </td> <td style="text-align: left"> frugal, high performance file carver </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/myrescue"> <code class="literal">myrescue</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=myrescue">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/myrescue">83</a> </td> <td style="text-align: left"> rescue data from damaged harddisks </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/extundelete"> <code class="literal">extundelete</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=extundelete">V:0, I:8</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/extundelete">147</a> </td> <td style="text-align: left"> utility to undelete files on the ext3/4 filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ext4magic"> <code class="literal">ext4magic</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ext4magic">V:0, I:4</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ext4magic">233</a> </td> <td style="text-align: left"> utility to undelete files on the ext3/4 filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/ext3grep"> <code class="literal">ext3grep</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=ext3grep">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/ext3grep">293</a> </td> <td style="text-align: left"> tool to help recover deleted files on the ext3 filesystem </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/scrounge-ntfs"> <code class="literal">scrounge-ntfs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=scrounge-ntfs">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/scrounge-ntfs">50</a> </td> <td style="text-align: left"> data recovery program for NTFS filesystems </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gzrt"> <code class="literal">gzrt</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gzrt">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gzrt">33</a> </td> <td style="text-align: left"> gzip recovery toolkit </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/sleuthkit"> <code class="literal">sleuthkit</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=sleuthkit">V:3, I:24</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/sleuthkit">1671</a> </td> <td style="text-align: left"> tools for forensics analysis. (Sleuthkit) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/autopsy"> <code class="literal">autopsy</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=autopsy">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/autopsy">1026</a> </td> <td style="text-align: left"> graphical interface to SleuthKit </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/foremost"> <code class="literal">foremost</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=foremost">V:0, I:5</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/foremost">102</a> </td> <td style="text-align: left"> forensics application to recover data </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/guymager"> <code class="literal">guymager</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=guymager">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/guymager">1021</a> </td> <td style="text-align: left"> forensic imaging tool based on Qt </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dcfldd"> <code class="literal">dcfldd</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dcfldd">V:0, I:3</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dcfldd">114</a> </td> <td style="text-align: left"> enhanced version of <code class="literal">dd</code> for forensics and security </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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You can undelete files on the ext2 filesystem using <code class="literal">list_deleted_inodes</code> and <code class="literal">undel</code> commands of <code class="literal">debugfs</code>(8) in the <code class="literal">e2fsprogs</code> package.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_splitting_a_large_file_into_small_files"/>9.8.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"> <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 id="_clearing_file_contents"/>9.8.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 <code class="literal">rm</code>(1) to delete the file and then create a new empty file, because the file may still be accessed in the interval between commands. The following is the safe way to clear the contents of the file.</p> <pre class="screen">$ :&gt;file_to_be_cleared</pre> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_dummy_files"/>9.8.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"> <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 id="_erasing_an_entire_hard_disk"/>9.8.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"> <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 <code class="literal">mount</code>(8) 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 everything by overwriting with random data as follows.</p> <pre class="screen"># dd if=/dev/urandom of=/dev/sda</pre> <p>Erase everything by overwriting with random data very efficiently as follows.</p> <pre class="screen"># shred -v -n 1 /dev/sda</pre> <p>You may alternatively use <code class="literal">badblocks</code>(8) with <code class="literal">-t random</code> option.</p> <p>Since <code class="literal">dd</code>(1) is available from the shell of many bootable Linux CDs such as Debian installer CD, you can erase your installed system completely by running an erase command from such media on the system hard disk, e.g., "<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 id="_erasing_unused_area_of_an_hard_disk"/>9.8.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"> <img alt="[Warning]" src="images/warning.png"/> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p>This is usually good enough for your USB memory stick. But this is not perfect. Most parts of erased filenames and their attributes may be hidden and remain in the filesystem.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_undeleting_deleted_but_still_open_files"/>9.8.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 id="_searching_all_hardlinks"/>9.8.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="https://en.wikipedia.org/wiki/Inode">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="https://en.wikipedia.org/wiki/Inode">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 id="_invisible_disk_space_consumption"/>9.8.12. Invisible disk space consumption</h3> </div> </div> </div> <p>All deleted but open files consume disk space although they are not visible from normal <code class="literal">du</code>(1). 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"><a id="_data_encryption_tips"/>9.9. Data encryption tips</h2> </div> </div> </div> <p>With physical access to your PC, anyone can easily gain root privilege and access all the files on your PC (see <a class="xref" href="ch04.en.html#_securing_the_root_password" title="4.6.4. Securing the root password">Section 4.6.4, “Securing the root password”</a>). This means that login password system can not secure your private and sensitive data against possible theft of your PC. You must deploy data encryption technology to do it. Although <a class="ulink" href="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU privacy guard</a> (see <a class="xref" href="ch10.en.html#_data_security_infrastructure" title="10.3. Data security infrastructure">Section 10.3, “Data security infrastructure”</a>) can encrypt files, it takes some user efforts.</p> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Dm-crypt">Dm-crypt</a> facilitates automatic data encryption via native Linux kernel modules with minimal user efforts using <a class="ulink" href="https://en.wikipedia.org/wiki/Device_mapper">device-mapper</a>.</p> <div class="table"> <a id="listofdataencryptionutilities"/> <p class="title"> <strong>Table 9.25. List of data encryption utilities</strong> </p> <div class="table-contents"> <table class="table" summary="List of data encryption utilities" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cryptsetup"> <code class="literal">cryptsetup</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cryptsetup">V:19, I:79</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cryptsetup">417</a> </td> <td style="text-align: left"> utilities for encrypted block device (<a class="ulink" href="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</a> / <a class="ulink" href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</a>) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cryptmount"> <code class="literal">cryptmount</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cryptmount">V:2, I:3</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cryptmount">231</a> </td> <td style="text-align: left"> utilities for encrypted block device (<a class="ulink" href="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</a> / <a class="ulink" href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</a>) with focus on mount/unmount by normal users </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fscrypt"> <code class="literal">fscrypt</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fscrypt">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fscrypt">5520</a> </td> <td style="text-align: left"> utilities for Linux filesystem encryption (<a class="ulink" href="https://www.kernel.org/doc/html/latest/filesystems/fscrypt.html">fscrypt</a>) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libpam-fscrypt"> <code class="literal">libpam-fscrypt</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libpam-fscrypt">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libpam-fscrypt">5519</a> </td> <td style="text-align: left"> PAM module for Linux filesystem encryption (<a class="ulink" href="https://www.kernel.org/doc/html/latest/filesystems/fscrypt.html">fscrypt</a>) </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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>Data encryption costs CPU time etc. Encrypted data becomes inaccessible if its password is lost. Please weigh its benefits and costs.</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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>Entire Debian system can be installed on a encrypted disk by the <a class="ulink" href="https://www.debian.org/devel/debian-installer/">debian-installer</a> (lenny or newer) using <a class="ulink" href="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</a>/<a class="ulink" href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</a> and initramfs.</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"> <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="ch10.en.html#_data_security_infrastructure" title="10.3. Data security infrastructure">Section 10.3, “Data security infrastructure”</a> for user space encryption utility: <a class="ulink" href="https://en.wikipedia.org/wiki/GNU_Privacy_Guard">GNU Privacy Guard</a>.</p> </td> </tr> </table> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_removable_disk_encryption_with_dm_crypt_luks"/>9.9.1. Removable disk encryption with dm-crypt/LUKS</h3> </div> </div> </div> <p>You can encrypt contents of removable mass devices, e.g. USB memory stick on "<code class="literal">/dev/sdx</code>", using <a class="ulink" href="https://en.wikipedia.org/wiki/Dm-crypt">dm-crypt</a>/<a class="ulink" href="https://en.wikipedia.org/wiki/Linux_Unified_Key_Setup">LUKS</a>. You simply format it as the following.</p> <pre class="screen"># fdisk /dev/sdx ... "n" "p" "1" "return" "return" "w" # cryptsetup luksFormat /dev/sdx1 ... # cryptsetup open /dev/sdx1 secret ... # ls -l /dev/mapper/ total 0 crw-rw---- 1 root root 10, 60 2021-10-04 18:44 control lrwxrwxrwx 1 root root 7 2021-10-04 23:55 secret -&gt; ../dm-0 # mkfs.vfat /dev/mapper/secret ... # cryptsetup close secret</pre> <p>Then, it can be mounted just like normal one on to "<code class="literal">/media/<span class="emphasis"><em>username/disk_label</em></span></code>", except for asking password (see <a class="xref" href="ch10.en.html#_removable_storage_device" title="10.1.7. Removable storage device">Section 10.1.7, “Removable storage device”</a>) under modern desktop environment using the <code class="literal">udisks2</code> package. The difference is that every data written to it is encrypted. The password entry may be automated using keyring (see <a class="xref" href="ch10.en.html#_password_keyring" title="10.3.6. Password keyring">Section 10.3.6, “Password keyring”</a>).</p> <p>You may alternatively format media in different filesystem, e.g., ext4 with "<code class="literal">mkfs.ext4 /dev/mapper/sdx1</code>". If btrfs is used instead, the <code class="literal">udisks2-btrfs</code> package needs to be installed. For these filesystems, the file ownership and permissions may need to be configured.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_mounting_encrypted_disk_with_dm_crypt_luks"/>9.9.2. Mounting encrypted disk with dm-crypt/LUKS</h3> </div> </div> </div> <p>For example, an encrypted disk partition created with dm-crypt/LUKS on "<code class="literal">/dev/sdc5</code>" by Debian Installer can be mounted onto "<code class="literal">/mnt</code>" as follows:</p> <pre class="screen">$ sudo cryptsetup open /dev/sdc5 ninja --type luks Enter passphrase for /dev/sdc5: **** $ sudo lvm lvm&gt; lvscan inactive '/dev/ninja-vg/root' [13.52 GiB] inherit inactive '/dev/ninja-vg/swap_1' [640.00 MiB] inherit ACTIVE '/dev/goofy/root' [180.00 GiB] inherit ACTIVE '/dev/goofy/swap' [9.70 GiB] inherit lvm&gt; lvchange -a y /dev/ninja-vg/root lvm&gt; exit Exiting. $ sudo mount /dev/ninja-vg/root /mnt</pre> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_the_kernel"/>9.10. The kernel</h2> </div> </div> </div> <p>Debian distributes modularized <a class="ulink" href="https://en.wikipedia.org/wiki/Linux_kernel">Linux kernel</a> as packages for supported architectures.</p> <p>If you are reading this documentation, you probably don't need to compile Linux kernel by yourself.</p> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_kernel_parameters"/>9.10.1. Kernel parameters</h3> </div> </div> </div> <p>Many Linux features are configurable via kernel parameters as follows.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Kernel parameters initialized by the bootloader (see <a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.1.2. Stage 2: the boot loader">Section 3.1.2, “Stage 2: the boot loader”</a>) </p> </li> <li class="listitem"> <p> Kernel parameters changed by <code class="literal">sysctl</code>(8) at runtime for ones accessible via sysfs (see <a class="xref" href="ch01.en.html#_procfs_and_sysfs" title="1.2.12. procfs and sysfs">Section 1.2.12, “procfs and sysfs”</a>) </p> </li> <li class="listitem"> <p> Module parameters set by arguments of <code class="literal">modprobe</code>(8) when a module is activated (see <a class="xref" href="ch09.en.html#_mounting_the_disk_image_file" title="9.7.3. Mounting the disk image file">Section 9.7.3, “Mounting the disk image file”</a>) </p> </li> </ul> </div> <p>See "<a class="ulink" href="https://www.kernel.org/doc/html/latest/admin-guide/index.html">The Linux kernel user’s and administrator’s guide</a> » <a class="ulink" href="https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html">The kernel’s command-line parameters</a>" for the detail.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_kernel_headers"/>9.10.2. Kernel headers</h3> </div> </div> </div> <p>Most <span class="strong"><strong>normal programs</strong></span> don't need kernel headers and in fact may break if you use them directly for compiling. They should be compiled against the headers in "<code class="literal">/usr/include/linux</code>" and "<code class="literal">/usr/include/asm</code>" provided by the <code class="literal">libc6-dev</code> package (created from the <code class="literal">glibc</code> source package) 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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>For compiling some kernel-specific programs such as the kernel modules from the external source and the automounter daemon (<code class="literal">amd</code>), you must include path to the corresponding kernel headers, e.g. "<code class="literal">-I/usr/src/linux-particular-version/include/</code>", to your command line. </p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_compiling_the_kernel_and_related_modules"/>9.10.3. Compiling the kernel and related modules</h3> </div> </div> </div> <p>Debian has its own method of compiling the kernel and related modules.</p> <div class="table"> <a id="listofkeypackagenthedebiansystem"/> <p class="title"> <strong>Table 9.26. List of key packages to be installed for the kernel recompilation on the Debian system</strong> </p> <div class="table-contents"> <table class="table" summary="List of key packages to be installed for the kernel recompilation on the Debian system" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/build-essential"> <code class="literal">build-essential</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=build-essential">I:480</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/build-essential">17</a> </td> <td style="text-align: left"> essential packages for building Debian packages: <code class="literal">make</code>, <code class="literal">gcc</code>, … </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bzip2"> <code class="literal">bzip2</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bzip2">V:166, I:970</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bzip2">112</a> </td> <td style="text-align: left"> compress and decompress utilities for bz2 files </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libncurses5-dev"> <code class="literal">libncurses5-dev</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libncurses5-dev">I:71</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libncurses5-dev">6</a> </td> <td style="text-align: left"> developer's libraries and docs for ncurses </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/git"> <code class="literal">git</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=git">V:351, I:549</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/git">46734</a> </td> <td style="text-align: left"> git: distributed revision control system used by the Linux kernel </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/fakeroot"> <code class="literal">fakeroot</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=fakeroot">V:29, I:486</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/fakeroot">224</a> </td> <td style="text-align: left"> provide fakeroot environment for building package as non-root </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/initramfs-tools"> <code class="literal">initramfs-tools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=initramfs-tools">V:430, I:989</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/initramfs-tools">113</a> </td> <td style="text-align: left"> tool to build an initramfs (Debian specific) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dkms"> <code class="literal">dkms</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dkms">V:74, I:162</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dkms">196</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support">dynamic kernel module support (DKMS)</a> (generic) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/module-assistant"> <code class="literal">module-assistant</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=module-assistant">V:0, I:19</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/module-assistant">406</a> </td> <td style="text-align: left"> helper tool to make module package (Debian specific) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/devscripts"> <code class="literal">devscripts</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=devscripts">V:6, I:40</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/devscripts">2658</a> </td> <td style="text-align: left"> helper scripts for a Debian Package maintainer (Debian specific) </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>If you use <code class="literal">initrd</code> in <a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.1.2. Stage 2: the boot loader">Section 3.1.2, “Stage 2: the boot loader”</a>, make sure to read the related information in <code class="literal">initramfs-tools</code>(8), <code class="literal">update-initramfs</code>(8), <code class="literal">mkinitramfs</code>(8) and <code class="literal">initramfs.conf</code>(5).</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"> <img alt="[Warning]" src="images/warning.png"/> </td> <th align="left">Warning</th> </tr> <tr> <td align="left" valign="top"> <p>Do not put symlinks to the directories in the source tree (e.g. "<code class="literal">/usr/src/linux*</code>") from "<code class="literal">/usr/include/linux</code>" and "<code class="literal">/usr/include/asm</code>" when compiling the Linux kernel source. (Some outdated documents suggest this.)</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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>When compiling the latest Linux kernel on the Debian <code class="literal">stable</code> system, the use of backported latest tools from the Debian <code class="literal">unstable</code> may be needed.</p> <p> <code class="literal">module-assistant</code>(8) (or its short form <code class="literal">m-a</code>) helps users to build and install module package(s) easily for one or more custom kernels.</p> <p>The <a class="ulink" href="https://en.wikipedia.org/wiki/Dynamic_Kernel_Module_Support">dynamic kernel module support (DKMS)</a> is a new distribution independent framework designed to allow individual kernel modules to be upgraded without changing the whole kernel. This is used for the maintenance of out-of-tree modules. This also makes it very easy to rebuild modules as you upgrade kernels.</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_compiling_the_kernel_source_debian_kernel_team_recommendation"/>9.10.4. Compiling the kernel source: Debian Kernel Team recommendation</h3> </div> </div> </div> <p>For building custom kernel binary packages from the upstream kernel source, you should use the "<code class="literal">deb-pkg</code>" target provided by it.</p> <pre class="screen">$ sudo apt-get build-dep linux $ cd /usr/src $ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-<span class="emphasis"><em>version</em></span>.tar.xz $ tar --xz -xvf linux-<span class="emphasis"><em>version</em></span>.tar.xz $ cd linux-<span class="emphasis"><em>version</em></span> $ cp /boot/config-<span class="emphasis"><em>version</em></span> .config $ make menuconfig ... $ make deb-pkg</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The linux-source-<span class="emphasis"><em>version</em></span> package provides the Linux kernel source with Debian patches as "<code class="literal">/usr/src/linux-<span class="emphasis"><em>version</em></span>.tar.bz2</code>".</p> </td> </tr> </table> </div> <p>For building specific binary packages from the Debian kernel source package, you should use the "<code class="literal">binary-arch_<span class="emphasis"><em>architecture</em></span>_<span class="emphasis"><em>featureset</em></span>_<span class="emphasis"><em>flavour</em></span></code>" targets in "<code class="literal">debian/rules.gen</code>".</p> <pre class="screen">$ sudo apt-get build-dep linux $ apt-get source linux $ cd linux-3.* $ fakeroot make -f debian/rules.gen binary-arch_i386_none_686</pre> <p>See further information:</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Debian Wiki: <a class="ulink" href="https://wiki.debian.org/KernelFAQ">KernelFAQ</a> </p> </li> <li class="listitem"> <p> Debian Wiki: <a class="ulink" href="https://wiki.debian.org/DebianKernel">DebianKernel</a> </p> </li> <li class="listitem"> <p> Debian Linux Kernel Handbook: <a class="ulink" href="https://kernel-team.pages.debian.net/kernel-handbook/">https://kernel-handbook.debian.net</a> </p> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_hardware_drivers_and_firmware"/>9.10.5. Hardware drivers and firmware</h3> </div> </div> </div> <p>The hardware driver is the code running on the main CPUs of the target system. Most hardware drivers are available as free software now and are included in the normal Debian kernel packages in the <code class="literal">main</code> area.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Graphics_processing_unit">GPU</a> driver </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Intel GPU driver (<code class="literal">main</code>) </p> </li> <li class="listitem"> <p> AMD/ATI GPU driver (<code class="literal">main</code>) </p> </li> <li class="listitem"> <p> NVIDIA GPU driver (<code class="literal">main</code> for <a class="ulink" href="https://en.wikipedia.org/wiki/Nouveau_(software)">nouveau</a> driver, and <code class="literal">non-free</code> for binary-only drivers supported by the vendor.) </p> </li> </ul> </div> </li> </ul> </div> <p>The firmware is the code or data loaded on the device attach to the target system (e.g., CPU <a class="ulink" href="https://en.wikipedia.org/wiki/Microcode">microcode</a>, rendering code running on GPU, or <a class="ulink" href="https://en.wikipedia.org/wiki/FPGA">FPGA</a> / <a class="ulink" href="https://en.wikipedia.org/wiki/Complex_programmable_logic_device">CPLD</a> data, …). Some firmware packages are available as free software but many firmware packages are not available as free software since they contain sourceless binary data. Installing these firmware data is essential for the device to function as expected.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p>The firmware data packages containing data loaded to the volatile memory on the target device.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> firmware-linux-free (<code class="literal">main</code>) </p> </li> <li class="listitem"> <p> firmware-linux-nonfree (<code class="literal">non-free-firmware</code>) </p> </li> <li class="listitem"> <p> firmware-linux-* (<code class="literal">non-free-firmware</code>) </p> </li> <li class="listitem"> <p> *-firmware (<code class="literal">non-free-firmware</code>) </p> </li> <li class="listitem"> <p> intel-microcode (<code class="literal">non-free-firmware</code>) </p> </li> <li class="listitem"> <p> amd64-microcode (<code class="literal">non-free-firmware</code>) </p> </li> </ul> </div> </li> <li class="listitem"> <p>The firmware update program packages which update data on the non-volatile memory on the target device.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> <a class="ulink" href="https://en.wikipedia.org/wiki/Fwupd">fwupd</a> (<code class="literal">main</code>): Firmware update daemon which downloads firmware data from <a class="ulink" href="https://fwupd.org/">Linux Vendor Firmware Service</a>.</p> </li> <li class="listitem"> <p> gnome-firmware (<code class="literal">main</code>): GTK front end for fwupd </p> </li> <li class="listitem"> <p> plasma-discover-backend-fwupd (<code class="literal">main</code>): Qt front end for fwupd </p> </li> </ul> </div> </li> </ul> </div> <p>Please note that access to <code class="literal">non-free-firmware</code> packages are provided by the official installation media to offer functional installation experience to the user since Debian 12 Bookworm. The <code class="literal">non-free-firmware</code> area is described in <a class="xref" href="ch02.en.html#_debian_archive_basics" title="2.1.5. Debian archive basics">Section 2.1.5, “Debian archive basics”</a>.</p> <p>Please also note that the firmware data downloaded by <a class="ulink" href="https://en.wikipedia.org/wiki/Fwupd">fwupd</a> from <a class="ulink" href="https://fwupd.org/">Linux Vendor Firmware Service</a> and loaded to the running Linux kernel may be <code class="literal">non-free</code>.</p> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h2 class="title"><a id="_virtualized_system"/>9.11. Virtualized system</h2> </div> </div> </div> <p>Use of virtualized system enables us to run multiple instances of system simultaneously on a single hardware.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>See <a class="ulink" href="https://wiki.debian.org/SystemVirtualization">Debian wiki on SystemVirtualization</a>.</p> </td> </tr> </table> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_virtualization_tools"/>9.11.1. Virtualization and emulation tools</h3> </div> </div> </div> <p>There are several <a class="ulink" href="https://en.wikipedia.org/wiki/Virtualization">virtualization</a> and emulation tool platforms.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Complete <a class="ulink" href="https://en.wikipedia.org/wiki/Hardware_emulation">hardware emulation</a> packages such as ones installed by the <a class="ulink" href="https://packages.debian.org/sid/games-emulator">games-emulator</a> metapackage</p> </li> <li class="listitem"> <p> Mostly CPU level emulation with some I/O device emulations such as <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> </p> </li> <li class="listitem"> <p> Mostly CPU level virtualization with some I/O device emulations such as <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">Kernel-based Virtual Machine (KVM)</a> </p> </li> <li class="listitem"> <p> OS level container virtualization with the kernel level support such as <a class="ulink" href="https://en.wikipedia.org/wiki/LXC">LXC (Linux Containers)</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/Docker_(software)">Docker</a>, <code class="literal">systemd-nspawn</code>(1), ... </p> </li> <li class="listitem"> <p> OS level filesystem access virtualization with the system library call override on the file path such as <a class="ulink" href="https://en.wikipedia.org/wiki/Chroot">chroot</a> </p> </li> <li class="listitem"> <p> OS level filesystem access virtualization with the system library call override on the file ownership such as <a class="ulink" href="https://en.wikipedia.org/wiki/">fakeroot</a> </p> </li> <li class="listitem"> <p> OS API emulation such as <a class="ulink" href="https://en.wikipedia.org/wiki/Wine_(software)">Wine</a> </p> </li> <li class="listitem"> <p> Interpreter level virtualization with its executable selection and run-time library overrides such as <a class="ulink" href="https://virtualenv.pypa.io/">virtualenv</a> and <a class="ulink" href="https://docs.python.org/3/library/venv.html">venv</a> for Python </p> </li> </ul> </div> <p>The container virtualization uses <a class="xref" href="ch04.en.html#_linux_security_features" title="4.7.5. Linux security features">Section 4.7.5, “Linux security features”</a> and is the backend technology of <a class="xref" href="ch07.en.html#_sandbox" title="7.7. Sandbox">Section 7.7, “Sandbox”</a>.</p> <p>Here are some packages to help you to setup the virtualized system.</p> <div class="table"> <a id="listofvirtualizationtools"/> <p class="title"> <strong>Table 9.27. List of virtualization tools</strong> </p> <div class="table-contents"> <table class="table" summary="List of virtualization tools" border="1"> <colgroup> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> <col style="text-align: left"/> </colgroup> <thead> <tr> <th style="text-align: left"> package </th> <th style="text-align: left"> popcon </th> <th style="text-align: left"> size </th> <th style="text-align: left"> description </th> </tr> </thead> <tbody> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/coreutils"> <code class="literal">coreutils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=coreutils">V:880, I:999</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/coreutils">18307</a> </td> <td style="text-align: left"> GNU core utilities which contain <code class="literal">chroot</code>(8) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/systemd-container"> <code class="literal">systemd-container</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=systemd-container">V:53, I:61</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/systemd-container">1330</a> </td> <td style="text-align: left"> systemd container/nspawn tools which contain <code class="literal">systemd-nspawn</code>(1) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/schroot"> <code class="literal">schroot</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=schroot">V:5, I:7</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/schroot">2579</a> </td> <td style="text-align: left"> specialized tool for executing Debian binary packages in chroot </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/sbuild"> <code class="literal">sbuild</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=sbuild">V:1, I:3</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/sbuild">243</a> </td> <td style="text-align: left"> tool for building Debian binary packages from Debian sources </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/debootstrap"> <code class="literal">debootstrap</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=debootstrap">V:5, I:54</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/debootstrap">314</a> </td> <td style="text-align: left"> bootstrap a basic Debian system (written in sh) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cdebootstrap"> <code class="literal">cdebootstrap</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cdebootstrap">V:0, I:1</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cdebootstrap">115</a> </td> <td style="text-align: left"> bootstrap a Debian system (written in C) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cloud-image-utils"> <code class="literal">cloud-image-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cloud-image-utils">V:1, I:17</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cloud-image-utils">66</a> </td> <td style="text-align: left"> cloud image management utilities </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/cloud-guest-utils"> <code class="literal">cloud-guest-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=cloud-guest-utils">V:3, I:13</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/cloud-guest-utils">71</a> </td> <td style="text-align: left"> cloud guest utilities </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/virt-manager"> <code class="literal">virt-manager</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=virt-manager">V:11, I:44</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/virt-manager">2296</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Virt-manager">Virtual Machine Manager</a>: desktop application for managing virtual machines </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/libvirt-clients"> <code class="literal">libvirt-clients</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=libvirt-clients">V:46, I:65</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/libvirt-clients">1241</a> </td> <td style="text-align: left"> programs for the <a class="ulink" href="https://en.wikipedia.org/wiki/Libvirt">libvirt</a> library </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/incus"> <code class="literal">incus</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=incus">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/incus">56209</a> </td> <td style="text-align: left"> <a class="ulink" href="https://wiki.debian.org/Incus">Incus</a>: system container and virtual machine manager (for Debian 13 "Trixie") </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/lxd"> <code class="literal">lxd</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=lxd">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/lxd">52119</a> </td> <td style="text-align: left"> <a class="ulink" href="https://wiki.debian.org/LXD">LXD</a>: system container and virtual machine manager (for Debian 12 "Bookworm") </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/podman"> <code class="literal">podman</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=podman">V:14, I:16</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/podman">41948</a> </td> <td style="text-align: left"> <a class="ulink" href="https://podman.io/">podman</a>: engine to run OCI-based containers in Pods </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/podman-docker"> <code class="literal">podman-docker</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=podman-docker">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/podman-docker">249</a> </td> <td style="text-align: left"> engine to run OCI-based containers in Pods - wrapper for docker </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/docker.io"> <code class="literal">docker.io</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=docker.io">V:41, I:43</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/docker.io">150003</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Docker_(software)">docker</a>: Linux container runtime </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/games-emulator"> <code class="literal">games-emulator</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=games-emulator">I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/games-emulator">21</a> </td> <td style="text-align: left"> <a class="ulink" href="https://packages.debian.org/sid/games-emulator">games-emulator</a>: Debian's emulators for games </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/bochs"> <code class="literal">bochs</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=bochs">V:0, I:0</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/bochs">6956</a> </td> <td style="text-align: left"><a class="ulink" href="https://en.wikipedia.org/wiki/Bochs">Bochs</a>: IA-32 PC emulator </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/qemu"> <code class="literal">qemu</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=qemu">I:14</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/qemu">97</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>: fast generic processor emulator </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/qemu-system"> <code class="literal">qemu-system</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=qemu-system">I:22</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/qemu-system">66</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>: full system emulation binaries </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/qemu-user"> <code class="literal">qemu-user</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=qemu-user">V:1, I:6</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/qemu-user">93760</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>: user mode emulation binaries </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/qemu-utils"> <code class="literal">qemu-utils</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=qemu-utils">V:12, I:106</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/qemu-utils">10635</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>: utilities </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/qemu-system-x86"> <code class="literal">qemu-system-x86</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=qemu-system-x86">V:33, I:91</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/qemu-system-x86">58140</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a>: full virtualization on x86 hardware with the <a class="ulink" href="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</a> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/virtualbox"> <code class="literal">virtualbox</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=virtualbox">V:6, I:8</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/virtualbox">130868</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/VirtualBox">VirtualBox</a>: x86 virtualization solution on i386 and amd64 </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/gnome-boxes"> <code class="literal">gnome-boxes</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=gnome-boxes">V:1, I:7</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/gnome-boxes">6691</a> </td> <td style="text-align: left"> <a class="ulink" href="https://wiki.gnome.org/Apps/Boxes">Boxes</a>: Simple GNOME app to access virtual systems </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/xen-tools"> <code class="literal">xen-tools</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=xen-tools">V:0, I:2</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/xen-tools">719</a> </td> <td style="text-align: left"> tools to manage debian <a class="ulink" href="https://en.wikipedia.org/wiki/Xen">XEN</a> virtual server </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/wine"> <code class="literal">wine</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=wine">V:13, I:60</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/wine">132</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/Wine_(software)">Wine</a>: Windows API Implementation (standard suite) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/dosbox"> <code class="literal">dosbox</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=dosbox">V:1, I:15</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/dosbox">2696</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/DOSBox">DOSBox</a>: x86 emulator with Tandy/Herc/CGA/EGA/VGA/SVGA graphics, sound and DOS </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/lxc"> <code class="literal">lxc</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=lxc">V:9, I:12</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/lxc">25890</a> </td> <td style="text-align: left"> <a class="ulink" href="https://en.wikipedia.org/wiki/LXC">Linux containers user space tools</a> </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/python3-venv"> <code class="literal">python3-venv</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=python3-venv">I:88</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/python3-venv">6</a> </td> <td style="text-align: left"> <a class="ulink" href="https://docs.python.org/3/library/venv.html">venv</a> for creating virtual python environments (system library) </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/python3-virtualenv"> <code class="literal">python3-virtualenv</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=python3-virtualenv">V:9, I:50</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/python3-virtualenv">356</a> </td> <td style="text-align: left"> <a class="ulink" href="https://virtualenv.pypa.io/">virtualenv</a> for creating isolated virtual python environments </td> </tr> <tr> <td style="text-align: left"> <a class="ulink" href="http://packages.debian.org/sid/pipx"> <code class="literal">pipx</code> </a> </td> <td style="text-align: left"> <a class="ulink" href="http://qa.debian.org/popcon-graph.php?packages=pipx">V:3, I:19</a> </td> <td style="text-align: left"> <a class="ulink" href="https://tracker.debian.org/pkg/pipx">3324</a> </td> <td style="text-align: left"> <a class="ulink" href="https://pipx.pypa.io/">pipx</a> for installing python applications in isolated environments </td> </tr> </tbody> </table> </div> </div> <br class="table-break"/> <p>See Wikipedia article <a class="ulink" href="https://en.wikipedia.org/wiki/Comparison_of_platform_virtual_machines">Comparison of platform virtual machines</a> for detail comparison of different platform virtualization solutions.</p> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_virtualization_work_flow"/>9.11.2. Virtualization work flow</h3> </div> </div> </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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>Default Debian kernels support <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a> since <code class="literal">lenny</code>.</p> </td> </tr> </table> </div> <p>Typical work flow for <a class="ulink" href="https://en.wikipedia.org/wiki/Virtualization">virtualization</a> involves several steps.</p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> Create an empty filesystem (a file tree or a disk image). </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> The file tree can be created by "<code class="literal">mkdir -p /path/to/chroot</code>". </p> </li> <li class="listitem"> <p> The raw disk image file can be created with <code class="literal">dd</code>(1) (see <a class="xref" href="ch09.en.html#_making_the_disk_image_file" title="9.7.1. Making the disk image file">Section 9.7.1, “Making the disk image file”</a> and <a class="xref" href="ch09.en.html#_making_the_empty_disk_image_file" title="9.7.5. Making the empty disk image file">Section 9.7.5, “Making the empty disk image file”</a>). </p> </li> <li class="listitem"> <p><code class="literal">qemu-img</code>(1) can be used to create and convert disk image files supported by <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>. </p> </li> <li class="listitem"> <p> The raw and <a class="ulink" href="https://en.wikipedia.org/wiki/VMDK">VMDK</a> file format can be used as common format among virtualization tools. </p> </li> </ul> </div> </li> <li class="listitem"> <p> Mount the disk image with <code class="literal">mount</code>(8) to the filesystem (optional). </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> For the raw disk image file, mount it as <a class="ulink" href="https://en.wikipedia.org/wiki/Loop_device">loop device</a> or <a class="ulink" href="https://en.wikipedia.org/wiki/Device_mapper">device mapper</a> devices (see <a class="xref" href="ch09.en.html#_mounting_the_disk_image_file" title="9.7.3. Mounting the disk image file">Section 9.7.3, “Mounting the disk image file”</a>). </p> </li> <li class="listitem"> <p> For disk images supported by <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>, mount them as <a class="ulink" href="https://en.wikipedia.org/wiki/Network_block_device">network block device</a> (see <a class="xref" href="ch09.en.html#_mounting_the_virtual_disk_image_file" title="9.11.3. Mounting the virtual disk image file">Section 9.11.3, “Mounting the virtual disk image file”</a>). </p> </li> </ul> </div> </li> <li class="listitem"> <p> Populate the target filesystem with required system data. </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p> The use of programs such as <code class="literal">debootstrap</code> and <code class="literal">cdebootstrap</code> helps with this process (see <a class="xref" href="ch09.en.html#_chroot_system" title="9.11.4. Chroot system">Section 9.11.4, “Chroot system”</a>). </p> </li> <li class="listitem"> <p> Use installers of OSs under the full system emulation. </p> </li> </ul> </div> </li> <li class="listitem"> <p> Run a program under a virtualized environment. </p> <div class="itemizedlist"> <ul class="itemizedlist"> <li class="listitem"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Chroot">chroot</a> provides basic virtualized environment enough to compile programs, run console applications, and run daemons in it. </p> </li> <li class="listitem"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> provides cross-platform CPU emulation. </p> </li> <li class="listitem"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> with <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a> provides full system emulation by the <a class="ulink" href="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</a>. </p> </li> <li class="listitem"> <p><a class="ulink" href="https://en.wikipedia.org/wiki/VirtualBox">VirtualBox</a> provides full system emulation on i386 and amd64 with or without the <a class="ulink" href="https://en.wikipedia.org/wiki/Hardware-assisted_virtualization">hardware-assisted virtualization</a>. </p> </li> </ul> </div> </li> </ul> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_mounting_the_virtual_disk_image_file"/>9.11.3. Mounting the virtual disk image file</h3> </div> </div> </div> <p>For the raw disk image file, see <a class="xref" href="ch09.en.html#_the_disk_image" title="9.7. The disk image">Section 9.7, “The disk image”</a>.</p> <p>For other virtual disk image files, you can use <code class="literal">qemu-nbd</code>(8) to export them using <a class="ulink" href="https://en.wikipedia.org/wiki/Network_block_device">network block device</a> protocol and mount them using the <code class="literal">nbd</code> kernel module.</p> <p><code class="literal">qemu-nbd</code>(8) supports disk formats supported by <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a>: raw, <a class="ulink" href="https://en.wikipedia.org/wiki/Qcow">qcow2, qcow</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/VMDK">vmdk</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/VirtualBox#Virtual_Desktop_Image">vdi</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/Bochs">bochs</a>, cow (user-mode Linux copy-on-write), <a class="ulink" href="https://en.wikipedia.org/wiki/Parallels_Workstation">parallels</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/Apple_Disk_Image">dmg</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/Cloop">cloop</a>, <a class="ulink" href="https://en.wikipedia.org/wiki/VHD_(file_format)">vpc</a>, vvfat (virtual VFAT), and host_device.</p> <p>The <a class="ulink" href="https://en.wikipedia.org/wiki/Network_block_device">network block device</a> can support partitions in the same way as the <a class="ulink" href="https://en.wikipedia.org/wiki/Loop_device">loop device</a> (see <a class="xref" href="ch09.en.html#_mounting_the_disk_image_file" title="9.7.3. Mounting the disk image file">Section 9.7.3, “Mounting the disk image file”</a>). You can mount the first partition of "<code class="literal">disk.img</code>" as follows.</p> <pre class="screen"># modprobe nbd max_part=16 # qemu-nbd -v -c /dev/nbd0 disk.img ... # mkdir /mnt/part1 # mount /dev/nbd0p1 /mnt/part1</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>You may export only the first partition of "<code class="literal">disk.img</code>" using "<code class="literal">-P 1</code>" option to <code class="literal">qemu-nbd</code>(8).</p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_chroot_system"/>9.11.4. Chroot system</h3> </div> </div> </div> <p>If you wish to try a new Debian environment from a terminal console, I recommend you to use <a class="ulink" href="https://en.wikipedia.org/wiki/Chroot">chroot</a>. This enables you to run console applications of Debian <code class="literal">unstable</code> and <code class="literal">testing</code> without usual risks associated and without rebooting. <code class="literal">chroot</code>(8) is the most basic way.</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"> <img alt="[Caution]" src="images/caution.png"/> </td> <th align="left">Caution</th> </tr> <tr> <td align="left" valign="top"> <p>Examples below assumes both parent system and chroot system share the same <code class="literal">amd64</code> CPU architecture.</p> </td> </tr> </table> </div> <p>Although you can manually create a <code class="literal">chroot</code>(8) environment using <code class="literal">debootstrap</code>(1), this requires non-trivial efforts.</p> <p>The <a class="ulink" href="https://packages.debian.org/search?keywords=sbuild">sbuild</a> package to build Debian packages from source uses the chroot environment managed by the <a class="ulink" href="https://packages.debian.org/search?keywords=schroot">schroot</a> package. It comes with helper script <code class="literal">sbuild-createchroot</code>(1). Let's learn how it works by running it as follows.</p> <pre class="screen">$ sudo mkdir -p /srv/chroot $ sudo sbuild-createchroot -v --include=eatmydata,ccache unstable /srv/chroot/unstable-amd64-sbuild http://deb.debian.org/debian ...</pre> <p>You see how <code class="literal">debootstrap</code>(8) populates system data for <code class="literal">unstable</code> environment under "<code class="literal">/srv/chroot/unstable-amd64-sbuild</code>" for a minimal build system.</p> <p>You can login to this environment using <code class="literal">schroot</code>(1).</p> <pre class="screen">$ sudo schroot -v -c chroot:unstable-amd64-sbuild</pre> <p>You see how a system shell running under <code class="literal">unstable</code> environment is created.</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"> <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">/usr/sbin/policy-rc.d</code>" file which always exits with 101 prevents daemon programs to be started automatically on the Debian system. See "<code class="literal">/usr/share/doc/init-system-helpers/README.policy-rc.d.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"> <img alt="[Note]" src="images/note.png"/> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p>Some programs under chroot may require access to more files from the parent system to function than <code class="literal">sbuild-createchroot</code> provides as above. For example, "<code class="literal">/sys</code>", "<code class="literal">/etc/passwd</code>", "<code class="literal">/etc/group</code>", "<code class="literal">/var/run/utmp</code>", "<code class="literal">/var/log/wtmp</code>", etc. may need to be bind-mounted or copied.</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="literal">sbuild</code> package helps to construct a chroot system and builds a package inside the chroot using <code class="literal">schroot</code> as its backend. It is an ideal system to check build-dependencies. See more on <a class="ulink" href="https://wiki.debian.org/sbuild">sbuild at Debian wiki</a> and <a class="ulink" href="https://www.debian.org/doc/manuals/debmake-doc/ch03.en.html#sbuild-setup">sbuild configuration example in "Guide for Debian Maintainers"</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>The <code class="literal">systemd-nspawn</code>(1) command helps to run a command or OS in a light-weight container in similar ways to <code class="literal">chroot</code>. It is more powerful since it uses namespaces to fully virtualize the the process tree, IPC, hostname, domain name and, optionally, networking and user databases. See <a class="ulink" href="https://wiki.debian.org/nspawn">systemd-nspawn</a>. </p> </td> </tr> </table> </div> </div> <div class="section"> <div class="titlepage"> <div> <div> <h3 class="title"><a id="_multiple_desktop_systems"/>9.11.5. Multiple desktop systems</h3> </div> </div> </div> <p>If you wish to try a new GUI Desktop environment of any OS, I recommend you to use <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> or <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a> on a Debian <code class="literal">stable</code> system to run multiple desktop systems safely using <a class="ulink" href="https://en.wikipedia.org/wiki/Virtualization">virtualization</a>. These enable you to run any desktop applications including ones of Debian <code class="literal">unstable</code> and <code class="literal">testing</code> without usual risks associated with them and without rebooting.</p> <p>Since pure <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> is very slow, it is recommended to accelerate it with <a class="ulink" href="https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine">KVM</a> when the host system supports it.</p> <p><a class="ulink" href="https://en.wikipedia.org/wiki/Virt-manager">Virtual Machine Manager</a> also known as <code class="literal">virt-manager</code> is a convenient GUI tool for managing KVM virtual machines via <a class="ulink" href="https://en.wikipedia.org/wiki/Libvirt">libvirt</a>.</p> <p>The virtual disk image "<code class="literal">virtdisk.qcow2</code>" containing a Debian system for <a class="ulink" href="https://en.wikipedia.org/wiki/QEMU">QEMU</a> can be created using <a class="ulink" href="https://www.debian.org/distrib/netinst">debian-installer: Small CDs</a> as follows.</p> <pre class="screen">$ wget https://cdimage.debian.org/debian-cd/5.0.3/amd64/iso-cd/debian-503-amd64-netinst.iso $ qemu-img create -f qcow2 virtdisk.qcow2 5G $ qemu -hda virtdisk.qcow2 -cdrom debian-503-amd64-netinst.iso -boot d -m 256 ...</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"> <img alt="[Tip]" src="images/tip.png"/> </td> <th align="left">Tip</th> </tr> <tr> <td align="left" valign="top"> <p>Running other GNU/Linux distributions such as <a class="ulink" href="https://www.ubuntu.com/">Ubuntu</a> and <a class="ulink" href="https://fedoraproject.org/">Fedora</a> under <a class="ulink" href="https://en.wikipedia.org/wiki/Virtualization">virtualization</a> is a great way to learn configuration tips. Other proprietary OSs may be run nicely under this GNU/Linux <a class="ulink" href="https://en.wikipedia.org/wiki/Virtualization">virtualization</a>, too.</p> </td> </tr> </table> </div> <p>See more tips at <a class="ulink" href="https://wiki.debian.org/SystemVirtualization">Debian wiki: SystemVirtualization</a>.</p> </div> </div> <div class="footnotes"> <br/> <hr/> <div id="ftn.idm14510" class="footnote"> <p><a href="#idm14510" class="para"><sup class="para">[2] </sup></a>More elaborate customization examples: "<a class="ulink" href="https://github.com/mhinz/vim-galore">Vim Galore</a>", "<a class="ulink" href="https://github.com/tpope/vim-sensible">sensible.vim</a>", ... </p> </div> <div id="ftn.idm14569" class="footnote"> <p><a href="#idm14569" class="para"><sup class="para">[3] </sup></a> <a class="ulink" href="https://packages.debian.org/unstable/vim-pathogen">vim-pathogen</a> was popular. </p> </div> </div> </div> <div class="navfooter"> <hr/> <table width="100%" summary="Navigation footer"> <tr> <td align="left"><a accesskey="p" href="ch08.en.html"><img src="images/prev.png" alt="Prev"/></a> </td> <td align="center"> </td> <td align="right"> <a accesskey="n" href="ch10.en.html"><img src="images/next.png" alt="Next"/></a></td> </tr> <tr> <td align="left" valign="top">Chapter 8. I18N and L10N </td> <td align="center"> <a accesskey="h" href="index.en.html"> <img src="images/home.png" alt="Home"/> </a> </td> <td align="right" valign="top"> Chapter 10. Data management</td> </tr> </table> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10