Debian Reference
Debian Reference
Osamu Aoki
Copyright 2007-2010 Osamu Aoki This Debian Reference (v2) (2011-02-26 17:58:45 UTC) 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 for non-developers. Abstract This book is free; you may redistribute it and/or modify it under the terms of the GNU General Public License of any version compliant to the Debian Free Software Guidelines (DFSG). Table of Contents Preface 1. Disclaimer 2. What is Debian 3. About this document 3.1. Guiding rules 3.2. Prerequisites 3.3. Conventions 3.4. Debian BTS 3.5. The popcon 3.6. The package size 3.7. Bug reports on this document 4. Some quotes for new users 1. GNU/Linux tutorials 1.1. Console basics 1.1.1. The shell prompt 1.1.2. The shell prompt under X 1.1.3. The root account 1.1.4. The root shell prompt 1.1.5. GUI system administration tools 1.1.6. Virtual consoles 1.1.7. How to leave the command prompt 1.1.8. How to shutdown the system 1.1.9. Recovering a sane console 1.1.10. Additional package suggestions for the newbie 1.1.11. An extra user account 1.1.12. sudo configuration 1.1.13. Play time 1.2. Unix-like filesystem 1.2.1. Unix file basics 1.2.2. Filesystem internals 1.2.3. Filesystem permissions 1.2.4. Control of permissions for newly created files: umask 1.2.5. Permissions for groups of users (group) 1.2.6. Timestamps 1.2.7. Links 1.2.8. Named pipes (FIFOs) 1.2.9. Sockets 1.2.10. Device files 1.2.11. Special device files 1.2.12. procfs and sysfs 1.3. Midnight Commander (MC) 1.3.1. Customization of MC 1.3.2. Starting MC 1.3.3. File manager in MC 1.3.4. Command-line tricks in MC 1.3.5. The internal editor in MC 1.3.6. The internal viewer in MC 1.3.7. Auto-start features of MC 1.3.8. FTP virtual filesystem of MC 1.4. The basic Unix-like work environment 1.4.1. The login shell 1.4.2. Customizing bash 1.4.3. Special key strokes 1.4.4. Unix style mouse operations 1.4.5. The pager 1.4.6. The text editor 1.4.7. Setting a default text editor
1.4.8. Customizing vim 1.4.9. Recording the shell activities 1.4.10. Basic Unix commands 1.5. The simple shell command 1.5.1. Command execution and environment variable 1.5.2. "$LANG" variable 1.5.3. "$PATH" variable 1.5.4. "$HOME" variable 1.5.5. Command line options 1.5.6. Shell glob 1.5.7. Return value of the command 1.5.8. Typical command sequences and shell redirection 1.5.9. Command alias 1.6. Unix-like text processing 1.6.1. Unix text tools 1.6.2. Regular expressions 1.6.3. Replacement expressions 1.6.4. Global substitution with regular expressions 1.6.5. Extracting data from text file table 1.6.6. Script snippets for piping commands 2. Debian package management 2.1. Debian package management prerequisites 2.1.1. Package configuration 2.1.2. Basic precautions 2.1.3. Life with eternal upgrades 2.1.4. Debian archive basics 2.1.5. Package dependencies 2.1.6. The event flow of the package management 2.1.7. First response to package management troubles 2.2. Basic package management operations 2.2.1. apt-get / apt-cache vs. aptitude 2.2.2. Basic package management operations with the commandline 2.2.3. Interactive use of aptitude 2.2.4. Key bindings of aptitude 2.2.5. Package views under aptitude 2.2.6. Search method options with aptitude 2.2.7. The aptitude regex formula 2.2.8. Dependency resolution of aptitude 2.2.9. Package activity logs 2.3. Examples of aptitude operations 2.3.1. Listing packages with regex matching on package names 2.3.2. Browsing with the regex matching 2.3.3. Purging removed packages for good 2.3.4. Tidying auto/manual install status 2.3.5. System wide upgrade 2.4. Advanced package management operations 2.4.1. Advanced package management operations with commandline 2.4.2. Verification of installed package files 2.4.3. Safeguarding for package problems 2.4.4. Searching on the package meta data 2.5. Debian package management internals 2.5.1. Archive meta data 2.5.2. Top level "Release" file and authenticity 2.5.3. Archive level "Release" files 2.5.4. Fetching of the meta data for the package 2.5.5. The package state for APT 2.5.6. The package state for aptitude 2.5.7. Local copies of the fetched packages 2.5.8. Debian package file names 2.5.9. The dpkg command 2.5.10. The update-alternative command 2.5.11. The dpkg-statoverride command 2.5.12. The dpkg-divert command 2.6. Recovery from a broken system 2.6.1. Incompatibility with old user configuration 2.6.2. Different packages with overlapped files 2.6.3. Fixing broken package script 2.6.4. Rescue with the dpkg command 2.6.5. Recovering package selection data 2.7. Tips for the package management
2.7.1. How to pick Debian packages 2.7.2. Packages from mixed source of archives 2.7.3. Tweaking candidate version 2.7.4. Updates and Backports 2.7.5. Automatic download and upgrade of packages 2.7.6. Limiting download bandwidth for APT 2.7.7. Emergency downgrading 2.7.8. Who uploaded the package? 2.7.9. The equivs package 2.7.10. Porting a package to the stable system 2.7.11. Proxy server for APT 2.7.12. Small public package archive 2.7.13. Recording and copying system configuration 2.7.14. Converting or installing an alien binary package 2.7.15. Extracting package without dpkg 2.7.16. More readings for the package management 3. The system initialization 3.1. An overview of the boot strap process 3.2. Stage 1: the BIOS 3.3. Stage 2: the boot loader 3.4. Stage 3: the mini-Debian system 3.5. Stage 4: the normal Debian system 3.5.1. The meaning of the runlevel 3.5.2. The configuration of the runlevel 3.5.3. The runlevel management example 3.5.4. The default parameter for each init script 3.5.5. The hostname 3.5.6. The filesystem 3.5.7. Network interface initialization 3.5.8. Network service initialization 3.5.9. The system message 3.5.10. The kernel message 3.5.11. The udev system 3.5.12. The kernel module initialization 4. Authentication 4.1. Normal Unix authentication 4.2. Managing account and password information 4.3. Good password 4.4. Creating encrypted password 4.5. PAM and NSS 4.5.1. Configuration files accessed by the PAM and NSS 4.5.2. The modern centralized system management 4.5.3. "Why GNU su does not support the wheel group" 4.5.4. Stricter password rule 4.6. Other access controls 4.6.1. sudo 4.6.2. SELinux 4.6.3. Restricting access to some server services 4.7. Security of authentication 4.7.1. Secure password over the Internet 4.7.2. Secure Shell 4.7.3. Extra security measures for the Internet 4.7.4. Securing the root password 5. Network setup 5.1. The basic network infrastructure 5.1.1. The 5.1.2. The 5.1.3. The 5.1.4. The 5.1.5. The domain name hostname resolution network interface name network address range for the LAN network device support
5.2. The modern network configuration for desktop 5.2.1. GUI network configuration tools 5.3. The legacy network connection and configuration 5.4. The network connection method (legacy) 5.4.1. The 5.4.2. The 5.4.3. The 5.4.4. The 5.4.5. The DHCP connection with the Ethernet static IP connection with the Ethernet PPP connection with pppconfig alternative PPP connection with wvdialconf PPPoE connection with pppoeconf
5.5.1. The command syntax simplified 5.5.2. The basic syntax of "/etc/network/interfaces" 5.5.3. The loopback network interface 5.5.4. The network interface served by the DHCP 5.5.5. The network interface with the static IP 5.5.6. The basics of wireless LAN interface 5.5.7. The wireless LAN interface with WPA/WPA2 5.5.8. The wireless LAN interface with WEP 5.5.9. The PPP connection 5.5.10. The alternative PPP connection 5.5.11. The PPPoE connection 5.5.12. The network configuration state of ifupdown 5.5.13. The basic network reconfiguration 5.5.14. The ifupdown-extra package 5.6. The advanced network configuration with ifupdown (legacy) 5.6.1. The ifplugd package 5.6.2. The ifmetric package 5.6.3. The virtual interface 5.6.4. The advanced command syntax 5.6.5. The mapping stanza 5.6.6. The manually switchable network configuration 5.6.7. Scripting with the ifupdown system 5.6.8. Mapping with guessnet 5.7. The low level network configuration 5.7.1. Iproute2 commands 5.7.2. Safe low level network operations 5.8. Network optimization 5.8.1. Finding optimal MTU 5.8.2. Setting MTU 5.8.3. WAN TCP optimization 5.9. Netfilter infrastructure 6. Network applications 6.1. Web browsers 6.1.1. Browser configuration 6.2. The mail system 6.2.1. Modern mail service basics 6.2.2. The mail configuration strategy for workstation 6.3. Mail transport agent (MTA) 6.3.1. The configuration of exim4 6.3.2. The configuration of postfix with SASL 6.3.3. The mail address configuration 6.3.4. Basic MTA operations 6.4. Mail user agent (MUA) 6.4.1. Basic MUA Mutt 6.5. The remote mail retrieval and forward utility 6.5.1. getmail configuration 6.5.2. fetchmail configuration 6.6. Mail delivery agent (MDA) with filter 6.6.1. maildrop configuration 6.6.2. procmail configuration 6.6.3. Redeliver mbox contents 6.7. POP3/IMAP4 server 6.8. The print server and utility 6.9. The remote access server and utility (SSH) 6.9.1. Basics of SSH 6.9.2. Port forwarding for SMTP/POP3 tunneling 6.9.3. Connecting without remote passwords 6.9.4. Dealing with alien SSH clients 6.9.5. Setting up ssh-agent 6.9.6. How to shutdown the remote system on SSH 6.9.7. Troubleshooting SSH 6.10. Other network application servers 6.11. Other network application clients 6.12. The diagnosis of the system daemons 7. The X Window System
7.1. Key packages 7.2. Setting up desktop environment 7.2.1. Debian menu 7.2.2. Freedesktop.org menu 7.2.3. Debian menu under GNOME desktop environment 7.3. The server/client relationship 7.4. The X server 7.4.1. The (re)configuration of the X server 7.4.2. The connection methods to the X server 7.5. Starting the X Window System 7.5.1. Starting X session with gdm 7.5.2. Customizing the X session (classic method) 7.5.3. Customizing the X session (new method) 7.5.4. Connecting a remote X client via SSH 7.5.5. Secure X terminal via the Internet 7.6. Fonts in the X Window 7.6.1. Basic fonts 7.6.2. Additional fonts 7.6.3. CJK fonts 7.7. X applications 7.7.1. X office applications 7.7.2. X utility applications 7.8. The X trivia 7.8.1. Keymaps and pointer button mappings in X 7.8.2. Classic X clients 7.8.3. The X terminal emulator xterm 7.8.4. Running X clients as root 8. I18N and L10N 8.1. The keyboard input 8.1.1. The input method support with IBus 8.1.2. An example for Japanese 8.1.3. Disabling the input method 8.2. The display output 8.3. The locale 8.3.1. Basics of encoding 8.3.2. Rationale for UTF-8 locale 8.3.3. The reconfiguration of the locale 8.3.4. The value of the "$LANG" environment variable 8.3.5. Specific locale only under X Window 8.3.6. Filename encoding 8.3.7. Localized messages and translated documentation 8.3.8. Effects of the locale 9. System tips 9.1. The screen program 9.1.1. The use scenario for screen(1) 9.1.2. Key bindings for the screen command 9.2. Data recording and presentation 9.2.1. The log daemon 9.2.2. Log analyzer 9.2.3. Recording the shell activities cleanly 9.2.4. Customized display of text data 9.2.5. Customized display of time and date 9.2.6. Colorized shell echo 9.2.7. Colorized commands 9.2.8. Recording the editor activities for complex repeats 9.2.9. Recording the graphic image of an X application 9.2.10. Recording changes in configuration files 9.3. Data storage tips 9.3.1. Disk partition configuration 9.3.2. Accessing partition using UUID 9.3.3. Filesystem configuration 9.3.4. Filesystem creation and integrity check 9.3.5. Optimization of filesystem by mount options 9.3.6. Optimization of filesystem via superblock 9.3.7. Optimization of hard disk 9.3.8. Using SMART to predict hard disk failure
9.3.9. Expansion of usable storage space via LVM 9.3.10. Expansion of usable storage space by mounting another partition 9.3.11. Expansion of usable storage space using symlink 9.3.12. Expansion of usable storage space using aufs 9.4. Data encryption tips 9.4.1. Removable disk encryption with dm-crypt/LUKS 9.4.2. Encrypted swap partition with dm-crypt 9.4.3. Automatically encrypting files with eCryptfs 9.4.4. Automatically mounting eCryptfs 9.5. Monitoring, controlling, and starting program activities 9.5.1. Timing a process 9.5.2. The scheduling priority 9.5.3. The ps command 9.5.4. The top command 9.5.5. Listing files opened by a process 9.5.6. Tracing program activities 9.5.7. Identification of processes using files or sockets 9.5.8. Repeating a command with a constant interval 9.5.9. Repeating a command looping over files 9.5.10. Starting a program from GUI 9.5.11. Customizing program to be started 9.5.12. Killing a process 9.5.13. Scheduling tasks once 9.5.14. Scheduling tasks regularly 9.5.15. Alt-SysRq key 9.6. System maintenance tips 9.6.1. Who is on the system? 9.6.2. Warning everyone 9.6.3. Hardware identification 9.6.4. Hardware configuration 9.6.5. System and hardware time 9.6.6. The terminal configuration 9.6.7. The sound infrastructure 9.6.8. Disabling the screen saver 9.6.9. Disabling beep sounds 9.6.10. Memory usage 9.6.11. System security and integrity check 9.7. The kernel 9.7.1. Linux kernel 2.6 9.7.2. Kernel parameters 9.7.3. Kernel headers 9.7.4. Compiling the kernel and related modules 9.7.5. Compiling the kernel source: Debian standard method 9.7.6. Compiling the module source: Debian standard method 9.7.7. Compiling the kernel source: classic method 9.7.8. Non-free hardware drivers 9.8. Virtualized system 9.8.1. Virtualization tools 9.8.2. Virtualization work flow 9.8.3. Mounting the virtual disk image file 9.8.4. Chroot system 9.8.5. Multiple desktop systems 10. Data management 10.1. Sharing, copying, and archiving 10.1.1. Archive and compression tools 10.1.2. Copy and synchronization tools 10.1.3. Idioms for the archive 10.1.4. Idioms for the copy 10.1.5. Idioms for the selection of files 10.1.6. Backup and recovery 10.1.7. Backup utility suites 10.1.8. An example script for the system backup 10.1.9. A copy script for the data backup 10.1.10. Removable storage device 10.1.11. Sharing data via network 10.1.12. Archive media 10.2. The disk image 10.2.1. Making the disk image file 10.2.2. Writing directly to the disk 10.2.3. Mounting the disk image file 10.2.4. Cleaning a disk image file 10.2.5. Making the empty disk image file
10.2.6. Making the ISO9660 image file 10.2.7. Writing directly to the CD/DVD-R/RW 10.2.8. Mounting the ISO9660 image file 10.3. The binary data 10.3.1. Viewing and editing binary data 10.3.2. Manipulating files without mounting disk 10.3.3. Data redundancy 10.3.4. Data file recovery and forensic analysis 10.3.5. Splitting a large file into small files 10.3.6. Clearing file contents 10.3.7. Dummy files 10.3.8. Erasing an entire hard disk 10.3.9. Erasing unused area of an hard disk 10.3.10. Undeleting deleted but still open files 10.3.11. Searching all hardlinks 10.3.12. Invisible disk space consumption 10.4. Data security infrastructure 10.4.1. Key management for GnuPG 10.4.2. Using GnuPG on files 10.4.3. Using GnuPG with Mutt 10.4.4. Using GnuPG with Vim 10.4.5. The MD5 sum 10.5. Source code merge tools 10.5.1. Extracting differences for source files 10.5.2. Merging updates for source files 10.5.3. Updating via 3-way-merge 10.6. Version control systems 10.6.1. Comparison of VCS commands 10.7. CVS 10.7.1. Configuration of CVS repository 10.7.2. Local access to CVS 10.7.3. Remote access to CVS with pserver 10.7.4. Remote access to CVS with ssh 10.7.5. Importing a new source to CVS 10.7.6. File permissions in CVS repository 10.7.7. Work flow of CVS 10.7.8. Latest files from CVS 10.7.9. Administration of CVS 10.7.10. Execution bit for CVS checkout 10.8. Subversion 10.8.1. Configuration of Subversion repository 10.8.2. Access to Subversion via Apache2 server 10.8.3. Local access to Subversion by group 10.8.4. Remote access to Subversion via SSH 10.8.5. Subversion directory structure 10.8.6. Importing a new source to Subversion 10.8.7. Work flow of Subversion 10.9. Git 10.9.1. Configuration of Git client 10.9.2. Git references 10.9.3. Git commands 10.9.4. Git for the Subversion repository 10.9.5. Git for recording configuration history 11. Data conversion 11.1. Text data conversion tools 11.1.1. Converting a text file with iconv 11.1.2. Checking file to be UTF-8 with iconv 11.1.3. Converting file names with iconv 11.1.4. EOL conversion 11.1.5. TAB conversion 11.1.6. Editors with auto-conversion 11.1.7. Plain text extraction 11.1.8. Highlighting and formatting plain text data 11.2. XML data 11.2.1. Basic hints for XML 11.2.2. XML processing 11.2.3. The XML data extraction 11.3. Printable data
11.3.1. Ghostscript 11.3.2. Merge two PS or PDF files 11.3.3. Printable data utilities 11.3.4. Printing with CUPS 11.4. Type setting 11.4.1. roff typesetting 11.4.2. TeX/LaTeX 11.4.3. Pretty print a manual page 11.4.4. Creating a manual page 11.5. The mail data conversion 11.5.1. Mail data basics 11.6. Graphic data tools 11.7. Miscellaneous data conversion 12. Programming 12.1. The shell script 12.1.1. POSIX shell compatibility 12.1.2. Shell parameters 12.1.3. Shell conditionals 12.1.4. Shell loops 12.1.5. The shell command-line processing sequence 12.1.6. Utility programs for shell script 12.1.7. Shell script dialog 12.1.8. Shell script example with zenity 12.2. Make 12.3. C 12.3.1. Simple C program (gcc) 12.4. Debug 12.4.1. Basic gdb execution 12.4.2. Debugging the Debian package 12.4.3. Obtaining backtrace 12.4.4. Advanced gdb commands 12.4.5. Debugging X Errors 12.4.6. Check dependency on libraries 12.4.7. Memory leak detection tools 12.4.8. Static code analysis tools 12.4.9. Disassemble binary 12.5. Flex a better Lex 12.6. Bison a better Yacc 12.7. Autoconf 12.7.1. Compile and install a program 12.7.2. Uninstall program 12.8. Perl short script madness 12.9. Web 12.10. The source code translation 12.11. Making Debian package A. Appendix A.1. The Debian maze A.2. Copyright history A.3. Document format List of Tables 1.1. List of interesting text-mode program packages 1.2. List of informative documentation packages 1.3. List of usage of key directories 1.4. List of the first character of "ls -l" output 1.5. The numeric mode for file permissions in chmod(1) commands 1.6. The umask value examples 1.7. List of notable system-provided groups for file access 1.8. List of notable system provided groups for particular command executions 1.9. List of types of timestamps 1.10. List of special device files 1.11. The key bindings of MC 1.12. The reaction to the enter key in MC 1.13. List of shell programs 1.14. List of key bindings for bash 1.15. List of Unix style mouse operations 1.16. List of basic Unix commands 1.17. 3 parts of locale value 1.18. List of locale recommendations 1.19. List of "$HOME" values
1.20. Shell glob patterns 1.21. Command exit codes 1.22. Shell command idioms 1.23. Predefined file descriptors 1.24. Metacharacters for BRE and ERE 1.25. The replacement expression 1.26. List of script snippets for piping commands 2.1. List of Debian package management tools 2.2. List of Debian archive sites 2.3. List of Debian archive area 2.4. The relationship between suite and codename 2.5. List of key web site to resolving problems with a specific package 2.6. Basic package management operations with the commandline using aptitude(8) and apt-get(8) /apt-cache(8) 2.7. Notable command options for aptitude(8) 2.8. List of key bindings for aptitude 2.9. List of views for aptitude 2.10. The categorization of standard package views 2.11. List of the aptitude regex formula 2.12. The log files for package activities 2.13. List of advanced package management operations 2.14. The content of the Debian archive meta data 2.15. The name structure of Debian packages 2.16. The usable characters for each component in the Debian package names 2.17. The notable files created by dpkg 2.18. List of the default Pin-Priority value for each package source type 2.19. List of the proxy tools specially for Debian archive 3.1. List of boot loaders 3.2. The meaning of GRUB parameters 3.3. List of boot utilities for the Debian system 3.4. List of runlevels and description of their usage 3.5. List of kernel error levels 4.1. 3 important configuration files for pam_unix(8) 4.2. The second entry content of "/etc/passwd" 4.3. List of commands to manage account information 4.4. List of tools to generate password 4.5. List of notable PAM and NSS systems 4.6. List of configuration files accessed by the PAM 4.7. List of insecure and secure services and ports 4.8. List of tools to provide extra security measures 5.1. List of network configuration tools 5.2. List of network address ranges 5.3. List of network connection methods and connection paths 5.4. List of network connection configurations 5.5. List of network connection acronyms 5.6. List of configuration files for the PPP connection with pppconfig 5.7. List of configuration files for the PPP connection with wvdialconf 5.8. List of configuration files for the PPPoE connection with pppoeconf 5.9. List of basic network configuration commands with ifupdown 5.10. List of stanzas in "/etc/network/interfaces" 5.11. List of acronyms for WLAN 5.12. List of terminology for network devices 5.13. List of advanced network configuration commands with ifupdown 5.14. List of environment variables passed by the ifupdown system 5.15. Translation table from obsolete net-tools commands to new iproute2 commands 5.16. List of low level network commands 5.17. List of network optimization tools 5.18. Basic guide lines of the optimal MTU value 5.19. List of firewall tools 6.1. List of web browsers 6.2. List of browser plugin packages 6.3. List of basic mail transport agent related packages for workstation 6.4. List of choices for mail transport agent (MTA) packages in Debian archive 6.5. List of important postfix manual pages 6.6. List of mail address related configuration files 6.7. List of basic MTA operation 6.8. List of mail user agent (MUA) 6.9. List of remote mail retrieval and forward utilities 6.10. List of MDA with filter 6.11. List of POP3/IMAP4 servers 6.12. List of print servers and utilities 6.13. List of remote access server and utilities 6.14. List of SSH authentication protocols and methods 6.15. List of SSH configuration files 6.16. List of SSH client startup examples 6.17. List of free SSH clients for other platforms 6.18. List of other network application servers 6.19. List of network application clients 6.20. List of popular RFCs 7.1. List of key (meta)packages for X Window 7.2. List of server/client terminology 7.3. List of connection methods to the X server 7.4. Table of packages to support X Window font systems 7.5. Table of corresponding PostScript Type 1 fonts
7.6. Table of corresponding TrueType fonts 7.7. Table of key words used in CJK font names to indicate font types 7.8. List of basic X office applications 7.9. List of basic X utility applications 8.1. List of keyboard reconfiguration methods 8.2. List of input method supports with IBus 9.1. List of programs to support interrupted network connections 9.2. List of key bindings for screen 9.3. List of system log analyzers 9.4. Display examples of time and date for the "ls -l" command for lenny 9.5. List of graphic image manipulation tools 9.6. List of packages to record configuration history in VCS 9.7. List of disk partition management packages 9.8. List of filesystem management packages 9.9. List of data encryption utilities 9.10. List of tools for monitoring and controlling program activities 9.11. List of nice values for the scheduling priority 9.12. List of ps command styles 9.13. List of commands for top 9.14. List of frequently used signals for kill command 9.15. List of SAK command keys 9.16. List of hardware identification tools 9.17. List of hardware configuration tools 9.18. List of sound packages 9.19. List of commands for disabling the screen saver 9.20. List of memory sizes reported 9.21. List of tools for system security and integrity check 9.22. List of key packages to be installed for the kernel recompilation on the Debian system 9.23. List of virtualization tools 10.1. List of archive and compression tools 10.2. List of copy and synchronization tools 10.3. List of backup suite utilities 10.4. List of packages which permit normal users to mount removable devices without a matching "/etc/fstab" entry 10.5. List of filesystem choices for removable storage devices with typical usage scenarios 10.6. List of the network service to chose with the typical usage scenario 10.7. List of packages which view and edit binary data 10.8. List of packages to manipulate files without mounting disk 10.9. List of tools to add data redundancy to files 10.10. List of packages for data file recovery and forensic analysis 10.11. List of data security infrastructure tools 10.12. List of GNU Privacy Guard commands for the key management 10.13. List of the meaning of the trust code 10.14. List of GNU Privacy Guard commands on files 10.15. List of source code merge tools 10.16. List of version control system tools 10.17. Comparison of native VCS commands 10.18. Notable options for CVS commands (use as first argument(s) to cvs(1)) 10.19. Notable options for Subversion commands (use as first argument(s) to svn(1)) 10.20. List of git related packages and commands 11.1. List of text data conversion tools 11.2. List of encoding values and their usage 11.3. List of EOL styles for different platforms 11.4. List of TAB conversion commands from bsdmainutils and coreutils packages 11.5. List of tools to extract plain text data 11.6. List of tools to highlight plain text data 11.7. List of predefined entities for XML 11.8. List of XML tools 11.9. List of DSSL tools 11.10. List of XML data extraction tools 11.11. List of XML pretty print tools 11.12. List of Ghostscript PostScript interpreters 11.13. List of printable data utilities 11.14. List of type setting tools 11.15. List of packages to help creating the manpage 11.16. List of packages to help mail data conversion 11.17. List of graphic data tools 11.18. List of miscellaneous data conversion tools 12.1. List of packages to help programing 12.2. List of typical bashisms 12.3. List of shell parameters 12.4. List of shell parameter expansions 12.5. List of key shell parameter substitutions 12.6. List of file comparison operators in the conditional expression 12.7. List of string comparison operators in the conditional expression 12.8. List of packages containing small utility programs for shell scripts 12.9. List of user interface programs 12.10. List of make automatic variables 12.11. List of make variable expansions 12.12. List of advanced gdb commands 12.13. List of memory leak detection tools 12.14. List of tools for static code analysis 12.15. List of Yacc-compatible LALR parser generators 12.16. List of source code translation tools
Preface
This Debian Reference (version 2) (2011-02-26 17:58:45 UTC) is intended to provide a broad overview of Debian system administration as a post-installation user guide. The target reader is someone who is willing to learn shell scripts but who is not ready to read all the C sources to figure out how the GNU/Linux system works.
1. Disclaimer
All warranties are disclaimed. All trademarks are property of their respective trademark owners. The Debian system itself is a moving target. This makes its documentation difficult to be current and correct. Although the current unstable version of Debian system was used as the basis for writing this, some contents may be already outdated by the time you read this. Please treat this document as the secondary reference. This document does not replace any authoritative guides. The author and contributors do not take responsibility for consequences of errors, omissions or ambiguity in this document.
2. What is Debian
The Debian Project is an association of individuals who have made common cause to create a free operating system. It's distribution is characterized by the following. Commitment to the software freedom: Debian Social Contract and Debian Free Software Guidelines (DFSG) Internet based distributed unpaid volunteer effort: http://www.debian.org Large number of pre-compiled high quality softwares Focus on stability and security with easy access to the security updates Focus on smooth upgrade to latest softwares with unstable and testing archives Large number of supported hardware architectures Free Software pieces in Debian come from GNU, Linux, BSD, X, ISC, Apache, Ghostscript, Common Unix Printing System , Samba, GNOME, KDE, Mozilla, OpenOffice.org, Vim, TeX, LaTeX, DocBook, Perl, Python, Tcl, Java, Ruby, PHP, Berkeley DB, MySQL, PostgreSQL, Exim, Postfix, Mutt, FreeBSD, OpenBSD, Plan 9 and many more independent free software projects. Debian integrates this diversity of Free Software into one system.
Tip
I tried to elucidate hierarchical aspects and lower levels of the system.
Note
For detailed documentation, you may need to install the corresponding documentation package named with "-doc" as its suffix.
3.3. Conventions
This document provides information through the following simplified presentation style with bash(1) shell command examples.
# <command in root account> $ <command in user account> These shell prompts distinguish account used and correspond to set environment variables as: "PS1='\$'" and "PS2=' '". These values are chosen for the sake of readability of this document and are not typical on actual installed system.
Note
See the meaning of the "$PS1" and "$PS2" environment variables in bash(1). Action required by the system administrator is written in the imperative sentence, e.g. "Type Enter-key after typing each command string to the shell." The description column and similar ones in the table may contain a noun phrase following the package short description convention which drops leading articles such as "a" and "the". They may alternatively contain an infinitive phrase as a noun phrase without leading "to" following the short command description convention in manpages. These may look funny to some people but are my intentional choices of style to keep this documentation as simple as possible. These Noun phrases do not capitalize their starting nor end with periods following these short description convention.
Note
Proper nouns including command names keeps their case irrespective of their location. A command snippet quoted in a text paragraph is referred by the typewriter font between double quotation marks, such as "aptitude safe-upgrade". A text data from a configuration file quoted in a text paragraph is referred by the typewriter font between double quotation marks, such as "deb-src". A command is referred by its name in the typewriter font optionally followed by its manpage section number in parenthesis, such as bash(1). You are encouraged to obtain information by typing the following. $ man 1 bash A manpage is referred by its name in the typewriter font followed by its manpage section number in parenthesis, such as sources.list(5). You are encouraged to obtain information by typing the following. $ man 5 sources.list An info page is referred by its command snippet in the typewriter font between double quotation marks, such as "info make". You are encouraged to obtain information by typing the following. $ info make A filename is referred by the typewriter font between double quotation marks, such as "/etc/passwd". For configuration files, you are encouraged to obtain information by typing the following. $ sensible-pager "/etc/passwd" A directory name is referred by the typewriter font between double quotation marks, such as "/etc/init.d/". You are encouraged to explore its contents by typing the following. $ mc "/etc/init.d/" A package name is referred by its name in the typewriter font, such as vim. You are encouraged to obtain information by typing the following. $ dpkg -L vim $ apt-cache show vim $ aptitude show vim A documentation may indicate its location by the filename in the typewriter font between double quotation marks, such as "/usr/share/doc/sysv-rc/README.runlevels.gz" and "/usr/share/doc/base-passwd/users-and-groups.html"; or by its URL, such as http://www.debian.org. You are encouraged to read the documentation by typing the following. $ zcat "/usr/share/doc/sysv-rc/README.runlevels.gz" | sensible-pager $ sensible-browser "/usr/share/doc/base-passwd/users-and-groups.html" $ sensible-browse "http://www.debian.org" An environment variable is referred by its name with leading "$" in the typewriter font between double quotation marks, such as "$TERM". You are encouraged to obtain its current value by typing the following. $ echo "$TERM"
Note
Please note that the amd64 unstable archive contains only 30552 packages currently. The popcon data contains reports from many old system installations. The popcon number preceded with "V:" for "votes" is calculated by "100 * (the popcon submissions for the package executed recently on the PC)/(the total popcon submissions)". The popcon number preceded with "I:" for "installs" is calculated by "100 * (the popcon submissions for the package installed on the PC)/(the total popcon submissions)".
Note
The popcon figures should not be considered as absolute measures of the importance of packages. There are many factors which can skew statistics. For example, some system participating popcon may have mounted directories such as "/bin" with "noatime" option for system performance improvement and effectively disabled "vote" from such system.
Note
A package with a small numerical package size may indicate that the package in the unstable release is a dummy package which installs other packages with significant contents by the dependency. The dummy package enables a smooth transition or split of the package.
Note
A package size followed by "(*)" indicates that the package in the unstable release is missing and the package size for the experimental release is used instead.
Note
If you have been using any Unix-like system for a while with command line tools, you probably know everything I explain here. Please use this as a reality check and refresher.
Note
Following the Unix tradition, the username and password of the Debian system are case sensitive. The username is usually chosen only from the lowercase. The first user account is usually created during the installation. Additional user accounts can be created with adduser(8) by root. The system starts with the greeting message stored in "/etc/motd" (Message Of The Day) and presents a command prompt. Debian GNU/Linux lenny/sid foo tty1 foo login: penguin Password: Last login: Sun Apr 22 09:29:34 2007 on tty1 Linux snoopy 2.6.20-1-amd64 #1 SMP Sun Apr 15 20:25:49 UTC 2007 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. foo:~$ Here, the main part of the greeting message can be customized by editing the "/etc/motd.tail" file. The first line is generated from the system information using "uname -snrvm". Now you are in the shell. The shell interprets your commands.
Warning
Never share the root password with others.
Note
File permissions of a file (including hardware devices such as CD-ROM etc. which are just another file for the Debian system) may render it unusable or inaccessible by non-root users. Although the use of root account is a quick way to test this kind of situation, its resolution should be done through proper setting of file permissions and user's group membership (see Section 1.2.3, Filesystem permissions).
Warning
Never start the X display/session manager under the root account by typing in root to the prompt of the display manager such as gdm(1).
Warning
Never run untrusted remote GUI program under X Window when critical information is displayed since it may eavesdrop your X screen.
13016 GNU project Emacs, the Lisp based extensible text editor (version 23)
gpm *
V:3, I:4
484
It may be a good idea to read some informative documentations. Table 1.2. List of informative documentation packages package doc-debian * debian-policy * popcon size I:82 I:3 408 3500 1388 776 3736 1224 8616 964 description Debian Project documentation, (Debian FAQ) and other documents Debian Policy Manual and related documents Guidelines and information for Debian developers Debian New Maintainers' Guide History of the Debian Project Debian FAQ Linux HOWTOs and FAQ (text) The Linux System Administrators' Guide
developers-reference I:1.0 * maint-guide * debian-history * debian-faq * doc-linux-text * doc-linux-html * sysadmin-guide * I:0.7 I:0.3 I:66 I:82 I:0.7 I:0.2
You can install some of these packages by the following. # apt-get install package_name
Alternatively, it is also common to do as follows to let the non-privileged user, e.g. penguin, to gain administrative privilege without any password. # echo "penguin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
This trick should only be used for the single user workstation which you administer and where you are the only user.
Warning
Do not set up accounts of regular users on multiuser workstation like this because it would be very bad for system security.
Caution
The password and the account of the penguin in the above example requires as much protection as the root password and the root account.
Caution
Administrative privilege in this context belongs to someone authorized to perform the system administration task on the workstation. Never give some manager in the Admin department of your company or your boss such privilege unless they are authorized and capable.
Note
For providing access privilege to limited devices and limited files, you should consider to use group to provide limited access instead of using the root privilege via sudo(8).
Note
With more thoughtful and careful configuration, sudo(8) can grant limited administrative privileges to other users on a shared system without sharing the root password. This can help with accountability with hosts with multiple administrators so you can tell who did what. On the other hand, you might not want anyone else to have such privileges.
Note
While you can use almost any letters or symbols in a file name, in practice it is a bad idea to do so. It is better to avoid any characters that often have special meanings on the command line, including spaces, tabs, newlines, and other special characters: { } ( ) [ ] ' ` " \ / > < | ; ! # & ^ * % @ $ . If you want to separate words in a name, good choices are the period, hyphen, and underscore. You could also capitalize each word, "LikeThis". Experienced Linux users tend to avoid spaces in filenames.
Note
The word "root" can mean either "root user" or "root directory". The context of their usage should make it clear.
Note
The word path is used not only for fully-qualified filename as above but also for the command search path. The intended meaning is usually clear from the context. The detailed best practices for the file hierarchy are described in the Filesystem Hierarchy Standard
("/usr/share/doc/debian-policy/fhs/fhs-2.3.txt.gz" and hier(7)). You should remember the following facts as the starter. Table 1.3. List of usage of key directories directory usage of the directory / /etc/ /home/ the root directory system wide configuration files all the home directories for all non-privileged users
Tip
If you need to identify the correspondence between the file tree and the physical entity, execute mount(8) with no arguments.
chown(1) is used from the root account to change the owner of the file. chgrp(1) is used from the file's owner or root account to change the group of the file. chmod(1) is used from the file's owner or root account to change file and directory access permissions. Basic syntax to manipulate a foo file is the following. # chown <newowner> foo # chgrp <newgroup> foo # chmod [ugoa][+-=][rwxXst][,...] foo For example, you can make a directory tree to be owned by a user foo and shared by a group bar by the following. # cd /some/location/ # chown -R foo:bar . # chmod -R ug+rwX,o=rX . There are three more special permission bits. The set user ID bit (s or S instead of user's x) The set group ID bit (s or S instead of group's x) The sticky bit (t or T instead of other's x) Here the output of "ls -l" for these bits is capitalized if execution bits hidden by these outputs are unset. Setting set user ID on an executable file allows a user to execute the executable file with the owner ID of the file (for example root). Similarly, setting set group ID on an executable file allows a user to execute the executable file with the group ID of the file (for example root). Because these settings can cause security risks, enabling them requires extra caution. Setting set group ID on a directory enables the BSD-like file creation scheme where all files created in the directory belong to the group of the directory. Setting the sticky bit on a directory prevents a file in the directory from being removed by a user who is not the owner of the file. In order to secure contents of a file in world-writable directories such as "/tmp" or in group-writable directories, one must not only reset the write permission for the file but also set the sticky bit on the directory. Otherwise, the file can be removed and a new file can be created with the same name by any user who has write access to the directory. Here are a few interesting examples of file permissions. $ ls -l /etc/passwd /etc/shadow /dev/ppp /usr/sbin/exim4 crw------- 1 root root 108, 0 2007-04-29 07:00 /dev/ppp -rw-r--r-- 1 root root 1427 2007-04-16 00:19 /etc/passwd -rw-r----- 1 root shadow 943 2007-04-16 00:19 /etc/shadow -rwsr-xr-x 1 root root 700056 2007-04-22 05:29 /usr/sbin/exim4 $ ls -ld /tmp /var/tmp /usr/local /var/mail /usr/src drwxrwxrwt 10 root root 4096 2007-04-29 07:59 /tmp drwxrwsr-x 10 root staff 4096 2007-03-24 18:48 /usr/local drwxrwsr-x 4 root src 4096 2007-04-27 00:31 /usr/src drwxrwsr-x 2 root mail 4096 2007-03-28 23:33 /var/mail drwxrwxrwt 2 root root 4096 2007-04-29 07:11 /var/tmp There is an alternative numeric mode to describe file permissions with chmod(1). This numeric mode uses 3 to 4 digit wide octal (radix=8) numbers. Table 1.5. The numeric mode for file permissions in chmod(1) commands digit meaning
1st optional digit sum of set user ID (=4), set group ID (=2), and sticky bit (=1) 2nd digit 3rd digit 4th digit sum of read (=4), write (=2), and execute (=1) permissions for user ditto for group ditto for other
This sounds complicated but it is actually quite simple. If you look at the first few (2-10) columns from "ls -l" command output and read it as a binary (radix=2) representation of file permissions ("-" being "0" and "rwx" being "1"), the last 3 digit of the numeric mode value should make sense as an octal (radix=8) representation of file permissions to you. For example, try the following $ touch foo bar $ chmod u=rw,go=r foo $ chmod 644 bar $ ls -l foo bar -rw-r--r-- 1 penguin penguin 17 2007-04-29 08:22 bar -rw-r--r-- 1 penguin penguin 12 2007-04-29 08:22 foo
Tip
If you need to access information displayed by "ls -l" in shell script, you should use pertinent commands such as test(1), stat(1) and readlink(1). The shell builtin such as "[" or "test" may be used too.
The Debian system uses a user private group (UPG) scheme as its default. A UPG is created whenever a new user is added to the system. A UPG has the same name as the user for which it was created and that user is the only member of the UPG. UPG scheme makes it is safe to set umask to 0002 since every user has their own private group. (In some Unix variants, it is quite common to setup all normal users belonging to a single users group and is good idea to set umask to 0022 for security in such cases.)
Note
Alternatively, you may dynamically add users to groups during the authentication process by adding "auth optional pam_group.so" line to "/etc/pam.d/common-auth" and setting "/etc/security/group.conf". (See Chapter 4, Authentication.) The hardware devices are just another kind of file on the Debian system. If you have problems accessing devices such as CD-ROM and USB memory stick from a user account, you should make that user a member of the relevant group. Some notable system-provided groups allow their members to access particular files and devices without root privilege. Table 1.7. List of notable system-provided groups for file access group description for accessible files and devices
dialout full and direct access to serial ports ("/dev/ttyS[0-3]") dip cdrom audio video adm staff limited access to serial ports for Dialup IP connection to trusted peers CD-ROM, DVD+/-RW drives audio device video device system monitoring logs some directories for junior administrative work: "/usr/local", "/home"
scanner scanner(s)
Tip
You need to belong to the dialout group to reconfigure modem, dial anywhere, etc. But if root creates pre-defined configuration files for trusted peers in "/etc/ppp/peers/", you only need to belong to the dip group to create Dialup IP connection to those trusted peers using pppd(8), pon(1), and poff(1) commands. Some notable system-provided groups allow their members to execute particular commands without root privilege. Table 1.8. List of notable system provided groups for particular command executions group sudo accessible commands execute sudo without their password
lpadmin execute commands to add, modify, and remove printers from printer databases plugdev execute pmount(1) for removable devices such as USB memories
For the full listing of the system provided users and groups, see the recent version of the "Users and Groups" document in "/usr/share/doc/base-passwd/users-and-groups.html" provided by the basepasswd package. See passwd(5), group(5), shadow(5), newgrp(1), vipw(8), vigr(8), and pam_group(8) for management commands of the user and group system.
1.2.6. Timestamps
There are three types of timestamps for a GNU/Linux file. Table 1.9. List of types of timestamps
type
meaning
mtime the file modification time (ls -l) ctime the file status change time (ls -lc) atime the last file access time (ls -lu)
Note
ctime is not file creation time. Overwriting a file changes all of the mtime, ctime, and atime attributes of the file. Changing ownership or permission of a file changes the ctime and atime attributes of the file. Reading a file changes the atime of the file.
Note
Even simply reading a file on the Debian system normally causes a file write operation to update atime information in the inode. Mounting a filesystem with "noatime" or "relatime" option makes the system skip this operation and results in faster file access for the read. This is often recommended for laptops, because it reduces hard drive activity and saves power. See mount(8). Use touch(1) command to change timestamps of existing files. For timestamps, the ls command outputs different strings under the modern English locale ("en_US.UTF8") from under the old one ("C"). $ LANG=en_US.UTF-8 ls -l foo -rw-r--r-- 1 penguin penguin 3 2008-03-05 00:47 foo $ LANG=C ls -l foo -rw-r--r-- 1 penguin penguin 3 Mar 5 00:47 foo
Tip
See Section 9.2.5, Customized display of time and date to customize "ls -l" output.
1.2.7. Links
There are two methods of associating a file "foo" with a different filename "bar". Hard link Duplicate name for an existing file "ln foo bar" Symbolic link or symlink Special file that points to another file by name "ln -s foo bar" See the following example for changes in link counts and the subtle differences in the result of the rm command. $ echo "Original Content" > foo $ ls -li foo 2398521 -rw-r--r-- 1 penguin penguin $ ln foo bar # hard link $ ln -s foo baz # symlink $ ls -li foo bar baz 2398521 -rw-r--r-- 2 penguin penguin 2398538 lrwxrwxrwx 1 penguin penguin 2398521 -rw-r--r-- 2 penguin penguin $ rm foo $ echo "New Content" > foo $ ls -li foo bar baz 2398521 -rw-r--r-- 1 penguin penguin 2398538 lrwxrwxrwx 1 penguin penguin 2398540 -rw-r--r-- 1 penguin penguin $ cat bar Original Content $ cat baz New Content
17 2007-04-29 08:15 bar 3 2007-04-29 08:16 baz -> foo 17 2007-04-29 08:15 foo
17 2007-04-29 08:15 bar 3 2007-04-29 08:16 baz -> foo 12 2007-04-29 08:17 foo
The hardlink can be made within the same filesystem and shares the same inode number which the "-i" option with ls(1) reveals. The symlink always has nominal file access permissions of "rwxrwxrwx", as shown in the above example, with the effective access permissions dictated by permissions of the file that it points to.
Caution
It is generally good idea not to create complicated symbolic links or hardlinks at all unless you have a very good reason. It may cause nightmares where the logical combination of the symbolic links results in loops in the filesystem.
Note
It is generally preferable to use symbolic links rather than hardlinks unless you have a good reason for using a hardlink. The "." directory links to the directory that it appears in, thus the link count of any new directory starts at 2. The ".." directory links to the parent directory, thus the link count of the directory increases with the addition of new subdirectories. If you are just moving to Linux from Windows, it soon becomes clear how well-designed the filename linking of Unix is, compared with the nearest Windows equivalent of "shortcuts". Because it is implemented in the filesystem, applications can't see any difference between a linked file and the original. In the case of hardlinks, there really is no difference.
1.2.9. Sockets
Sockets are used extensively by all the Internet communication, databases, and the operating system itself. It is similar to the named pipe (FIFO) and allows processes to exchange information even between different computers. For the socket, those processes do not need to be running at the same time nor to be running as the children of the same ancestor process. This is the endpoint for the inter process communication (IPC). The exchange of information may occur over the network between different hosts. The two most common ones are the Internet socket and the Unix domain socket.
Tip
"netstat -an" provides a very useful overview of sockets that are open on a given system.
Note
For the normal access to a printer, use lp(1). The device node number are displayed by executing ls(1) as the following. $ ls -l /dev/hda /dev/ttyS0 /dev/zero brw-rw---- 1 root cdrom 3, 0 2007-04-29 07:00 /dev/hda crw-rw---- 1 root dialout 4, 64 2007-04-29 07:00 /dev/ttyS0 crw-rw-rw- 1 root root 1, 5 2007-04-29 07:00 /dev/zero
"/dev/hda" has the major device number 3 and the minor device number 0. This is read/write accessible by the user who belongs to cdrom group. "/dev/ttyS0" has the major device number 4 and the minor device number 64. This is read/write accessible by the user who belongs to dialout group. "/dev/zero" has the major device number 1 and the minor device number 5. This is read/write accessible by anyone. In the Linux 2.6 system, the filesystem under "/dev/" is automatically populated by the udev(7) mechanism.
These are frequently used in conjunction with the shell redirection (see Section 1.5.8, Typical command sequences and shell redirection).
Note
The Linux kernel may complain "Too many open files". You can fix this by increasing "filemax" value to a larger value from the root shell, e.g., "echo "65536" > /proc/sys/fs/file-max" (This was needed on older kernels). People frequently panic when they notice one file in particular - "/proc/kcore" - which is generally huge. This is (more or less) a copy of the content of your computer's memory. It's used to debug the kernel. It is a virtual file that points to computer memory, so don't worry about its size. The directory under "/sys" contains exported kernel data structures, their attributes, and their linkages between them. It also contains interface to change certain kernel parameters at run time. See "proc.txt(.gz)", "sysfs.txt(.gz)" and other related documents in the Linux kernel documentation ("/usr/share/doc/linux-doc-2.6.*/Documentation/filesystems/*") provided by the linux-doc-2.6.* package.
1.3.1. Customization of MC
In order to make MC to change working directory upon exit and cd to the directory, I suggest to modify "~/.bashrc" to include a script provided by the mc package. . /usr/share/mc/bin/mc.sh
See mc(1) (under the "-P" option) for the reason. (If you do not understand what exactly I am talking here, you can do this later.)
1.3.2. Starting MC
MC can be started by the following. $ mc MC takes care of all file operations through its menu, requiring minimal user effort. Just press F1 to get the help screen. You can play with MC just by pressing cursor-keys and function-keys.
Note
In some consoles such as gnome-terminal(1), key strokes of function-keys may be stolen by the console program. You can disable these features by "Edit" "Keyboard Shortcuts" for gnome-terminal. If you encounter character encoding problem which displays garbage characters, adding "-a" to MC's command line may help prevent problems. If this doesn't clear up your display problems with MC, see Section 9.6.6, The terminal configuration.
If you are uncomfortable with vim(1), you can keep using mcedit(1) for most system maintenance tasks.
In order to allow these viewer and virtual file features to function, viewable files should not be set as executable. Change their status using chmod(1) or via the MC file menu.
V:0.2, I:1.0 856 V:0.5, I:1.6 2800 V:0.16, I:1.6 V:0.01, I:0.11 204 228
PATH="${PATH}":/usr/sbin:/sbin # set PATH so it includes user's private bin if it exists if [ -d ~/bin ] ; then PATH=~/bin:"${PATH}" fi export PATH EDITOR=vim export EDITOR
Tip
You can find more bash customization tips, such as Section 9.2.7, Colorized commands, in Chapter 9, System tips.
Tip
The terminal feature of Ctrl-S can be disabled using stty(1).
Left-click-and-drag mouse select and copy to the clipboard Left-click Right-click Middle-click select the start of selection select the end of selection and copy to the clipboard paste clipboard at the cursor
The center wheel on the modern wheel mouse is considered middle mouse button and can be used for middle-click. Clicking left and right mouse buttons together serves as the middle-click under the 2 button mouse system situation. In order to use a mouse in Linux character consoles, you need to have gpm(8) running as daemon.
If you chose either Emacs or XEmacs instead as your choice of the editor, that is another good choice indeed, particularly for programming. Emacs has a plethora of other features as well, including functioning as a newsreader, directory editor, mail program, etc. When used for programming or editing shell scripts, it intelligently recognizes the format of what you are working on, and tries to provide assistance. Some people maintain that the only program they need on Linux is Emacs. Ten minutes learning Emacs now can save hours later. Having the GNU Emacs manual for reference when learning Emacs is highly recommended. All these programs usually come with tutoring program for you to learn them by practice. Start Vim by typing "vim" and press F1-key. You should at least read the first 35 lines. Then do the online training course by moving cursor to "|tutor|" and pressing Ctrl-].
Note
Good editors, such as Vim and Emacs, can be used to handle UTF-8 and other exotic encoding texts correctly with proper option in the x-terminal-emulator on X under UTF-8 locale with proper font settings. Please refer to their documentation on multibyte text.
Tip
Many programs use the environment variables "$EDITOR" or "$VISUAL" to decide which editor to use (see Section 1.3.5, The internal editor in MC and Section 9.5.11, Customizing program to be started). For the consistency on Debian system, set these to "/usr/bin/editor". (Historically, "$EDITOR" was "ed" and "$VISUAL" was "vi".)
examples are not meant to be executed in this order. Try all following commands from the non-privileged user account. Table 1.16. List of basic Unix commands command pwd whoami id file <foo> type -p <commandname> which <commandname> type <commandname> apropos <keyword> man -k <keyword> whatis <commandname> man -a <commandname> info <commandname> ls ls -a ls -A ls -la ls -lai ls -d tree lsof <foo> lsof -p <pid> mkdir <foo> rmdir <foo> cd <foo> cd / cd cd /<foo> cd .. cd ~<foo> cd </etc/motd pager touch <junkfile> cp <foo> <bar> rm <junkfile> mv <foo> <bar> mv <foo> <bar> mv <foo> <bar>/<baz> chmod 600 <foo> chmod 644 <foo> chmod 755 <foo> find . -name <pattern> locate -d . <pattern> grep -e "<pattern>" description display name of current/working directory display current user name display current user identity (name, uid, gid, and associated groups) display a type of file for the file "<foo>" display a file location of command "<commandname>" ,, display information on command "<commandname>" find commands related to "<key-word>" ,, display one line explanation on command "<commandname>" display explanation on command "<commandname>" (Unix style) display rather long explanation on command "<commandname>" (GNU style) list contents of directory (non-dot files and directories) list contents of directory (all files and directories) list contents of directory (almost all files and directories, i.e., skip ".." and ".") list all contents of directory with detail information list all contents of directory with inode number and detail information list all directories under the current directory display file tree contents list open status of file "<foo>" list files opened by the process ID: "<pid>" make a new directory "<foo>" in the current directory remove a directory "<foo>" in the current directory change directory to the directory "<foo>" in the current directory or in the directory listed in the variable "$CDPATH" change directory to the root directory change directory to the current user's home directory change directory to the absolute path directory "/<foo>" change directory to the parent directory change directory to the home directory of the user "<foo>" change directory to the previous directory display contents of "/etc/motd" using the default pager create a empty file "<junkfile>" copy a existing file "<foo>" to a new file "<bar>" remove a file "<junkfile>" rename an existing file "<foo>" to a new name "<bar>" ("<bar>" must not exist) move an existing file "<foo>" to a new location "<bar>/<foo>" (the directory "<bar>" must exist) move an existing file "<foo>" to a new location with a new name "<bar>/<baz>" (the directory "<bar>" must exist but the directory "<bar>/<baz>" must not exist) make an existing file "<foo>" to be non-readable and non-writable by the other people (non-executable for all) make an existing file "<foo>" to be readable but non-writable by the other people (non-executable for all) make an existing file "<foo>" to be readable but non-writable by the other people (executable for all) find matching filenames using shell "<pattern>" (slower) find matching filenames using shell "<pattern>" (quicker using regularly generated database) find a "<pattern>" in all files ending with ".html" in current directory and display them all
them all display process information using full screen, type "q" to quit display information on all the running processes using BSD style output display information on all the running processes using Unix system-V style output
ps aux | grep display all processes running "exim" and "exim4" e "[e]xim4*" ps axf | pager kill <1234> gzip <foo> display information on all the running processes with ASCII art output kill a process identified by the process ID: "<1234>" compress "<foo>" to create "<foo>.gz" using the Lempel-Z iv coding (LZ77) compress "<foo>" to create "<foo>.bz2" using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding (better compression than gzip) decompress "<foo>.bz2" to create "<foo>" compress "<foo>" to create "<foo>.xz" using the LempelZ ivMarkov chain algorithm (better compression than bzip2) decompress "<foo>.xz" to create "<foo>" extract files from "<foo>.tar" archive extract files from gzipped "<foo>.tar.gz" archive extract files from "<foo>.tar.bz2" archive extract files from "<foo>.tar.xz" archive
gunzip <foo>.gz decompress "<foo>.gz" to create "<foo>" bzip2 <foo> bunzip2 <foo>.bz2 xz <foo> unxz <foo>.xz tar -xvf <foo>.tar tar -xvzf <foo>.tar.gz tar -xvjf <foo>.tar.bz2 tar -xvJf <foo>.tar.xz tar -cvf <foo>.tar <bar>/ tar -cvzf <foo>.tar.gz <bar>/ tar -cvjf <foo>.tar.bz2 <bar>/ tar -cvJf <foo>.tar.xz <bar>/ zcat README.gz | pager zcat README.gz > foo zcat README.gz >> foo
display contents of compressed "README.gz" using the default pager create a file "foo" with the decompressed content of "README.gz" append the decompressed content of "README.gz" to the end of the file "foo" (if it does not exist, create it first)
Note
Unix has a tradition to hide filenames which start with ".". They are traditionally files that contain configuration information and user preferences.
Note
For cd command, see builtins(7).
Note
The default pager of the bare bone Debian system is more(1) which cannot scroll back. By installing the less package using command line "apt-get install less", less(1) becomes default pager and you can scroll back with cursor keys.
Note
The "[" and "]" in the regular expression of the "ps aux | grep -e "[e]xim4*"" command above enable grep to avoid matching itself. The "4*" in the regular expression means 0 or more repeats of character "4" thus enables grep to match both "exim" and "exim4". Although "*" is used in the shell filename glob and the regular expression, their meanings are different. Learn the regular expression from grep(1). Please traverse directories and peek into the system using the above commands as training. If you have questions on any of console commands, please make sure to read the manual page. For example, try the following $ $ $ $ man man man man man bash builtins grep
$ man ls The style of man pages may be a little hard to get used to, because they are rather terse, particularly the older, very traditional ones. But once you get used to it, you come to appreciate their succinctness. Please note that many Unix-like commands including ones from GNU and BSD display brief help information if you invoke them in one of the following ways (or without any arguments in some cases). $ <commandname> --help $ <commandname> -h
For language codes and country codes, see pertinent description in the "info gettext". For the codeset on the modern Debian system, you should always set it to UTF-8 unless you specifically want to use the historic one with good reason and background knowledge. For fine details of the locale configuration, see Section 8.3, The locale.
Note
The "LANG=en_US" is not "LANG=C" nor "LANG=en_US.UTF-8". It is "LANG=en_US.ISO-88591" (see Section 8.3.1, Basics of encoding). Table 1.18. List of locale recommendations locale recommendation Language (area) en_US.UTF-8 en_GB.UTF-8 fr_FR.UTF-8 de_DE.UTF-8 it_IT.UTF-8 es_ES.UTF-8 ca_ES.UTF-8 sv_SE.UTF-8 pt_BR.UTF-8 ru_RU.UTF-8 zh_CN.UTF-8 zh_TW.UTF-8 ja_JP.UTF-8 ko_KR.UTF-8 vi_VN.UTF-8 English(USA) English(Great_Britain) French(France) German(Germany) Italian(Italy) Spanish(Spain) Catalan(Spain) Swedish(Sweden) Portuguese(Brazil) Russian(Russia) Chinese(P.R._of_China) Chinese(Taiwan_R.O.C.) Japanese(Japan) Korean(Republic_of_Korea) Vietnamese(Vietnam)
$ date Sun Jun 3 10:27:39 JST 2007 $ LANG=fr_FR.UTF-8 date dimanche 3 juin 2007, 10:27:33 (UTC+0900) Here, the program date(1) is executed with different values of the environment variable "$LANG". For the first command, "$LANG" is set to the system default locale value "en_US.UTF-8". For the second command, "$LANG" is set to the French UTF-8 locale value "fr_FR.UTF-8". Most command executions usually do not have preceding environment variable definition. For the above example, you can alternatively execute as the following. $ LANG=fr_FR.UTF-8 $ date dimanche 3 juin 2007, 10:27:33 (UTC+0900) As you can see here, the output of command is affected by the environment variable to produce French output. If you want the environment variable to be inherited to subprocesses (e.g., when calling shell script), you need to export it instead by the following. $ export LANG
Tip
When filing a bug report, running and checking the command under "LANG=en_US.UTF-8" is good idea if you use non-English environment. See locale(5) and locale(7) for "$LANG" and related environment variables.
Note
I recommend you to configure the system environment just by the "$LANG" variable and to stay away from "$LC_*" variables unless it is absolutely needed.
/home/<normal_user> program run from the normal user shell /home/<normal_user> program run from the normal user GUI desktop menu /home/<normal_user> program run as root with "sudo program" /root program run as root with "sudo -H program"
Tip
Shell expands "~/" to current user's home directory, i.e., "$HOME/". Shell expands "~foo/" to foo's home directory, i.e., "/home/foo/".
pattern using the shell glob, (sometimes referred as wildcards), facilitate this need. Table 1.20. Shell glob patterns shell glob pattern description of match rule * .* ? [] [a-z] [^] filename (segment) not started with "." filename (segment) started with "." exactly one character exactly one character with any character enclosed in brackets exactly one character with any character between "a" and "z" exactly one character other than any character enclosed in brackets (excluding "^")
For example, try the following $ mkdir junk; cd junk; touch 1.txt 2.txt 3.c 4.h .5.txt ..6.txt $ echo *.txt 1.txt 2.txt $ echo * 1.txt 2.txt 3.c 4.h $ echo *.[hc] 3.c 4.h $ echo .* . .. .5.txt ..6.txt $ echo .*[^.]* .5.txt ..6.txt $ echo [^1-3]* 4.h $ cd ..; rm -rf junk See glob(7).
Note
Unlike normal filename expansion by the shell, the shell pattern "*" tested in find(1) with "name" test etc., matches the initial "." of the filename. (New POSIX feature)
Note
BASH can be tweaked to change its glob behavior with its shopt builtin options such as "dotglob", "noglob", "nocaseglob", "nullglob", "nocaseglob", "extglob", etc. See bash(1).
Note
Please note that, in the logical context for the shell, success is treated as the logical TRUE which has 0 (zero) as its value. This is somewhat non-intuitive and needs to be reminded here.
command1 2>&1 pipe both standard output and standard error of command1 to the standard input of | command2 command2 (concurrent execution) command1 ; execute command1 and command2 sequentially
command2 command1 && command2 command1 || command2 command 2> foo command >> foo command 2>> foo
execute command1 and command2 sequentially execute command1; if successful, execute command2 sequentially (return success if both command1 and command2 are successful) execute command1; if not successful, execute command2 sequentially (return success if command1 or command2 are successful)
command > foo redirect standard output of command to a file foo (overwrite) redirect standard error of command to a file foo (overwrite) redirect standard output of command to a file foo (append) redirect standard error of command to a file foo (append)
command > foo redirect both standard output and standard error of command to a file "foo" 2>&1 command < foo redirect standard input of command to a file foo command << delimiter command <<delimiter redirect standard input of command to the following lines until "delimiter" is met (here document) redirect standard input of command to the following lines until "delimiter" is met (here document, the leading tab characters are stripped from input lines)
The Debian system is a multi-tasking system. Background jobs allow users to run multiple programs in a single shell. The management of the background process involves the shell builtins: jobs, fg, bg, and kill. Please read sections of bash(1) under "SIGNALS", and "JOB CONTROL", and builtins(1). For example, try the following $ </etc/motd pager $ pager </etc/motd $ pager /etc/motd $ cat /etc/motd | pager Although all 4 examples of shell redirections display the same thing, the last example runs an extra cat command and wastes resources with no reason. The shell allows you to open files using the exec builtin with an arbitrary file descriptor. $ echo Hello >foo $ exec 3<foo 4>bar $ cat <&3 >&4 $ exec 3<&- 4>&$ cat bar Hello # open files # redirect stdin to 3, stdout to 4 # close files
Here, "n<&-" and "n>&-" mean to close the file descriptor "n". The file descriptor 0-2 are predefined. Table 1.23. Predefined file descriptors device description stdin standard input file descriptor 0 2
la is aliased to ls -la $ type echo echo is a shell builtin $ type file file is /usr/bin/file Here ls was recently searched while "file" was not, thus "ls" is "hashed", i.e., the shell has an internal record for the quick access to the location of the "ls" command.
Tip
See Section 9.2.7, Colorized commands.
Note
Sort order and range expression are locale dependent. If you wish to obtain traditional behavior for a command, use C locale instead of UTF-8 ones by prepnding command with "LANG=C" (see Section 1.5.2, "$LANG" variable and Section 8.3, The locale).
Note
Perl regular expressions (perlre(1)), Perl Compatible Regular Expressions (PCRE), and Python regular expressions offered by the re module have many common extensions to the normal ERE.
\ . [ ] \ . [ ] ^ $ * ^ $ * \+ \? \( \) \{ \} \|
+ ? ( ) { } | c \c . ^ $ \< \> \[abc\] \[^abc\] r* r\+ r\? r1\|r2 \(r1\|r2\) c \c . ^ $ \< \> [abc] [^abc] r* r+ r? r1|r2 (r1|r2)
ERE only non-"\" escaped metacharacters match non-metacharacter "c" match a literal character "c" even if "c" is metacharacter by itself match any character including newline position at the beginning of a string position at the end of a string position at the beginning of a word position at the end of a word match any characters in "abc" match any characters except in "abc" match zero or more regular expressions identified by "r" match one or more regular expressions identified by "r" match zero or one regular expressions identified by "r" match one of the regular expressions identified by "r1" or "r2" match one of the regular expressions identified by "r1" or "r2" and treat it as a bracketed regular expression
The regular expression of emacs is basically BRE but has been extended to treat "+"and "?" as the metacharacters as in ERE. Thus, there are no needs to escape them with "\" in the regular expression of emacs. grep(1) can be used to perform the text search using the regular expression. For example, try the following $ egrep 'GNU.*LICENSE|Yoyodyne' /usr/share/common-licenses/GPL GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE Yoyodyne, Inc., hereby disclaims all copyright interest in the program
Tip
See Section 9.2.7, Colorized commands.
For Perl replacement string, "$n" is used instead of "\n" and "&" has no special meaning. For example, try the following $ echo zzz1abc2efg3hij4 | \ sed -e 's/\(1[a-z]*\)[0-9]*\(.*\)$/=&=/' zzz=1abc2efg3hij4= $ echo zzz1abc2efg3hij4 | \ sed -e 's/\(1[a-z]*\)[0-9]*\(.*\)$/\2===\1/' zzzefg3hij4===1abc $ echo zzz1abc2efg3hij4 | \ perl -pe 's/(1[a-z]*)[0-9]*(.*)$/$2===$1/' zzzefg3hij4===1abc $ echo zzz1abc2efg3hij4 | \ perl -pe 's/(1[a-z]*)[0-9]*(.*)$/=&=/' zzz=&= Here please pay extra attention to the style of the bracketed regular expression and how the matched strings are used in the text replacement process on different tools. These regular expressions can be used for cursor movements and text replacement actions in some editors too. The back slash "\" at the end of line in the shell commandline escapes newline as a white space character and continues shell command line input to the next line. Please read all the related manual pages to learn these commands.
w q EOF The sed(1) command can replace all instances of "FROM_REGEX" with "TO_TEXT" in "file". $ sed file 's/FROM_REGEX/TO_TEXT/g' | sponge file
Tip
The sponge(8) command is a non-standard Unix tool offered by the moreutils package. This is quite useful when you wish to overwrite original file. The vim(1) command can replace all instances of "FROM_REGEX" with "TO_TEXT" in "file" by using ex(1) commands. $ vim '+%s/FROM_REGEX/TO_TEXT/gc' '+w' '+q' file
Tip
The "c" flag in the above ensures interactive confirmation for each substitution. Multiple files ("file1", "file2", and "file3") can be processed with regular expressions similarly with vim(1) or perl(1). $ vim '+argdo %s/FROM_REGEX/TO_TEXT/ge|update' '+q' file1 file2 file3
Tip
The "e" flag in the above prevents the "No match" error from breaking a mapping. $ perl -i -p -e 's/FROM_REGEX/TO_TEXT/g;' file1 file2 file3 In the perl(1) example, "-i" is for in-place editing, "-p" is for implicit loop over files.
Tip
Use of argument "-i.bak" instead of "-i" keeps each original file by adding ".bak" to its filename. This makes recovery from errors easier for complex substitutions.
Note
ed(1) and vim(1) are BRE; perl(1) is ERE.
Tip
See "A Brief History of Debian" for the latest Debian leadership history. Awk is frequently used to extract data from these types of files. For example, try the following $ awk '{ print $3 }' <DPL # month started August April January January April April March $ awk '($1=="Ian") { print }' <DPL # DPL called Ian Ian Murdock August 1993 Ian Jackson January 1998 $ awk '($2=="Perens") { print $3,$4 }' <DPL # When Perens started April 1996 Shells such as Bash can be also used to parse this kind of file. For example, try the following $ while read first last month year; do echo $month done <DPL ... same output as the first Awk example Here, the read builtin command uses characters in "$IFS" (internal field separators) to split lines into
words. If you change "$IFS" to ":", you can parse "/etc/passwd" with shell nicely. $ oldIFS="$IFS" # save old value $ IFS=':' $ while read user password uid gid rest_of_line; do if [ "$user" = "bozo" ]; then echo "$user's ID is $uid" fi done < /etc/passwd bozo's ID is 1000 $ IFS="$oldIFS" # restore old value (If Awk is used to do the equivalent, use "FS=':'" to set the field separator.) IFS is also used by the shell to split results of parameter expansion, command substitution, and arithmetic expansion. These do not occur within double or single quoted words. The default value of IFS is <space>, <tab>, and <newline> combined. Be careful about using this shell IFS tricks. Strange things may happen, when shell interprets some parts of the script as its input. $ IFS=":," $ echo IFS=$IFS, IFS="$IFS" IFS= , IFS=:, $ date -R Sat, 23 Aug 2003 08:30:15 +0200 $ echo $(date -R) Sat 23 Aug 2003 08 30 36 +0200 $ unset IFS $ echo $(date -R) Sat, 23 Aug 2003 08:30:50 +0200 # use ":" and "," as IFS # echo is a Bash builtin # just a command output # sub shell --> input to main shell # reset IFS to the default
One-line shell script can loop over many files using find(1) and xargs(1) to perform quite complicated tasks. See Section 10.1.5, Idioms for the selection of files and Section 9.5.9, Repeating a command looping over files. When using the shell interactive mode becomes too complicated, please consider to write a shell script (see Section 12.1, The shell script).
of free software and distributes them from its archive. The Debian archive is offered by many remote mirror sites for access through HTTP and FTP methods. It is also available as CD-ROM/DVD. The Debian package management system, when used properly, offers the user to install consistent sets of binary packages to the system from the archive. Currently, there are 30552 packages available for the amd64 architecture. The Debian package management system has a rich history and many choices for the front end user program and back end archive access method to be used. Currently, we recommend the following. apt-get(8) for all commandline operations, including package installation and removal, and distupgrades. aptitude(8) for an interactive text interface to manage the installed packages and to search the available packages. update-manager(8) for keeping your system up-to-date if you're running the default GNOME desktop. Table 2.1. List of Debian package management tools package apt * popcon size V:90, I:99 V:25, I:98 5600 description Advanced Packaging Tool (APT), front-end for dpkg providing "http", "ftp", and "file" archive access methods (apt-get/apt-cache commands included)
11916 interactive terminal-based package manager with aptitude(8) GNOME application that manages software updates with updatemanager(8) tool for selecting tasks for installation on Debian system (front-end for APT) enhancement package for APT to enable automatic installation of security upgrades terminal-based package manager (previous standard, front-end for APT and other old access methods) package management system for Debian graphical package manager (GNOME front-end for APT) APT utility programs: apt-extracttemplates(1), apt-ftparchive(1), and apt-sortpkgs(1) package change history notification tool
unattendedV:4, I:31 280 upgrades * dselect * dpkg * synaptic * apt-utils * V:2, I:30 2404 V:92, I:99 V:13, I:40 V:51, I:99 6804 6464 516
aptV:11, listchanges I:17 * aptlistbugs * apt-file * aptrdepends * V:1.4, I:2 V:2, I:9 V:0.13, I:0.9
280
508 188 92
lists critical bugs before each APT installation APT package searching utility command-line interface recursively lists package dependencies
security updates. I mean that some of the following valid actions are better avoided, as a precaution, until you understand the Debian system very well. Here are some reminders. Do not include testing or unstable in "/etc/apt/sources.list". Do not mix standard Debian with other non-Debian archives such as Ubuntu in "/etc/apt/sources.list". Do not create "/etc/apt/preferences". Do not change default behavior of package management tools through configuration files without knowing their full impacts. Do not install random packages by "dpkg -i <random_package>". Do not ever install random packages by "dpkg --force-all -i <random_package>". Do not erase or alter files in "/var/lib/dpkg/". Do not overwrite system files by installing software programs directly compiled from source. Install them into "/usr/local" or "/opt", if needed. The non-compatible effects caused by above actions to the Debian package management system may leave your system unusable. The serious Debian system administrator who runs mission critical servers, should use extra precautions. Do not install any packages including security updates from Debian without thoroughly testing them with your particular configuration under safe conditions. You as the system administrator are responsible for your system in the end. The long stability history of Debian system is no guarantee by itself.
Caution
For your production server, the stable suite with the security updates is recommended. The same can be said for desktop PCs on which you can spend limited administration efforts, e.g. for your mother's PC. It takes no more than simply setting the distribution string in the "/etc/apt/sources.list" to the suite name: "testing" or "unstable"; or the codename: "wheezy" or "sid". This makes you live the life of eternal upgrades. The use of testing or unstable is a lot of fun but comes with some risks. Even though the unstable suite of Debian system looks very stable for most of the times, there have been some package problems on the testing and unstable suite of Debian system and a few of them were not so trivial to resolve. It may be quite painful for you. Sometimes, you may have a broken package or missing functionality for a few weeks. Here are some ideas to ensure quick and easy recovery from bugs in Debian packages. Make the system dual bootable by installing the stable suite of Debian system to another partition Make the installation CD handy for the rescue boot Consider installing apt-listbugs to check the Debian Bug Tracking System (BTS) information before the upgrade Learn the package system infrastructure enough to work around the problem Create a chroot or similar environment and run the latest system in it in advance (see Section 9.8, Virtualized system) (If you can not do any one of these precautionary actions, you are probably not ready for the testing and unstable suites.) Enlightenment with the following saves a person from the eternal karmic struggle of upgrade hell and let him reach Debian nirvana.
Tip
Official policy of the Debian archive is defined at Debian Policy Manual, Chapter 2 - The Debian Archive. For the typical HTTP access, the archive is specified in the "/etc/apt/sources.list" file as the following, e.g. for the current stable = squeeze system. deb http://ftp.XX.debian.org/debian/ squeeze main contrib non-free deb-src http://ftp.XX.debian.org/debian/ squeeze main contrib non-free deb http://security.debian.org/ squeeze/updates main contrib deb-src http://security.debian.org/ squeeze/updates main contrib Please note "ftp.XX.debian.org" must be replaced with appropriate mirror site URL for your location, for USA "ftp.us.debian.org", which can be found in the list of Debian worldwide mirror sites. The status of these servers can be checked at Debian Mirror Checker site. Here, I tend to use codename "squeeze" instead of suite name "stable" to avoid surprises when the next
stable is released. The meaning of "/etc/apt/sources.list" is described in sources.list(5) and key points are followings. The The The The The "deb" line defines for the binary packages. "deb-src" line defines for the source packages. 1st argument is the root URL of the Debian archive. 2nd argument is the distribution name: either the suite name or the codename. 3rd and following arguments are the list of valid archive area names of the Debian archive.
The "deb-src" lines can safely be omitted (or commented out by placing "#" at the start of the line) if it is just for aptitude which does not access source related meta data. It speeds up the updates of the archive meta data. The URL can be "http://", "ftp://", "file://", .
Tip
If "sid" is used in the above example instead of "squeeze", the "deb: http://security.debian.org/ " line for security updates in the "/etc/apt/sources.list" is not required. This is because there is no security update archive for "sid" (unstable). Here is the list of URL of the Debian archive sites and suite name or codename used in the configuration file. Table 2.2. List of Debian archive sites archive URL http://ftp.XX.debian.org/debian/ http://ftp.XX.debian.org/debian/ http://ftp.XX.debian.org/debian/ http://ftp.XX.debian.org/debian/ http://ftp.XX.debian.org/debian/ http://security.debian.org/ http://security.debian.org/ http://ftp.XX.debian.org/debian/ suite name (codename) stable (squeeze) testing (wheezy) unstable (sid) experimental stable-proposedupdates stable/updates testing/updates squeeze-updates purpose stable (squeeze) release testing (wheezy) release unstable (sid) release experimental pre-release (optional, only for developer) Updates for the next stable point release (optional) security updates for stable release (important) security updates for testing release (important) compatible updates for spam filter, IM clients, etc. for squeeze
Caution
Only pure stable release with security updates provides the best stability. Running mostly stable release mixed with some packages from testing or unstable release is riskier than running pure unstable release for library version mismatch etc. If you really need the latest version of some programs under stable release, please use packages from squeeze-updates and backports.debian.org (see Section 2.7.4, Updates and Backports) services. These services must be used with extra care.
Caution
You should basically list only one of stable, testing, or unstable suites in the "deb" line. If you list any combination of stable, testing, and unstable suites in the "deb" line, APT programs slow down while only the latest archive is effective. Multiple listing makes sense for these when the "/etc/apt/preferences" file is used with clear objectives (see Section 2.7.3, Tweaking candidate version).
Tip
For the Debian system with the stable and testing suites, it is a good idea to include lines with "http://security.debian.org/" in the "/etc/apt/sources.list" to enable security updates as in the example above.
Note
The security bugs for the stable archive are fixed by the Debian security team. This activity has been quite rigorous and reliable. Those for the testing archive may be fixed by the Debian testing security team. For several reasons, this activity is not as rigorous as that for stable and you may need to wait for the migration of fixed unstable packages. Those for the unstable archive are fixed by the individual maintainer. Actively maintained unstable packages are usually in a fairly good shape by leveraging latest upstream security fixes. See Debian security FAQ for how Debian handles security bugs. Table 2.3. List of Debian archive area area main number of packages criteria of package component 29887 DSFG compliant and no dependency to non-free
contrib
202
non-free 463
Here the number of packages in the above is for the amd64 architecture. Strictly speaking, only the main area archive shall be considered as the Debian system. The Debian archive organization can be studied best by pointing your browser to the each archive URL appended with dists or pool. The distribution is referred by two ways, the suite or codename. The word distribution is alternatively used as the synonym to the suite in many documentations. The relationship between the suite and the codename can be summarized as the following. Table 2.4. The relationship between suite and codename Timing suite = stable suite = testing suite = unstable codename = sid
after the squeeze release codename = squeeze codename = wheezy after the wheezy release codename = wheezy
The history of codenames are described in Debian FAQ: 6.3.1 Which other codenames have been used in the past? In the stricter Debian archive terminology, the word "section" is specifically used for the categorization of packages by the application area. (Although, the word "main section" may sometimes be used to describe the Debian archive area named as "main".) Every time a new upload is done by the Debian developer (DD) to the unstable archive (via incoming processing), DD is required to ensure uploaded packages to be compatible with the latest set of packages in the latest unstable archive. If DD breaks this compatibility intentionally for important library upgrade etc, there is usually announcement to the debian-devel mailing list etc. Before a set of packages are moved by the Debian archive maintenance script from the unstable archive to the testing archive, the archive maintenance script not only checks the maturity (about 10 days old) and the status of the RC bug reports for the packages but also tries to ensure them to be compatible with the latest set of packages in the testing archive. This process makes the testing archive very current and usable. Through the gradual archive freeze process led by the release team, the testing archive is matured to make it completely consistent and bug free with some manual interventions. Then the new stable release is created by assigning the codename for the old testing archive to the new stable archive and creating the new codename for the new testing archive. The initial contents of the new testing archive is exactly the same as that of the newly released stable archive. Both the unstable and the testing archives may suffer temporary glitches due to several factors. Broken package upload to the archive (mostly for unstable) Delay of accepting the new packages to the archive (mostly for unstable) Archive synchronization timing issue (both for testing and unstable) Manual intervention to the archive such as package removal (more for testing) etc. So if you ever decide to use these archives, you should be able to fix or work around these kinds of glitches.
Caution
For about few months after a new stable release, most desktop users should use the stable archive with its security updates even if they usually use unstable or testing archives. For this transition period, both unstable and testing archives are not good for most people. Your system is difficult to keep in good working condition with the unstable archive since it suffers surges of major upgrades for core packages. The testing archive is not useful either since it contains mostly the same content as the stable archive without its security support (Debian testing-security-announce 2008-12). After a month or so, the unstable archive may be usable if you are careful.
Tip
When tracking the testing archive, problem caused by a removed package is usually worked around by installing corresponding package from the unstable archive which is uploaded for bug fix. See Debian Policy Manual for archive definitions. "Sections" "Priorities" "Base system" "Essential packages"
"Depends" This declares an absolute dependency and all of the packages listed in this field must be installed at the same time or in advance. "Pre-Depends" This is like Depends, except that it requires completed installation of the listed packages in advance. "Recommends" This declares a strong, but not absolute, dependency. Most users would not want the package unless all of the packages listed in this field are installed. "Suggests" This declares a weak dependency. Many users of this package may benefit from installing packages listed in this field but can have reasonable functions without them. "Enhances" This declares a week dependency like Suggests but works in the opposite direction. "Breaks" This declares a package incompatibility usually with some version specification. Generally the resolution is to upgrade all of the packages listed in this field. "Conflicts" This declares an absolute incompatibility. All of the packages listed in this field must be removed to install this package. "Replaces" This is declared when files installed by this package replace files in the listed packages. "Provides" This is declared when this package provide all of the files and functionality in the listed packages.
Note
Please note that defining, "Provides", "Conflicts" and "Replaces" simultaneously to an virtual package is the sane configuration. This ensures that only one real package providing this virtual package can be installed at any one time. The official definition including source dependency can be found in the Policy Manual: Chapter 7 - Declaring relationships between packages.
Remove ("aptitude remove " or "apt-get remove "): 1. 2. 3. 4. Chose packages listed on the command line Make package dependency resolution Run prerm script Remove installed files except configuration files
5. Run postrm script Purge ("aptitude purge " or "apt-get purge "): 1. 2. 3. 4. 5. Chose packages listed on the command line Make package dependency resolution Run prerm script Remove installed files including configuration files Run postrm script
Here, I intentionally skipped technical details for the sake of big picture.
Search Google with search words including "site:debian.org", "site:wiki.debian.org", "site:lists.debian.org", etc. When you file a bug report, please use reportbug(1) command.
Note
Although the aptitude command comes with rich features such as its enhanced package resolver, this complexity has caused (or may still causes) some regressions such as Bug
#411123, Bug #514930, and Bug #570377. In case of doubt, please use the apt-get and apt-cache commands over the aptitude command.
apt-get dist-upgrade install candidate version of installed packages while <package> removing other packages if needed apt-get remove foo apt-get autoremove apt-get purge foo apt-get clean apt-get autoclean apt-cache show <package> apt-cache search <regex> N/A N/A remove "foo" package while leaving its configuration files remove auto-installed packages which is no longer required purge "foo" package with its configuration files clear out the local repository of retrieved package files completely clear out the local repository of retrieved package files for outdated packages display detailed information about "foo" package search packages which match <regex> explain the reason why <regex> matching packages should be installed explain the reason why <regex> matching packages can not be installed
Note
Since apt-get and aptitude share auto-installed package status (see Section 2.5.5, The package state for APT) after lenny, you can mix these tools without major troubles (see Bug #594490). The difference between "safe-upgrade"/"upgrade" and "full-upgrade"/"dist-upgrade" only appears when new versions of packages stand in different dependency relationships from old versions of those packages. The "aptitude safe-upgrade" command does not install new packages nor remove installed packages. The "aptitude why <regex>" can list more information by "aptitude -v why <regex>". Similar information can be obtained by "apt-cache rdepends <package>". When aptitude command is started in the commandline mode and faces some issues such as package conflicts, you can switch to the full screen interactive mode by pressing "e"-key later at the prompt. You may provide command options right after "aptitude". Table 2.7. Notable command options for aptitude(8) command option description -s -d -D simulate the result of the command download only but no install/upgrade show brief explanations before the automatic installations and removals
Tip
The dselect package is still available and was the preferred full screen interactive package management tool in previous releases.
Password: This updates the local copy of the archive information and display the package list in the full screen with menu. Aptitude places its configuration at "~/.aptitude/config".
Tip
If you want to use root's configuration instead of user's one, use "sudo -H aptitude " instead of "sudo aptitude " in the above expression.
Tip
Aptitude automatically sets pending actions as it is started interactively. If you do not like it, you can reset it from menu: "Action" "Cancel pending actions".
The file name specification of the command line and the menu prompt after pressing "l" and "//" take the aptitude regex as described below. Aptitude regex can explicitly match a package name using a string started by "~n and followed by the package name.
Tip
You need to press "U" to get all the installed packages upgraded to the candidate version in the visual interface. Otherwise only the selected packages and certain packages with versioned dependency to them are upgraded to the candidate version.
Here, this line means from the left as the following. The The The The The The The "current state" flag (the first letter) "planned action" flag (the second letter) "automatic" flag (the third letter) Package name change in disk space usage attributed to "planned action" current version of the package candidate version of the package
Tip
The full list of flags are given at the bottom of Help screen shown by pressing "?". The candidate version is chosen according to the current local preferences (see apt_preferences(5) and Section 2.7.3, Tweaking candidate version). Several types of package views are available under the menu "Views". Table 2.9. List of views for aptitude view status description of view
Package View Audit Recommendations Flat Package List Debtags Browser Categorical Browser
see Table 2.10, The categorization of standard package views (default) list packages which are recommended by some installed packages but not yet installed are listed list packages without categorization (for use with regex)
Very usable list packages categorized according to their debtags entries Deprecated list packages categorized according to their category (use Debtags Browser, instead)
Note
Please help us improving tagging packages with debtags! The standard "Package View" categorizes packages somewhat like dselect with few extra features. Table 2.10. The categorization of standard package views category Upgradable Packages New Packages Installed Packages Not Installed Packages Obsolete and Locally Created Packages Virtual Packages Tasks description of view list packages organized as section area package ,, ,, ,, ,, list packages with the same function list packages with different functions generally needed for a task
Tip
Tasks view can be used to cherry pick packages for your task.
Tip
The string for <package_name> is treated as the exact string match to the package name unless it is started explicitly with "~" to be the regex formula.
match essential packages match virtual packages match new packages match with pending action match installed packages match installed packages with A-mark (auto installed package)
~E ~v ~N ~a{install,upgrade,downgrade,remove,purge,hold,keep} ~i ~M
match installed packages without A~i!~M mark (administrator selected package) match installed and upgradable packages match removed but not purged packages match removed, purged or can-beremoved packages match packages with broken relation match packages with broken depends/predepends/conflict ~U ~c ~g ~b ~B<type>
match packages from which relation ~D[<type>:]<term> <type> is defined to <term> package match packages from which broken relation <type> is defined to <term> package match packages to which the <term> package defines relation <type> match packages to which the <term> package defines broken relation <type> match packages to which some other installed packages depend on match packages to which no other installed packages depend on match packages to which some other installed packages depend or recommend on match <term> package with filtered version match all packages (true) match no packages (false) ~DB[<type>:]<term>
~R[<type>:]<term>
~RB[<type>:]<term>
~R~i !~R~i
~R~i|~Rrecommends:~i
~S filter <term> ~T ~F
The regex part is the same ERE as the one used in typical Unix-like text tools using "^", ".*", "$" etc. as in egrep(1), awk(1) and perl(1). The relation <type> is one of (depends, predepends, recommends, suggests, conflicts, replaces, provides). The default relation type is "depends".
Tip
When <regex_pattern> is a null string, place "~T" immediately after the command. Here are some short cuts. "~P<term>" == "~Dprovides:<term>" "~C<term>" == "~Dconflicts:<term>" "~W term" == "(|term)" Users familiar with mutt pick up quickly, as mutt was the inspiration for the expression syntax. See "SEARCHING, LIMITING, AND EXPRESSIONS" in the "User's Manual" "/usr/share/doc/aptitude/README".
Note
With the lenny version of aptitude(8), the new long form syntax such as "?broken" may be used for regex matching in place for its old short form equivalent "~b". Now space character " " is considered as one of the regex terminating character in addition to tilde character "~". See "User's Manual" for the new long form syntax.
Note
Before the lenny release, apt-get and other standard APT tools did not offer the autoremove functionality.
In reality, it is not so easy to get meaningful understanding quickly out from these logs. See Section 9.2.10, Recording changes in configuration files for easier way.
chance to remove garbages collected and exposes you to the best combination of latest packages. Of course, you should make a full backup of system to a safe place (see Section 10.1.6, Backup and recovery) before doing this. I recommend to make a dual boot configuration using different partition to have the smoothest transition. You can perform system wide upgrade to a newer release by changing contents of the "/etc/apt/sources.list" file pointing to a new release and running the "apt-get update; apt-get dist-upgrade" command. To upgrade from stable to testing or unstable, you replace "squeeze" in the "/etc/apt/sources.list" example of Section 2.1.4, Debian archive basics with "wheezy" or "sid". In reality, you may face some complications due to some package transition issues, mostly due to package dependencies. The larger the difference of the upgrade, the more likely you face larger troubles. For the transition from the old stable to the new stable after its release, you can read its new Release Notes and follow the exact procedure described in it to minimize troubles. When you decide to move from stable to testing before its formal release, there are no Release Notes to help you. The difference between stable and testing could have grown quite large after the previous stable release and makes upgrade situation complicated. You should make precautionary moves for the full upgrade while gathering latest information from mailing list and using common senses. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Read previous "Release Notes". Backup entire system (especially data and configuration information). Have bootable media handy for broken bootloader. Inform users on the system well in advance. Record upgrade activity with script(1). Apply "unmarkauto" to required packages, e.g., "aptitude unmarkauto vim", to prevent removal. Minimize installed packages to reduce chance of package conflicts, e.g., remove desktop task packages. Remove the "/etc/apt/preferences" file (disable apt-pinning). Try to upgrade step wise: oldstable stable testing unstable. Update the "/etc/apt/sources.list" file to point to new archive only and run "aptitude update". Install, optionally, new core packages first, e.g., "aptitude install perl". Run the "apt-get -s dist-upgrade" command to assess impact. Run the "apt-get dist-upgrade" command at last.
Caution
It is not wise to skip major Debian release when upgrading between stable releases.
Caution
In previous "Release Notes", GCC, Linux Kernel, initrd-tools, Glibc, Perl, APT tool chain, etc. have required some special attention for system wide upgrade. For daily upgrade in unstable, see Section 2.4.3, Safeguarding for package problems.
apt-cache showsrc <binary_package_name> apt-get build-dep <package_name> apt-get source <package_name> dget <URL for dsc file> dpkg-source -x <package_name>_<version><debian_version>.dsc debuild binary make-kpkg kernel_image make-kpkg --initrd kernel_image dpkg -i <package_name><version><debian_version><arch>.deb debi <package_name><version><debian_version><arch>.dsc dpkg --get-selections '*' >selection.txt dpkg --set-selections <selection.txt
show source package information of a binary package install required packages to build package download a source (from standard archive) download a source packages (from other archive) build a source tree from a set of source packages ("*.orig.tar.gz" and "*.debian.tar.gz"/"*.diff.gz") build package(s) from a local source tree build a kernel package from a kernel source tree build a kernel package from a kernel source tree with initramfs enabled install a local package to the system install local package(s) to the system save dpkg level package selection state information set dpkg level package selection state information
echo <package_name> hold | dpkg - set dpkg level package selection state for a package to hold -set-selections (equivalent to "aptitude hold <package_name>")
Caution
Lower level package tools such as "dpkg -i " and "debi " should be carefully used by the system administrator. It does not automatically take care required package dependencies. Dpkg's commandline options "--force-all" and similar (see dpkg(1)) are intended to be used by experts only. Using them without fully understanding their effects may break your whole system. Please note the following. All system configuration and installation commands require to be run from root. Unlike aptitude which uses regex (see Section 1.6.2, Regular expressions), other package management commands use pattern like shell glob (see Section 1.5.6, Shell glob). apt-file(1) provided by the apt-file package must run "apt-file update" in advance. configure-debian(8) provided by the configure-debian package runs dpkg-reconfigure(8) as its backend. dpkg-reconfigure(8) runs package scripts using debconf(1) as its backend. "apt-get build-dep", "apt-get source" and "apt-cache showsrc" commands require "debsrc" entry in "/etc/apt/sources.list". dget(1), debuild(1), and debi(1) require devscripts package. See (re)packaging procedure using "apt-get source" in Section 2.7.10, Porting a package to the stable system. make-kpkg command requires the kernel-package package (see Section 9.7, The kernel). See Section 12.11, Making Debian package for general packaging.
Note
Because MD5sum database may be tampered by the intruder, debsums(1) is of limited use as a security tool. It is only good for checking local modifications by the administrator or damage due to media errors.
If you need to make more elaborate search on the dpkg meta data, you need to run "grep -e regex_pattern *" command in the "/var/lib/dpkg/info/" directory. This makes you search words mentioned in package scripts and installation query texts. If you wish to look up package dependency recursively, you should use apt-rdepends(8).
top of each distribution/area/architecture archive description used for the rule of combination apt_preferences(5) top of each distribution/area/binaryarchitecture combination top of each distribution/area/source combination concatenated debian/control for binary packages concatenated debian/control for source packages
In the recent archive, these meta data are stored as the compressed and differential files to reduce network traffic.
Note
Here, you can find my rationale to use the "suite", and "codeneme" in Section 2.1.4, Debian archive basics. The "distribution" is used when referring to both "suite" and "codeneme". All archive "area" names offered by the archive are listed under "Component". The integrity of the top level "Release" file is verified by cryptographic infrastructure called the secure apt. The cryptographic signature file "Release.gpg" is created from the authentic top level "Release" file and the secret Debian archive key. The public Debian archive key can be seeded into "/etc/apt/trusted.gpg"; automatically by installing the keyring with the latest base-files package, or manually by gpg or apt-key tool with the latest public archive key posted on the ftpmaster.debian.org . The secure APT system verifies the integrity of the downloaded top level "Release" file cryptographically by this "Release.gpg" file and the public Debian archive key in "/etc/apt/trusted.gpg". The integrity of all the "Packages" and "Sources" files are verified by using MD5sum values in its top level "Release" file. The integrity of all package files are verified by using MD5sum values in the "Packages" and "Sources" files. See debsums(1) and Section 2.4.2, Verification of installed package files. Since the cryptographic signature verification is very CPU intensive process than the MD5sum value
calculation, use of MD5sum value for each package while using cryptographic signature for the top level "Release" file provides the good security with the performance (see Section 10.4, Data security infrastructure).
Caution
For "Archive:" stanza, suite names ("stable", "testing", "unstable", ) are used in the Debian archive while codenames ("dapper", "feisty", "gutsy", "hardy", "intrepid", ) are used in the Ubuntu archive. For some archives, such as experimental, and squeeze-backports, which contain packages which should not be installed automatically, there is an extra line, e.g., "http://ftp.us.debian.org/debian/dists/experimental/main/binary-amd64/Release" as follows. Archive: experimental Component: main Origin: Debian Label: Debian NotAutomatic: yes Architecture: amd64 Please note that for normal archives without "NotAutomatic: yes", the default Pin-Priority value is 500, while for special archives with "NotAutomatic: yes", the default Pin-Priority value is 1 (see apt_preferences(5) and Section 2.7.3, Tweaking candidate version).
All the remotely fetched packages via APT mechanism are stored in the "/var/cache/apt/packages" until they are cleaned.
Tip
Here only the basic source package formats are described. See more on dpkg-source(1). Table 2.16. The usable characters for each component in the Debian package names name component <package-name> <epoch>: <debian.version> usable characters (regex) existence [a-z,A-Z,0-9,.,,-] [0-9]+: [a-z,A-Z,0-9,.,,~] required optional required optional
<upstream-version> [a-z,A-Z,0-9,.,,-,:]
Note
You can check package version order by dpkg(1), e.g., "dpkg --compare-versions 7.0 gt 7.~pre1 ; echo $?" .
Note
The debian-installer (d-i) uses udeb as the file extension for its binary package instead of normal deb. An udeb package is a stripped down deb package which removes few nonessential contents such as documentation to save space while relaxing the package policy requirements. Both deb and udeb packages share the same package structure. The "u" stands for micro.
The debconf system provides standardized user interaction with I18N and L10N (Chapter 8, I18N and L10N) supports. Table 2.17. The notable files created by dpkg file description of contents
/var/lib/dpkg/info/<package_name>.conffiles list of configuration files. (user modifiable) /var/lib/dpkg/info/<package_name>.list /var/lib/dpkg/info/<package_name>.md5sums /var/lib/dpkg/info/<package_name>.preinst /var/lib/dpkg/info/<package_name>.postinst /var/lib/dpkg/info/<package_name>.prerm /var/lib/dpkg/info/<package_name>.postrm /var/lib/dpkg/info/<package_name>.config /var/lib/dpkg/alternatives/<package_name> list of files and directories installed by the package list of MD5 hash values for files installed by the package package script run before the package installation package script run after the package installation package script run before the package removal package script run after the package removal package script for debconf system the alternative information used by the update-
alternatives command the availability information for all the package the diversions information used by dpkg(1) and set by`dpkg-divert`(8) the stat override information used by dpkg(1) and set by`dpkg-statoverride`(8) the status information for all the packages the first-generation backup of the "var/lib/dpkg/status" file the second-generation backup and older ones of the "var/lib/dpkg/status" file
The "status" file is also used by the tools such as dpkg(1), "dselect update" and "apt-get -u dselect-upgrade". The specialized search command grep-dctrl(1) can search the local copies of "status" and "available" meta data.
Tip
In the debian-installer environment, the udpkg command is used to open udeb packages. The udpkg command is a stripped down version of the dpkg command.
Caution
The direct alteration of owner or mode for a file owned by the package using chmod or chown commands by the system administrator is reset by the next upgrade of the package.
Note
I use the word file here, but in reality this can be any filesystem object that dpkg handles, including directories, devices, etc.
Caution
Some methods described here are high risk actions. You have been warned!
Caution
The use of third party packages introduces significant system risks via maintainer scripts which are run with root privilege and can do anything to your system. The dpkg(1) command only protects against overwriting by the unpacking. You can work around such broken installation by removing the old offending package, <old-package>, first. $ sudo dpkg -P <old-package>
Tip
If system breakage is minor, you may alternatively downgrade the whole system as Section 2.7.7, Emergency downgrading using the higher level APT system. If your system is unbootable from hard disk, you should seek other ways to boot it. 1. Boot the system using the debian-installer CD in rescue mode. 2. Mount the unbootable system on the hard disk to "/target". 3. Install older version of foo package by the following. # dpkg --root /target -i /path/to/foo_<old_version>_<arch>.deb This example works even if the dpkg command on the hard disk is broken.
Tip
Any GNU/Linux system started by another system on hard disk, live GNU/Linux CD, bootable USB-key drive, or netboot can be used similarly to rescue broken system. If attempting to install a package this way fails due to some dependency violations and you really need to do this as the last resort, you can override dependency using dpkg's "--ignore-depends", "--forcedepends" and other options. If you do this, you need to make serious effort to restore proper dependency later. See dpkg(8) for details.
Note
When your system is seriously broken, you should make a full backup of system to a safe
place (see Section 10.1.6, Backup and recovery) and should perform a clean installation. This is less time consuming and produces better results in the end.
Then you are presented with package names to install. (There may be some non-package names such as "texmf".)
You do not create the "/etc/apt/preferences" file nor need to worry about apt-pinning with this manual approach. But this is very cumbersome.
Caution
When using mixed source of archives, you must ensure compatibility of packages by yourself since the Debian does not guarantee it. If package incompatibility exists, you may break system. You must be able to judge these technical requirements. The use of mixed source of random archives is completely optional operation and its use is not something I encourage you to use. General rules for installing packages from different archives are followings.
Non-binary packages ("Architecture: all") are safer to install. documentation packages: no special requirements interpreter program packages: compatible interpreter must be available Binary packages (non "Architecture: all") usually face many road blocks and unsafe to install. library version compatibility (including "libc") related utility program version compatibility Kernel ABI compatibility C++ ABI compatibility
Note
In order to make a package to be safer to install, some commercial non-free binary program packages may be provided with completely statically linked libraries. You should still check ABI compatibility issues etc. for them.
Note
Except to avoid broken package for a short term, installing binary packages from officially unsupported archives is generally bad idea. This is true even if you use apt-pinning (see Section 2.7.3, Tweaking candidate version). You should consider chroot or similar techniques (see Section 9.8, Virtualized system) to run programs from different archives.
Tip
The version string comparison rule can be verified with, e.g., "dpkg --compare-versions ver1.1 gt ver1.1~1; echo $?" (see dpkg(1)). When you install packages from mixed source of archives (see Section 2.7.2, Packages from mixed source of archives) regularly, you can automate these complicated operations by creating the "/etc/apt/preferences" file with proper entries and tweaking the package selection rule for candidate version as described in apt_preferences(5). This is called apt-pinning.
Warning
Use of apt-pinning by a novice user is sure call for major troubles. You must avoid using aptpinning except when you absolutely need it.
Caution
When using apt-pinning, you must ensure compatibility of packages by yourself since the Debian does not guarantee it. The apt-pinning is completely optional operation and its use is not something I encourage you to use.
Caution
Archive level Release files (see Section 2.5.3, Archive level "Release" files) are used for the rule of apt_preferences(5). Thus apt-pinning works only with "suite" name for normal Debian archives and security Debian archives. (This is different from Ubuntu archives). For example, you can do "Pin: release a=unstable" but can not do "Pin: release a=sid" in the "/etc/apt/preferences" file.
Caution
When you use non-Debian archive as a part of apt-pinning, you should check what they are intended for and also check their credibility. For example, Ubuntu and Debian are not meant to be mixed.
Note
Even if you do not create the "/etc/apt/preferences" file, you can do fairly complex system operations (see Section 2.6.4, Rescue with the dpkg command and Section 2.7.2, Packages from mixed source of archives) without apt-pinning. Here is a simplified explanation of apt-pinning technique. APT system choses highest Pin-Priority upgrading package from available package sources defined in the "/etc/apt/sources.list" file as the candidate version package. If the Pin-Priority of the package is larger than 1000, this version restriction for upgrading is dropped to enable downgrading (see Section 2.7.7, Emergency downgrading). Pin-Priority value of each package is defined by "Pin-Priority" entries in the "/etc/apt/preferences" file or uses its default value. Table 2.18. List of the default Pin-Priority value for each package source type
default Pin-Priority package source type 990 500 100 1 target release archive normal archive installed package NotAutomatic archive
The target release archive can be set by several methods. "/etc/apt/apt.conf" configuration file with "APT::Default-Release "stable";" line command line option, e.g., "apt-get install -t testing some-package" The NotAutomatic archive is set by archive server having its archive level Release file (see Section 2.5.3, Archive level "Release" files) containing "NotAutomatic: yes". The apt-pinning situation of <package> from multiple archive sources is displayed by "apt-cache policy <package>". A line started with "Package pin:" lists the package version of pin if association just with <package> is defined, e.g., "Package pin: 0.190". No line with "Package pin:" exists if no association just with <package> is defined. The Pin-Priority value associated just with <package> is listed right side of all version strings, e.g., "0.181 700". "0" is listed right side of all version strings if no association just with <package> is defined, e.g., "0.181 0". The Pin-Priority values of archives (defined as "Package: *" in the "/etc/apt/preferences" file) are listed left side of all archive paths, e.g., "200 http://backports.debian.org/debianbackports/ squeeze-backports/main Packages". Here is an example of apt-pinning technique to include specific newer upstream version packages found in unstable regularly upgraded while tracking testing. You list all required archives in the "/etc/apt/sources.list" file as the following. deb http://ftp.us.debian.org/debian/ testing main contrib non-free deb http://ftp.us.debian.org/debian/ unstable main contrib non-free deb http://security.debian.org/ testing/updates main contrib Set the "/etc/apt/preferences" file as as the following. Package: * Pin: release a=testing Pin-Priority: 500 Package: * Pin: release a=unstable Pin-Priority: 200 When you wish to install a package named "<package-name>" with its dependencies from unstable archive under this configuration, you issue the following command which switches target release with "-t" option (Pin-Priority of unstable becomes 990.). $ sudo apt-get install -t unstable <package-name> With this configuration, usual execution of "apt-get upgrade" and "apt-get dist-upgrade" (or "aptitude safe-upgrade" and "aptitude full-upgrade") upgrades packages which were installed from testing archive using current testing archive and packages which were installed from unstable archive using current unstable archive.
Caution
Be careful not to remove "testing" entry from the "/etc/apt/sources.list" file. Without "testing" entry in it, APT system upgrades packages using newer unstable archive.
Tip
I usually edit the "/etc/apt/sources.list" file to comment out "unstable" archive entry right after above operation. This avoids slow update process of having too many entries in the "/etc/apt/sources.list" file although this prevents upgrading packages which were installed from unstable archive using current unstable archive.
Tip
If "Pin-Priority: 20" is used instead of "Pin-Priority: 200" for the "/etc/apt/preferences" file, already installed packages having Pin-Priority value of 100 are not upgraded by unstable archive even if "testing" entry in the "/etc/apt/sources.list" file is removed. If you wish to track particular packages in unstable automatically without initial "-t unstable" installation, you must create the "/etc/apt/preferences" file and explicitly list all those packages at the top of it as the following. Package: <package-1> Pin: release a=unstable Pin-Priority: 700 Package: <package-2>
Pin: release a=unstable Pin-Priority: 700 These set Pin-Priority value for each specific package. For example, in order to track the latest unstable version of this "Debian Reference" in English, you should have following entries in the "/etc/apt/preferences" file. Package: debian-reference-en Pin: release a=unstable Pin-Priority: 700 Package: debian-reference-common Pin: release a=unstable Pin-Priority: 700
Tip
This apt-pinning technique is valid even when you are tracking stable archive. Documentation packages have been always safe to install from unstable archive in my experience, so far. Here is another example of apt-pinning technique to include specific newer upstream version packages found in experimental while tracking unstable. You list all required archives in the "/etc/apt/sources.list" file as the following. deb http://ftp.us.debian.org/debian/ unstable main contrib non-free deb http://ftp.us.debian.org/debian/ experimental main contrib non-free deb http://security.debian.org/ testing/updates main contrib The default Pin-Priority value for experimental archive is always 1 (<<100) since it is NotAutomatic archive (see Section 2.5.3, Archive level "Release" files). There is no need to set Pin-Priority value explicitly in the "/etc/apt/preferences" file just to use experimental archive unless you wish to track particular packages in it automatically for next upgrading.
Warning
Do not use all packages available in the NotAutomatic archives such as squeezebackports. Use only selected packages which fits your needs. Here is an example of apt-pinning technique to include specific newer upstream version packages found in squeeze-backports while tracking squeeze and squeeze-updates. You list all required archives in the "/etc/apt/sources.list" file as the following. deb deb deb deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free http://security.debian.org/ squeeze/updates main contrib http://ftp.us.debian.org/debian/ squeeze-updates main contrib non-free http://backports.debian.org/debian-backports/ squeeze-backports main contrib non-free
The default Pin-Priority value for backports.debian.org archive is always 1 (<<100) since it is NotAutomatic archive (see Section 2.5.3, Archive level "Release" files). There is no need to set PinPriority value explicitly in the "/etc/apt/preferences" file just to use backports.debian.org archive unless you wish to track particular packages in it automatically for next upgrading. So whenever you wish to install a package named "<package-name>" with its dependency from squeezebackports archive, you use following command while switching target release with "-t" option. $ sudo apt-get install -t squeeze-backports <package-name> If you wish to upgrade particular packages, you must create the "/etc/apt/preferences" file and explicitly lists all packages in it as the following. Package: <package-1> Pin: release o=Backports.org archive Pin-Priority: 700 Alternatively, with the "/etc/apt/preferences" file as the following. Package: * Pin: release a=stable , o=Debian Pin-Priority: 500 Package: * Pin: release a=squeeze-updates, o=Debian Pin-Priority: 500 Package: * Pin: release a=squeeze-backports, o=Backports.org archive Pin-Priority: 200 Execution of "apt-get upgrade" and "apt-get dist-upgrade" (or "aptitude safe-upgrade" and "aptitude full-upgrade") upgrades packages which were installed from stable archive using current stable archive and packages which were installed from other archives using current corresponding archive for all archives in the "/etc/apt/sources.list" file.
Tip
It is good idea to remove (not purge!) as much packages to minimize dependency problems. You may need to manually remove and install some packages to get system downgraded. Linux kernel, bootloader, udev, PAM, APT, and networking related packages and their configuration files require special attention.
Section: admin Description: Circumventing Debian package dependencies This is a dummy package which can be used to create Debian packages, which only contain dependency information.
Install required packages for the compilation and download the source package as the following. # # # $ $ $ apt-get apt-get apt-get apt-get apt-get cd foo* update dist-upgrade install fakeroot devscripts build-essential build-dep foo source foo
Adjust installed packages if needed. Execute the following. $ dch -i Bump package version, e.g. one appended with "+bp1" in "debian/changelog" Build packages and install them to the system as the following. $ debuild $ cd .. # debi foo*.changes
Caution
When Debian reorganizes its archive structure, these specialized proxy tools tend to require code rewrites by the package maintainer and may not be functional for a while. On the other hand, generic web (http) proxy servers are more robust and easier to cope with such changes.
uid Foo (ARCHIVE KEY) <[email protected]> ssb 2048g/6856F4A7 2008-08-14 $ gpg --export -a 3A3CB5A6 >foo.public.key Publish the archive key file "foo.public.key" with the key ID "3A3CB5A6" for Foo Create an archive tree called "Origin: Foo" as the following. $ umask 022 $ mkdir -p ~/public_html/debian/pool/main $ mkdir -p ~/public_html/debian/dists/unstable/main/binary-amd64 $ mkdir -p ~/public_html/debian/dists/unstable/main/source $ cd ~/public_html/debian $ cat > dists/unstable/main/binary-amd64/Release << EOF Archive: unstable Version: 4.0 Component: main Origin: Foo Label: Foo Architecture: amd64 EOF $ cat > dists/unstable/main/source/Release << EOF Archive: unstable Version: 4.0 Component: main Origin: Foo Label: Foo Architecture: source EOF $ cat >aptftp.conf <<EOF APT::FTPArchive::Release { Origin "Foo"; Label "Foo"; Suite "unstable"; Codename "sid"; Architectures "amd64"; Components "main"; Description "Public archive for Foo"; }; EOF $ cat >aptgenerate.conf <<EOF Dir::ArchiveDir "."; Dir::CacheDir "."; TreeDefault::Directory "pool/"; TreeDefault::SrcDirectory "pool/"; Default::Packages::Extensions ".deb"; Default::Packages::Compress ". gzip bzip2"; Default::Sources::Compress "gzip bzip2"; Default::Contents::Compress "gzip bzip2"; BinDirectory "dists/unstable/main/binary-amd64" { Packages "dists/unstable/main/binary-amd64/Packages"; Contents "dists/unstable/Contents-amd64"; SrcPackages "dists/unstable/main/source/Sources"; }; Tree "dists/unstable" { Sections "main"; Architectures "amd64 source"; }; EOF You can automate repetitive updates of APT archive contents on your server system by configuring dupload. Place all package files into "~foo/public_html/debian/pool/main/" by executing "dupload -t foo changes_file" in client while having "~/.dupload.conf" containing the following. $cfg{'foo'} = { fqdn => "www.example.com", method => "scpb", incoming => "/home/foo/public_html/debian/pool/main", # The dinstall on ftp-master sends emails itself dinstall_runs => 1, }; $cfg{'foo'}{postupload}{'changes'} = " echo 'cd public_html/debian ; apt-ftparchive generate -c=aptftp.conf aptgenerate.conf; apt-ftparchive release -c=aptftp.conf dists/unstable >dists/unstable/Release ; rm -f dists/unstable/Release.gpg ; gpg -u 3A3CB5A6 -bao dists/unstable/Release.gpg dists/unstable/Release'| ssh [email protected] 2>/dev/null ; echo 'Package archive created!'"; The postupload hook script initiated by dupload(1) creates updated archive files for each upload.
You can add this small public archive to the apt-line of your client system by the following. $ sudo bash # echo "deb http://www.example.com/~foo/debian/ unstable main" \ >> /etc/apt/sources.list # apt-key add foo.public.key
Tip
If the archive is located on the local filesystem, you can use "deb file:///home/foo/debian/ " instead.
If you are thinking about managing many servers in a cluster with practically the same configuration, you should consider to use specialized package such as fai to manage the whole system.
Warning
alien(1) should not be used to replace essential system packages, such as sysvinit, libc6, libpam-modules, etc. Practically, alien(1) should only used for non-free binaryonly packages which are LSB compliant or statically linked. For free softwares, you should use their source packages to make real Debian packages.
It is wise for you as the system administrator to know roughly how the Debian system is started and configured. Although the exact details are in the source files of the packages installed and their documentations, it is a bit overwhelming for most of us. I did my best to provide a quick overview of the key points of the Debian system and their configuration for your reference, based on the current and previous knowledge of mine and others. Since the Debian system is a moving target, the situation over the system may have been changed. Before making any changes to the system, you should refer to the latest documentation for each package.
Of course, these can be configured differently. For example, if you compiled your own kernel, you may be skipping the step with the mini-Debian system. So please do not assume this is the case for your system until you check it yourself.
Note
For non-legacy PC platform such as the SUN or the Macintosh system, the BIOS on ROM and the partition on the disk may be quite different (Section 9.3.1, Disk partition configuration). Please seek the platform specific documentations elsewhere for such a case.
GRUB 2
3896 Supported
GRUB 2
rescue-pc I:0.5 * lilo * syslinux * syslinux * loadlin * V:0.5, I:2 V:1.3, I:8 V:1.3, I:8 V:0.03, I:0.2 V:0.8, I:5
3896 Supported
floppy) (PC/BIOS version) This relies on the sector locations of data on the hard disk. (Old) This understands the ISO9660 filesystem. This is used by the boot CD. This understands the MSDOS filesystem (FAT). This is used by the boot floppy. New system is started from the FreeDOS/MSDOS system.
Not This is free software which substitutes MSDOS MBR. supported This only understands disk partitions.
Warning
Do not play with boot loaders without having bootable rescue media (CD or floppy) created from images in the grub-rescue-pc package. It makes you boot your system even without functioning bootloader on the hard disk. For GRUB Legacy, the menu configuration file is located at "/boot/grub/menu.lst". For example, it has entries as the following. title root kernel initrd Debian GNU/Linux (hd0,2) /vmlinuz root=/dev/hda3 ro /initrd.img
For GRUB 2, the menu configuration file is located at "/boot/grub/grub.cfg". It is automatically generated by "/usr/sbin/update-grub" using templates from "/etc/grub.d/*" and settings from "/etc/default/grub". For example, it has entries as the following. menuentry "Debian GNU/Linux" { set root=(hd0,3) linux /vmlinuz root=/dev/hda3 initrd /initrd.img } For these examples, these GRUB parameters mean the following. Table 3.2. The meaning of GRUB parameters GRUB parameter root kernel initrd meaning use 3rd partition on the primary disk by setting it as "(hd0,2)" in GRUB legacy or as "(hd0,3)" in GRUB 2 use kernel located at "/vmlinuz" with kernel parameter: "root=/dev/hda3 ro" use initrd/initramfs image located at "/initrd.img"
Note
The value of the partition number used by GRUB legacy program is one less than normal one used by Linux kernel and utility tools. GRUB 2 program fixes this problem.
Tip
UUID (see Section 9.3.2, Accessing partition using UUID) may be used to identify a block special device instead of its file name such as "/dev/hda3", e.g."root=UUID=81b289d54341-4003-9602-e254a17ac232 ro".
Tip
You can start a boot loader from another boot loader using techniques called chain loading. See "info grub" and grub-install(8).
Note
The term "the mini-Debian system" is coined by the author to describe this 3rd stage boot process for this document. This system is commonly referred as the initrd or initramfs system. Similar system on the memory is used by the Debian Installer. The "/init" script is executed as the first program in this root filesystem on the memory. It is a shell script program which initializes the kernel in user space and hands control over to the next stage. This miniDebian system offers flexibility to the boot process such as adding kernel modules before the main boot process or mounting the root filesystem as an encrypted one.
You can interrupt this part of the boot process to gain root shell by providing "break=init" etc. to the kernel boot parameter. See the "/init" script for more break conditions. This shell environment is sophisticated enough to make a good inspection of your machine's hardware. Commands available in this mini-Debian system are stripped down ones and mainly provided by a GNU tool called busybox(1).
Caution
You need to use "-n" option for mount command when you are on the readonly root filesystem.
readahead-fedora V:0.3, I:0.5 144 readahead(8) to preload boot process files * uswsusp * kexec-tools * bootchart * bootchart-view * mingetty * mgetty * V:4, I:14 V:0.17, I:0.5 V:0.13, I:0.7 V:0.10, I:0.6 V:0.19, I:0.6 536 tools to use userspace software suspend provided by Linux 320 kexec tool for kexec(8) reboots (warm reboot) 132 boot process performance analyser 280 boot process performance analyser (visualisation) console-only getty(8)
V:0.2, I:0.5 64
Note
This section describes classical System V style boot system on lenny. Debian is moving to the event driven boot system. See The future of the boot system in Debian and Dependency based boot sequence.
Tip
All boot mechanisms are compatible through "/etc/init.d/rc", "/etc/init.d/rcS", "/usr/sbin/update-rc.d", and "/usr/sbin/invoke-rc.d" scripts.
Tip
The readahead-fedora package can speed up starting of a system with decent amount of DRAM. The normal Debian system is the 4th stage of the boot process which is started by the mini-Debian system. The system kernel for the mini-Debian system continues to run in this environment. The root filesystem is switched from the one on the memory to the one on the real hard disk filesystem. The "/sbin/init" program is executed as the first program and performs the main boot process. The Debian normally uses the traditional sysvinit scheme with the sysv-rc package. See init(8), inittab(5), and "/usr/share/doc/sysv-rc/README.runlevels.gz" for the exact explanation. This main boot process essentially goes through the following. 1. The Debian system goes into runlevel N (none) to initialize the system by following the "/etc/inittab" description. 2. The Debian system goes into runlevel S to initialize the system under the single-user mode to complete hardware initialization etc. 3. The Debian system goes into one of the specified multi-user runlevels (2 to 5) to start the system services. The initial runlevel used for multi-user mode is specified with the "init=" kernel boot parameter or in the "initdefault" line of the "/etc/inittab". The Debian system as installed starts at the runlevel 2. All actual script files executed by the init system are located in the directory "/etc/init.d/".
Table 3.4. List of runlevels and description of their usage runlevel directory N 0 S 1 2 3 4 5 6 7 8 9 none description of runlevel usage system bootup (NONE) level (no "/etc/rcN.d/" directory)
/etc/rc0.d/ halt the system /etc/rcS.d/ single-user mode on boot (alias: "s") /etc/rc1.d/ single-user mode switched from multi-user mode /etc/rc2.d/ multi-user mode /etc/rc3.d/ ,, /etc/rc4.d/ ,, /etc/rc5.d/ ,, /etc/rc6.d/ reboot the system /etc/rc7.d/ valid multi-user mode but not normally used /etc/rc8.d/ ,, /etc/rc9.d/ ,,
You can change the runlevel from the console to, e.g., 4 by the following. $ sudo telinit 4
Caution
The Debian system does not pre-assign any special meaning differences among the runlevels between 2 and 5. The system administrator on the Debian system may change this. (I.e., Debian is not Red Hat Linux nor Solaris by Sun Microsystems nor HP-UX by Hewlett Packard nor AIX by IBM nor )
Caution
The Debian system does not populate directories for the runlevels between 7 and 9 when the package is installed. Traditional Unix variants don't use these runlevels.
Warning
It is not advisable to make any changes to symlinks in "/etc/rcS.d/" unless you know better than the maintainer.
Please note the "/etc/X11/default-display-manager" file is checked when starting the display manager daemons: xdm, gdm, kdm, and wdm.
Note
You can still start X from any console shell with the startx(1) command.
Note
The actual mounting of network filesystems waits for the start of the network interface.
Warning
After mounting all the filesystems, temporary files in "/tmp", "/var/lock", and "/var/run" are cleaned for each boot up.
Tip
If "/lib/modules/<kernel-version>/modules.dep" was not generated properly by depmod(8) for some reason, modules may not be loaded as expected by the udev system. Execute "depmod -a" to fix it. The name of device nodes can be configured by udev rule files in "/etc/udev/rules.d/". Current default rules tend to create dynamically generated names resulting non-static device names except for cd and network devices. By adding your custom rules similar to what cd and network devices do, you can generate static device names for other devices such as USB memory sticks, too. See "Writing udev rules" or "/usr/share/doc/udev/writing_udev_rules/index.html". Since the udev system is somewhat a moving target, I leave details to other documentations and describe the minimum information here.
Tip
For mounting rules in "/etc/fstab", device nodes do not need to be static ones. You can use UUID to mount devices instead of device names such as "/dev/sda". See Section 9.3.2, Accessing partition using UUID.
Note
If you experience module loading issues with boot time module loading or with modprobe(8), "depmod -a" may resolve these issues by reconstructing "modules.dep". The modinfo(8) program shows information about a Linux kernel module. The lsmod(8) program nicely formats the contents of the "/proc/modules", showing what kernel modules are currently loaded.
Tip
You can identify exact hardware on your system. See Section 9.6.3, Hardware identification.
Tip
You may configure hardware at boot time to activate expected hardware features. See Section 9.6.4, Hardware configuration.
Tip
You can add support for your device by recompiling kernel. See Section 9.7, The kernel.
Chapter 4. Authentication
When a person (or a program) requests access to the system, authentication confirms the identity to be a trusted one.
Warning
Configuration errors of PAM may lock you out of your own system. You must have a rescue CD handy or setup an alternative boot partition. To recover, boot the system with them and correct things from there.
"/etc/passwd" contains the following. ... user1:x:1000:1000:User1 Name,,,:/home/user1:/bin/bash user2:x:1001:1001:User2 Name,,,:/home/user2:/bin/bash ... As explained in passwd(5), each ":" separated entry of this file means the following. Login name Password specification entry Numerical user ID Numerical group ID User name or comment field User home directory Optional user command interpreter The second entry of "/etc/passwd" was used for the encrypted password entry. After the introduction of "/etc/shadow", this entry is used for the password specification entry. Table 4.2. The second entry content of "/etc/passwd" content meaning (empty) passwordless account x * ! the encrypted password is in "/etc/shadow" no login for this account no login for this account
"/etc/shadow" contains the following. ... user1:$1$Xop0FYH9$IfxyQwBe9b8tiyIkt2P4F/:13262:0:99999:7::: user2:$1$vXGZLVbS$ElyErNf/agUDsm1DehJMS/:13261:0:99999:7::: ... As explained in shadow(5), each ":" separated entry of this file means the following. Login name Encrypted password (The initial "$1$" indicates use of the MD5 encryption. The "*" indicates no login.) Days since Jan 1, 1970 that password was last changed Days before password may be changed Days after which password must be changed Days before password is to expire that user is warned "/etc/group" contains the following.
group1:x:20:user1,user2 As explained in group(5), each ":" separated entry of this file means the following. Group name Encrypted password (not really used) Numerical group ID "," separated list of user names
Note
"/etc/gshadow" provides the similar function as "/etc/shadow" for "/etc/group" but is not really used.
Note
The actual group membership of a user may be dynamically added if "auth optional pam_group.so" line is added to "/etc/pam.d/common-auth" and set it in "/etc/security/group.conf". See pam_group(8).
Note
The base-passwd package contains an authoritative list of the user and the group: "/usr/share/doc/base-passwd/users-and-groups.html".
getent passwd <user_name> browse account information of "<user_name>" getent shadow <user_name> browse shadowed account information of "<user_name>" getent group <group_name> browse group information of "<group_name>" passwd passwd -e chage manage password for the account set one-time password for the account activation manage password aging information
You may need to have the root privilege for some functions to work. See crypt(3) for the password and data encryption.
Note
On the system set up with PAM and NSS as the Debian alioth machine, the content of local "/etc/passwd", "/etc/group" and "/etc/shadow" may not be actively used by the system. Above commands are valid even under such environment.
Warning
Do not chose guessable words for the password.
openssl * V:56, I:91 2380 openssl passwd compute password hashes (OpenSSL). passwd(1ssl)
password data exchange. NSS offers a flexible name service mechanism which is frequently used by the C standard library to obtain the user and group name for programs such as ls(1) and id(1). These PAM and NSS systems need to be configured consistently. The notable packages of PAM and NSS systems are the following. Table 4.5. List of notable PAM and NSS systems package libpam-modules * libpam-ldap * popcon size V:88, I:99 1036 V:2, I:4 408 104 1208 description Pluggable Authentication Modules (basic service) Pluggable Authentication Module allowing LDAP interfaces Pluggable Authentication Module to enable cracklib support Pluggable Authentication Modules (documentation in html and text) GNU C Library: Shared libraries which also provides "Name Service Switch" service GNU C Library: Manpages GNU C Library: Reference manual in info, pdf and html format (non-free) NSS module for Multicast DNS name resolution NSS module for using LDAP as a naming service NSS module for using LDAP as a naming service (new folk of libnss-ldap)
libpam-cracklib * V:2, I:2 libpam-doc * libc6 * glibc-doc * glibc-docreference * libnss-mdns * libnss-ldap * libnss-ldapd * I:0.6
V:97, I:99 10012 I:3 I:1.4 I:49 I:4 V:0.18, I:0.5 2008 12156 116 268 144
"The Linux-PAM System Administrators' Guide" in libpam-doc is essential for learning PAM configuration. "System Databases and Name Service Switch" section in glibc-doc-reference is essential for learning NSS configuration.
Note
You can see more extensive and current list by "aptitude search 'libpam-|libnss-'" command. The acronym NSS may also mean "Network Security Service" which is different from "Name Service Switch".
Note
PAM is the most basic way to initialize environment variables for each program with the system wide default value.
/etc/security/pam_env.conf set environment variables by the pam_env(8) module /etc/environment /etc/default/locale /etc/security/limits.conf /etc/security/time.conf
The limitation of the password selection is implemented by the PAM modules, pam_unix(8) and pam_cracklib(8). They can be configured by their arguments.
Tip
PAM modules use suffix ".so" for their filenames.
open source implementation of the Lightweight Directory Access Protocol is OpenLDAP Software. The LDAP server provides the account information through the use of PAM and NSS with libpam-ldap and libnss-ldap packages for the Debian system. Several actions are required to enable this (I have not used this setup and the following is purely secondary information. Please read this in this context.). You set up a centralized LDAP server by running program such as stand-alone LDAP daemon, slapd(8). You change the PAM configuration files in the "/etc/pam.d/" directory to use "pam_ldap.so" instead of the default "pam_unix.so". Debian uses "/etc/pam_ldap.conf" as the configuration file for libpam-ldap and "/etc/pam_ldap.secret" as the file to store the password of the root. You change the NSS configuration in the "/etc/nsswitch.conf" file to use "ldap" instead of the default ("compat" or "file"). Debian uses "/etc/libnss-ldap.conf" as the configuration file for libnss-ldap. You must make libpam-ldap to use SSL (or TLS) connection for the security of password. You may make libnss-ldap to use SSL (or TLS) connection to ensure integrity of data at the cost of the LDAP network overhead. You should run nscd(8) locally to cache any LDAP search results in order to reduce the LDAP network traffic. See documentations in pam_ldap.conf(5) and "/usr/share/doc/libpam-doc/html/" offered by the libpam-doc package and "info libc 'Name Service Switch'" offered by the glibc-doc package. Similarly, you can set up alternative centralized systems with other methods. NIS (originally called YP) or NIS+ with older Unix-like systems Winbind with Windows NT and SAMBA
4.6.1. sudo
sudo(8) is a program designed to allow a sysadmin to give limited root privileges to users and log root activity. sudo requires only an ordinary user's password. Install sudo package and activate it by setting options in "/etc/sudoers". See configuration example at "/usr/share/doc/sudo/examples/sudoers". My usage of sudo for the single user system (see Section 1.1.12, sudo configuration) is aimed to protect myself from my own stupidity. Personally, I consider using sudo a better alternative to using the system from the root account all the time. For example, the following changes the owner of "<some_file>" to "<my_name>". $ sudo chown <my_name> <some_file> Of course if you know the root password (as self-installed Debian users do), any command can be run under root from any user's account using "su -c".
4.6.2. SELinux
Security-Enhanced Linux (SELinux) is a framework to tighten privilege model tighter than the ordinary Unixlike security model with the mandatory access control (MAC) policies. The root power may be restricted under some conditions.
critical for network servers. Having unused servers, activated either directly as daemon or via super-server program, are considered security risks. Many programs, such as sshd(8), use PAM based access control. There are many ways to restrict access to some server services. configuration files: "/etc/default/<program_name>" runlevel configuration for daemon PAM (Pluggable Authentication Modules) "/etc/inetd.conf" for super-server "/etc/hosts.deny" and "/etc/hosts.allow" for TCP wrapper, tcpd(8) "/etc/rpc.conf" for Sun RPC "/etc/at.allow" and "/etc/at.deny" for atd(8) "/etc/cron.allow" and "/etc/cron.deny" for crontab(1) Network firewall of netfilter infrastructure See Section 3.5.3, The runlevel management example, Section 3.5.4, The default parameter for each init script, Section 4.5.1, Configuration files accessed by the PAM and NSS, Section 3.5.8, Network service initialization, and Section 5.9, Netfilter infrastructure.
Tip
Sun RPC services need to be active for NFS and other RPC based programs.
Tip
If you have problems with remote access in a recent Debian system, comment out offending configuration such as "ALL: PARANOID" in "/etc/hosts.deny" if it exists. (But you must be careful on security risks involved with this kind of action.)
The encryption costs CPU time. As a CPU friendly alternative, you can keep communication in plain text while securing just password with the secure authentication protocol such as "Authenticated Post Office Protocol" (APOP) for POP and "Challenge-Response Authentication Mechanism MD5" (CRAM-MD5) for SMTP and IMAP. (For sending mail messages over the Internet to your mail server from your mail client, it is recently popular to use new message submission port 587 instead of traditional SMTP port 25 to avoid port 25 blocking by the network provider while authenticating yourself with CRAM-MD5.)
164 small port-knock daemon knockd(1) and client konck(1) 356 utility to help sysadmins thwart ssh hackers 660 ban IPs that cause multiple authentication errors
libpam-shield * V:0.01, I:0.05 104 lock out remote attackers trying password guessing
If you have the edit access to the GRUB menu entry (see Section 3.3, Stage 2: the boot loader) for grub-rescue-pc at the boot time, it is even easier with following steps. 1. Boot system with the kernel parameter changed to something like "root=/dev/hda6 rw init=/bin/sh". 2. Edit "/etc/passwd" and make the second entry for the root account empty. 3. Reboot system. The root shell of the system is now accessible without password.
Note
Once one has root shell access, he can access everything on the system and reset any passwords on the system. Further more, he may compromise password for all user accounts using brute force password cracking tools such as john and crack packages (see Section 9.6.11, System security and integrity check). This cracked password may lead to compromise other systems. The only reasonable software solution to avoid all these concerns is to use software encrypted root partition (or "/etc" partition) using dm-crypt and initramfs (see Section 9.4, Data encryption tips). You always need password to boot the system, though.
wicd * wicd-cli * wicd-curses * wicd-daemon * wicd-gtk * iptables * iproute * ifrename * ethtool * iputils-ping * iputils-arping * iputilstracepath * net-tools * inetutils-ping * arping * traceroute * dhcp3-client * wpasupplicant * wireless-tools * ppp * pppoeconf * pppconfig * wvdial * mtr-tiny * mtr *
wired and wireless network manager (metapackage) wired and wireless network manager (commandline client) wired and wireless network manager (Curses client) wired and wireless network manager (daemon) wired and wireless network manager (GTK+ client) administration tools for packet filtering and NAT (Netfilter) iproute2, IPv6 and other advanced network configuration: ip(8), tc(8), etc rename network interfaces based on various static criteria: ifrename(8) display or change Ethernet device settings test network reachability of a remote host by hostname or IP address (iproute2) test network reachability of a remote host specified by the ARP address trace the network path to a remote host NET-3 networking toolkit (net-tools, IPv4 network configuration): ifconfig(8) etc. test network reachability of a remote host by hostname or IP address (legacy, GNU) test network reachability of a remote host specified by the ARP address (legacy) trace the network path to a remote host (legacy, console)
V:1.9, I:2 1780 V:1.6, I:2 772 V:27, I:99 V:41, I:88 V:0.2, I:0.6 V:36, I:99 1316 1044 236
V:0.6, I:6 36 V:0.4, I:2 72 V:70, I:99 V:0.03, I:0.12 1016 296
V:0.5, I:3 104 V:13, I:99 V:32, I:92 V:28, I:39 192 60 828
config::low-level DHCP client ,, ,, ,, config::helper ,, ,, test::low-level ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, ,, client support for WPA and WPA2 (IEEE 802.11i) tools for manipulating Linux Wireless Extensions PPP/PPPoE connection with chat configuration helper for PPPoE connection configuration helper for PPP connection with chat configuration helper for PPP connection with wvdial and ppp trace the network path to a remote host (curses) trace the network path to a remote host (curses and GTK+) tools for common network information operations (GNOME) network mapper / port scanner (Nmap, console) network mapper / port scanner (GTK+) network mapper / port scanner (KDE) network traffic analyzer (Tcpdump, console) network traffic analyzer (Wireshark, GTK+) network traffic analyzer (console) monitoring and management system for hosts, services and networks (Nagios) produce a summarization of the connections from tcpdump output flexible network intrusion detection system (Snort) display network usage in web browser network clients provided with BIND: nslookup(8), nsupdate(8), dig(8) check DNS zone information using nameserver lookups trace a chain of DNS servers to the source
V:7, I:22 420 V:6, I:26 1016 V:0.4, I:3 344 V:0.2, I:2 964 V:0.5, I:2 416 V:2, I:26 120 V:0.7, I:3 180
gnome-nettool * V:2, I:33 2848 nmap * zenmap * knmap * tcpdump * wireshark * tshark * nagios3 * tcptrace * snort * ntop * dnsutils * dlint * dnstracer * V:6, I:31 7112 V:0.2, I:1.3 V:0.10, I:0.6 2400 712
V:3, I:24 1020 V:1.4, I:9 2052 V:0.4, I:3 276 V:1.0, I:1.8 V:0.05, I:0.4 V:0.6, I:0.8 V:14, I:90 32 436 1260
The naming for the domain name is a tricky one for the normal PC workstation users. The PC workstation may be mobile one hopping around the network or located behind the NAT firewall inaccessible from the Internet. For such case, you may not want the domain name to be a valid domain name to avoid name collision.
Tip
When you use an invalid domain name, you need to spoof the domain name used by some programs such as MTA for their proper operation. See Section 6.3.3, The mail address configuration. According to rfc2606, "invalid" seems to be a choice for the top level domain (TLD) to construct domain names that are sure to be invalid from the Internet. The mDNS network discovery protocol (Apple Bonjour / Apple Rendezvous, Avahi on Debian) uses "local" as the pseudo-top-level domain. Microsoft also seems to promote "local" for the TLD of local area network.
Warning
If the DNS service on your LAN uses "local" as TLD for your LAN, it may interfare with mDNS. Other popular choices for the invalid TLD seem to be "localdomain", "lan", "localnet", or "home" according to my incoming mail analysis.
Tip
For <domain_name> of the mobile PC without the real FQDN, you may pick a bogus and safe TLD such as "lan", "home", "invalid", "localdomain", "none", and "private". The "/etc/resolv.conf" is a static file if the resolvconf package is not installed. If installed, it is a symbolic link. Either way, it contains information that initialize the resolver routines. If the DNS is found at IP="192.168.11.1", it contains the following. nameserver 192.168.11.1 The resolvconf package makes this "/etc/resolv.conf" into a symbolic link and manages its contents by the hook scripts automatically. The hostname resolution via Multicast DNS (using Zeroconf, aka Apple Bonjour / Apple Rendezvous) which effectively allows name resolution by common Unix/Linux programs in the ad-hoc mDNS domain "local", can be provided by installing the libnss-mdns package. The "/etc/nsswitch.conf" file should have stanza like "hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4" to enable this functionality.
Caution
When editing the "/etc/udev/rules.d/70-persistent-net.rules" rules file, you must
keep each rule on a single line and the MAC address in lowercase. For example, if you find "Firewire device" and "PCI device" in this file, you probably want to name "PCI device" as eth0 and configure it as the primary network interface.
Note
If one of these addresses is assigned to a host, then that host must not access the Internet directly but must access it through a gateway that acts as a proxy for individual services or else does Network Address Translation(NAT). The broadband router usually performs NAT for the consumer LAN environment.
Note
Do not use these automatic network configuration tools for servers. These are aimed primarily for mobile desktop users on laptops. These modern network configuration tools need to be configured properly to avoid conflicting with the legacy ifupdown package and its configuration file "/etc/network/interfaces".
Note
Some features of these automatic network configuration tools may suffer regressions. These are not as robust as the legacy ifupdown package. Check BTS of network-manager and BTS of wicd for current issues and limitations.
Note
Only interfaces which are not listed in "/etc/network/interfaces" or which have been configured with "auto " or "allow-hotplug " and "iface inet dhcp" (with no other
Tip
If you wish to extend network configuration capabilities of NM, please seek appropriate plugin modules and supplemental packages such as network-manager-openconnect, network-manager-openvpn-gnome, network-manager-pptp-gnome, mobilebroadband-provider-info, gnome-bluetooth, etc. The same goes for those of Wicd.
Caution
These automatic network configuration tools may not be compatible with esoteric configurations of legacy ifupdown in "/etc/network/interfaces" such as ones in Section 5.5, The basic network configuration with ifupdown (legacy) and Section 5.6, The advanced network configuration with ifupdown (legacy). Check BTS of network-manager and BTS of wicd for current issues and limitations.
Serial port (ppp0) PPP Ethernet port (eth0) Ethernet port (eth0)
PPPoE/DHCP/Static BB-modem BB service BB access point ISP DHCP/Static LAN BB-router with network address translation (NAT) ( BBmodem )
Here is the summary of configuration script for each connection method. Table 5.4. List of network connection configurations
connection method configuration PPP PPP (alternative) PPPoE DHCP static IP (IPv4) static IP (IPv6) pppconfig to create deterministic chat wvdialconf to create heuristic chat pppoeconf to create deterministic chat described in "/etc/network/interfaces" described in "/etc/network/interfaces"
backend package(s) pppconfig, ppp ppp, wvdial pppoeconf, ppp net-tools iproute
The network connection acronyms mean the following. Table 5.5. List of network connection acronyms acronym POTS BB meaning plain old telephone service broadband
BB-service e.g., the digital subscriber line (DSL), the cable TV, or the fiber to the premises (FTTP) BB-modem e.g., the DSL modem, the cable modem, or the optical network terminal (ONT) LAN WAN DHCP PPP PPPoE ISP local area network wide area network dynamic host configuration protocol point-to-point protocol point-to-point protocol over Ethernet Internet service provider
Note
The WAN connection services via cable TV are generally served by DHCP or PPPoE. The ones by ADSL and FTTP are generally served by PPPoE. You have to consult your ISP for exact configuration requirements of the WAN connection.
Note
When BB-router is used to create home LAN environment, PCs on LAN are connected to the WAN via BB-router with network address translation (NAT). For such case, PC's network interfaces on the LAN are served by static IP or DHCP from the BB-router. BB-router must be configured to connect the WAN following the instruction by your ISP.
Table 5.6. List of configuration files for the PPP connection with pppconfig file /etc/ppp/peers/<isp_name> /etc/chatscripts/<isp_name> /etc/ppp/options /etc/ppp/pap-secret /etc/ppp/chap-secret function The pppconfig generated configuration file for pppd specific to <isp_name> The pppconfig generated configuration file for chat specific to <isp_name> The general execution parameter for pppd Authentication data for the PAP (security risk) Authentication data for the CHAP (more secure)
Caution
The "<isp_name>" value of "provider" is assumed if pon and poff commands are invoked without arguments. You can test configuration using low level network configuration tools as the following. $ sudo pon <isp_name> ... $ sudo poff <isp_name> See "/usr/share/doc/ppp/README.Debian.gz".
/etc/ppp/peers/wvdial The wvdialconf generated configuration file for pppd specific to wvdial /etc/wvdial.conf /etc/ppp/options /etc/ppp/pap-secret /etc/ppp/chap-secret The wvdialconf generated configuration file The general execution parameter for pppd Authentication data for the PAP (security risk) Authentication data for the CHAP (more secure)
You can test configuration using low level network configuration tools as the following. $ sudo wvdial ... $ sudo killall wvdial See wvdial(1) and wvdial.conf(5).
/etc/ppp/peers/dsl-provider The pppoeconf generated configuration file for pppd specific to pppoe /etc/ppp/options /etc/ppp/pap-secret /etc/ppp/chap-secret The general execution parameter for pppd Authentication data for the PAP (security risk) Authentication data for the CHAP (more secure)
You can test configuration using low level network configuration tools as the following. $ sudo $ sudo ... $ sudo $ sudo /sbin/ifconfig eth0 up pon dsl-provider poff dsl-provider /sbin/ifconfig eth0 down
See "/usr/share/doc/pppoeconf/README.Debian".
These traditional setup methods are quite useful if you wish to set up advanced configuration (see Section 5.5, The basic network configuration with ifupdown (legacy)). The ifupdown package provides the standardized framework for the high level network configuration in the Debian system. In this section, we learn the basic network configuration with ifupdown with simplified introduction and many typical examples.
Warning
Do not use low level configuration tools such as ifconfig(8) and ip(8) commands to configure an interface in up state.
Note
There is no command ifupdown.
Lines started with iface stanza has the following syntax. iface <config_name> <address_family> <method_name> <option1> <value1> <option2> <value2> ... For the basic configuration, the mapping stanza is not used and you use the network interface name as the network configuration name (See Section 5.6.5, The mapping stanza).
Warning
Do not define duplicates of the "iface" stanza for a network interface in "/etc/network/interfaces".
hostname "mymachine" When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza causes ifup to bring up the interface and the iface stanza causes ifup to use DHCP to configure the interface.
Caution
The IP addresses used in the above example are not meant to be copied literally. You have to adjust IP numbers to your actual network configuration.
Tip
The wmaster0 device is the master device which is an internal device used only by SoftMAC with new mac80211 API of Linux. Here are some keywords to remember for the WLAN. Table 5.11. List of acronyms for WLAN acronym full word NWID (E)SSID WEP, (WEP2) WPA WPA2 Network ID meaning 16 bit network ID used by pre-802.11 WaveLAN network (very deprecated)
(Extended) Service network name of the Wireless Access Points (APs) interconnected to form an integrated 802.11 wireless LAN, Domain ID Set Identifier Wired Equivalent Privacy Wi-Fi Protected Access Wi-Fi Protected Access 2 1st generation 64-bit (128-bit) wireless encryption standard with 40-bit key (deprecated) 2nd generation wireless encryption standard (most of 802.11i), compatible with WEP 3rd generation wireless encryption standard (full 802.11i), non-compatible with WEP
The actual choice of protocol is usually limited by the wireless router you deploy.
Caution
Please note that your network traffic on WLAN with WEP may be sniffed by others. In case of the DHCP served IP on WLAN connection, the "/etc/network/interfaces" file entry should be as the following. allow-hotplug eth0 iface eth0 inet dhcp wireless-essid Home wireless-key1 0123-4567-89ab-cdef wireless-key2 12345678 wireless-key3 s:password wireless-defaultkey 2 wireless-keymode open See "/usr/share/doc/wireless-tools/README.Debian".
Note
For the Ethernet device connected to the PPPoE, the output of the ifconfig(8) command lacks a line which looks like above example.
Tip
You can (re)initialize the network interface simply by "sudo ifdown eth0;sudo ifup eth0".
Tip
The automatic behavior of the ifupdown-extra package is configurable with the "/etc/default/network-test". Some of these automatic checks slow down the system boot-up a little bit since it takes some time to listen for ARP replies.
Caution
If you could not set up network connection by information in Section 5.5, The basic network configuration with ifupdown (legacy), you make situation worse by using information below.
Now, the network reconfiguration works as you desire. Upon power-on or upon hardware discovery, the interface is not brought up by itself. Quick boot process without the long DHCP timeout. No funny activated interface without proper IPv4 address (see Section 5.5.12, The network configuration state of ifupdown). Upon finding the Ethernet cable, the interface is brought up. Upon some time after unplugging the Ethernet cable, the interface is brought down automatically. Upon plugging in another Ethernet cable, the interface is brought up under the new network environment.
Tip
The arguments for the ifplugd(8) command can set its behaviors such as the delay for reconfiguring interfaces.
1. Install the ifmetric package. 2. Add an option line with "metric 0" just below the "iface eth0 inet dhcp" line. 3. Add an option line with "metric 1" just below the "iface wlan0 inet dhcp" line. The metric 0 means the highest priority route and is the default one. The larger metric value means lower priority routes. The IP address of the active interface with the lowest metric value becomes the originating one. See ifmetric(8).
Caution
Although this configuration example with network address translation (NAT) using netfilter/iptables (see Section 5.9, Netfilter infrastructure) can provide cheap router for the LAN with only single interface, there is no real firewall capability with such set up. You should use 2 physical interfaces with NAT to secure the local network from the Internet.
physical network interface name interface name network logical configuration interface name name
Basic network configuration commands in Section 5.5.1, The command syntax simplified require the network configuration name token of the iface stanza to match the network interface name in the "/etc/network/interfaces". Advanced network configuration commands enables separation of the network configuration name and the network interface name in the "/etc/network/interfaces" as the following. Table 5.13. List of advanced network configuration commands with ifupdown command ifup eth0=config1 ifdown eth0=config1 ifup eth0 ifdown eth0 action bring up a network interface eth0 with the configuration config1 bring down a network interface eth0 with the configuration config1 bring up a network interface eth0 with the configuration selected by mapping stanza bring down a network interface eth0 with the configuration selected by mapping stanza
map <script_input1> map <script_input2> map ... This provides advanced feature to the "/etc/network/interfaces" file by automating the choice of the configuration with the mapping script specified by <script_name>. Let's follow the execution of the following. $ sudo ifup eth0 When the "<interface_name_glob>" matches "eth0", this execution produces the execution of the following command to configure eth0 automatically. $ sudo ifup eth0=$(echo -e '<script_input1> \n <script_input2> \n ...' | <script_name> eth0) Here, script input lines with "map" are optional and can be repeated.
Note
The glob for mapping stanza works like shell filename glob (see Section 1.5.6, Shell glob).
... The interface eth0 is down and disconnected from LAN, again. Let's move your PC to a port on BB-modem connected to the PPPoE served service. You bring up the network interface eth0 by assigning the network configuration name pppoe to it by the following. $ sudo ifup eth0=pppoe ... The interface eth0 is up, configured with PPPoE connection directly to the ISP. $ sudo ifdown eth0=pppoe ... The interface eth0 is down and disconnected, again. Let's move your PC to a location without LAN or BB-modem but with POTS and modem. You bring up the network interface ppp0 by assigning the network configuration name pots to it by the following. $ sudo ifup ppp0=pots ... The interface ppp0 is up and connected to the Internet with PPP. $ sudo ifdown ppp0=pots ... The interface ppp0 is down and disconnected from the Internet. You should check the "/etc/network/run/ifstate" file for the current network configuration state of the ifupdown system.
Warning
You may need to adjust numbers at the end of eth*, ppp*, etc. if you have multiple network interfaces.
Here, each environment variable, "$IF_<OPTION>", is created from the name for the corresponding option such as <option1> and <option2> by prepending "$IF_", converting the case to the upper case, replacing hyphens to underscores, and discarding non-alphanumeric characters.
Tip
See Section 5.5.2, The basic syntax of "/etc/network/interfaces" for <address_family>, <method_name>, <option1> and <option2>. The ifupdown-extra package (see Section 5.5.14, The ifupdown-extra package) uses these environment variables to extend the functionality of the ifupdown package. The ifmetric package (see Section 5.6.2, The ifmetric package) installs the "/etc/network/if-up.d/ifmetric" script which sets the metric via the "$IF_METRIC" variable. The guessnet package (see Section 5.6.8, Mapping with guessnet), which provides simple and powerful framework for the auto-selection of the network configuration via the mapping mechanism, also uses these.
Note
For more specific examples of custom network configuration scripts using these environment variables, you should check example scripts in "/usr/share/doc/ifupdown/examples/*" and scripts used in ifscheme and ifupdownscripts-zg2 packages. These additional scripts have some overlaps of functionalities with basic ifupdown-extra and guessnet packages. If you install these additional scripts, you should customize these scripts to avoid interferences.
Note
When multiple guessnet option lines are required in "/etc/network/interfaces", use option lines started with guessnet1, guessnet2, and so on, since the ifupdown package does not allow starting strings of option lines to be repeated.
Tip
Some of these low level network configuration tools reside in "/sbin/". You may need to issue full command path such as "/sbin/ifconfig" or add "/sbin" to the "$PATH" list in your "~/.bashrc".
200 Internet Protocol bandwidth measuring tool 204 write a "/etc/apt/sources.list" file based on bandwidth tests 88 84 96 52 InterFace STATistics Monitoring script that quickly measures network device throughput empirical stochastic bandwidth tester console-based Ethernet statistics monitor 188 portable bandwidth monitor and rate estimator
Tip
The above example with PMTU value of 1454 is for my previous FTTP provider which used Asynchronous Transfer Mode (ATM) as its backbone network and served its clients with the PPPoE. The actual PMTU value depends on your environment, e.g., 1500 for the my new FTTP provider. Table 5.18. Basic guide lines of the optimal MTU value network environment Dial-up link (IP: PPP) Ethernet link (IP: DHCP or fixed) Ethernet link (IP: PPPoE) Ethernet link (ISP's backbone: ATM, IP: DHCP or fixed) Ethernet link (ISP's backbone: ATM, IP: PPPoE) MTU 576 1500 1492 (=15008) rationale standard standard and default 2 bytes for PPP header and 6 bytes for PPPoE header
1462 (=48*31- author's speculation: 18 for Ethernet header, 8 for 18-8) SAR trailer 1454 (=48*31- see "Optimal MTU configuration for PPPoE ADSL 8-18-8) Connections" for rationale
In addtion to these basic guide lines, you should know the following. Any use of tunneling methods (VPN etc.) may reduce optimal MTU further by their overheads. The MTU value should not exceed the experimentally determined PMTU value. The bigger MTU value is generally better when other limitations are met.
pre-up /sbin/ifconfig $IFACE mtu 1454 For the static IP (see Section 5.5.5, The network interface with the static IP), you can replace pertinent 'iface' stanza lines in the "/etc/network/interfaces" with the following. iface eth0 inet static address 192.168.11.100 netmask 255.255.255.0 broadcast 192.168.11.255 gateway 192.168.11.1 mtu 1454 dns-domain lan dns-nameservers 192.168.11.1 For the direct PPPoE (see Section 5.4.5, The PPPoE connection with pppoeconf), you can replace pertinent "mtu" line in the "/etc/ppp/peers/dsl-provider" with the following. mtu 1454 The maximum segment size (MSS) is used as an alternative measure of packet size. The relationship between MSS and MTU are the following. MSS = MTU - 40 for IPv4 MSS = MTU - 60 for IPv6
Note
The iptables(8) (see Section 5.9, Netfilter infrastructure) based optimization can clamp packet size by the MSS and is useful for the router. See "TCPMSS" in iptables(8).
Main user space program of netfilter is iptables(8). You can manually configure netfilter interactively from shell, save its state with iptables-save(8), and restore it via init script with iptables-restore(8) upon system reboot. Configuration helper scripts such as shorewall ease this process. See documentations at http://www.netfilter.org/documentation/ (or in "/usr/share/doc/iptables/html/"). Linux Networking-concepts HOWTO Linux 2.4 Packet Filtering HOWTO Linux 2.4 NAT HOWTO
Tip
Although these were written for Linux 2.4, both iptables(8) command and netfilter kernel function apply for current Linux 2.6.
iceweasel *
unbranded Mozilla Firefox unbrandedMozilla, removed due to security concerns bug#505565 GNOME, HIG compliant, Epiphany GNOME, Galeon, superseded by Epiphany KDE, Konqueror w3m Lynx ELinks Links (text only)
iceape-browser * V:1.4, I:2 35686 , , epiphanybrowser * galeon * konqueror * w3m * lynx * elinks * links * links2 * V:13, I:34 1060 V:0.9, I:1.4 V:8, I:15 I:22 V:2, I:5 V:3, I:9 1776 3584 252 1448 1380 ,, ,, ,, text ,, ,, ,,
mozilla-plugin-vlc V:3, I:4 * totem-mozilla * gecko-mediaplayer * nspluginwrapper * V:20, I:34 V:0.6, I:0.8
Tip
Although use of above Debian packages are much easier, browser plugins can be still manually enabled by installing "*.so" into plugin directories (e.g., "/usr/lib/iceweasel/plugins/") and restarting browsers. Some web sites refuse to be connected based on the user-agent string of your browser. You can work around this situation by spoofing the user-agent string. For example, you can do this by adding following line into user configuration files such as "~/.gnome2/epiphany/mozilla/epiphany/user.js" or "~/.mozilla/firefox/*.default/user.js". user_pref{"general.useragent.override","Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"}; Alternatively, you can add and reset this variable by typing "about:config" into URL and right clicking its display contents.
Caution
Spoofed user-agent string may cause bad side effects with Java.
Note
The following configuration examples are only valid for the typical mobile workstation on
Caution
It is not realistic to run SMTP server on consumer grade network to send mail directly to the remote host reliably. They are very likely to be rejected. You must use some smarthost services offered by your connection ISP or independent mail ISPs. For the simplicity, I assume that the smarthost is located at "smtp.hostname.dom", requires SMTP AUTH, and uses the message submission port (587) in the following text.
Tip
You may wish to configure MUA/MDA to use Maildir for storing email messages somewhere under your home directory.
exim4-daemon-light V:60, * I:65 exim4-base * exim4-doc-html * exim4-doc-info * postfix * postfix-doc * sasl2-bin * cyrus-sasl2-doc * V:62, I:68 I:0.6 I:0.3 V:18, I:20 I:1.9 V:2, I:5 I:2
3492 Postfix mail transport agent (MTA: alternative) 3420 Postfix documentation (html+text) 448 284 Cyrus SASL API implementation (supplement postfix for SMTP AUTH) Cyrus SASL - documentation
Although the popcon vote count of exim4-* looks several times popular than that of postfix, this does not mean postfix is not popular with Debian developers. The Debian server system uses both exim4 and postfix. The mail header analysis of mailing list postings from prominent Debian developers also indicate both of these MTAs are as popular.
The exim4-* packages are known to have very small memory consumption and very flexible for its configuration. The postfix package is known to be compact, fast, simple, and secure. Both come with ample documentation and are as good in quality and license. There are many choices for mail transport agent (MTA) packages with different capability and focus in Debian archive. Table 6.4. List of choices for mail transport agent (MTA) packages in Debian archive package popcon size 1104 3492 1220 2052 436 0 capability and focus full full (security) full (flexible) full (only if you are already familiar) strip down, no local mail strip down, no local mail light light light light (sendmail compatibility extension to esmtp) light light (sendmail compatibility extension to msmtp)
exim4-daemon-light * V:60, I:65 postfix * sendmail-bin * nullmailer * ssmtp * courier-mta * xmail * masqmail * esmtp * esmtp-run * msmtp * msmtp-mta * V:18, I:20 V:1.9, I:2 V:0.7, I:0.8 V:1.2, I:1.7 exim4-daemon-heavy * V:1.7, I:1.9
V:0.14, I:0.15 12316 very full (web interface etc.) V:0.14, I:0.16 836 V:0.04, I:0.05 624 V:0.09, I:0.2 V:0.3, I:0.8 172 340 V:0.07, I:0.11 64 V:0.11, I:0.15 32
Caution
You must execute update-exim4.conf(8) after manually updating exim4 configuration files in "/etc/exim4/".
Caution
Starting exim4 takes long time if "No" (default value) was chosen for the debconf query of "Keep number of DNS-queries minimal (Dial-on-Demand)?" and the system is not connected to the Internet while booting.
Note
Please read the official guide at: "/usr/share/doc/exim4-base/README.Debian.gz" and update-exim4.conf(8).
Tip
Local customization file "/etc/exim4/exim4.conf.localmacros" may be created to set MACROs. For example, Yahoo's mail service is said to require "MAIN_TLS_ENABLE = true" and "AUTH_CLIENT_ALLOW_NOTLS_PASSWORDS = yes" in it.
Tip
If you are looking for a light weight MTA that respects "/etc/aliases" for your laptop PC, you should consider to configure exim4(8) with "QUEUERUNNER='queueonly'", "QUEUERUNNER='nodaemon'", etc. in "/etc/default/exim4".
You (re)configure postfix and sasl2-bin packages as follows. $ sudo /etc/init.d/postfix stop $ sudo dpkg-reconfigure postfix Chose "Internet with smarthost". Set "SMTP relay host (blank for none):" to "[smtp.hostname.dom]:587" and configure it by the following. $ $ $ $ $ sudo sudo sudo sudo sudo postconf -e 'smtp_sender_dependent_authentication = yes' postconf -e 'smtp_sasl_auth_enable = yes' postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' postconf -e 'smtp_sasl_type = cyrus' vim /etc/postfix/sasl_passwd
Create password entries for the smarthost. $ cat /etc/postfix/sasl_passwd [smtp.hostname.dom]:587 username:password $ sudo postmap hush:/etc/postfix/sasl_passwd Start the postfix by the following. $ sudo /etc/init.d/postfix start Here the use of "[" and "]" in the dpkg-reconfigure dialog and "/etc/postfix/sasl_passwd" ensures not to check MX record but directly use exact hostname specified. See "Enabling SASL authentication in the Postfix SMTP client" in "usr/share/doc/postfix/html/SASL_README.html".
The mailname in the "/etc/mailname" file is usually a fully qualified domain name (FQDN) that resolves to one of the host's IP addresses. For the mobile workstation which does not have a hostname with resolvable IP address, set this mailname to the value of "hostname -f". (This is safe choice and works for
Tip
The contents of "/etc/mailname" is used by many non-MTA programs for their default behavior. For mutt, set "hostname" and "from" variables in ~/muttrc file to override the mailname value. For programs in the devscripts package, such as bts(1) and dch(1), export environment variables "$DEBFULLNAME" and "$DEBEMAIL" to override it.
Tip
The popularity-contest package normally send mail from root account with FQDN. You need to set MAILFROM in /etc/popularity-contest.conf as described in the /usr/share/popularity-contest/default.conf file. Otherwise, your mail will be rejected by the smarthost SMTP server. Although this is tedious, this approach is safer than rewriting the source address for all mails from root by MTA and should be used for other daemons and cron scripts. When setting the mailname to "hostname -f", the spoofing of the source mail address via MTA can be realized by the following. "/etc/email-addresses" file for exim4(8) as explained in the exim4-config_files(5) "/etc/postfix/generic" file for postfix(1) as explained in the generic(5) For postfix, the following extra steps are needed. # postmap hash:/etc/postfix/generic # postconf -e 'smtp_generic_maps = hash:/etc/postfix/generic' # postfix reload You can test mail address configuration using the following. exim(8) with -brw, -bf, -bF, -bV, options postmap(1) with -q option.
Tip
Exim comes with several utility programs such as exiqgrep(8) and exipick(8). See "dpkg -L exim4-base|grep man8/" for available commands.
postsuper -r ALL; postqueue -f flush even frozen mails postsuper -h queue_id postsuper -d queue_id postsuper -d ALL freeze one message by its queue ID remove one message by its queue ID remove all messages
Tip
It may be a good idea to flush all mails by a script in "/etc/ppp/ip-up.d/*".
iceweasel * V:30, I:48 evolution * V:16, I:34 icedove * mutt * gnus * V:8, I:12 V:26, I:83
Tip
Mutt can be used as the IMAP client and the mailbox format converter. You can tag messages with "t", "T", etc. These tagged messages can be copied with ";C" between different mailboxes and deleted with ";d" in one action.
else echo "getmail has not been running ... " >&2 fi if [ -f $HOME/.getmail/stop ]; then echo "do not run getmail ... (if not, remove $HOME/.getmail/stop)" >&2 exit fi if [ "x$1" = "x-l" ]; then exit fi rcfiles="/usr/bin/getmail" for file in $HOME/.getmail/config/* ; do rcfiles="$rcfiles --rcfile $file" done date -u > $HOME/.getmail/running eval "$rcfiles $@" rm $HOME/.getmail/running Configure it as the following. $ $ $ $ sudo chmod 755 /usr/local/bin/getmails mkdir -m 0700 $HOME/.getmail mkdir -m 0700 $HOME/.getmail/config mkdir -m 0700 $HOME/.getmail/log
Create configuration files "$HOME/.getmail/config/pop3_name" for each POP3 accounts as the following. [retriever] type = SimplePOP3SSLRetriever server = pop.example.com username = [email protected] password = secret [destination] type = MDA_external path = /usr/bin/maildrop unixfrom = True [options] verbose = 0 delete = True delivered_to = False message_log = ~/.getmail/log/pop3_name.log Configure it as the following. $ chmod 0600 $HOME/.getmail/config/* Schedule "/usr/local/bin/getmails" to run every 15 minutes with cron(8) by executing "sudo crontab -e -u <user_name>" and adding following to user's cron entry. 5,20,35,50 * * * * /usr/local/bin/getmails --quiet
Tip
Problems of POP3 access may not come from getmail. Some popular free POP3 services may be violating the POP3 protocol and their SPAM filter may not be perfect. For example, they may delete messages just after receiving RETR command before receiving DELE command and may quarantined messages into Spam mailbox. You should minimize damages by configuring them to archive accessed messages and not to delete them. See also "Some mail was not downloaded".
Warning
Unlike procmail, maildrop does not create missing maildir directories automatically. You must create them manually using maildirmake(1) in advance as in the example "$HOME/.mailfilter".
V:0.10, I:0.18 212 V:0.14, I:0.16 836 V:2, I:3 V:0.7, I:4 280
1624 IMAP Courier mail server - IMAP server (maildir format only)
15540 IPP (631) Internet Printing CUPS server System V printer commands for CUPS: lp(1), lpstat(1), lpoptions(1), cancel(1), lpmove(8), lpinfo(8), lpadmin(8), BSD printer commands for CUPS: lpr(1), lpq(1), lprm(1), lpc(8)
cups-client *
908
,,
cups-bsd * cups-drivergutenprint *
,,
Tip
You can configure CUPS system by pointing your web browser to "http://localhost:631/" .
Caution
See Section 4.7.3, Extra security measures for the Internet if your SSH is accessible from the Internet.
Tip
Please use the screen(1) program to enable remote shell process to survive the interrupted connection (see Section 9.1, The screen program).
Table 6.14. List of SSH authentication protocols and methods SSH SSH method protocol SSH-1 ,, ,, ,, ,, SSH-2 ,, ,, ,, "RSAAuthentication" "RhostsAuthentication" "RhostsRSAAuthentication" description RSA identity key based user authentication ".rhosts" based host authentication (insecure, disabled) ".rhosts" based host authentication combined with RSA host key (disabled) password based authentication public key based user authentication "~/.rhosts" or "/etc/hosts.equiv" based host authentication combined with public key client host authentication (disabled) password based authentication
Caution
Be careful about these differences if you are using a non-Debian system. See "/usr/share/doc/ssh/README.Debian.gz", ssh(1), sshd(8), ssh-agent(1), and ssh-keygen(1) for details. Following are the key configuration files. Table 6.15. List of SSH configuration files configuration file /etc/ssh/ssh_config /etc/ssh/sshd_config ~/.ssh/authorized_keys ~/.ssh/identity ~/.ssh/id_rsa ~/.ssh/id_dsa description of configuration file SSH client defaults, see ssh_config(5) SSH server defaults, see sshd_config(5) default public SSH keys that clients use to connect to this account on this SSH server secret SSH-1 RSA key of the user secret SSH-2 RSA key of the user secret SSH-2 DSA key of the user
Tip
See ssh-keygen(1), ssh-add(1) and ssh-agent(1) for how to use public and secret SSH keys.
Tip
Make sure to verify settings by testing the connection. In case of any problem, use "ssh v".
Tip
You can change the pass phrase to encrypt local secret SSH keys later with "ssh-keygen p".
Tip
You can add options to the entries in "~/.ssh/authorized_keys" to limit hosts and to run specific commands. See sshd(8) for details. The following starts an ssh(1) connection from a client. Table 6.16. List of SSH client startup examples command ssh [email protected] ssh -v [email protected] ssh -1 [email protected] ssh -1 -o RSAAuthentication=no -l username hostname.domain.ext description connect with default mode connect with default mode with debugging messages force to connect with SSH version 1 force to use password with SSH version 1
ssh -o PreferredAuthentications=password -l username force to use password with SSH hostname.domain.ext version 2
If you use the same user name on the local and the remote host, you can eliminate typing "username@". Even if you use different user name on the local and the remote host, you can eliminate it using "~/.ssh/config". For Debian Alioth service with account name "foo-guest", you set "~/.ssh/config" to
contain the following. Host alioth.debian.org svn.debian.org git.debian.org User foo-guest For the user, ssh(1) functions as a smarter and more secure telnet(1). Unlike telnet command, ssh command does not bomb on the telnet escape character (initial default CTRL-]).
Tip
Use of DSA key for SSH-2 is deprecated because key is smaller and slow. There are no more reasons to work around RSA patent using DSA since it has been expired. DSA stands for Digital Signature Algorithm and slow. Also see DSA-1571-1.
Note
For "HostbasedAuthentication" to work in SSH-2, you must adjust the settings of "HostbasedAuthentication" to "yes" in both "/etc/ssh/sshd_config" on the server host and "/etc/ssh/ssh_config" or "~/.ssh/config" on the client host.
Windows (cygwin) SSH in cygwin (http://www.cygwin.com/) (GPL) Macintosh Classic macSSH (http://www.macssh.com/) (GPL) Mac OS X OpenSSH; use ssh in the Terminal application (GPL)
23096 SMB
Common Internet File System Protocol (CIFS) is the same protocol as Server Message Block (SMB) and is used widely by Microsoft Windows.
Tip
Use of proxy server such as squid is much more efficient for saving bandwidth than use of local mirror server with the full Debian archive contents.
V:56, I:91 2380 V:0.6, I:2 512 V:13, I:89 200 208
V:0.2, telnet-ssl * I:1.1 smbclient * smbfs * ftp * lftp * ncftp * V:6, I:35 V:5, I:24 V:9, I:85
45200 SMB
web downloader ,, host(1) from bind9, "Priority: standard" dig(1) from bind, "Priority: standard" obtain IP address obtain data from LDAP server
bind9-host * V:43, I:91 188 V:14, I:90 412 dhcp3-client V:32, I:92 60 * ldap-utils * V:2, I:7 672
rfc1939 and rfc2449 POP3 service rfc3501 rfc2821 (rfc821) rfc2822 (rfc822) rfc2045 rfc819 rfc2616 rfc2396 IMAP4 service SMTP service Mail file format Multipurpose Internet Mail Extensions (MIME) DNS service HTTP service URI definition
1956 miscellaneous documentation for the X.Org software suite 2060 generate the Debian menu for all menu-aware applications 540 76 300 44 36 40 36 Gtk+ frontend to su(1) or sudo(8) convert the Debian menu structure to the freedesktop.org xdg menu structure utilities to integrate desktop environment provided by the freedesktop.org standard GNOME desktop environment (metapackage) core KDE desktop environment (metapackage) Xfce lightweight desktop environment (metapackage) LXDE lightweight desktop environment (metapackage)
fluxbox *
V:0.9, I:2
4424
Fluxbox: package for highly configurable and low resource X window manager
Tip
Task menu may be out of sync with the latest package transition state under Debian unstable/testing environment. In such situation, you need to deselect some (meta)packages listed under aptitude(8) task menu to avoid package conflicts. When deselecting (meta)packages, you must select certain packages providing their dependencies manually to avoid them deleted automatically. You may alternatively setup a simple environment manually just with a X window manager such as Fluxbox. See Window Managers for X for the guide to the X window manager and the desktop environment.
Tip
You may need to do the similar for other modern desktop environments which are compliant to Freedesktop.org standard.
application server a program run on a remote host that processes data and talks to the clients. application client a program run on a local host connected to the user's display and input devices.
# sudo dpkg-reconfigure -phigh xserver-xorg Please check your X configuration with respect to the specification of your monitor carefully. For the large high resolution CRT monitor, it is a good idea to set the refresh rate as high as your monitor can handle (85 Hz is great, 75 Hz is OK) to reduce flicker. For the LCD monitor, slower standard refresh rate (60Hz) is usually fine due to its slow response.
Note
Be careful not to use too high refresh rate which may cause fatal hardware failure of your monitor system.
V:22, I:33 16548 checked V:8, I:11 V:0.7, I:1.8 5510 780 checked checked checked checked
no(XDMCP) local connection via pipe no(XDMCP) local connection via pipe no(XDMCP) local connection via pipe no(XDMCP) local connection via pipe yes remote SSH network connection (thin client)
KDE display manager kdm * X display manager WindowMaker display manager xdm * wdm *
Warning
Do not use remote TCP/IP connection over unsecured network for X connection unless you have very good reason such as use of encryption. A remote TCP/IP socket connection without encryption is prone to the eavesdropping attack and is disabled by default on the Debian system. Use "ssh -X".
Warning
Do not use XDMCP connection over unsecured network either. It sends data via UDP/IP without encryption and is prone to the eavesdropping attack.
Tip
You can dare to enable remote TCP/IP connection by setting "DisallowTCP=false" in "/etc/gdm/gdm.conf" to override "/usr/share/gdm/defaults.conf" and by removing "nolisten" from lines found by "find /etc/X11 -type f -print0 | xargs -0 grep nolisten", if you are in the fully secured environment.
Tip
LTSP stands for Linux Terminal Server Project.
Tip
The start up script for the display manager daemons checks the content of the "/etc/X11/default-display-manager" file before actually executing themselves. This ensures to have only one X display manager daemon program activated.
Tip
See Section 8.3.5, Specific locale only under X Window for initial environment variables of the X display manager.
Essentially, all these programs execute the "/etc/X11/Xsession" script. Then the "/etc/X11/Xsession" script performs run-parts(8) like action to execute scripts in the "/etc/X11/Xsession.d/" directory. This is essentially an execution of a first program which is found in the following order with the exec builtin command. 1. The script specified as the argument of "/etc/X11/Xsession" by the X display manager, if it is defined. 2. The "~/.xsession" or "~/.Xsession" script, if it is defined. 3. The "/usr/bin/x-session-manager" command, if it is defined. 4. The "/usr/bin/x-window-manager" command, if it is defined. 5. The "/usr/bin/x-terminal-emulator" command, if it is defined. This process is affected by the content of "/etc/X11/Xsession.options". The exact programs to which these "/usr/bin/x-*" commands point, are determined by the Debian alternative system and changed by "update-alternatives --config x-session-manager", etc.
FALSE "gnome-session" "GNOME session" \ FALSE "xterm" "Safe choice" \ FALSE "rxvt" "Safe choice" \ FALSE "gnome-terminal" "Safe choice") echo "Connecting to "$TARGETHOST" with $TARGETSESSION" /usr/bin/ssh -A -X -T -n "$TARGETHOST" "$TARGETSESSION" #SSH_ASKPASS=/usr/bin/ssh-askpass /usr/bin/ssh -A -X -T -n "$TARGETHOST" "$TARGETSESSION" Add followings to "/etc/dm/Sessions/ssh.desktop". [Desktop Entry] Encoding=UTF-8 Name=SSH Comment=This session logs you into a remote host using ssh Exec=/usr/local/bin/ssh-session Type=Application
740 FreeType 2.0 font rasterization library 472 Fontconfig, a generic font configuration library support binaries 440 Fontconfig, a generic font configuration library configuration data
You can check font configuration information by the following. "xset q" for core X11 font path "fc-match" for fontconfig font default "fc-list" for available fontconfig fonts
Tip
"The Penguin and Unicode" is a good overview of modern X Window System. Other documentations at http://unifont.org/ should provide good information on Unicode fonts, Unicode-enabled software, internationalization, and Unicode usability issues on free/libre/open source (FLOSS) operating systems.
Outline fonts on the Debian system are provided by the following. PostScript Type 1 font files having their file extension ".pfb" (binary font file) and ".afm" (font metrics file). TrueType (or OpenType) font files usually having their file extension ".ttf".
Tip
OpenType is intended to supersede both TrueType and PostScript Type 1. Table 7.5. Table of corresponding PostScript Type 1 fonts font popcon size package PostScript N/A gsfonts * V:18, I:66 N/A 4632 sansserif font monospace source of font font Courier Adobe
serif font
Nimbus Nimbus Mono Roman No9 URW (Adobe compatible size) L L Nimbus Nimbus Mono X font support with PostScript Type 1 Roman No9 L fonts. L URW extended (Adobe compatible size) scalable PostScript and OpenType fonts based on Computer Modern (from TeX)
gsfontsx11 * t1-cyrillic *
I:30
116
I:1.9
5008
Table 7.6. Table of corresponding TrueType fonts font package sansserif font Arial serif font Times New Roman monospace source of font font Microsoft (Adobe compatible size) (This installs non-free data) Liberation Fonts project (Microsoft compatible size) GNU freefont (Microsoft compatible size)
popcon size
ttfmscorefonts- I:11 installer * ttf-liberation I:43 * ttf-freefont * ttf-dejavu * ttf-dejavucore * ttf-dejavuextra * V:10, I:26 I:77
200
Courier New
1724 4204 68
Liberation Liberation Liberation Sans Serif Mono FreeSans FreeSerif FreeMono DejaVu Sans DejaVu Sans DejaVu Serif DejaVu Serif
DejaVu Sans DejaVu, Bitstream Vera with Unicode Mono coverage DejaVu, Bitstream Vera with Unicode DejaVu Sans coverage (sans, sans-bold, serif, serifMono bold, mono, mono-bold) N/A DejaVu, Bitstream Vera with Unicode coverage (oblique, italic, bold-oblique, bold-italic, condensed) GNU Unifont, with all printable character code in Unicode 5.1 Basic Multilingual Plane (BMP)
I:72
2592
I:69
5788
N/A
N/A
ttf-unifont *
I:4
16060 N/A
N/A
unifont
Tip
DejaVu fonts are based on and superset of Bitstream Vera fonts.
Table 7.7. Table of key words used in CJK font names to indicate font types font type Japanese font name Chinese font name Korean font name sans-serif gothic, serif mincho, hei, gothic song, ming dodum, gulim, gothic batang
Font name such as "VL PGothic" with "P" is a proportional font which corresponds to the fixed width "VL Gothic" font. For example, Shift_JIS code table comprises 7070 characters. They can be grouped as the following. JIS X 0201 single-byte characters (191 characters, a.k.a. half-width characters) JIS X 0208 double-byte characters (6879 characters, a.k.a. full-width characters) Double-byte characters occupy double width on console terminals which uses CJK fixed width fonts. In order to cope with such situation, Hanzi Bitmap Font (HBF) File with file extension ".hbf" may be deployed for fonts containing single-byte and double-byte characters. In order to save space for TrueType font files, TrueType font collection file with file extension ".ttc" may be used. In order to cover complicated code space of characters, CID keyed PostScript Type 1 font is used with CMap files starting themselves with "%!PS-Adobe-3.0 Resource-CMap". This is rarely used for normal X display but used for PDF rendering etc. (see Section 7.7.2, X utility applications).
Tip
The multiple glyphs are expected for some Unicode code points due to Han unification. One of the most annoying ones are "U+3001 IDEOGRAPHIC COMMA" and "U+3002 IDEOGRAPHIC FULL STOP" whose character positions differ among CJK countries. Configuring priority of Japanese centric fonts over Chinese ones using "~/.fonts.conf" should give peace of minds to Japanese.
7.7. X applications
7.7.1. X office applications
Here is a list of basic office applications (OO is OpenOffice.org). Table 7.8. List of basic X office applications package openoffice.org-writer * openoffice.org-calc * openoffice.org-impress * openoffice.org-base * openoffice.org-draw * openoffice.org-math * abiword * gnumeric * gimp * inkscape * dia-gnome * planner * kword * kspread * kpresenter * kexi * karbon * krita * kchart * kformula * kplato * popcon V:21, I:41 V:21, I:40 V:18, I:40 V:16, I:39 V:18, I:40 V:17, I:40 V:6, I:10 V:5, I:11 V:12, I:44 V:15, I:32 V:1.4, I:2 V:0.4, I:4 package size 26892 20524 4208 10708 10720 2712 4776 7860 13560 87436 576 6704 type OO OO OO OO OO OO description word processor spreadsheet presentation database management vector graphics editor (draw) mathematical equation/formula editor
GNOME word processor GNOME spreadsheet GTK bitmap graphics editor (paint) GNOME vector graphics editor (draw) GNOME flowchart and diagram editor GNOME project management KDE KDE KDE KDE KDE KDE KDE KDE KDE word processor spreadsheet presentation database management vector graphics editor (draw) bitmap graphics editor (paint) graph and chart drawing program mathematical equation/formula editor project management
V:0.6, I:1.5 5334 V:0.6, I:1.6 8792 V:0.5, I:1.3 2877 V:0.2, I:1.6 7625 V:0.6, I:1.4 2403 V:0.6, I:1.6 11822 V:0.8, I:1.9 2503 V:0.4, I:1.3 2065 V:0.15, I:1.4 5978
V:26, I:38 V:4, I:6 V:16, I:34 V:1.3, I:8 V:0.5, I:3 V:0.16, I:0.7 V:0.05, I:0.3 V:0.7, I:2
1116 3408 4724 1326 26888 1148 2180 5748 1092 144 748
GNOME document(pdf) viewer KDE GNOME KDE KDE document(pdf) viewer Personal information Management (groupware and email) Personal information Management (groupware and email) desktop page layout editor
GNOME personal accounting GTK KDE GTK personal accounting personal accounting scanner frontend
Caution
The poppler-data package (previously non-free, see Section 11.3.1, Ghostscript) needs to be installed for evince and okular to display CJK PDF documents using Cmap data (Section 7.6.3, CJK fonts).
Note
Installing softwares such as scribus (KDE) on GNOME desktop environment are quite acceptable since corresponding functionality is not available under GNOME desktop environment. But installing too many packages with duplicated functionalities clutter your menu.
Caution
Use of ssh(1) just for this purpose as above is waste of resource. In order for the X client to connect to the X server, please note the following. Values of the old user's "$XAUTHORITY" and "$DISPLAY" environment variables must be copied to the new user's ones. The file pointed by value of the "$XAUTHORITY" environment variable must be readable by the new user. The gksu package (popcon: V:23, I:46) is a specialized GTK+ GUI package for gaining the root privileges. It can be configured to use su(1) or sudo(8) as its backend depending on the "/apps/gksu/sudo-mode" gconf key. You can edit gconf key using gconf-editor(1) (menu: "Applications" "System Tools" "Configuration Editor").
Tip
There are 17, 18, or 10 letters between "m" and "n", "i" and "n", or "l" and "n" in multilingualization, internationalization, and localization which correspond to M17N, I18N, and L10N. The modern software such as GNOME and KDE are multilingualized. They are internationalized by making them handle UTF-8 data and localized by providing their translated messages through the gettext(1) infrastructure. Translated messages may be provided as separate localization packages. They can be selected simply by setting pertinent environment variables to the appropriate locale. The simplest representation of the text data is ASCII which is sufficient for English and uses less than 127 characters (representable with 7 bits). In order to support much more characters for the international support, many character encoding systems have been invented. The modern and sensible encoding system is UTF-8 which can handle practically all the characters known to the human (see Section 8.3.1, Basics of encoding). See Introduction to i18n for details. The international hardware support is enabled with localized hardware configuration data.
This supports keyboard input for accented characters of many European languages with its dead-key function. For Asian languages, you need more complicated input method support such as IBus discussed next.
V:0.04, I:0.10 684 V:0.00, I:0.03 404 V:0.06, I:0.09 1184 V:0.01, I:0.02 252 V:0.01, I:0.03 216 V:0.05, I:0.10 680 V:0.00, I:0.00 316 V:0.02, I:0.05 180
ibus-table-thai * I:0.00
The kinput2 method and other locale dependent Asian classic input methods still exist but are not recommended for the modern UTF-8 X environment. The SCIM and uim tool chains are an slightly older
recommended for the modern UTF-8 X environment. The SCIM and uim tool chains are an slightly older approach for the international input method for the modern UTF-8 X environment.
Tip
For meaning of encoding values, see Table 11.2, List of encoding values and their usage.
double quoted text single quoted text When ASCII plain text data is converted to UTF-8 one, it has exactly the same content and size as the original ASCII one. So you loose nothing by deploying UTF-8 locale. Some programs consume more memory after supporting I18N. This is because they are coded to use UTF32(UCS4) internally to support Unicode for speed optimization and consume 4 bytes per each ASCII character data independent of locale selected. Again, you loose nothing by deploying UTF-8 locale. The vendor specific old non-UTF-8 encoding systems tend to have minor but annoying differences on some characters such as graphic ones for many countries. The deployment of the UTF-8 system by the modern OSs practically solved these conflicting encoding issues.
Note
Although setting locale to "C" uses US English message, it handles only ASCII characters.
Tip
It is good idea to install system wide default locale as "en_US.UTF-8" for maximum compatibility.
Note
There may be another way available as the improvement of X session manager package but please read following as the generic and basic method of setting the locale. For gdm(1), I know you can select the locale of X session via its memu. The following line defines file location of the language environment in the PAM configuration file, such as "/etc/pam.d/gdm. auth required pam_env.so read_env=1 envfile=/etc/default/locale
For Japanese, create a "/etc/defaults/locale-gdm" file with "-rw-r--r-- 1 root root" permission containing the following. LANG="ja_JP.UTF-8"
Keep the default "/etc/defaults/locale" file for other programs as the the following. LANG="en_US.UTF-8" This is the most generic technique to customize locale and makes the menu selection dialog of gdm(1) itself to be localized. Alternatively for this case, you may simply change locale using the "~/.xsessionrc" file.
Note
When auto-mounting a hot-pluggable USB memory stick under modern desktop environment such as GNOME, you may provide such mount option by right clicking the icon on the desktop, click "Drive" tab, click to expand "Setting", and entering "utf8" to "Mount options:". The next time this memory stick is mounted, mount with UTF-8 is enabled.
Note
If you are upgrading system or moving disk drives from older non-UTF-8 system, file names with non-ASCII characters may be encoded in the historic and deprecated encodings such as ISO-8859-1 or eucJP. Please seek help of text conversion tools to convert them to UTF-8. See Section 11.1, Text data conversion tools. Samba uses Unicode for newer clients (Windows NT, 200x, XP) but uses CP850 for older clients (DOS and Windows 9x/Me) as default. This default for older clients can be changed using "dos charset" in the "/etc/samba/smb.conf" file, e.g., to CP932 for Japanese.
connection. 6. You may detach the screen session by any methods. Brutally unplug your network connection Type ^A d ("Control-A" followed by "d") and manually logging out from the remote connection Type ^A DD ("Control-A" followed by "DD") to have screen detach and log you out 7. You log in again to the same remote machine (even from a different terminal). 8. You start screen as "screen -r". 9. screen magically reattaches all previous screen windows with all actively running programs.
Tip
You can save connection fees with screen for metered network connections such as dial-up and packet ones, because you can leave a process active while disconnected, and then reattach it later when you connect again.
syslog-summary * V:0.2, I:0.9 V:0.10, I:0.2 V:0.11, I:0.6 V:0.09, I:0.3 V:0.06, I:0.2 V:0.04, I:0.2
V:0.06, I:0.18 1300 Controllable Regex Mutilator and Spam Filter (CRM114)
Note
CRM114 provides language infrastructure to write fuzzy filters with the TRE regex library. Its popular use is spam mail filter but it can be used as log analyzer.
Tip
Some x-terminal-emulator such as gnome-terminal can record. You may wish to extend line buffer for scrollback.
Tip
You may use screen(1) with "^A H" (see Section 9.1.2, Key bindings for the screen command) to perform recording of console.
Tip
You may use emacs(1) with "M-x shell", "M-x eshell", or "M-x term" to perform recording of console. You may later use "C-x C-w" to write the buffer to a file.
Tip
For vim(1) and its pager mode alias view(1), ":set hls" enables highlighted search.
Tip
You can eliminate typing long option on commandline using command alias, e.g. "alias ls='ls --time-style=+%d.%m.%y\ %H:%M'" (see Section 1.5.9, Command alias).
Tip
Tip
You can turn off these colorizing aliases in the interactive environment by invoking shell with "TERM=dumb bash".
xbase-clients * V:3, I:47 gimp * imagemagick * scrot * V:12, I:44 V:13, I:35
V:0.3, I:1.4 80
or Bazaar (new)
I recommend to use the etckeeper package with git(1) which put entire "/etc" under VCS control. Its installation guide and tutorial are found in "/usr/share/doc/etckeeper/README.gz". Essentially, running "sudo etckeeper init" initializes the git repository for "/etc" just like the process explained in Section 10.9.5, Git for recording configuration history but with special hook scripts for more thorough setups. As you change your configuration, you can use git(1) normally to record them. It automatically records changes nicely every time you run package management commands, too.
Tip
You can browse the change history of "/etc" by executing "sudo GIT_DIR=/etc/.git gitk" with clear view for new installed packages, removed packages, and version changes of packages.
Note
Some new PCs with Extensible Firmware Interface (EFI), including Intel-based Macs, use GUID Partition Table (GPT) scheme to hold disk partitioning data not in the first sector. Although fdisk(8) has been standard for the disk partitioning tool, parted(8) is replacing it. Table 9.7. List of disk partition management packages package utillinux * parted * gparted * qtparted * gptsync * kpartx * popcon V:91, I:99 V:1.0, I:9 V:3, I:31 V:0.10, I:0.9 V:0.01, I:0.18 size 2216 236 4548 GPT Not supported Supported Supported description miscellaneous system utilities including fdisk(8) and cfdisk(8) GNU Parted disk partition resizing program GNOME partition editor based on libparted KDE partition editor based on libparted synchronize classic MBR partition table with the GPT one program to create device mappings for partitions
Caution
Although parted(8) claims to create and to resize filesystem too, it is safer to do such things using best maintained specialized tools such as mkfs(8) (mkfs.msdos(8), mkfs.ext2(8), mkfs.ext3(8), ) and resize2fs(8).
Note
In order to switch between GPT and MBR, you need to erase first few blocks of disk contents directly (see Section 10.3.6, Clearing file contents) and use "parted /dev/sdx mklabel gpt" or "parted /dev/sdx mklabel msdos" to set it. Please note "msdos" is use here for MBR.
Tip
You can probe UUID of a block special device with blkid(8).
Tip
Device nodes of devices such as removable storage media can be made static by using udev rules, if needed. See Section 3.5.11, The udev system.
V:0.09, I:0.7 1264 utilities for the Reiser4 filesystem V:0.06, I:0.8 316 V:0.3, I:0.6 V:0.10, I:0.7 56 1288 utilities for the btrfs filesystem
Tip
Ext3 filesystem is the default filesystem for the Linux system and strongly recommended to use it unless you have some specific reasons not to. After Linux kernel 2.6.30 (Debian squeeze), ext4 filesystem is available and expected to be the default filesystem for the Linux system. btrfs filesystem is expected to be the next default filesystem after ext4 filesystem for the Linux system.
Warning
You might face some limitations with ext4 since it is new. For example, you must have Linux kernel 2.6.30 or later if you wish to resize an ext4 partition.
Tip
Some tools allow access to filesystem without Linux kernel support (see Section 10.3.2, Manipulating files without mounting disk).
Caution
It is generally not safe to run fsck on mounted filesystems.
Tip
Check files in "/var/log/fsck/" for the result of the fsck(8) command run from the boot script.
Tip
Use "shutdown -F -r now" to force to run the fsck(8) command safely on all filesystems including root filesystem on reboot. See the shutdown(8) manpage for more.
write speed.
Tip
You need to provide kernel boot parameter (see Section 3.3, Stage 2: the boot loader), e.g. "rootflags=data=journal" to deploy a non-default journaling mode for the root filesystem. For lenny, the default jounaling mode is "rootflags=data=ordered". For squeeze, it is "rootflags=data=writeback".
Warning
Filesystem conversion for the boot device to the ext4 filesystem should be avoided until GRUB boot loader supports the ext4 filesystem well and installed Linux Kernel version is newer than 2.6.30.
Tip
Despite its name, tune2fs(8) works not only on the ext2 filesystem but also on the ext3 and ext4 filesystems.
Tip
The smartd(8) daemon can be customized with the /etc/smartd.conf file including how to be notified of warnings.
Caution
Deployment of the current LVM system may degrade guarantee against filesystem corruption offered by journaled filesystems such as ext3fs unless their system performance is sacrificed by disabling write cache of hard disk.
Tip
You may alternatively mount an empty disk image file (see Section 10.2.5, Making the empty disk image file) as a loop device (see Section 10.2.3, Mounting the disk image file). The actual disk usage grows with the actual data stored.
Caution
Some software may not function well with "symlink to a directory".
Caution
Use of aufs for long term data storage is not good idea since it is under development and its design change may introduce issues.
Tip
In order to use aufs, its utility package aufs-tools and kernel module package for aufs such as aufs-modules-2.6-amd64 need to be installed.
Tip
aufs is used to provide writable root filesystem by many modern live CD projects.
Dm-crypt is a cryptographic filesystem using device-mapper. Device-mapper maps one block device to another. eCryptfs is another cryptographic filesystem using stacked filesystem. Stacked filesystem stacks itself on top of an existing directory of a mounted filesystem.
Caution
Data encryption costs CPU time etc. Please weigh its benefits and costs.
Note
Entire Debian system can be installed on a encrypted disk by the debian-installer (lenny or newer) using dm-crypt/LUKS and initramfs.
Tip
See Section 10.4, Data security infrastructure for user space encryption utility: GNU Privacy Guard.
Note
If you are really paranoid for the security of data, you may need to overwrite multiple times in the above example. This operation is very time consuming though.
Tip
Since eCryptfs selectively encrypt only the sensitive files, its system cost is much less than using dm-crypt on the entire root or "/home" device. It does not require any special on-disk storage allocation effort but cannot keep all filesystem metadata confidential.
(Pluggable Authentication Modules). Insert the following line just before "pam_permit.so" in "/etc/pam.d/common-auth". auth required pam_ecryptfs.so unwrap Insert the following line just at the last line in "/etc/pam.d/common-session". session optional pam_ecryptfs.so unwrap Insert the following line at first active line in "/etc/pam.d/common-password". password required pam_ecryptfs.so This is quite convenient.
Warning
Configuration errors of PAM may lock you out of your own system. See Chapter 4, Authentication.
Caution
If you use your login password for wrapping encryption keys, your encrypted data are as secure as your user login password (see Section 4.3, Good password). Unless you are careful to set up a strong password, your data is at risk when someone runs password cracking software after stealing your laptop (see Section 4.7.4, Securing the root password).
coreutils V:92, I:99 * bsdutils * V:77, I:99 procps * psmisc * time * sysstat * isag * lsof * strace * ltrace * xtrace * V:86, I:99 V:47, I:88 V:6, I:84 V:4, I:9 V:16, I:90 V:5, I:39 V:0.3, I:2 V:0.02, I:0.18
13828 nice(1): run a program with modified scheduling priority 196 772 716 152 872 444 396 188 372 524 240 120 220 renice(1): modify the scheduling priority of a running process "/proc" filesystem utilities: ps(1), top(1), kill(1), watch(1), "/proc" filesystem utilities: killall(1), fuser(1), peekfd(1), pstree(1) time(1): run a program to report system resource usages with respect to time sar(1), iostat(1), mpstat(1), : system performance tools for Linux Interactive System Activity Grapher for sysstat lsof(8): list open files by a running process using "-p" option strace(1): trace system calls and signals ltrace(1): trace library calls xtrace(1): trace communication between X11 client and server powertop(1): information about system power use on Intel-based laptops run processes according to a schedule in background from cron(8) daemon cron-like command scheduler for systems that don't run 24 hours a day at(1) or batch(1): run a job at a specified time or below certain load level
powertop * V:0.7, I:12 cron * anacron * at * V:91, I:99 V:41, I:44 V:50, I:83
Tip
The procps packages provide very basics of monitoring, controlling, and starting program activities. You should learn all of them.
nice value scheduling priority 19 0 -20 lowest priority process (nice) very high priority process for user very high priority process for root (not-nice)
# nice -19 top # very nice # nice --20 wodim -v -eject speed=2 dev=0,0 disk.img # very fast Sometimes an extreme nice value does more harm than good to the system. Use this command carefully.
System V ps -efH
For the zombie (defunct) children process, you can kill them by the parent process ID identified in the "PPID" field. The pstree(1) command display a tree of processes.
$ watch w This displays who is logged on to the system updated every 2 seconds.
Create an open-with association as as the following. 1. Right click folder to select "Open with Other Application ". 2. Click open "Use a custom command" dialog and enter "mc-term %f". 3. Click "Open".
Tip
Launcher is a file at "~/Desktop" with ".desktop" as its extension.
Tip
update-mime(8) updates the "/etc/mailcap" file using "/etc/mailcap.order" file (see mailcap.order(5)).
Tip
The debianutils package provides sensible-browser(1), sensible-editor(1), and
sensible-pager(1) which make sensible decisions on which editor, pager, and web browser to call, respectively. I recommend you to read these shell scripts.
Tip
In order to run a console application such as mutt under X as your preferred application, you should create an X application as following and set "/usr/local/bin/mutt-term" as your preferred application to be started as described. # cat /usr/local/bin/mutt-term <<EOF #!/bin/sh gnome-terminal -e "mutt \$@" EOF chmod 755 /usr/local/bin/mutt-term
Tip
For the system not running continuously, install the anacron package to schedule periodic commands at the specified intervals as closely as machine-uptime permits. See anacron(8) and anacrontab(5).
Tip
For scheduled system maintenance scripts, you can run them periodically from root account by placing such scripts in "/etc/cron.hourly/", "/etc/cron.daily/", "/etc/cron.weekly/", or "/etc/cron.monthly/". Execution timings of these scripts can be customized by "/etc/crontab" and "/etc/anacrontab".
k e i s u b
kill all processes on the current virtual console send a SIGTERM to all processes, except for init(8) send a SIGKILL to all processes, except for init(8) sync all mounted filesystems remount all mounted filesystems read-only (umount) reboot the system without syncing or unmounting
The combination of "Alt-SysRq s", "Alt-SysRq u", and "Alt-SysRq r" is good for getting out of really bad situations. See "/usr/share/doc/linux-doc-2.6.*/Documentation/sysrq.txt.gz".
Caution
The Alt-SysRq feature may be considered a security risk by allowing users access to rootprivileged functions. Placing "echo 0 >/proc/sys/kernel/sysrq" in "/etc/rc.local" or "kernel.sysrq = 0" in "/etc/sysctl.conf" disables the Alt-SysRq feature.
Tip
From SSH terminal etc., you can use the Alt-SysRq feature by writing to the "/proc/sysrqtrigger". For example, "echo s > /proc/sysrq-trigger; echo u > /proc/sysrqtrigger" from the root shell prompt syncs and umounts all mounted filesystems.
Tip
"/var/run/utmp", "/var/log/wtmp", and "/var/run/utmp" hold such user information. See login(1) and utmp(5).
V:34, I:51 544 V:51, I:91 208 V:4, I:35 V:1.2, I:11 V:0.04, I:0.09 V:0.07, I:0.09 92 252 248 148
X server utilities: xset(1), xmodmap(1) daemon to manage events delivered by the Advanced Configuration and Power Interface (ACPI) utility to display information on ACPI devices daemon to manage events delivered by the Advanced Power Management (APM) daemon to allow idle hard disks to spin down daemon to put a laptop to sleep during inactivity hard disk access optimization (see Section 9.3.7, Optimization of hard disk)
1076 control and monitor storage systems using S.M.A.R.T. collection of tools for serial port management collection of tools for memory hardware management collection of tools for SCSI hardware management utility to configure touchpad devices compact disc drive access optimization larger mouse cursors for X
V:1.5, I:3 180 V:0.5, I:5 652 V:0.18, I:1.1 V:0.3, I:0.5 V:0.06, I:0.3 I:0.16 484 220 28 68
Here, ACPI is a newer framework for the power management system than APM.
Tip
CPU frequency scaling on modern system is governed by kernel modules such as acpi_cpufreq.
Tip
ntptrace(8) in the ntp package can trace a chain of NTP servers back to the primary source.
Tip
Use "cat /dev/urandom > /dev/audio" or speaker-test(1) to test speaker. (^C to stop)
Tip
If you can not get sound, your speaker may be connected to a muted output. Modern sound system has many outputs. alsamixer(1) in the alsa-utils package is useful to configure volume and mute settings. Application softwares may be configured not only to access sound devices directly but also to access them via some standardized sound server system. Table 9.18. List of sound packages package linux-sound-base * alsa-base * alsa-utils * oss-compat * esound-common * esound * esound-clients * libesd0 * arts * libarts1c2a * libartsc0 * jackd * libjack0 * nas * libaudio2 * pulseaudio * libpulse0 * popcon size description base package for ALSA and OSS sound systems ALSA driver configuration files OSS compatibility under ALSA preventing "/dev/dsp not found" errors Enlightened Sound Daemon (ESD) common (Enlightenment and GNOME) Enlightened Sound Daemon (ESD) server (Enlightenment and GNOME) Enlightened Sound Daemon (ESD) client (Enlightenment and GNOME) Enlightened Sound Daemon (ESD) library (Enlightenment and GNOME) aRts server (KDE) aRts library (KDE) JACK Audio Connection Kit. (JACK) server (low latency) JACK Audio Connection Kit. (JACK) library (low latency) Network Audio System (NAS) server Network Audio System (NAS) library PulseAudio client library, replacement for ESD
V:34, I:48 1984 utilities for configuring and using ALSA V:28, I:33 60 V:19, I:56 232 V:0.6, I:6 V:7, I:20 80 188
V:13, I:23 5968 aRts library (KDE) V:10, I:32 48 V:0.8, I:3 V:0.14, I:0.2 V:3, I:5 32 V:1.3, I:33 164 328
libgstreamer0.10V:30, I:51 3368 GStreamer: GNOME sound engine 0* libxine1 * libphonon4 * V:5, I:27 I:16 36 572 xine: KDE older sound engine Phonon: KDE new sound engine
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.
free(1) and top(1) display information on memory resources on the running system. $ 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
Tip
Do not worry about the large size of "used" and the small size of "free" in the "Mem:" line, but read the one under them (675404 and 321780 in the example below) and relax. For my MacBook with 1GB=1048576k DRAM (video system steals some of this), I see the following. Table 9.20. List of memory sizes reported report size
Total size in dmesg 1016784k = 1GB - 31792k Free in dmesg Total under shell Free under shell 990528k 997184k 20256k (but effectively 321780k)
3148 report system security vulnerabilities 9456 file and directory integrity checker 532 active password cracking tool 1213 Advanced Intrusion Detection Environment - static binary 1960 security hardening tool file integrity verification program password guessing program 204
Here is a simple script to check for typical world writable incorrect file permissions. # find / -perm 777 -a \! -type s -a \! -type l -a \! \( -type d -a -perm 1777 \)
Caution
Since the debsums package uses MD5 checksums stored locally, it can not be fully trusted as the system security audit tool against malicious attacks.
Section 1.2.12, procfs and sysfs) Module parameters set by arguments of modprobe(8) when a module is activated (see Section 10.2.3, Mounting the disk image file) See "kernel-parameters.txt(.gz)" and other related documents in the Linux kernel documentation ("/usr/share/doc/linux-doc-2.6.*/Documentation/filesystems/*") provided by the linux-doc2.6.* package.
Note
For compiling some kernel-specific programs such as the kernel modules from the external source and the automounter daemon (amd), you must include path to the corresponding kernel headers, e.g. "-I/usr/src/linux-particular-version/include/", to your command line. module-assistant(8) (or its short form m-a) helps users to build and install module package(s) easily for one or more custom kernels.
10632 git: distributed revision control system used by the Linux kernel
V:49, I:98 468 V:1.5, I:14 2316 568 468 1696 N/A V:6, I:9 V:2, I:11 N/A
If you use initrd in Section 3.3, Stage 2: the boot loader, make sure to read the related information in initramfs-tools(8), update-initramfs(8), mkinitramfs(8) and initramfs.conf(5).
Warning
Do not put symlinks to the directories in the source tree (e.g. "/usr/src/linux*") from "/usr/include/linux" and "/usr/include/asm" when compiling the Linux kernel source. (Some outdated documents suggest this.)
Note
When compiling the latest Linux kernel on the Debian stable system, the use of backported latest tools from the Debian unstable may be needed.
Note
The dynamic kernel module support (DKMS) is a new distribution independent framework designed to allow individual kernel modules to be upgraded without changing the whole kernel. This will be endorsed for the maintenance of out-of-tree modules for squeeze. This also makes it very easy to rebuild modules as you upgrade kernels.
Caution
When you intend to create a non-modularized kernel compiled only for one machine, invoke make-kpkg without "--initrd" option since initrd is not used. Invocation of "make oldconfig" and "make dep" are not required since "make-kpkg kernel_image" invokes them.
Tip
See http://wiki.debian.org/SystemVirtualization .
schroot * sbuild * pbuilder * debootstrap * cdebootstrap * rootstrap * virt-manager * libvirt-bin * user-modelinux * bochs * qemu * qemu-system * qemu-user * qemu-utils * qemu-kvm * virtualboxose * xen-tools * wine * dosbox * dosemu * vzctl * vzquota * lxc *
specialized tool for executing Debian binary packages in chroot tool for building Debian binary packages from Debian sources personal package builder for Debian packages bootstrap a basic Debian system (written in sh) bootstrap a Debian system (written in C) tool for building complete Linux filesystem images Virtual Machine Manager: desktop application for managing virtual machines programs for the libvirt library
V:1.6, I:12 268 V:0.3, I:2 V:0.02, I:0.17 V:0.5, I:1.6 V:1.4, I:2 V:0.07, I:0.3 V:0.05, I:0.3 V:0.6, I:6 V:2, I:3 V:0.3, I:3 V:0.4, I:3 V:1.3, I:2 V:2, I:4 V:0.2, I:1.9 116 156 5908 2240
20540 User-mode Linux (kernel) 3280 460 Bochs: IA-32 PC emulator QEMU: fast generic processor emulator
38196 QEMU: full system emulation binaries 16716 QEMU: user mode emulation binaries 756 4308 QEMU: utilities KVM: full virtualization on x86 hardware with the hardware-assisted virtualization
31728 VirtualBox: x86 virtualization solution on i386 and amd64 1236 tools to manage debian XEN virtual server Wine: Windows API Implementation (standard suite) DOSBox: x86 emulator with Tandy/Herc/CGA/EGA/VGA/SVGA graphics, sound and DOS DOSEMU: The Linux DOS Emulator OpenVZ server virtualization solution - control tools OpenVZ server virtualization solution - quota tools Linux containers user space tools
V:1.7, I:13 96 V:0.5, I:2 V:0.2, I:1.2 V:0.7, I:1.1 V:0.7, I:1.2 V:0.05, I:0.2 2460 5940 1056 204 744
See Wikipedia article Comparison of platform virtual machines for detail comparison of different platform virtualization solutions.
Note
Default Debian kernels support KVM since lenny. Typical work flow for virtualization involves several steps. Create an empty filesystem (a file tree or a disk image). The file tree can be created by "mkdir -p /path/to/chroot". The raw disk image file can be created with dd(1) (see Section 10.2.1, Making the disk image file and Section 10.2.5, Making the empty disk image file). qemu-img(1) can be used to create and convert disk image files supported by QEMU. The raw and VMDK file format can be used as common format among virtualization tools. Mount the disk image with mount(8) to the filesystem (optional). For the raw disk image file, mount it as loop device or device mapper devices (see Section 10.2.3, Mounting the disk image file). For disk images supported by QEMU, mount them as network block device (see Section 9.8.3, Mounting the virtual disk image file). Populate the target filesystem with required system data. Use programs such as debootstrap and cdebootstrap help this process (see Section 9.8.4, Chroot system). Use installers of OSs under the full system emulation. Run a program under a virtualized environment. chroot provides basic virtualized environment enough to compile programs, run console applications, and run daemons in it.
QEMU provides cross-platform CPU emulation. QEMU with KVM provides full system emulation by the hardware-assisted virtualization. VirtualBox provides full system emulation on i386 and amd64 with or without the hardwareassisted virtualization.
Tip
You may export only the first partition of "disk.img" using "-P 1" option to qemu-nbd(8).
Caution
Examples below assumes both parent system and chroot system share the same CPU architecture. You can learn how to setup and use chroot(8) by running pbuilder(8) program under script(1) as follows. $ sudo mkdir /sid-root $ sudo pbuilder --create --no-targz --debug --buildplace /sid-root You see how debootstrap(8) or cdebootstrap(1) populate system data for sid environment under "/sid-root".
Tip
These debootstrap(8) or cdebootstrap(1) are used to install Debian by the Debian Installer. These can also be used to install Debian to a system without using a Debian install disk, but instead from another GNU/Linux distribution. $ sudo pbuilder --login --no-targz --debug --buildplace /sid-root
You see how a system shell running under sid environment is created as the following. 1. 2. 3. 4. 5. Copy local configuration ("/etc/hosts", "/etc/hostname", "/etc/resolv.conf") Mount "/proc" filesystem Mount "/dev/pts" filesystem Create "/usr/sbin/policy-rc.d" which always exits with 101 Run "chroot /sid-root bin/bash -c 'exec -a -bash bin/bash'"
Note
Some programs under chroot may require access to more files from the parent system to function than pbuilder provides. For example, "/sys", "/etc/passwd", "/etc/group", "/var/run/utmp", "/var/log/wtmp", etc. may need to be bind-mounted or copied.
Note
The "/usr/sbin/policy-rc.d" file prevents daemon programs to be started automatically on Debian system. See "/usr/share/doc/sysv-rc/README.policy-rc.d.gz".
Tip
The original purpose of the specialized chroot package, pbuilder is to construct a chroot system and builds a package inside the chroot. It is an ideal system to use to check that a package's build-dependencies are correct, and to be sure that unnecessary and wrong build dependencies do not exist in the resulting package.
Tip
Similar schroot package may give you an idea to run i386 chroot system under amd64 parent system.
I recommend you to use QEMU or VirtualBox on a Debian stable system to run multiple desktop systems safely using virtualization. These enable you to run desktop applications of Debian unstable and testing without usual risks associated with them. Since pure QEMU is very slow, it is recommended to accelerate it with KVM when the host system support it. The virtual disk image "virtdisk.qcow2" containing Debian system for QEMU can be created using debian-installer: Small CDs as follows. $ wget http://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 ... See more tips at Debian wiki: QEMU. VirtualBox comes with Qt GUI tools and quite intuitive. Its GUI and command line tools are explained in VirtualBox User Manual and VirtualBox User Manual (PDF).
Tip
Running other GNU/Linux distributions such as Ubuntu and Fedra under virtualization is a great way to learn configuration tips. Other proprietary OSs may be run nicely under this GNU/Linux virtualization, too.
Warning
The uncoordinated write access to actively accessed devices and files from multiple processes must not be done to avoid the race condition. File locking mechanisms using flock(1) may be used to avoid it.
These can be realized by using some combination of tools. Archive and compression tools Copy and synchronization tools Network filesystems Removable storage media The secure shell The authentication system Version control system tools Hash and cryptographic encryption tools
11996 ar(1)
V:7, I:31 216 V:1.5, I:6 V:0.3, I:1.7 V:91, I:99 V:51, I:79 172 240 284
bzip2 *
132
lzma(1) xz(1), xzdec(1), 7zr(1), p7zip(1) 7z(1), 7za(1) lzop(1) zip(1) unzip(1) .lzma
than gzip with similar syntax) LZMA compression utility with higher compression ratio than gzip(1) (deprecated) XZ compression utility with higher compression ratio than bzip2(1) (slower than gzip but faster than bzip2; replacement for LZMA compression utility) 7-Zip file archiver with high compression ratio (LZMA compression) 7-Zip file archiver with high compression ratio (LZMA compression and others) LZO compression utility with higher compression and decompression speed than gzip(1) (lower compression ratio than gzip with similar syntax) InfoZIP: DOS archive and compression tool InfoZIP: DOS unarchive and decompression tool
xz-utils V:5, I:26 460 * p7zip * p7zipfull * lzop * zip * unzip * V:2, I:23 1052 V:14, I:26 V:0.7, I:6 3612
.xz
.7z .7z
144
Warning
Do not set the "$TAPE" variable unless you know what to expect. It changes tar(1) behavior.
Note
The gzipped tar(1) archive uses the file extension ".tgz" or ".tar.gz".
Note
The xz-compressed tar(1) archive uses the file extension ".txz" or ".tar.xz".
Note
Popular compression method in FOSS tools such as tar(1) has been moving as follows: gzip bzip2 xz
Note
cp(1), scp(1) and tar(1) may have some limitation for special files. cpio(1) and afio(1) are most versatile.
Note
cpio(1) and afio(1) are designed to be used with find(1) and other commands and suitable for creating backup scripts since the file selection part of the script can be tested independently.
Note
afio(1) compresses each file in the archive. This makes afio to be much safer for the file corruption than the globally compressed tar or cpio archives and to be the best archive engine for the backup script.
Note
Internal structure of OpenOffice data files are ".jar" file.
Copying files with rsync(8) offers richer features than others. delta-transfer algorithm that sends only the differences between the source files and the existing files in the destination quick check algorithm (by default) that looks for files that have changed in size or in last-modified time
"--exclude" and "--exclude-from" options similar to tar(1) "a trailing slash on the source directory" syntax that avoids creating an additional directory level at the destination.
Tip
Execution of the bkup script mentioned in Section 10.1.9, A copy script for the data backup with the "-gl" option under cron(8) should provide very similar functionality as Plan9's dumpfs for the static data archive.
Tip
Version control system (VCS) tools in Table 10.16, List of version control system tools can function as the multi-way copy and synchronization tools.
Tip
rsync(8) and GNU cp(1) have option "-u" to skip files that are newer on the receiver.
Its conditional arguments are evaluated from left to right. This evaluation stops once its outcome is determined. "Logical OR" (specified by "-o" between conditionals) has lower precedence than "logical AND" (specified by "-a" or nothing between conditionals). "Logical NOT" (specified by "!" before a conditional) has higher precedence than "logical AND". "-prune" always returns logical TRUE and, if it is a directory, searching of file is stopped beyond this point. "-name" matches the base of the filename with shell glob (see Section 1.5.6, Shell glob) but it also matches its initial "." with metacharacters such as "*" and "?". (New POSIX feature) "-regex" matches the full path with emacs style BRE (see Section 1.6.2, Regular expressions) as default. "-size" matches the file based on the file size (value precedented with "+" for larger, precedented with "-" for smaller) "-newer" matches the file newer than the one specified in its argument. "-print0" always returns logical TRUE and print the full filename (null terminated) on the standard output. find(1) is often used with an idiomatic style as the following. # find /path/to \ -xdev -regextype posix-extended \ -type f -regex ".*\.afio|.*~" -prune -o \ -type d -regex ".*/\.git" -prune -o \ -type f -size +99M -prune -o \ -type f -newer /path/to/timestamp -print0 This means to do following actions. 1. Search all files starting from "/path/to" 2. Globally limit its search within its starting filesystem and uses ERE (see Section 1.6.2, Regular expressions) instead 3. Exclude files matching regex of ".*\.afio" or ".*~" from search by stop processing 4. Exclude directories matching regex of ".*/\.git" from search by stop processing 5. Exclude files larger than 99 Megabytes (units of 1048576 bytes) from search by stop processing 6. Print filenames which satisfy above search conditions and newer than "/path/to/timestamp" Please note the idiomatic use of "-prune -o" to exclude files in the above example.
Note
For non-Debian Unix-like system, some options may not be supported by find(1). In such a case, please consider to adjust matching methods and replace "-print0" with "-print". You may need to adjust related commands too.
Tip
Keep your backup system simple and backup your system often. Having backup data is more important than how technically good your backup method is. There are 3 key factors which determine actual backup and recovery policy. 1. Knowing what to backup and recover. Data files directly created by you: data in "~/" Data files created by applications used by you: data in "/var/" (except "/var/cache/", "/var/run/", and "/var/tmp/") System configuration files: data in "/etc/" Local softwares: data in "/usr/local/" or "/opt/" System installation information: a memo in plain text on key steps (partition, ) Proven set of data: confirmed by experimental recovery operations in advance 2. Knowing how to backup and recover. Secure storage of data: protection from overwrite and system failure Frequent backup: scheduled backup Redundant backup: data mirroring Fool proof process: easy single command backup 3. Assessing risks and costs involved. Value of data when lost Required resources for backup: human, hardware, software, Failure mode and their possibility As for secure storage of data, data should be at least on different disk partitions preferably on different disks and machines to withstand the filesystem corruption. Important data are best stored on a write-once media such as CD/DVD-R to prevent overwrite accidents. (See Section 10.3, The binary data for how to write to the storage media from the shell commandline. GNOME desktop GUI environment gives you easy access via menu: "PlacesCD/DVD Creator".)
Note
You may wish to stop some application daemons such as MTA (see Section 6.3, Mail transport agent (MTA)) while backing up data.
Note
You should pay extra care to the backup and restoration of identity related data files such as "/etc/ssh/ssh_host_dsa_key", "/etc/ssh/ssh_host_rsa_key", "~/.gnupg/*", "~/.ssh/*", "/etc/passwd", "/etc/shadow", "/etc/fetchmailrc", "popularitycontest.conf", "/etc/ppp/pap-secrets", and "/etc/exim4/passwd.client". Some of these data can not be regenerated by entering the same input string to the system.
Note
If you run a cron job as a user process, you must restore files in "/var/spool/cron/crontabs" directory and restart cron(8). See Section 9.5.14, Scheduling tasks regularly for cron(8) and crontab(1).
V:1.4, I:3 804 V:0.4, I:1.5 V:0.3, I:1.9 716 628 452
backupninja V:0.5, * I:0.6 mondo * sbackup * keep * baculacommon * baculaclient * baculaconsole * baculaserver * amandacommon * amandaclient * amandaserver * backuppc * backupmanager * backup2l * V:0.11, I:0.5 V:0.05, I:0.16 V:0.13, I:0.3
1168 Mondo Rescue: disaster recovery backup suite 488 simple backup suite for GNOME desktop
V:1.3, I:2 1404 Bacula: network backup, recovery and verification - common support files I:0.9 V:0.3, I:1.2 I:0.5 V:0.4, I:0.8 V:0.4, I:0.8 V:0.11, I:0.3 V:0.8, I:1.0 V:0.4, I:0.6 V:0.2, I:0.3 84 184 84 Bacula: network backup, recovery and verification - client meta-package Bacula: network backup, recovery and verification - text console Bacula: network backup, recovery and verification - server meta-package
6924 Amanda: Advanced Maryland Automatic Network Disk Archiver (Libs) 748 916 2460 672 152 Amanda: Advanced Maryland Automatic Network Disk Archiver (Client) Amanda: Advanced Maryland Automatic Network Disk Archiver (Server) BackupPC is a high-performance, enterprise-grade system for backing up PCs (disk based) command-line backup tool low-maintenance backup/restore tool for mountable media (disk based)
Backup tools have their specialized focuses. Mondo Rescue is a backup system to facilitate restoration of complete system quickly from backup CD/DVD etc. without going through normal system installation processes. sbackup and keep packages provide easy GUI frontend for desktop users to make regular backups of user data. An equivalent function can be realized by a simple script (Section 10.1.8, An example script for the system backup) and cron(8). Bacula, Amanda, and BackupPC are full featured backup suite utilities which are focused on regular backups over network. Basic tools described in Section 10.1.1, Archive and compression tools and Section 10.1.2, Copy and synchronization tools can be used to facilitate system backup via custom scripts. Such script can be enhanced by the following. The rdiff-backup package enables incremental (remote) backups. The dump package helps to archive and restore the whole filesystem incrementally and efficiently.
Tip
See files in "/usr/share/doc/dump/" and "Is dump really deprecated?" to lean about the dump package.
Tip
You can recover debconf configuration data with "debconf-set-selections debconfselections" and dpkg selection data with "dpkg --set-selection <dpkgselections.list".
l) OPT="-alv";; # hardlink (GNU cp) L) OPT="-av";; # copy (GNU cp) a) FIND="fall";; # find all A) FIND="fdot";; # find non CVS/ .???/ x) set -x;; # trace e) EXTP="${OPTARG}";; # hostname -f h) HOST="${OPTARG}";; # [email protected] T) MODE="TEST";; # test find mode \?) echo "use -x for trace." esac; done shift $(expr $OPTIND - 1) if [ $# -gt 0 ]; then for x in $@; do cp $OPT $x $x.$TIME; done elif [ $MODE = GNUCP ]; then mkdir -p "../$BU";chmod 700 "../$BU";cp $OPT . "../$BU/" elif [ $MODE = CPIOP ]; then mkdir -p "../$BU";chmod 700 "../$BU" $FIND|cpio --null --sparse -pvd ../$BU elif [ $MODE = CPIOI ]; then $FIND|cpio -ov --null | ( mkdircd "../$BU"&&cpio -i ) elif [ $MODE = CPIOSSH ]; then $FIND|cpio -ov --null|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&&cpio -i )" elif [ $MODE = AFIOSSH ]; then $FIND|afio -ov -0 -|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&&afio -i - )" elif [ $MODE = TARSSH ]; then (tar cvf - . )|ssh -C $HOST "( mkdircd \"$EXTP/$BU\"&& tar xvfp - )" elif [ $MODE = RSYNCSSH ]; then rsync -rlpt ./ "${HOST}:${EXTP}-${BKUP}-${TIME}" else echo "Any other idea to backup?" $FIND |xargs -0 -n 1 echo fi This is meant to be command examples. Please read script and edit it by yourself before using it.
Tip
I keep this bkup in my "/usr/local/bin/" directory. I issue this bkup command without any option in the working directory whenever I need a temporary snapshot backup.
Tip
For making snapshot history of a source file tree or a configuration file tree, it is easier and space efficient to use git(7) (see Section 10.9.5, Git for recording configuration history).
Note
Automounting under modern desktop environment happens only when those removable media devices are not listed in "/etc/fstab".
Tip
When providing wrong mount option causes problem, erase its corresponding setting under "/system/storage/" via gconf-editor(1). Table 10.4. List of packages which permit normal users to mount removable devices without a matching "/etc/fstab" entry package popcon size description
gnome-mount wrapper for (un)mounting and ejecting storage devices (used by V:15, I:28 NOT_FOUND GNOME) * pmount * cryptmount * V:4, I:19 V:0.2, I:0.5 548 360 mount removable devices as normal user (used by KDE) Management and user-mode mounting of encrypted filesystems
usbmount *
V:0.4, I:1.4
112
When sharing data with other system via removable storage device, you should format it with common filesystem supported by both systems. Here is a list of filesystem choices. Table 10.5. List of filesystem choices for removable storage devices with typical usage scenarios filesystem description of typical usage scenario FAT12 FAT16 FAT32 NTFS ISO9660 UDF MINIX filesystem ext2 filesystem ext3 filesystem cross platform sharing of data on the floppy disk (<32MiB) cross platform sharing of data on the small hard disk like device (<2GiB) cross platform sharing of data on the large hard disk like device (<8TiB, supported by newer than MS Windows95 OSR2) cross platform sharing of data on the large hard disk like device (supported natively on MS Windows NT and later version, and supported by NTFS-3G via FUSE on Linux) cross platform sharing of static data on CD-R and DVD+/-R incremental data writing on CD-R and DVD+/-R (new) space efficient unix file data storage on the floppy disk sharing of data on the hard disk like device with older Linux systems sharing of data on the hard disk like device with current Linux systems (journaling filesystem)
Tip
See Section 9.4.1, Removable disk encryption with dm-crypt/LUKS for cross platform sharing of data using device level encryption. The FAT filesystem is supported by almost all modern operating systems and is quite useful for the data exchange purpose via removable hard disk like media. When formatting removable hard disk like devices for cross platform sharing of data with the FAT filesystem, the following should be safe choices. Partitioning them with fdisk(8), cfdisk(8) or parted(8) (see Section 9.3.1, Disk partition configuration) into a single primary partition and to mark it as the following. Type "6" for FAT16 for media smaller than 2GB. Type "c" for FAT32 (LBA) for larger media. Formatting the primary partition with mkfs.vfat(8) with the following. Just its device name, e.g. "/dev/sda1" for FAT16 The explicit option and its device name, e.g. "-F 32 /dev/sda1" for FAT32 When using the FAT or ISO9660 filesystems for sharing data, the following should be the safe considerations. Archiving files into an archive file first using tar(1), cpio(1), or afio(1) to retain the long filename, the symbolic link, the original Unix file permission and the owner information. Splitting the archive file into less than 2 GiB chunks with the split(1) command to protect it from the file size limitation. Encrypting the archive file to secure its contents from the unauthorized access.
Note
For FAT filesystems by its design, the maximum file size is (2^32 - 1) bytes = (4GiB 1 byte). For some applications on the older 32 bit OS, the maximum file size was even smaller (2^31 - 1) bytes = (2GiB - 1 byte). Debian does not suffer the latter problem.
Note
Microsoft itself does not recommend to use FAT for drives or partitions of over 200 MB. Microsoft highlights its short comings such as inefficient disk space usage in their "Overview of FAT, HPFS, and NTFS File Systems". Of course, we should normally use the ext3 filesystem for Linux.
Tip
For more on filesystems and accessing filesystems, please read "Filesystems HOWTO".
SMB/CIFS network mounted filesystem with Samba NFS network mounted filesystem with the Linux kernel HTTP service HTTPS service FTP service
sharing files via "Microsoft Windows Network", see smb.conf(5) and The Official Samba 3.2.x HOWTO and Reference Guide or the samba-doc package
sharing files via "Unix/Linux Network", see exports(5) and Linux NFS-HOWTO sharing file between the web server/client sharing file between the web server/client with encrypted Secure Sockets Layer (SSL) or Transport Layer Security (TLS) sharing file between the FTP server/client
Although these filesystems mounted over network and file transfer methods over network are quite convenient for sharing data, these may be insecure. Their network connection must be secured by the following. Encrypt it with SSL/TLS Tunnel it via SSH Tunnel it via VPN Limit it behind the secure firewall See also Section 6.10, Other network application servers and Section 6.11, Other network application clients.
Note
A fire-resistant safe are meant for paper documents. Most of the computer data storage media have less temperature tolerance than paper. I usually rely on multiple secure encrypted copies stored in multiple secure locations. Optimistic storage life of archive media seen on the net (mostly from vendor info). 100+ years : Acid free paper with ink 100 years : Optical storage (CD/DVD, CD/DVD-R) 30 years : Magnetic storage (tape, floppy) 20 years : Phase change optical storage (CD-RW) These do not count on the mechanical failures due to handling etc. Optimistic write cycle of archive media seen on the net (mostly from vendor info). 250,000+ cycles : Harddisk drive 10,000+ cycles : Flash memory 1,000 cycles : CD/DVD-RW 1 cycles : CD/DVD-R, paper
Caution
Figures of storage life and write cycle here should not be used for decisions on any critical data storage. Please consult the specific product information provided by the manufacture.
Tip
Since CD/DVD-R and paper have only 1 write cycle, they inherently prevent accidental data loss by overwriting. This is advantage!
Tip
If you need fast and frequent backup of large amount of data, a hard disk on a remote host linked by a fast network connection, may be the only realistic option.
"mbr.img": The MBR with the partition table "mbr-nopart.img": The MBR without the partition table "part.img": The partition table of the MBR only If you have a SCSI device (including the new serial ATA drive) as the boot disk, substitute "/dev/hda" with "/dev/sda". If you are making an image of a disk partition of the original disk, substitute "/dev/hda" with "/dev/hda1" etc.
Alternatively, similar effects can be done by using the device mapper devices created by kpartx(8) from the kpartx package as follows. # kpartx -a -v disk.img ... # mkdir -p /mnt/loop0p2 # mount -t ext3 /dev/mapper/loop0p2 /mnt/loop0p2 ... ...hack...hack...hack # umount /dev/mapper/loop0p2 ... # kpartx -d /mnt/loop0
Note
You can mount a single partition of such disk image with loop device using offset to skip MBR etc., too. But this is more error prone.
If "disk.img" is in ext2 or ext3, you can also use zerofree(8) from the zerofree package as follows. # losetup -f -v disk.img Loop device is /dev/loop3 # zerofree /dev/loop3 # cp --sparse=always disk.img new.img
Tip
The actual disk usage of sparse file grows with data which are written to it. Using similar operation on devices created by the loop device or the device mapper devices as Section 10.2.3, Mounting the disk image file, you can partition this disk image "disk.img" using parted(8) or fdisk(8), and can create filesystem on it using mkfs.ext3(8), mkswap(8), etc.
Similarly, the bootable ISO9660 image file, "cdboot.iso", can be made from debian-installer like directory tree at "source_directory" by the following. # 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
Here Isolinux boot loader (see Section 3.3, Stage 2: the boot loader) is used for booting. You can calculate the md5sum value and make the ISO9660 image directly from the CD-ROM device as follows. $ 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 > cd.iso
Warning
You must carefully avoid ISO9660 filesystem read ahead bug of Linux as above to get the right result.
Tip
If your desktop system mounts CD automatically, unmount it by "sudo unmount /dev/hda" before using wodim(1).
Tip
Modern desktop system mounts removable media automatically (see Section 10.1.10, Removable storage device).
ncurses-hexedit V:0.07, I:0.5 192 * lde * beav * hex * V:0.04, I:0.3 992 V:0.03, I:0.3 164 V:0.01, I:0.09 84
Tip
HEX is used as an acronym for hexadecimal format with radix 16. OCTAL is for octal format with radix 8. ASCII is for American Standard Code for Information Interchange, i.e., normal English text code. EBCDIC is for Extended Binary Coded Decimal Interchange Code used on IBM mainframe operating systems.
hfsutils * V:0.19, I:1.6 236 utilities for HFS and HFS+ files without mounting them
Software RAID systems offered by the Linux kernel provide data redundancy in the kernel filesystem level to achieve high levels of storage reliability. There are tools to add data redundancy to files in application program level to achieve high levels of storage reliability, too. Table 10.9. List of tools to add data redundancy to files package par2 * dvbackup * vdmfec * popcon V:0.5, I:1.7 size description 272 Parity Archive Volume Set, for checking and repair of files backup tool using MiniDV camcorders (providing rsbep(1)) recover lost blocks using Forward Error Correction
V:0.02, I:0.18 84
scrounge-ntfs * V:0.03, I:0.4 V:0.13, I:0.7 V:0.07, I:0.4 V:0.11, I:0.8 V:0.03, I:0.2 V:0.03, I:0.2
V:0.01, I:0.12 68
Caution
Please make sure you do not have any files starting with "x" to avoid name crashes.
You should find following files. "5kb.file" is 5KB of zeros. "7mb.file" is 7MB of random data. "zero.file" may be a 0 byte file. If it existed, its mtime is updated while its content and its length are kept. "alwayszero.file" is always a 0 byte file. If it existed, its mtime is updated and its content is reset.
There are several ways to completely erase data from an entire hard disk like device, e.g., USB memory stick at "/dev/sda".
Caution
Check your USB memory stick location with mount(8) first before executing commands here. The device pointed by "/dev/sda" may be SCSI hard disk or serial-ATA hard disk where your entire system resides. Erase all the disk content by resetting data to 0 with the following. # dd if=/dev/zero of=/dev/sda Erase all by overwriting random data with the following. # dd if=/dev/urandom of=/dev/sda Erase all by overwriting random data very efficiently with the following. # shred -v -n 1 /dev/sda Since dd(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., "/dev/hda", "/dev/sda", etc.
Warning
This is usually a good enough for your USB memory stick. But this is not perfect. Most parts of erased filenames and their attributes may be hidden and remain in the filesystem.
Both "baz" and "foo" have link counts of "2" (>1) showing them to have hardlinks. Their inode 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 inode, e.g., "2738404" as the following. # find /path/to/mount/point -xdev -inum 2738404
cryptsetup(8), cryptsetup * ecryptfs(7), md5sum(1) sha1sum(1) openssl(1ssl) ecryptfsutils * coreutils * coreutils * openssl *
13828 compute and check MD5 message digest 13828 compute and checks SHA1 message digest 2380 compute message digest with "openssl dgst" (OpenSSL)
See Section 9.4, Data encryption tips on dm-crypto and ecryptfs which implement automatic data encryption infrastructure via Linux kernel modules.
Here is the meaning of the trust code. Table 10.13. List of the meaning of the trust code code description of trust e q n m f u no owner trust assigned / not yet calculated trust calculation failed not enough information for calculation never trust this key marginally trusted fully trusted ultimately trusted
The following uploads my key "1DD8D791" to the popular keyserver "hkp://keys.gnupg.net". $ gpg --keyserver hkp://keys.gnupg.net --send-keys 1DD8D791 A good default keyserver set up in "~/.gnupg/gpg.conf" (or old location "~/.gnupg/options") contains the following. keyserver hkp://keys.gnupg.net The following obtains unknown keys from the keyserver. $ gpg --list-sigs --with-colons | grep '^sig.*\[User ID not found\]' |\ cut -d ':' -f 5| sort | uniq | xargs gpg --recv-keys There was a bug in OpenPGP Public Key Server (pre version 0.9.6) which corrupted key with more than 2 sub-keys. The newer gnupg (>1.2.1-2) package can handle these corrupted subkeys. See gpg(1) under "-repair-pks-subkey-bug" option.
foo bar
Note
The computation for the MD5 sum is less CPU intensive than the one for the cryptographic
signature by GNU Privacy Guard (GnuPG). Usually, only the top level digest file is cryptographically signed to ensure data integrity.
patchutils combinediff(1) V:1.8, I:14 * dehtmldiff(1) filterdiff(1) fixcvsdiff(1) flipdiff(1) grepdiff(1) interdiff(1) lsdiff(1) recountdiff(1) rediff(1) splitdiff(1) unwrapdiff(1) wiggle(1) quilt(1) meld(1) xxdiff(1) dirdiff(1) docdiff(1) imediff2(1) makepatch(1) applypatch(1) wdiff(1) patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * patchutils V:1.8, I:14 * wiggle * quilt * meld * xxdiff * dirdiff * docdiff * imediff2 * makepatch * makepatch * wdiff * V:0.01, I:0.11 V:1.5, I:9 V:0.7, I:2 V:0.08, I:0.6 V:0.01, I:0.14 V:0.02, I:0.10 V:0.01, I:0.17 V:0.01, I:0.17 V:1.6, I:14
2576 compare and merge files (GTK) display differences and merge changes between directory trees compare two files word by word / char by char interactive full screen 2-way merge tool generate extended patch files apply extended patch files
V:0.2, I:1.3 1352 compare and merge files (plain X) 224 688 76 148 148
Note
If you are new to VCS systems, you should start learning with Git, which is growing fast in popularity. Table 10.16. List of version control system tools package cssc * rcs * cvs * popcon V:0.00, I:0.04 V:1.3, I:7 V:3, I:21 size 2240 772 3660 4288 tool CSSC RCS CVS VCS type comment local local remote clone of the Unix SCCS (deprecated) "Unix SCCS done right" previous standard remote VCS "CVS done right", the new de facto standard remote VCS fast DVCS in C (used by the Linux kernel and others)
subversion V:10, I:31 * git * mercurial * bzr * darcs * tla * monotone * tkcvs * gitk * V:5, I:17 V:1.8, I:6 V:1.1, I:3 V:0.19, I:1.4 V:0.17, I:1.4 V:0.04, I:0.3 V:0.08, I:0.4 V:0.8, I:4
distributed DVCS in Python and some C distributed DVCS influenced by tla written in Python (used by Ubuntu)
16220 Bazaar 9504 932 5272 2476 900 Darcs GNU arch Monotone CVS, Git
distributed DVCS with smart algebra of patches (slow) distributed DVCS mainly by Tom Lord (Historic) distributed DVCS in C++ remote GUI display of VCS (CVS, Subversion, RCS) repository tree
VCS is sometimes known as revision control system (RCS), or software configuration management (SCM). Distributed VCS such as Git is the tool of choice these days. CVS and Subversion may still be useful to join some existing open source program activities. Debian provides free VCS services via Debian Alioth service. It supports practically all VCSs. Its documentation can be found at http://wiki.debian.org/Alioth .
Caution
The git package was "GNU Interactive Tools" and the git-core package was DVCS in lenny. There are few basics for creating a shared access VCS archive. Use "umask 002" (see Section 1.2.4, Control of permissions for newly created files: umask) Make all VCS archive files belonging to a pertinent group Enable set group ID on all VCS archive directories (BSD-like file creation scheme, see Section 1.2.3, Filesystem permissions) Make user sharing the VCS archive belonging to the group
cvs init svn create git init cvs login cvs co cvs up cvs add svn co svn up svn add git clone git pull git add .
svn rm svn ci -
remove file(s) in working tree from the VCS commit changes to the remote repository commit changes to the local repository update the remote repository by the local repository display the working tree status from the VCS diff <reference_repository> <working_tree> repack the local repository into single pack GUI display of VCS repository tree
svn status git status git diff git repack -a -d; git prune gitk
Caution
Invoking a git subcommand directly as "git-xyz" from the command line has been deprecated since early 2006.
Tip
GUI tools such as tkcvs(1) and gitk(1) really help you with tracking revision history of files. The web interface provided by many public archives for browsing their repositories is also quite useful, too.
Tip
Git can work directly with different VCS repositories such as ones provided by CVS and Subversion, and provides the local repository for local changes with git-cvs and git-svn packages. See git for CVS users, and Section 10.9.4, Git for the Subversion repository.
Tip
Git has commands which have no equivalents in CVS and Subversion: "fetch", "rebase", "cherry-pick",
10.7. CVS
See the following. cvs(1) "/usr/share/doc/cvs/html-cvsclient" "/usr/share/doc/cvs/html-info" "/usr/share/doc/cvsbook" "info cvs"
Tip
You may restrict creation of new project by changing the owner of "$CVSROOT" directory to "root:staff" and its permission to "3775".
Note
Since pserver is prone to eavesdropping attack and insecure, write access is usually disable by server administrators.
Search for "<<<<<<<" and ">>>>>>>" in files for conflicting changes. Edit files to fix conflicts as needed. Add a release tag "Release-1" by the following. $ cvs ci -m "last commit for Release-1" $ cvs tag Release-1 Edit further. Remove the release tag "Release-1" by the following. $ cvs tag -d Release-1 Check in changes to CVS by the following. $ cvs ci -m "real last commit for Release-1" Re-add the release tag "Release-1" to updated CVS HEAD of main by the following. $ cvs tag Release-1 Create a branch with a sticky branch tag "Release-initial-bugfixes" from the original version pointed by the tag "Release-initial" and check it out to "~/path/to/old" directory by the following. $ $ $ $ cvs rtag -b -r Release-initial Release-initial-bugfixes module1 cd ~/path/to cvs co -r Release-initial-bugfixes -d old module1 cd old
Tip
Use "-D 2005-12-20" (ISO 8601 date format) instead of "-r Release-initial" to specify particular date as the branch point. Work on this local source tree having the sticky tag "Release-initial-bugfixes" which is based on the original version. Work on this branch by yourself until someone else joins to this "Release-initial-bugfixes" branch. Sync with files modified by others on this branch while creating new directories as needed by the following. $ cvs up -d Edit files to fix conflicts as needed. Check in changes to CVS by the following. $ cvs ci -m "checked into this branch" Update the local tree by HEAD of main while removing sticky tag ("-A") and without keyword expansion ("kk") by the following. $ cvs up -d -kk -A Update the local tree (content = HEAD of main) by merging from the "Release-initial-bugfixes" branch and without keyword expansion by the following. $ cvs up -d -kk -j Release-initial-bugfixes Fix conflicts with editor. Check in changes to CVS by the following. $ cvs ci -m "merged Release-initial-bugfixes" Make archive by the following. $ $ $ $ cd .. mv old old-module1-bugfixes tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes rm -rf old-module1-bugfixes
Tip
"cvs up" command can take "-d" option to create new directories and "-P" option to prune empty directories.
Tip
You can checkout only a sub directory of "module1" by providing its name as "cvs co module1/subdir". Table 10.18. Notable options for CVS commands (use as first argument(s) to cvs(1)) option meaning -n -t dry run, no effect display messages showing steps of cvs activity
Now, you can check out "module1" (alias: "mx") from CVS to "new" directory by the following. $ cvs co -d new mx $ cd new
Note
In order to perform above procedure, you should have appropriate file permissions.
10.8. Subversion
Subversion is a recent-generation version control system replacing older CVS. It has most of CVS's features except tags and branches. You need to install subversion, libapache2-svn and subversion-tools packages to set up a Subversion server.
Tip
You must use "svn copy " command to mark branches and tags. This ensures Subversion to record modification history of files properly and saves storage spaces.
Tip
You can replace URLs such as "file:///" by any other URL formats such as "http://" and "svn+ssh://".
Tip
Client commands offered by the git-svn package may offer alternative work flow of Subversion using the git command. See Section 10.9.4, Git for the Subversion repository. Check all available modules from Subversion project pointed by URL "file:///srv/svn/project" by the following. $ svn list file:///srv/svn/project module1 module2 ... Checkout "module1/trunk" to a directory "module1" by the following.
$ cd ~/path/to $ svn co file:///srv/svn/project/module1/trunk module1 $ cd module1 Make changes to the content as needed. Check changes by making "diff -u [repository] [local]" equivalent by the following. $ svn diff You find that you broke some file "file_to_undo" severely but other files are fine. Overwrite "file_to_undo" file with the clean copy from Subversion by the following. $ svn revert file_to_undo Save the updated local source tree to Subversion by the following. $ svn ci -m "Describe change" Create and add "file_to_add" file to Subversion by the following. $ vi file_to_add $ svn add file_to_add $ svn ci -m "Added file_to_add" Merge the latest version from Subversion by the following. $ svn up Watch out for lines starting with "C filename" which indicates conflicting changes. Look for unmodified code in, e.g., "filename.r6", "filename.r9", and "filename.mine". Search for "<<<<<<<" and ">>>>>>>" in files for conflicting changes. Edit files to fix conflicts as needed. Add a release tag "Release-1" by the following. $ svn ci -m "last commit for Release-1" $ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1 Edit further. Remove the release tag "Release-1" by the following. $ svn rm file:///srv/svn/project/module1/tags/Release-1 Check in changes to Subversion by the following. $ svn ci -m "real last commit for Release-1" Re-add the release tag "Release-1" from updated Subversion HEAD of trunk by the following. $ svn cp file:///srv/svn/project/module1/trunk file:///srv/svn/project/module1/tags/Release-1 Create a branch with a path "module1/branches/Release-initial-bugfixes" from the original version pointed by the path "module1/tags/Release-initial" and check it out to "~/path/to/old" directory by the following. $ $ $ $ svn cp file:///srv/svn/project/module1/tags/Release-initial file:///srv/svn/project/module1/branches/Release-initial-bugfixes cd ~/path/to svn co file:///srv/svn/project/module1/branches/Release-initial-bugfixes old cd old
Tip
Use "module1/trunk@{2005-12-20}" (ISO 8601 date format) instead of "module1/tags/Release-initial" to specify particular date as the branch point. Work on this local source tree pointing to branch "Release-initial-bugfixes" which is based on the original version. Work on this branch by yourself until someone else joins to this "Release-initial-bugfixes" branch. Sync with files modified by others on this branch by the following. $ svn up Edit files to fix conflicts as needed. Check in changes to Subversion by the following. $ svn ci -m "checked into this branch" Update the local tree with HEAD of trunk by the following. $ svn switch file:///srv/svn/project/module1/trunk Update the local tree (content = HEAD of trunk) by merging from the "Release-initial-bugfixes" branch by the following.
$ svn merge file:///srv/svn/project/module1/branches/Release-initial-bugfixes Fix conflicts with editor. Check in changes to Subversion by the following. $ svn ci -m "merged Release-initial-bugfixes" Make archive by the following. $ $ $ $ cd .. mv old old-module1-bugfixes tar -cvzf old-module1-bugfixes.tar.gz old-module1-bugfixes rm -rf old-module1-bugfixes
Tip
You can replace URLs such as "file:///" by any other URL formats such as "http://" and "svn+ssh://".
Tip
You can checkout only a sub directory of "module1" by providing its name as "svn co file:///srv/svn/project/module1/trunk/subdir module1/subdir", etc. Table 10.19. Notable options for Subversion commands (use as first argument(s) to svn(1)) option meaning
10.9. Git
Git can do everything for both local and remote source code management. This means that you can record the source code changes without needing network connectivity to the remote repository.
Warning
Do not use the tag string with spaces in it even if some tools such as gitk(1) allow you to use it. It may choke some other git commands.
popcon I:3 I:0.3 V:5, I:17 V:0.8, I:4 V:0.3, I:2 V:0.5, I:3 V:0.5, I:3 V:0.17, I:1.6 V:0.17, I:1.6 V:0.17, I:1.6 V:0.12, I:1.7 V:0.07, I:0.7
size 7436 920 10632 900 1612 552 552 676 676 676 404 1864 596 336
description official documentation for Git "Git Magic", easier to understand guide for Git Git, the fast, scalable, distributed revision control system GUI Git repository browser with history GUI for Git (No history) import the data out of Subversion into Git provide bidirectional operation between the Subversion and Git import the data out of CVS into Git export a commit to a CVS checkout from Git CVS server emulator for Git send a collection of patches as email from the Git quilt on top of git (Python) automate the Debian packaging with the Git quilt on top of git (SH/AWK/SED/)
gitgit-cvs * cvsexportcommit(1) git-cvsserver(1) git-send-email(1) stg(1) gitbuildpackage(1) guilt(7) git-cvs * git-email * stgit *
Tip
With git(1), you work on a local branch with many commits and use something like "git rebase -i master" to reorganize change history later. This enables you to make clean change history. See git-rebase(1) and git-cherry-pick(1).
Tip
When you want to go back to a clean working directory without loosing the current state of the working directory, you can use "git stash". See git-stash(1).
Tip
The use of "-rHEAD" enables us to avoid cloning entire historical contents from the Subversion repository.
Commit configuration with description. Make modification to the configuration files. $ cd /etc/apt/ $ sudo git commit -a Commit configuration with description and continue your life. $ cd /etc/apt/ $ sudo gitk --all You have full configuration history with you.
Note
sudo(8) is needed to work with any file permissions of configuration data. For user configuration data, you may skip sudo.
Note
The "chmod 700 .git" command in the above example is needed to protect archive data from unauthorized read access.
Tip
For more complete setup for recording configuration history, please look for the etckeeper package: Section 9.2.10, Recording changes in configuration files.
10012 charset 772 192 300 544 76 48 320 charset+eol charset charset charset charset eol eol
recode * V:1.5, I:7 konwert * nkf * tcs * V:0.4, I:4 V:0.2, I:2 V:0.02, I:0.14
standard encoding for Japanese email which uses only 7 bit codes old Japanese UNIX standard 8 bit code and completely different from Shift-JIS JIS X 0208 Appendix 1 standard for Japanese (see CP932)
Note
Some encodings are only supported for the data conversion and are not used as locale values (Section 8.3.1, Basics of encoding). For character sets which fit in single byte such as ASCII and ISO-8859 character sets, the character encoding means almost the same thing as the character set. For character sets with many characters such as JIS X 0213 for Japanese or Universal Character Set (UCS, Unicode, ISO-10646-1) for practically all languages, there are many encoding schemes to fit them into the sequence of the byte data. EUC and ISO/IEC 2022 (also known as JIS X 0202) for Japanese UTF-8, UTF-16/UCS-2 and UTF-32/UCS-4 for Unicode For these, there are clear differentiations between the character set and the character encoding. The code page is used as the synonym to the character encoding tables for some vendor specific ones.
Note
Please note most encoding systems share the same code with ASCII for the 7 bit characters. But there are some exceptions. If you are converting old Japanese C programs and URLs data from the casually-called shift-JIS encoding format to UTF-8 format, use "CP932" as the encoding name instead of "shift-JIS" to get the expected results: 0x5C "\" and 0x7E "~" . Otherwise, these are converted to wrong characters.
Tip
recode(1) may be used too and offers more than the combined functionality of iconv(1), fromdos(1), todos(1), frommac(1), and tomac(1). For more, see "info recode".
Tip
Use "--verbose" option in the above example to find the first non-UTF-8 character.
The EOL format conversion programs, fromdos(1), todos(1), frommac(1), and tomac(1), are quite handy. recode(1) is also useful.
Note
Some data on the Debian system, such as the wiki page data for the python-moinmoin package, use MSDOS style CR-LF as the EOL code. So the above rule is just a general rule.
Note
Most editors (eg. vim, emacs, gedit, ) can handle files in MSDOS style EOL transparently.
Tip
The use of "sed -e '/\r$/!s/$/\r/'" instead of todos(1) is better when you want to unify the EOL style to the MSDOS style from the mixed MSDOS and Unix style. (e.g., after merging 2 MSDOS style files with diff3(1).) This is because todos adds CR to all lines.
indent(1) from the indent package completely reformats whitespaces in the C program. Editor programs such as vim and emacs can be used for TAB conversion, too. For example with vim, you can expand TAB with ":set expandtab" and ":%retab" command sequence. You can revert this with ":set noexpandtab" and ":%retab!" command sequence.
html2text V:15, I:37 * lynx * elinks * links * I:22 V:2, I:5 V:3, I:9
HTML to text converter with the "links2 -dump" command convert MSWord files to plain text or ps
2580 MSWordtext,TeX convert MSWord files to plain text or TeX ps/pdftext htmltext odttext WordPerfectsxw extract text from PostScript and PDF files remove the markup tags from an HTML file converter from OpenDocument Text to text WordPerfect to OpenOffice.org/StarOffice writer document converter
V:3, I:38 25864 highlight V:0.05, I:0.4 V:0.03, I:0.2 1252 1968 chtml highlight
sourceV:0.14, highlight I:1.1 * highlight V:0.2, * I:1.3 grc * txt2html * markdown * asciidoc * V:0.05, I:0.12 V:0.08, I:0.5 V:0.07, I:0.4 V:0.15, I:1.1
2164
highlight
756 164 296 96 3028 5740 1028 556 484 576 340 564 1940
highlight
textcolor generic colouriser for everything (Python) texthtml text to HTML converter (Perl) texthtml markdown text document formatter to (X)HTML (Perl) textany textany textany textany textany AsciiDoc text document formatter to XML/HTML (Python) ReStructured Text document formatter to XML (Python) document conversion from text to HTML, SGML, LaTeX, man page, MoinMoin, Magic Point and PageMaker (Python) universal document - text processing utility (C language) document converter from structured plain text to other formats (m4)
pythonV:0.4, docutils * I:3 txt2tags * udo * stx2any * rest2web * aft * yodl * sdf * sisu * V:0.06, I:0.3 V:0.01, I:0.07 V:0.00, I:0.04 V:0.01, I:0.08 V:0.01, I:0.06 V:0.01, I:0.06 V:0.01, I:0.08 V:0.01, I:0.07
texthtml document converter from ReStructured Text to html (Python) textany textany textany "free form" document preparation system (Perl) pre-document language and tools to process it (C language) simple document parser (Perl) document structuring, publishing and search framework (Ruby)
14384 textany
One easy XML system is the docbook-xsl package, which is used here. Each XML file starts with standard XML declaration as the following. <?xml version="1.0" encoding="UTF-8"?> The basic syntax for one XML element is marked up as the following. <name attribute="value">content</name> XML element with empty content is marked up in the following short form. <name attribute="value"/> The "attribute="value"" in the above examples are optional. The comment section in XML is marked up as the following. <!-- comment --> Other than adding markups, XML requires minor conversion to the content using predefined entities for following characters. Table 11.7. List of predefined entities for XML predefined entity character to be converted from " ' < > & " : quote ' : apostrophe < : less-than > : greater-than & : ampersand
Caution
"<" or "&" can not be used in attributes or elements.
Note
When SGML style user defined entities, e.g. "&some-tag:", are used, the first definition wins over others. The entity definition is expressed in "<!ENTITY some-tag "entity value">".
Note
As long as the XML markup are done consistently with certain set of the tag name (either some data as content or attribute value), conversion to another XML is trivial task using Extensible Stylesheet Language Transformations (XSLT).
V:4, I:46 152 V:0.5, I:7 V:0.3, I:2 V:0.2, I:2 V:0.3, I:2
Since XML is subset of Standard Generalized Markup Language (SGML), it can be processed by the extensive tools available for SGML, such as Document Style Semantics and Specification Language (DSSSL). Table 11.9. List of DSSL tools package popcon size keyword description
package openjade *
popcon size keyword V:0.4, I:3 1212 dsssl 2336 dsssl 1056 dsssl 3100 xml/dsssl
description ISO/IEC 10179:1996 standard DSSSL processor (latest) ISO/IEC 10179:1996 standard DSSSL processor (1.3.x series) James Clark's original DSSSL processor (1.2.x series) DSSSL stylesheets for processing DocBook XML to various output formats with DSSSL utilities for DocBook files including conversion to other formats (HTML, RTF, PS, man, PDF) with docbook2* commands with DSSSL
openjade1.3 V:0.02, * I:0.14 jade * docbookdsssl * docbookutils * sgml2x * V:0.3, I:2 V:0.5, I:4 V:0.2, I:2 V:0.00, I:0.06
440
xml/dsssl
216
Tip
GNOME's yelp is sometimes handy to read DocBook XML files directly since it renders decently on X.
texi2html V:0.3, I:2 * man2html * tex4ht * xlhtml * unrtf * info2www * ooo2dbk * wp2x *
V:0.5, I:1.1 184 V:0.4, I:0.9 224 V:0.6, I:1.2 156 V:0.03, I:0.16 V:0.01, I:0.07 941 240 424
For non-XML HTML files, you can convert them to XHTML which is an instance of well formed XML. XHTML can be processed by XML tools. Table 11.11. List of XML pretty print tools package libxml2utils * tidy * popcon size keyword V:3, I:49 160 xmlhtmlxhtml V:1.0, I:9 description command line XML tool with xmllint(1) (syntax check, reformat, lint, )
Once proper XML is generated, you can use XSLT technology to extract data based on the mark-up context etc.
11.3.1. Ghostscript
The core of printable data manipulation is the Ghostscript PostScript (PS) interpreter which generates raster image. The latest upstream Ghostscript from Artifex was re-licensed from AFPL to GPL and merged all the latest ESP version changes such as CUPS related ones at 8.60 release as unified release. Table 11.12. List of Ghostscript PostScript interpreters
package ghostscript * ghostscript-x * gs-cjk-resource * cmap-adobe-cns1 * cmap-adobe-gb1 * cmap-adobe-japan1 * cmap-adobe-japan2 * cmap-adobe-korea1 * libpoppler5 * poppler-data *
description The GPL Ghostscript PostScript/PDF interpreter GPL Ghostscript PostScript/PDF interpreter - X display support resource files for gs-cjk, Ghostscript CJK-TrueType extension CMaps for Adobe-CNS1 (for traditional Chinese support) CMaps for Adobe-GB1 (for simplified Chinese support) CMaps for Adobe-Japan1 (for Japanese standard support) CMaps for Adobe-Japan2 (for Japanese extra support) CMaps for Adobe-Korea1 (for Korean support) PDF rendering library based on xpdf PDF viewer PDF rendering library (GLib-based shared library)
V:0.04, I:0.4 4528 V:0.03, I:0.3 1572 V:0.03, I:0.3 1552 V:0.08, I:0.7 2428 I:0.4 V:0.01, I:0.19 V:4, I:21 I:3 416 872 2368 504
12232 CMaps for PDF rendering library (for CJK support: Adobe-*)
Tip
"gs -h" can display the configuration of Ghostscript.
Note
The PDF, which is widely used cross-platform printable data format, is essentially the compressed PS format with few additional features and extensions.
Tip
For command line, psmerge(1) and other commands from the psutils package are useful for manipulating PostScript documents. Commands in the pdfjam package work similarly for manipulating PDF documents. pdftk(1) from the pdftk package is useful for manipulating PDF documents, too.
poppler-utils V:8, I:49 536 * psutils * poster * xpdf-utils * enscript * a2ps * pdftk * mpage * html2ps * pdfjam * V:3, I:21 380 V:1.2, I:9 V:0.9, I:4 V:1.6, I:14 V:1.7, I:8 V:1.0, I:5 V:0.18, I:1.5 V:0.2, I:1.7 V:0.2, I:1.8 80 76 2464
pdfps,text, PDF utilities: pdftops, pdfinfo, pdfimages, pdftotext, pdffonts psps psps PostScript document conversion tools create large posters out of PostScript pages
pdfps,text, PDF utilities: pdftops, pdfinfo, pdfimages, pdftotext, pdffonts textps, html, rtf convert ASCII text to PostScript, HTML, RTF or Pretty-Print 'Anything to PostScript' converter and pretty-printer PDF document conversion tool: pdftk print multiple pages per sheet converter from HTML to PostScript PDF document conversion tools: pdf90, pdfjoin, and pdfnup converter from html to latex convert documents from LaTeX to RTF which can be read by MS Word converter from PostScript to EPS (Encapsulated PostScript) Text to PostScript converter with Japanese encoding support
4292 textps 200 224 260 228 60 508 116 188 pdfpdf text,psps htmlps pdfpdf htmllatex latexrtf pseps textps
gnuhtml2latex V:0.07, * I:0.6 latex2rtf * ps2eps * e2ps * V:0.14, I:1.0 V:1.3, I:12 V:0.01, I:0.10 V:0.03,
180 188 60 88
PostScript utilities pretty print many source codes (C, C++, Java, Pascal, Perl, Pike, Sh, and Verilog) to PostScript. (C language) converter from PDF to Scalable vector graphics format converter from PDF to IPE's XML format
Tip
"groff -Tascii -me -" produces plain text output with ANSI escape code. If you wish to get manpage like output with many "^H" and "_", use "GROFF_NO_SGR=1 groff -Tascii -me -" instead.
Tip
To remove "^H" and "_" from a text file generated by groff, filter it by "col -b -x".
11.4.2. TeX/LaTeX
The TeX Live software distribution offers a complete TeX system. The texlive metapackage provides a decent selection of the TeX Live packages which should suffice for the most common tasks. There are many references available for TeX and LaTeX. The teTeX HOWTO: The Linux-teTeX Local Guide tex(1) latex(1) "The TeXbook", by Donald E. Knuth, (Addison-Wesley) "LaTeX - A Document Preparation System", by Leslie Lamport, (Addison-Wesley) "The LaTeX Companion", by Goossens, Mittelbach, Samarin, (Addison-Wesley) This is the most powerful typesetting environment. Many SGML processors use this as their back end text processor. Lyx provided by the lyx package and GNU TeXmacs provided by the texmacs package offer nice WYSIWYG editing environment for LaTeX while many use Emacs and Vim as the choice for the source editor. There are many online resources available. The TEX Live Guide - TEX Live 2007 ("/usr/share/doc/texlive-doc-base/english/texliveen/live.html") (texlive-doc-base package) A Simple Guide to Latex/Lyx Word Processing Using LaTeX Local User Guide to teTeX/LaTeX When documents become bigger, sometimes TeX may cause errors. You must increase pool size in
When documents become bigger, sometimes TeX may cause errors. You must increase pool size in "/etc/texmf/texmf.cnf" (or more appropriately edit "/etc/texmf/texmf.d/95NonPath" and run update-texmf(8)) to fix this.
Note
The TeX source of "The TeXbook" is available at http://tug.ctan.org/texarchive/systems/knuth/dist/tex/texbook.tex. This file contains most of the required macros. I heard that you can process this document with tex(1) after commenting lines 7 to 10 and adding "\input manmac \proofmodefalse". It's strongly recommended to buy this book (and all other books from Donald E. Knuth) instead of using the online version but the source is a great example of TeX input!
V:0.02, I:0.2 88
sharutils V:2, I:32 904 mail * mpack * tnef * uudeview * readpst * V:1.5, I:23 V:0.8, I:1.5 V:0.17, I:1.6 V:0.04, I:0.3 84 MIME
Tip
The Internet Message Access Protocol version 4 (IMAP4) server (see Section 6.7, POP3/IMAP4 server) may be used to move mails out from proprietary mail systems if the mail client software can be configured to use IMAP4 server too.
Note
If your non-Unix mail data is accessible by a non-Debian client software which can talk to the IMAP4 server, you may be able to move them out by running your own IMAP4 server (see Section 6.7, POP3/IMAP4 server).
Note
If you use other mail storage formats, moving them to mbox format is the good first step. The versatile client program such as mutt(1) may be handy for this. You can split mailbox contents to each message using procmail(1) and formail(1). Each mail message can be unpacked using munpack(1) from the mpack package (or other specialized tools) to obtain the MIME encoded contents.
V:5, I:36 748 V:4, I:29 4612 V:0.3, I:1.3 V:0.5, I:3 V:18, I:40 V:15, I:32 V:1.4, I:2 V:3, I:5 V:2, I:4 V:1.9, I:16 V:1.4, I:13 V:0.03, I:0.2 V:0.2, I:1.7 V:0.7, I:3 V:0.2, I:2 V:0.8, I:5 V:0.4, I:4 V:0.3, I:1.7 V:0.3, I:2 V:0.7, I:13 V:0.5, I:3 V:0.2, I:1.7 V:0.14, I:0.9 V:0.4, I:3 200
26888 ps/pdf/SVG/ 10720 image(vector) 87436 image(vector) 576 572 1676 708 68 200 736 3196 1752 492 364 1100 1008 312 132 184 248 56 image(vector) image(vector) image(vector) ps/pdfimage(vector) Windows/image(vector) figsxd(vector) imageimage imagetext imagetext imagetext imagetext image(Exif) image(Exif) image(Exif) image(Exif) image(Exif) image(Exif) image(Exif)
exifprobe * dcraw * findimagedupes * ale * imageindex * f-spot * bins * gallery2 * outguess * qcad * blender * mm3d * open-fontdesign-toolkit * fontforge * xgridfit * gbdfed *
V:0.08, I:0.5 V:0.9, I:5 V:0.06, I:0.4 V:0.02, I:0.17 V:0.03, I:0.2 V:0.5, I:1.8 V:0.02, I:0.15 V:0.2, I:0.4 V:0.02, I:0.14 V:1.5, I:2 V:0.5, I:3 V:0.04, I:0.3 I:0.03 V:0.2, I:1.7 V:0.01, I:0.07 V:0.01, I:0.11
read metadata from digital pictures decode raw digital camera images find visually similar or duplicate images merge images to increase fidelity or create mosaics generate static HTML galleries from images personal photo management application (GNOME) generate static HTML photo albums using XML and EXIF tags generate browsable HTML photo albums with thumbnails universal Steganographic tool CAD data editor (KDE) 3D content editor for animation etc OpenGL based 3D model editor metapackage for open font design font editor for PS, TrueType and OpenType fonts program for gridfitting and hinting TrueType fonts editor for BDF fonts
28336 blend, TIFF, VRML, 4536 36 6612 1060 496 ms3d, obj, dxf, ttf, ps, ttf, ps, ttf bdf
Tip
Search more image tools using regex "~Gworks-with::image" in aptitude(8) (see Section 2.2.6, Search method options with aptitude). Although GUI programs such as gimp(1) are very powerful, command line tools such as imagemagick(1) are quite useful for automating image manipulation with the script. The de facto image file format of the digital camera is the Exchangeable Image File Format (EXIF) which is the JPEG image file format with additional metadata tags. It can hold information such as date, time, and camera settings. The Lempel-Ziv-Welch (LZW) lossless data compression patent has been expired. Graphics Interchange Format (GIF) utilities which use the LZW compression method are now freely available on the Debian system.
Tip
Any digital camera or scanner with removable recording media works with Linux through USB storage readers since it follows the Design rule for Camera Filesystem and uses FAT filesystem. See Section 10.1.10, Removable storage device.
244 rpm/tgzdeb converter for the foreign package into the Debian package 568 EBEPWING converter from "Electric Book" (popular in Japan) to a single JIS X 4081 format (a subset of the EPWING V1)
You can also extract data from RPM format with the following. $ rpm2cpio file.src.rpm | cpio --extract
programing. Table 12.1. List of packages to help programing package autoconf * automake * bash * bison * cpp * ddd * popcon V:4, I:25 V:3, I:21 V:91, I:99 V:2, I:15 V:38, I:82 V:0.3, I:2 size 2256 1812 3536 1504 32 3852 284 1352 2172 28 4812 7272 8 8 40 1652 508 10012 1220 1728 244 18528 736 3332 2712 120 1792 48 48 documentation "info autoconf" provided by autoconf-doc "info automake" provided by automake1.10-doc "info bash" provided by bash-doc "info bison" provided by bison-doc "info cpp" provided by cpp-doc "info ddd" provided by ddd-doc exuberant-ctags(1) "info flex" provided by flex-doc "info gawk" provided by gawk-doc "info gcc" provided by gcc-doc "info gdb" provided by gdb-doc "info gettext" provided by gettext-doc "info gfortran" provided by gfortran-doc (Fortran 95) "info gpc" provided by gpc-doc (Pascal) fpc(1) and html by fp-docs (Pascal) help provided via menu (UI Builder) help provided via menu (UI Builder) "info libc" provided by glibc-doc and glibc-docreference "info make" provided by make-doc imake(1), xmkmf(1), etc. mawk(1) perl(1) and html pages provided by perl-doc and perl-dochtml python(1) and html pages provided by python-doc tcl(3) and detail manual pages provided by tcl8.4-doc tk(3) and detail manual pages provided by tk8.4-doc ruby(1) and interactive reference provided by ri help(F1) menu provided by vim-doc fetch "The Single Unix Specifications v2" fetch "The Single Unix Specifications v3"
exuberant-ctags V:1.2, I:5 * flex * gawk * gcc * gdb * gettext * gfortran * gpc * fpc * glade * glade-gnome * libc6 * make * xutils-dev * mawk * perl * python * tcl8.4 * tk8.4 * ruby * vim * susv2 * susv3 * V:2, I:15 V:28, I:32 V:17, I:67 V:4, I:22 V:8, I:46 V:0.9, I:6 V:0.07, I:0.5 I:0.4 V:0.3, I:2 V:0.09, I:1.2 V:97, I:99 V:21, I:72 V:1.7, I:15 V:66, I:99 V:88, I:99 V:62, I:97 V:8, I:46 V:5, I:34 V:9, I:24 V:15, I:33 I:0.03 I:0.07
Online references are available by typing "man name" after installing manpages and manpages-dev packages. Online references for the GNU tools are available by typing "info program_name" after installing the pertinent documentation packages. You may need to include the contrib and non-free archives in addition to the main archive since some GFDL documentations are not considered to be DSFG compliant.
Warning
Do not use "test" as the name of an executable test file. "test" is a shell builtin.
Caution
You should install software programs directly compiled from source into "/usr/local" or "/opt" to avoid collision with system programs.
Tip
Code examples of creating "Song 99 Bottles of Beer" should give you good idea of practically all the programming languages.
text processing), shell scripts frequently use parameters, conditionals, and loops.
if [ "$foo" = "$bar" ] ; then if [ "$foo" == "$bar" ] ; then diff -u file.c.orig file.c mkdir /foobar /foobaz funcname() { } octal format: "\377" diff -u file.c{.orig,} mkdir /foo{bar,baz} function funcname() { } hexadecimal format: "\xff"
The "echo" command must be used with following cares since its implementation differs among shell builtin and external commands. Avoid using command option "-e" and "-E". Avoid using any command options except "-n". Avoid using escape sequences in the string since their handling varies.
Note
Although "-n" option is not really POSIX syntax, it is generally accepted.
Tip
Use the "printf" command instead of the "echo" command if you need to embed escape sequences in the output string.
Basic parameter expansions to remember are followings. Table 12.4. List of shell parameter expansions parameter expression form value if var is set value if var is not set ${var:-string} ${var:+string} ${var:=string} ${var:?string} "$var" "string" "$var" "$var" "string" "null" "string" (and run "var=string") echo "string" to stderr (and exit with error)
Here, the colon ":" in all of these operators is actually optional. with ":" = operator test for exist and not null without ":" = operator test for exist only Table 12.5. List of key shell parameter substitutions parameter substitution form result ${var%suffix} ${var%%suffix} remove smallest suffix pattern remove largest suffix pattern
${var#prefix} ${var##prefix}
Note
"0" in the shell conditional context means "True", while "0" in the C conditional context means "False".
Note
"[" is the equivalent of the test command, which evaluates its arguments up to "]" as a conditional expression. Basic conditional idioms to remember are followings. "<command> && <if_success_run_this_command_too> || true" "<command> || <if_not_success_run_this_command_too> || true" A multi-line script snippet as the following if [ <conditional_expression> ]; then <if_success_run_this_command> else <if_not_success_run_this_command> fi Here trailing "|| true" was needed to ensure this shell script does not exit at this line accidentally when shell is invoked with "-e" flag. Table 12.6. List of file comparison operators in the conditional expression equation -e <file> -d <file> -f <file> -w <file> -x <file> condition to return logical true <file> exists <file> exists and is a directory <file> exists and is a regular file <file> exists and is writable <file> exists and is executable
<file1> -nt <file2> <file1> is newer than <file2> (modification) <file1> -ot <file2> <file1> is older than <file2> (modification) <file1> -ef <file2> <file1> and <file2> are on the same device and the same inode number
Table 12.7. List of string comparison operators in the conditional expression equation -z <str> -n <str> <str1> = <str2> <str1> < <str2> <str1> > <str2> condition to return logical true the length of <str> is zero the length of <str> is non-zero <str1> and <str2> are equal <str1> sorts before <str2> (locale dependent) <str1> sorts after <str2> (locale dependent)
Arithmetic integer comparison operators in the conditional expression are "-eq", "-ne", "-lt", "-le", "gt", and "-ge".
Tip
The C-language like numeric iteration can be realized by using seq(1) as the "foo1 foo2 " generator.
Tip
13828 GNU core utilities 260 768 196 miscellaneous utilities specific to Debian collection of more utilities from FreeBSD basic utilities from 4.4BSD-Lite additional Unix utilities
Tip
Although moreutils may not exist ouside of Debian, it offers interesting small programs. Most notable one is sponge(8). See Section 1.6.4, Global substitution with regular expressions.
whiptail * V:42, I:99 dialog * zenity * ssft * gettext * V:4, I:25 V:8, I:41 V:0.01, I:0.11 V:8, I:46
104
1592 displays user-friendly dialog boxes from shell scripts (ncurses) 4992 display graphical dialog boxes from shell scripts (gtk2.0) 152 Shell Scripts Frontend Tool (wrapper for zenity, kdialog, and dialog with gettext)
12.2. Make
Make is a utility to maintain groups of programs. Upon execution of make(1), make read the rule file, "Makefile", and updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist. The execution of these updates may occur concurrently. The rule file syntax is the following. target: [TAB] [TAB] [TAB] [ prerequisites ... ] command1 -command2 # ignore errors @command3 # suppress echoing
Here " [TAB] " is a TAB code. Each line is interpreted by the shell after make variable substitution. Use "\" at the end of a line to continue the script. Use "$$" to enter "$" for environment values for a shell script. Implicit rules for the target and prerequisites can be written, for example, by the following. %.o: %.c header.h Here, the target contains the character "%" (exactly one of them). The "%" can match any nonempty substring in the actual target filenames. The prerequisites likewise use "%" to show how their names relate to the actual target name.
Table 12.10. List of make automatic variables automatic variable value $@ $< $? $^ $* target first prerequisite all newer prerequisites all prerequisites "%" matched stem in the target pattern
Table 12.11. List of make variable expansions variable expansion description foo1 := bar foo2 = bar foo3 += bar one-time expansion recursive expansion append
12.3. C
You can set up proper environment to compile programs written in the C programming language by the following. # apt-get install glibc-doc manpages-dev libc6-dev gcc build-essential The libc6-dev package, i.e., GNU C Library, provides C standard library which is collection of header files and library routines used by the C programming language. See references for C as the following. "info libc" (C library function reference) gcc(1) and "info gcc" each_C_library_function_name(3) Kernighan & Ritchie, "The C Programming Language", 2nd edition (Prentice Hall)
12.4. Debug
Debug is important part of programing activities. Knowing how to debug programs makes you a good Debian user who can produce meaningful bug reports.
Let's install gdb and related programs by the following. # apt-get install gdb gdb-doc build-essential devscripts Good tutorial of gdb is provided by "info gdb" or found elsewhere on the web. Here is a simple example of using gdb(1) on a "program" compiled with the "-g" option to produce debugging information. $ gdb (gdb) (gdb) (gdb) ... (gdb) ... (gdb) ... (gdb) ... (gdb) program b 1 run args next step p parm p parm=12 quit # set break point at line 1 # run program with args # next line # step forward # print parm # set value to 12
Tip
Many gdb(1) commands can be abbreviated. Tab expansion works as in the shell.
Fix bugs if needed. Bump package version to one which does not collide with official Debian versions, e.g. one appended with "+debug1" when recompiling existing package version, or one appended with "~pre1" when compiling unreleased package version by the following. $ dch -i Compile and install packages with debug symbols by the following. $ $ $ $ export DEB_BUILD_OPTIONS=nostrip,noopt debuild cd .. sudo debi package_name*.changes
You need to check build scripts of the package and ensure to use "CFLAGS=-g -Wall" for compiling binaries.
Tip
Often, you see a backtrace where one or more of the top lines are in "malloc()" or "g_malloc()". When this happens, chances are your backtrace isn't very useful. The easiest way to find some useful information is to set the environment variable "$MALLOC_CHECK_" to a value of 2 (malloc(3)). You can do this while running gdb by doing the following. $ MALLOC_CHECK_=2 gdb hello
(gdb) thread apply all bt (gdb) bt full (gdb) thread apply all bt full (gdb) thread apply all bt full 10 (gdb) set logging on
get a backtrace for all threads for multi-threaded program get parameters came on the stack of function calls get a backtrace and parameters as the combination of the preceding options get a backtrace and parameters for top 10 calls to cut off irrelevant output write log of gdb output to a file (the default is "gdb.txt")
V:0.06, I:0.5 1836 V:0.06, I:0.2 876 V:0.01, I:0.15 V:88, I:99 V:0.2, I:0.7 V:0.01, I:0.09 192
18528 interpreter with internal static code checker: B::Lint(3perl) 576 156
weblint-perl * V:0.10, I:0.7 28 linklint * V:0.05, I:0.3 432 160 libxml2-utils V:3, I:49 *
Note
gdb(1) may be used to disassemble code interactively.
Tutorial for bison(1) can be found in "info bison". You need to provide your own "main()" and "yyerror()". "main()" calls "yyparse()" which calls "yylex()", usually created with Flex. %% %%
12.7. Autoconf
Autoconf is a tool for producing shell scripts that automatically configure software source code packages to adapt to many kinds of Unix-like systems using the entire GNU build system. autoconf(1) produces the configuration script "configure". "configure" automatically creates a customized "Makefile" using the "Makefile.in" template.
best converted to one-liner Perl scripts manually. Let's think following AWK script snippet. awk '($2=="1957") { print $3 }' | This is equivalent to any one of the following lines. perl -ne '@f=split; if ($f[1] eq "1957") { print "$f[2]\n"}' | perl -ne 'if ((@f=split)[1] eq "1957") { print "$f[2]\n"}' | perl -ne '@f=split; print $f[2] if ( $f[1]==1957 )' | perl -lane 'print $F[2] if $F[1] eq "1957"' | perl -lane 'print$F[2]if$F[1]eq+1957' | The last one is a riddle. It took advantage of following Perl features. The whitespace is optional. The automatic conversion exists from number to the string. See perlrun(1) for the command-line options. For more crazy Perl scripts, Perl Golf may be interesting.
12.9. Web
Basic interactive dynamic web pages can be made as follows. Queries are presented to the browser user using HTML forms. Filling and clicking on the form entries sends one of the following URL string with encoded parameters from the browser to the web server. "http://www.foo.dom/cgi-bin/program.pl?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3" "http://www.foo.dom/cgi-bin/program.py?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3" "http://www.foo.dom/program.php?VAR1=VAL1&VAR2=VAL2&VAR3=VAL3" "%nn" in URL is replaced with a character with hexadecimal nn value. The environment variable is set as: "QUERY_STRING="VAR1=VAL1 VAR2=VAL2 VAR3=VAL3"". CGI program (any one of "program.*") on the web server executes itself with the environment variable "$QUERY_STRING". stdout of CGI program is sent to the web browser and is presented as an interactive dynamic web page. For security reasons it is better not to hand craft new hacks for parsing CGI parameters. There are established modules for them in Perl and Python. PHP comes with these functionalities. When client data storage is needed, HTTP cookies are used. When client side data processing is needed, Javascript is frequently used. For more, see the Common Gateway Interface, The Apache Software Foundation, and JavaScript. Searching "CGI tutorial" on Google by typing encoded URL http://www.google.com/search?hl=en&ie=UTF8&q=CGI+tutorial directly to the browser address is a good way to see the CGI script in action on the Google server.
18528 AWKPERL
FORTRANC convert source codes from FORTRAN 77 to C/C++: f2c(1) ANSI C intelgas create/remove ANSI prototypes from C code converter from NASM (Intel format) to the GNU Assembler (GAS)
Appendix A. Appendix
Appendix A. Appendix
Here are backgrounds of this document.