• Debian Reference



  •   


  • FileName: reference.en.pdf


Debian Reference
Osamu Aoki
‘Authors’ on page 247
CVS, Thu Jan 18 11:52:15 UTC 2007
Abstract
This Debian Reference (http://qref.sourceforge.net/) is intended to provide a broad
overview of the Debian system as a post-installation user’s guide. It covers many aspects
of system administration through shell-command examples. Basic tutorials, tips, and other
information are provided for topics including fundamental concepts of the Debian system,
system installation hints, Debian package management, the Linux kernel under Debian, system
tuning, building a gateway, text editors, CVS, programming, and GnuPG for non-developers.
Copyright Notice
Copyright © 2001–2005 by Osamu Aoki .
Copyright (Chapter 2) © 1996–2001 by Software in the Public Interest.
This document may be used under the terms of the GNU General Public License version 2 or
higher. (http://www.gnu.org/copyleft/gpl.html)
Permission is granted to make and distribute verbatim copies of this document provided the
copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this document under the
conditions for verbatim copying, provided that the entire resulting derived work is distributed
under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this document into another lan-
guage, under the above conditions for modified versions, except that this permission notice
may be included in translations approved by the Free Software Foundation instead of in the
original English.
i
Contents
1 Preface 1
1.1 Official document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Document conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Example scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 Basic setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 Basics of the Debian distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Debian fundamentals 5
2.1 The Debian archives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1 Directory structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2 Debian distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 The stable distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.4 The testing distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.5 The unstable distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.6 The frozen distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.7 Debian distribution codenames . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.8 Codenames used in the past . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.9 The source for codenames . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.10 The pool directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.11 Historical notes about Sid . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.12 Uploaded packages in incoming/ . . . . . . . . . . . . . . . . . . . . . . 9
2.1.13 Retrieving an older package . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.14 Architecture sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.15 The source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
CONTENTS ii
2.2 The Debian package management system . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 Overview of Debian packages . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.2 Debian package format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.3 Naming conventions for Debian package filenames . . . . . . . . . . . . . 12
2.2.4 Preservation of local configuration . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.5 Debian maintenance scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2.6 Package priorities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.7 Virtual packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.8 Package dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2.9 The meaning of “Pre-Depends” . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.10 Package status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.2.11 Holding back packages from an upgrade . . . . . . . . . . . . . . . . . . . 16
2.2.12 Source packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2.13 Building binary packages from a source package . . . . . . . . . . . . . . . 17
2.2.14 Creating new Debian packages . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3 Upgrading a Debian system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.1 dpkg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.2 APT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.3 dselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.4 Upgrading a running system . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.5 Downloaded and cached .deb archive files . . . . . . . . . . . . . . . . . . 19
2.3.6 Record-keeping for upgrades . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4 The Debian boot process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.1 The init program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.2 Runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.3 Customizing runlevels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5 Supporting diversity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.7 Debian and the kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.7.1 Compiling a kernel from non-Debian source . . . . . . . . . . . . . . . . . 22
2.7.2 Tools to build custom kernels . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.7.3 Special provisions for dealing with modules . . . . . . . . . . . . . . . . . 23
2.7.4 De-installing an old kernel package . . . . . . . . . . . . . . . . . . . . . . 23
CONTENTS iii
3 Debian System installation hints 25
3.1 General Linux system installation hints . . . . . . . . . . . . . . . . . . . . . . . . 25
3.1.1 Hardware compatibility basics . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.1.2 Determining a PC’s hardware and chip set . . . . . . . . . . . . . . . . . . 26
3.1.3 Determining a PC’s hardware via Debian . . . . . . . . . . . . . . . . . . . 26
3.1.4 Determining a PC’s hardware via other OSs . . . . . . . . . . . . . . . . . 27
3.1.5 A Lilo myth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.1.6 GRUB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.7 Choice of boot floppies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.8 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.1.9 Hosts and IP to use for LAN . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.1.10 User accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.1.11 Creating filesystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.1.12 DRAM memory guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.1.13 Swap space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.2 Bash configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3 Mouse configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3.1 PS/2 mice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3.2 USB mice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.3.3 Touchpad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.4 NFS configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.5 Samba configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.6 Printer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.1 lpr/lpd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.6.2 CUPS™ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.7 CRON for desktop PCs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.8 Other host installation hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.8.1 Install a few more packages after initial install . . . . . . . . . . . . . . . . 40
3.8.2 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.8.3 CD-RW basic setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.8.4 Large memory and auto power-off . . . . . . . . . . . . . . . . . . . . . . . 41
CONTENTS iv
3.8.5 Strange access problems with some websites . . . . . . . . . . . . . . . . . 42
3.8.6 Dialup PPP configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.8.7 Other configuration files to tweak in /etc/ . . . . . . . . . . . . . . . . . 43
4 Debian tutorials 45
4.1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.1 Login to a shell prompt as root . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.1.2 Set up minimal newbie environment . . . . . . . . . . . . . . . . . . . . . . 46
4.1.3 Add a user account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.4 Switch between virtual console . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.5 How to shut down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.1.6 Play time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.2 Midnight Commander (MC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.2.1 Enhance MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2.2 Start MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2.3 File manager in MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2.4 Command-line tricks in MC . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.2.5 Editor in MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2.6 Viewer in MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2.7 Auto-start features of MC . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.2.8 FTP virtual filesystem of MC . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.3 Unix-like work environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.3.1 Special key strokes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.3.2 Basic Unix commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3.3 The command execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.3.4 Simple command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
4.3.5 Command execution and environment variable . . . . . . . . . . . . . . . 56
4.3.6 Command search path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.3.7 Command line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.3.8 Shell wildcards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
4.3.9 Return value of the command . . . . . . . . . . . . . . . . . . . . . . . . . . 58
CONTENTS v
4.3.10 Typical command sequences . . . . . . . . . . . . . . . . . . . . . . . . . . 58
4.3.11 Command alias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.4 Unix-like text processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.4.1 Regular expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.4.2 Replacement expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
4.5 Unix-like filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.5.1 Unix file basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4.5.2 The filesystem concept in Debian . . . . . . . . . . . . . . . . . . . . . . . . 64
4.5.3 File and directory access permissions . . . . . . . . . . . . . . . . . . . . . 65
4.5.4 Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.5.5 Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.5.6 Named pipes (FIFOs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.5.7 Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.5.8 Device files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.5.9 /proc filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.6 X Window System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.6.1 Start the X Window System . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.2 Menu in the X Window System . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.6.3 Keyboard sequence for the X Window System . . . . . . . . . . . . . . . . 71
4.7 Further study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
5 Upgrading a distribution to stable, testing, or unstable 73
5.1 Upgrading from Potato to Woody . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
5.2 Preparing for upgrade . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.3 Upgrading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.3.1 Using dselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
5.3.2 Using apt-get . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
6 Debian package management 77
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
6.1.1 Main package management tools . . . . . . . . . . . . . . . . . . . . . . . . 78
6.1.2 Convenience tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
CONTENTS vi
6.2 Beginning Debian package management . . . . . . . . . . . . . . . . . . . . . . . . 78
6.2.1 Set up APT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.2.2 Installing tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.2.3 aptitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
6.2.4 dselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
6.2.5 Tracking a distribution using APT . . . . . . . . . . . . . . . . . . . . . . . 80
6.2.6 aptitude, apt-get and apt-cache commands . . . . . . . . . . . . . . 81
6.3 Debian survival commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.3.1 Check bugs in Debian and seek help . . . . . . . . . . . . . . . . . . . . . . 83
6.3.2 APT upgrade troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.3.3 Rescue using dpkg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.3.4 Recover package selection data . . . . . . . . . . . . . . . . . . . . . . . . . 84
6.3.5 Rescue system after crashing /var . . . . . . . . . . . . . . . . . . . . . . . 85
6.3.6 Install a package into an unbootable system . . . . . . . . . . . . . . . . . 85
6.3.7 What to do if the dpkg command is broken . . . . . . . . . . . . . . . . . . 86
6.4 Debian nirvana commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.4.1 Information on a file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
6.4.2 Information on a package . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
6.4.3 Unattended installation with APT . . . . . . . . . . . . . . . . . . . . . . . 87
6.4.4 Reconfigure installed packages . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.4.5 Remove and purge packages . . . . . . . . . . . . . . . . . . . . . . . . . . 88
6.4.6 Holding older packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.4.7 Mixed stable/testing/unstable system . . . . . . . . . . . . . . . . 89
6.4.8 Prune cached package files . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
6.4.9 Record/copy system configuration . . . . . . . . . . . . . . . . . . . . . . . 90
6.4.10 Port a package to the stable system . . . . . . . . . . . . . . . . . . . . . 90
6.4.11 Local package archive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.4.12 Convert or install an alien binary package . . . . . . . . . . . . . . . . . . . 92
6.4.13 Automatically install command . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.4.14 Verify installed package files . . . . . . . . . . . . . . . . . . . . . . . . . . 92
6.4.15 Optimized sources.list . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
CONTENTS vii
6.5 Other Debian peculiarities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
6.5.1 The dpkg-divert command . . . . . . . . . . . . . . . . . . . . . . . . . . 93
6.5.2 The equivs package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
6.5.3 Alternative commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
6.5.4 Runlevel usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
6.5.5 Disabled daemon services . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7 The Linux kernel under Debian 95
7.1 Kernel (re)compile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.1.1 Kernel headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
7.2 Tuning the kernel through the proc filesystem . . . . . . . . . . . . . . . . . . . . 96
7.2.1 Too many open files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.2.2 Disk flush intervals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.2.3 Sluggish old low memory machines . . . . . . . . . . . . . . . . . . . . . . 97
7.3 The 2.6 kernel with udev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8 Debian tips 99
8.1 Booting the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
8.1.1 “I forgot the root password!” (1) . . . . . . . . . . . . . . . . . . . . . . . . 99
8.1.2 “I forgot the root password!” (2) . . . . . . . . . . . . . . . . . . . . . . . . 100
8.1.3 Cannot boot the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
8.1.4 “Let me disable X on boot!” . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
8.1.5 Other boot tricks with the boot prompt . . . . . . . . . . . . . . . . . . . . 101
8.1.6 Setting GRUB boot parameters . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.2 Recording activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.2.1 Recording shell activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
8.2.2 Recording X activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
8.3 Copy and archive a whole subdirectory . . . . . . . . . . . . . . . . . . . . . . . . 103
8.3.1 Basic commands for copying a whole subdirectory . . . . . . . . . . . . . 103
8.3.2 cp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.3.3 tar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
8.3.4 pax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
CONTENTS viii
8.3.5 cpio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.3.6 afio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
8.4 Differential backup and data synchronization . . . . . . . . . . . . . . . . . . . . . 105
8.4.1 Differential backup with rdiff . . . . . . . . . . . . . . . . . . . . . . . . . . 106
8.4.2 Daily backup with pdumpfs . . . . . . . . . . . . . . . . . . . . . . . . . . 106
8.4.3 Regular differential backup with RCS . . . . . . . . . . . . . . . . . . . . . 106
8.5 System freeze recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.5.1 Kill a process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.5.2 Alt-SysRq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.6 Nifty little commands to remember . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.6.1 Pager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
8.6.2 Free memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.6.3 Set time (BIOS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.6.4 Set time (NTP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
8.6.5 How to control console features such as the screensaver . . . . . . . . . . 109
8.6.6 Search administrative database . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.6.7 Disable sound (beep) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
8.6.8 Error messages on the console screen . . . . . . . . . . . . . . . . . . . . . 110
8.6.9 Set console to the correct type . . . . . . . . . . . . . . . . . . . . . . . . . . 110
8.6.10 Get the console back to a sane state . . . . . . . . . . . . . . . . . . . . . . . 110
8.6.11 Convert a text file from DOS to Unix style . . . . . . . . . . . . . . . . . . . 111
8.6.12 Convert a text file with recode . . . . . . . . . . . . . . . . . . . . . . . . 111
8.6.13 Regular-expression substitution . . . . . . . . . . . . . . . . . . . . . . . . 112
8.6.14 Edit a file in place using a script . . . . . . . . . . . . . . . . . . . . . . . . 112
8.6.15 Extract differences and merge updates for source files . . . . . . . . . . . . 112
8.6.16 Convert a large file into small files . . . . . . . . . . . . . . . . . . . . . . . 113
8.6.17 Extract data from text file table . . . . . . . . . . . . . . . . . . . . . . . . . 113
8.6.18 Script snippets for piping commands . . . . . . . . . . . . . . . . . . . . . 114
8.6.19 Script snippets for looping over each file . . . . . . . . . . . . . . . . . . . 115
8.6.20 Perl short script madness . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
8.6.21 Get text or a mailing list archive from a web page . . . . . . . . . . . . . . 116
CONTENTS ix
8.6.22 Pretty print a web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.6.23 Pretty print a manual page . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.6.24 Merge two PostScript or PDF files . . . . . . . . . . . . . . . . . . . . . . . 117
8.6.25 Time a command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.6.26 nice command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
8.6.27 Schedule activity (cron, at) . . . . . . . . . . . . . . . . . . . . . . . . . . 118
8.6.28 Console switching with screen . . . . . . . . . . . . . . . . . . . . . . . . 118
8.6.29 Network testing basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
8.6.30 Flush mail from local spool . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
8.6.31 Remove frozen mail from local spool . . . . . . . . . . . . . . . . . . . . . 120
8.6.32 Redeliver mbox contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
8.6.33 Clear file contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
8.6.34 Dummy files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
8.6.35 chroot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
8.6.36 How to check hard links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
8.6.37 mount hard disk image file . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.6.38 Samba . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.6.39 Utilities for foreign filesystems . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.7 Typical mistakes to be noted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
8.7.1 rm -rf .* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
8.7.2 rm /etc/passwd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
9 Tuning a Debian system 127
9.1 System initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.1.1 Customizing init scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.1.2 Customizing system logging . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.1.3 Optimizing hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.2 Restricting access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
9.2.1 Restricting logins with PAM . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
9.2.2 “Why GNU su does not support the wheel group” . . . . . . . . . . . . . 130
9.2.3 Purposes of standard groups . . . . . . . . . . . . . . . . . . . . . . . . . . 130
CONTENTS x
9.2.4 Working more safely – sudo . . . . . . . . . . . . . . . . . . . . . . . . . . 131
9.2.5 Restricting access to services . . . . . . . . . . . . . . . . . . . . . . . . . . 131
9.2.6 Centralizing authentication – LDAP . . . . . . . . . . . . . . . . . . . . . . 132
9.3 CD writers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
9.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
9.3.2 Approach 1: modules + lilo . . . . . . . . . . . . . . . . . . . . . . . . . . 133
9.3.3 Approach 2: recompile the kernel . . . . . . . . . . . . . . . . . . . . . . . 133
9.3.4 Post-configuration steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
9.3.5 CD-image file (bootable) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
9.3.6 Write to the CD-writer (R, RW): . . . . . . . . . . . . . . . . . . . . . . . . . 135
9.3.7 Make an image file of a CD . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
9.3.8 Debian CD images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
9.3.9 Back up the system to CD-R . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.3.10 Copy a music CD to CD-R . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.3.11 Writing DVD-R, DVD-RW, and DVD+RW . . . . . . . . . . . . . . . . . . . 137
9.4 X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
9.4.1 X packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
9.4.2 Hardware detection for X . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
9.4.3 The X server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
9.4.4 X clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
9.4.5 X sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
9.4.6 Using X over TCP/IP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
9.4.7 Connecting to a remote X server – xhost . . . . . . . . . . . . . . . . . . . 146
9.4.8 Connecting to a remote X server – ssh . . . . . . . . . . . . . . . . . . . . 146
9.4.9 The X terminal emulator – xterm . . . . . . . . . . . . . . . . . . . . . . . 147
9.4.10 X resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
9.4.11 Keymaps and pointer button mappings in X . . . . . . . . . . . . . . . . . 148
9.4.12 Getting root in X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
9.4.13 TrueType fonts in X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
9.4.14 Web browsers in X . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.4.15 Mail Clients (MUAs) in X . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
CONTENTS xi
9.5 SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.5.1 Basics of SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.5.2 Port forwarding for SMTP/POP3 tunneling . . . . . . . . . . . . . . . . . 154
9.5.3 Connecting with fewer passwords – RSA . . . . . . . . . . . . . . . . . . . 155
9.5.4 Dealing with alien SSH clients . . . . . . . . . . . . . . . . . . . . . . . . . 155
9.5.5 Setting up ssh-agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
9.5.6 Troubleshooting SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
9.6 Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
9.6.1 Mail transport agents (MTAs) . . . . . . . . . . . . . . . . . . . . . . . . . . 157
9.6.2 Fetching mail – Fetchmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
9.6.3 Processing mail – Procmail . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.6.4 Processing spam with crm114 . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.6.5 Reading mail – Mutt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.7 Localization (l10n) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.7.1 Basics of localization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
9.7.2 Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
9.7.3 Introduction to locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
9.7.4 Activating locale support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
9.7.5 Activating a particular locale . . . . . . . . . . . . . . . . . . . . . . . . . . 164
9.7.6 ISO 8601 date format locale . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9.7.7 Example for the US (ISO-8859-1) . . . . . . . . . . . . . . . . . . . . . . . . 165
9.7.8 Example for France with Euro sign (ISO-8859-15) . . . . . . . . . . . . . . 165
9.7.9 Example for a multilingual X window system . . . . . . . . . . . . . . . . 165
9.7.10 Alternative X input methods . . . . . . . . . . . . . . . . . . . . . . . . . . 168
9.7.11 X terminal emulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
9.7.12 UTF-8 support for the X terminal emulator . . . . . . . . . . . . . . . . . . 169
9.7.13 Example for UTF-8 in a framebuffer console . . . . . . . . . . . . . . . . . 170
9.7.14 Beyond locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
9.8 Multilingualization (m17n) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
CONTENTS xii
10 Network configuration 173
10.1 Basics of IP networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
10.2 Low level network configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
10.2.1 Low level network configuration – ifconfig and route . . . . . . . . . 175
10.2.2 Low level network configuration – ip . . . . . . . . . . . . . . . . . . . . . 177
10.2.3 Configuring a Wi-Fi interface . . . . . . . . . . . . . . . . . . . . . . . . . . 177
10.2.4 Configuring a PPP interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
10.3 Naming the computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
10.3.1 Hostname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
10.3.2 Mailname . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
10.4 Domain Name Service (DNS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
10.4.1 The resolver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
10.4.2 Managing nameserver information – resolvconf . . . . . . . . . . . . . 183
10.4.3 Caching looked-up names – nscd, dnsmasq, pdnsd, bind9 . . . . . . . . 183
10.4.4 Providing Domain Name Service – bind . . . . . . . . . . . . . . . . . . . 183
10.5 Configuring network interfaces using DHCP . . . . . . . . . . . . . . . . . . . . . 184
10.6 High level network configuration in Debian . . . . . . . . . . . . . . . . . . . . . . 184
10.6.1 High level network configuration using ifupdown . . . . . . . . . . . . . 184
10.6.2 High level network configuration using ifupdown logical interface def-
initions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
10.6.3 Automatic network configuration using ifupdown . . . . . . . . . . . . . 189
10.6.4 Automatic network configuration using laptop-net . . . . . . . . . . . 190
10.6.5 Automatic network configuration using network-manager . . . . . . . 190
10.7 Dealing with inconsistent naming of interfaces by the kernel . . . . . . . . . . . . 191
10.8 Triggering network configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
10.8.1 Triggering network configuration at boot time . . . . . . . . . . . . . . . . 192
10.8.2 Triggering network configuration – hotplug . . . . . . . . . . . . . . . . 192
10.8.3 Triggering network configuration – ifplugd . . . . . . . . . . . . . . . . 193
10.8.4 Triggering network configuration – waproamd . . . . . . . . . . . . . . . . 193
10.8.5 Network configuration and PCMCIA . . . . . . . . . . . . . . . . . . . . . 194
10.9 Multi-stage mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
CONTENTS xiii
10.10Network service configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
10.11Network troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
10.12Building a gateway router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
10.12.1 Netfilter configuration . . . . . . . . . . . . . . . . . . . . .