%dbcent; %commondata; %popcon; %datadate1; %pkgsize; %datadate2; %urlsdata; ]> Debian Reference Osamu Aoki OA 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). 2007-2009 Osamu Aoki This Debian Reference (v2) (&build-date;) 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. Preface This Debian Reference (version 2) (&build-date;) 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.
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.
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: 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.
About this document
Guiding rules Following guiding rules were followed while compiling this document: don't explain in details what is well documented elsewhere (in the judgment of the author) Provide overview and skip corner cases (Big Picture) Keep It Short and Simple. (KISS) Focus on non-GUI tools and consoles. (Use shell examples) Do not reinvent the wheel. (Use pointers to the existing references) Be objective. (Use popcon etc.) I tried to elucidate hierarchical aspects and lower levels of the system.
Prerequisites You are expected to make good efforts to seek answers by yourself beyond this documentation. This document only gives efficient starting points. You are required to seek help from (in approximate order of importance, starting with the most important sources): the Debian site at http://www.debian.org for the general information, the documentation under the "/usr/share/doc/<package_name>" directory, the Unix style manpage: "dpkg -L <package_name> |grep '/man/man.*/'", the GNU style info page: "dpkg -L <package_name> |grep '/info/'", the bug report: http://bugs.debian.org/<package_name>, the Debian Wiki at http://wiki.debian.org/ for the moving and specific topics, the HOWTOs from The Linux Documentation Project (TLDP) at http://tldp.org/ , the Single UNIX Specification from the Open Group's The UNIX System Home Page at http://www.unix.org/ , and the free encyclopedia from Wikipedia at http://wikipedia.org/. For detailed documentation, you may need to install the corresponding documentation package named with "-doc" as its suffix.
Conventions This document provides information through the following simplified presentation style with bash(1) shell command examples and bullets: # <command in root account> $ <command in user account> <description of action> 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. See the meaning of the "$PS1" and "$PS2" environment variables in bash(1). 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: $ 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: $ 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: $ 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: $ 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: $ 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: $ 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: $ 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: $ echo "$TERM"
The popcon The popcon data is presented as the objective measure for the popularity of each package. It was downloaded on &pop-date; and contains the total submission of &pop-submissions; reports over &pop-packages; binary packages and &pop-architectures; architectures. Please note that the &arch; unstable archive contains only &all-packages; 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)". 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.
The package size The package size data is also presented as the objective measure for each package. It is based on the "Installed-Size:" reported by "apt-cache show" or "aptitude show" command (currently on &arch; architecture for the unstable release). The reported size is in KiB (Kibibyte = unit for 1024 bytes). 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.
Bug reports Please file bug reports on the debian-reference package using reportbug(1) if you find any issues. Please include correction suggestion by "diff -u" to the plain text version or to the source.
Some quotes for new users Here are some interesting quotes from the Debian mailing list which may help enlighten new users: "This is Unix. It gives you enough rope to hang yourself." --- Miquel van Smoorenburg <miquels at cistron.nl> "Unix IS user friendly… It's just selective about who its friends are." --- Tollef Fog Heen <tollef at add.no>
GNU/Linux tutorials I think learning a computer system is like learning a new foreign language. Although tutorial books and documentation are helpful, you have to practice it yourself. In order to help you get started smoothly, I will elaborate a few basic points. The powerful design of Debian GNU/Linux comes from the Unix operating system, i.e., a multiuser, multitasking operating system. You must learn to take advantage of the power of these features and similarities between Unix and GNU/Linux. Don't shy away from Unix oriented texts and don't rely solely on GNU/Linux texts, as this will rob you of much useful information. "Rute User's Tutorial and Exposition", in the Debian non-free archive as the rutebook package (popcon: &pop-rutebook;), provides a good online resource to the generic system administration. 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.
Console basics
The shell prompt Upon starting the system, you are presented with the character based login screen if you did not install X Window System with the display manager such as gdm. Suppose your hostname is foo, the login prompt looks like: foo login: If you did install a GUI environment such as GNOME or KDE, then you can get to a login prompt by Ctrl-Alt-F1, and you can return to the GUI environment via Alt-F7 (see below for more). At the login prompt, you type your username, e.g. penguin, and press the Enter-key, then type your password and press the Enter-key again. 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 with the command prompt as: 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.
The shell prompt under X If you installed X Window System with a display manager such as GNOME's gdm by selecting "Desktop environment" task during the installation, you will be presented with the graphical login screen upon starting your system. You type your username and your password to login to the non-privileged user account. Use tab to navigate between username and password, or use the mouse and primary click. You can gain the shell prompt under X by starting a x-terminal-emulator program such as gnome-terminal(1), rxvt(1) or xterm(1). Under the GNOME Desktop environment, clicking "Applications" → "Accessories" → "Terminal" does the trick. You can also see the section below . Under some other Desktop systems (like fluxbox), there may be no obvious starting point for the menu. If this happens, just try (right) clicking the center of the screen and hope for a menu to pop-up.
The root account The root account is also called superuser or privileged user. From this account, you can perform the following system administration activities: read, write, and remove any files on the system irrespective of their file permissions set file ownership and permissions of any files on the system set the password of any non-privileged users on the system login to any accounts without their passwords This unlimited power of root account requires you to be considerate and responsible when using it. Never share the root password with others. 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 ).
The root shell prompt Here are a few basic methods to gain the root shell prompt by using the root password: At the character based login prompt, you simply type root. Under the GNOME Desktop environment, click "Applications" → "Accessories" → "Root Terminal". From any user shell prompt, type "su -l". (This does not preserve the environment of the current user) From any user shell prompt, type "su". (This preserves some of the environment of the current user)
GUI system administration tools When your desktop menu does not start GUI system administration tools automatically with the appropriate privilege, you can start them from the root shell prompt of the X terminal emulator, such as gnome-terminal(1), rxvt(1), or xterm(1). See and . 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). Never run untrusted remote GUI program under X window when critical information is displayed since it may eavesdrop your X screen.
Virtual consoles In the default Debian system, there are six switchable VT100-like character consoles available to start the command shell directly on the Linux host. Unless you are in a GUI environment, you can switch between the virtual consoles by pressing the Left-Alt-key and one of the F1F6 keys simultaneously. Each character console allows independent login to the account and offers the multiuser environment. This multiuser environment is a great Unix feature, and very addictive. If you are under the X Window System, you gain access to the character console 1 by pressing Ctrl-Alt-F1 key, i.e., the left-Ctrl-key, the left-Alt-key, and the F1-key are pressed together. You can get back to the X Window System, normally running on the virtual console 7, by pressing Alt-F7. You can alternatively change to another virtual console, e.g. to the console 1, by the command: # chvt 1
How to leave the command prompt You type Ctrl-D, i.e., the left-Ctrl-key and the d-key pressed together, at the command prompt to close the shell activity. If you are at the character console, you will return to the login prompt with this. Even though these control characters are referred as "control D" with the upper case, you do not need to press the Shift-key. The short hand expression, ^D, is also used for Ctrl-D. Alternately, you can type "exit". If you are at x-terminal-emulator(1), you can close x-terminal-emulator window with this.
How to shutdown the system Just like any other modern OS where the file operation involves caching data in memory for improved performance, the Debian system needs the proper shutdown procedure before power can safely be turned off. This is to maintain the integrity of files, by forcing all changes in memory to be written to disk. If the software power control is available, the shutdown procedure automatically turns off power of the system. (Otherwise, you may have to press power button for few seconds after the shutdown procedure.) Under the normal multiuser mode, use following from the root command prompt to shutdown the system: # shutdown -h now Under the single-user mode, use following from the root command prompt to shutdown the system: # poweroff -i -f Alternatively, you may type Ctrl-Alt-Delete (The left-Ctrl-key, the left-Alt-Key, and the Delete are pressed together) to shutdown if "/etc/inittab" contains "ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -h now" in it. See inittab(5) for details.
Recovering a sane console When the screen goes berserk after doing some funny things such as "cat <some-binary-file>", type "reset" at the command prompt. You may not be able to see the command echoed as you type. You may also issue "clear" to clean up the screen.
Additional package suggestions for the newbie Although even the minimal installation of the Debian system without any desktop environment tasks provides the basic Unix functionality, it is a good idea to install few additional commandline and curses based character terminal packages such as mc and vim with aptitude(8) for beginners to get started. From the shell prompt as root: # aptitude update ... # aptitude install mc vim sudo ... If you already had these packages installed, nothing will be installed. List of interesting text-mode program packages. package popcon size description mc &pop-mc; &size-mc; A text-mode full-screen file manager sudo &pop-sudo; &size-sudo; A program to allow limited root privileges to users vim &pop-vim; &size-vim; Unix text editor Vi IMproved, a programmers text editor (standard version) vim-tiny &pop-vimtiny; &size-vimtiny; Unix text editor Vi IMproved, a programmers text editor (compact version) emacs21 &pop-emacscb; &size-emacscb; GNU project Emacs, the Lisp based extensible text editor (version 21) emacs22 &pop-emacscc; &size-emacscc; GNU project Emacs, the Lisp based extensible text editor (version 22) w3m &pop-wdm; &size-wdm; Text-mode WWW browsers gpm &pop-gpm; &size-gpm; The Unix style cut-and-paste on the text console (daemon)
It may be a good idea to read some informative documentations. List of informative documentation packages. package popcon size description doc-debian &pop-docdebian; &size-docdebian; Debian Project documentation, (Debian FAQ) and other documents debian-policy &pop-debianpolicy; &size-debianpolicy; Debian Policy Manual and related documents developers-reference &pop-developersreference; &size-developersreference; Guidelines and information for Debian developers maint-guide &pop-maintguide; &size-maintguide; Debian New Maintainers' Guide debian-history &pop-debianhistory; &size-debianhistory; History of the Debian Project debian-faq &pop-debianfaq; &size-debianfaq; Debian FAQ doc-linux-text &pop-doclinuxtext; &size-doclinuxtext; Linux HOWTOs and FAQ (text) doc-linux-html &pop-doclinuxhtml; &size-doclinuxhtml; Linux HOWTOs and FAQ (html) sysadmin-guide &pop-sysadminguide; &size-sysadminguide; The Linux System Administrators' Guide rutebook &pop-rutebook; &size-rutebook; Linux: Rute User's Tutorial and Exposition (non-free)
You can install some of these packages by issuing the following command from the root shell prompt: # aptitude install package_name
An extra user account If you do not want to use your main user account for the following training activities, you can create a training user account, e.g. fish. Type at root shell prompt: # adduser fish answer all the questions This will create a new account named as fish. After your practice, you can remove this user account and its home directory by: # deluser --remove-home fish
sudo configuration For the typical single user workstation such as the desktop Debian system on the laptop PC, it is common to deploy simple configuration of sudo(8) as follows to let the non-privileged user, e.g. penguin, to gain administrative privilege just with his user password (not with the root password). # echo "penguin ALL=(ALL) ALL" >> /etc/sudoers This trick should only be used for the single user workstation which you administer and where you are the only user. Do not set up accounts of regular users on multiuser workstation like this because it would be very bad for system security. The password and the account of the penguin in the above example requires as much protection as the root password and the root account. 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. 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). 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.
Play time Now you are ready to play with the Debian system without risks as long as you use the non-privileged user account. This is because the Debian system is, even after the default installation, configured with proper file permissions which prevent non-privileged users from damaging the system. Of course, there may still be some holes which can be exploited but those who worry about these issues should not be reading this section but should be reading Securing Debian Manual. We will learn the Debian system as a Unix-like system with: (basic concept), (survival method), (basic method), (shell mechanism), and (text processing method).
Unix-like filesystem In GNU/Linux and other Unix-like operating systems, files are organized into directories. All files and directories are arranged in one big tree rooted at "/". It's called a tree because if you draw the file system, it looks like a tree (upside down). These files and directories can be spread out over several devices. mount(8) serves to attach the file system found on some device to the big file tree. Conversely, umount(8) will detach it again. On recent Linux kernels, mount(8) with some options can bind part of a file tree somewhere else or can mount filesystem as shared, private, slave, or unbindable. Supported mount options for each filesystem are available in "/share/doc/linux-doc-2.6.*/Documentation/filesystems/". Directories on Unix systems are called folders on some other systems. Please also note that there is no concept for drive such as "A:" on any Unix system. There is one file system, and everything is included. This is a huge advantage compared to Windows.
Unix file basics Here are Unix file basics: Filenames are case sensitive. That is, "MYFILE" and "MyFile" are different files. The root directory means root of the filesystem referred as simply "/". Don't confuse this with the home directory for the root user: "/root". Every directory has a name which can contain any letters or symbols except "/". The root directory is an exception; its name is "/" (pronounced "slash" or "the root directory") and it cannot be renamed. Each file or directory is designated by a fully-qualified filename, absolute filename, or path, giving the sequence of directories which must be passed through to reach it. The three terms are synonymous. All fully-qualified filenames begin with the "/" directory, and there's a "/" between each directory or file in the filename. The first "/" is the top level directory, and the other "/"'s separate successive subdirectories, until we reach the last entry which is the name of the actual file. The words used here can be confusing. Take the following fully-qualified filename as an example: "/usr/share/keytables/us.map.gz". However, people will also refer to its basename "us.map.gz" alone as a filename. The root directory has a number of branches, such as "/etc/" and "/usr/". These subdirectories in turn branch into still more subdirectories, such as "/etc/init.d/" and "/usr/local/". The whole thing viewed collectively is called the directory tree. You can think of an absolute filename as a route from the base of the tree ("/") to the end of some branch (a file). You will also hear people talk about the directory tree as if it were a family tree: thus subdirectories have parents, and a path shows the complete ancestry of a file. There are also relative paths that begin somewhere other than the root directory. You should remember that the directory "../" refers to the parent directory. This terminology also applies to other directory like structures, such as hierarchical data structures. There's no special directory path name component that corresponds to a physical device, such as your hard disk. This differs from RT-11, CP/M, OpenVMS, MS-DOS, AmigaOS, and Microsoft Windows, where the path contains a device name such as "C:\". (However, directory entries do exist that refer to physical devices as a part of the normal filesystem. See .) 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. The word "root" can mean either "root user" or "root directory". The context of their usage should make it clear. 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: List of usage of key directories. directory usage / A simple "/" represents the root directory. /etc/ This is the place for the system wide configuration files. /var/log/ This is the place for the system log files. /home/ This is the directory which contains all the home directories for all non-privileged users.
Filesystem internals Following the Unix tradition, the Debian GNU/Linux system provides the filesystem under which physical data on harddisks and other storage devices reside, and the interaction with the hardware devices such as console screens and remote serial consoles are represented in an unified manner under "/dev/". Each file, directory, named pipe (a way two programs can share data), or physical device on a Debian GNU/Linux system has a data structure called an inode which describes its associated attributes such as the user who owns it (owner), the group that it belongs to, the time last accessed, etc. If you are really interested, see "/usr/include/linux/fs.h" for the exact definition of "struct inode" in the Debian GNU/Linux system. The idea of representing just about everything in the file system was a Unix innovation, and modern Linux kernels have developed this idea ever further. Now, even information about processes running in the computer can be found in the file system. This abstract and unified representation of physical entities and internal processes is very powerful since this allows us to use the same command for the same kind of operation on many totally different devices. It is even possible to change the way the kernel works by writing data to special files that are linked to running processes. If you need to identify the correspondence between the file tree and the physical entity, execute mount(8) with no arguments.
Filesystem permissions Filesystem permissions of Unix-like system are defined for three categories of affected users: the user who owns the file (u), other users in the group which the file belongs to (g), and all other users (o) also referred to as "world" and "everyone". For the file, each corresponding permission allows: read (r): to examine contents of the file, write (w): to modify the file, and execute (x): to run the file as a command. For the directory, each corresponding permission allows: read (r): to list contents of the directory, write (w): to add or remove files in the directory, and execute (x): to access files in the directory. Here, the execute permission on a directory means not only to allow reading of files in that directory but also to allow viewing their attributes, such as the size and the modification time. ls(1) is used to display permission information (and more) for files and directories. When it is invoked with the "-l" option, it displays the following information in the order given: the type of file (first character) the access permission of the file (nine characters, consisting of three characters each for user, group, and other in this order) the number of hard links to the file the name of the user who owns the file the name of the group which the file belongs to the size of the file in characters (bytes) the date and time of the file (mtime) the name of the file. List of the first character of "<literal>ls -l</literal>" output character meaning - normal file d directory l symlink c character device node b block device node p named pipe s socket
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: # chown <newowner> foo # chgrp <newgroup> foo # chmod [ugoa][+-=][rwxXst][,...] foo For example, in order to make a directory tree to be owned by a user foo and shared by a group bar, issue following commands from the root account: # cd /some/location/ # chown -R foo:bar . # chmod -R ug+rwX,o=rX . There are three more special permission bits: set user ID (s or S instead of user's x), set group ID (s or S instead of group's x), and 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. The numeric mode for file permissions in <literal>chmod</literal>(1) commands. digit meaning 1st optional digit sum of set user ID (=4), set group ID (=2), and sticky bit (=1) 2nd digit sum of read (=4), write (=2), and execute (=1) permissions for user 3rd digit ditto for group 4th digit 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: $ 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 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.
Control of permissions for newly created files: umask What permissions are applied to a newly created file or directory is restricted by the umask shell builtin command. See dash(1), bash(1), and builtins(7). (file permissions) = (requested file permissions) & ~(umask value) The <emphasis role="strong">umask</emphasis> value examples. umask file permissions created directory permissions created usage 0022 -rw-r--r-- -rwxr-xr-x writable only by the user 0002 -rw-rw-r-- -rwxrwxr-x writable by the group
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.)
Permissions for groups of users (group) In order to make group permissions to be applied to a particular user, that user needs to be made a member of the group using "sudo vigr". 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 .) 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. List of notable system-provided groups for file access. group accessible files and devices dialout Full and direct access to serial ports ("/dev/ttyS[0-3]"). dip Limited access to serial ports for Dialup IP connection to trusted peers. cdrom CD-ROM, DVD+/-RW drives. audio An audio device. video A video device. scanner Scanner(s). adm System monitoring logs. staff Some directories for junior administrative work: "/usr/local", "/home".
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. List of notable system provided groups for particular command executions. group accessible commands sudo 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 base-passwd 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.
Timestamps There are three types of timestamps for a GNU/Linux file. 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 that ctime is not file creation time. Overwriting a file will change all of the mtime, ctime, and atime attributes of the file. Changing ownership or permissions of a file will change the ctime and atime attributes of the file. Reading a file will change the atime of the file. Note that even simply reading a file on the Debian system will normally cause a file write operation to update atime information in the inode. Mounting a filesystem with "noatime" or "relatime" option will let the system skip this operation and will result 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.UTF-8") 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 See to cutomize "ls -l" output.
Named pipes (FIFOs) A named pipe is a file that acts like a pipe. You put something into the file, and it comes out the other end. Thus it's called a FIFO, or First-In-First-Out: the first thing you put in the pipe is the first thing to come out the other end. If you write to a named pipe, the process which is writing to the pipe doesn't terminate until the information being written is read from the pipe. If you read from a named pipe, the reading process waits until there is nothing to read before terminating. The size of the pipe is always zero --- it does not store data, it just links two processes like the shell "|". However, since this pipe has a name, the two processes don't have to be on the same command line or even be run by the same user. Pipes were a very influential innovation of Unix. You can try it by doing the following: $ cd; mkfifo mypipe $ echo "hello" >mypipe & # put into background [1] 8022 $ ls -l mypipe prw-r--r-- 1 penguin penguin 0 2007-04-29 08:25 mypipe $ cat mypipe hello [1]+ Done echo "hello" >mypipe $ ls mypipe mypipe $ rm mypipe
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. "netstat -an" will provide a very useful overview of sockets that are open on a given system.
Device files Device files refer to physical or virtual devices on your system, such as your hard disk, video card, screen, or keyboard. An example of a virtual device is the console, represented by "/dev/console". The device types. device type meaning character device This can be accessed one character at a time, that is, the smallest unit of data which can be written to or read from the device is a character (byte). block device This must be accessed in larger units called blocks, which contain a number of characters. Your hard disk is a block device.
You can read and write device files, though the file may well contain binary data which may be an incomprehensible-to-humans gibberish. Writing data directly to these files is sometimes useful for the troubleshooting of hardware connections. For example, you can dump a text file to the printer device "/dev/lp0" or send modem commands to the appropriate serial port "/dev/ttyS0". But, unless this is done carefully, it may cause a major disaster. So be cautious. For the normal access to a printer, use lp(1). The device node number are displayed by executing ls(1) as: $ 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 Here, "/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 disk 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, and "/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.
Special device files There are some special device files. List of special device files. device file action response /dev/null read it returns "end-of-file (EOF) character". /dev/null write it is a bottomless data dump pit. /dev/zero read it returns "the \0 (NUL) character" (not the same as the number zero ASCII). /dev/random read it returns random characters from a true random number generator, delivering real entropy. (slow) /dev/urandom read it returns random characters from a cryptographically secure pseudorandom number generator. /dev/full write it returns the disk-full (ENOSPC) error.
These are frequently used in conjunction with the shell redirection (see ).
procfs and sysfs The procfs and sysfs mounted on "/proc" and "/sys" are the pseudo-filesystem and expose internal data structures of the kernel to the userspace. In other word, these entries are virtual, meaning that they act as a convenient window into the operation of the operating system. The directory "/proc" contains (among other things) one subdirectory for each process running on the system, which is named after the process ID (PID). System utilities that access process information, such as ps(1), get their information from this directory structure. The directories under "/proc/sys/" contain interface to change certain kernel parameters at run time. (You may do the same through specialized sysctl(8) command or its preload/configuration file "/etc/sysctrl.conf".) The Linux kernel may complain "Too many open files". You can fix this by increasing "file-max" 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.
Midnight Commander (MC) Midnight Commander (MC) is a GNU "Swiss army knife" for the Linux console and other terminal environments. This gives newbie a menu driven console experience which is much easier to learn than standard Unix commands. You may need to install the Midnight Commander package which is titled "mc". $ sudo aptitude install mc Use the mc(1) command to explore the Debian system. This is the best way to learn. Please explore few interesting locations just using the cursor keys and Enter key: "/etc" and its subdirectories. "/var/log" and its subdirectories. "/usr/share/doc" and its subdirectories. "/sbin" and "/bin"
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: . /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.)
Starting MC MC can be started by: $ 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. 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 .
File manager in MC The default is two directory panels containing file lists. Another useful mode is to set the right window to "information" to see file access privilege information, etc. Following are some essential keystrokes. With the gpm(8) daemon running, one can use a mouse on Linux character consoles, too. (Make sure to press the shift-key to obtain the normal behavior of cut and paste in MC.) The key bindings of MC. key key binding F1 Help menu F3 Internal file viewer F4 Internal editor F9 Activate pull down menu F10 Exit Midnight Commander Tab Move between two windows Insert or Ctrl-T Mark file for a multiple-file operation such as copy Del Delete file (be careful---set MC to safe delete mode) Cursor keys Self-explanatory
Command-line tricks in MC Any cd command will change the directory shown on the selected screen. Ctrl-Enter or Alt-Enter will copy a filename to the command line. Use this with cp(1) and mv(1) commands together with command-line editing. Alt-Tab will show shell filename expansion choices. One can specify the starting directory for both windows as arguments to MC; for example, "mc /etc /root". Esc + n-keyFn (i.e., Esc + 1F1, etc.; Esc + 0F10) Pressing Esc before the key has the same effect as pressing the Alt and the key together.; i.e., type Esc + c for Alt-C. Esc is called meta-key and sometimes noted as "M-"
The internal editor in MC The internal editor has an interesting cut-and-paste scheme. Pressing F3 marks the start of a selection, a second F3 marks the end of selection and highlights the selection. Then you can move your cursor. If you press F6, the selected area will be moved to the cursor location. If you press F5, the selected area will be copied and inserted at the cursor location. F2 will save the file. F10 will get you out. Most cursor keys work intuitively. This editor can be directly started on a file: $ mc -e filename_to_edit $ mcedit filename_to_edit This is not a multi-window editor, but one can use multiple Linux consoles to achieve the same effect. To copy between windows, use Alt-F<n> keys to switch virtual consoles and use "File→Insert file" or "File→Copy to file" to move a portion of a file to another file. This internal editor can be replaced with any external editor of choice. Also, many programs use the environment variables "$EDITOR" or "$VISUAL" to decide which editor to use. If you are uncomfortable with vim(1) or nano(1) initially, you may set these to "mcedit" by adding these lines to "~/.bashrc": ... export EDITOR=mcedit export VISUAL=mcedit ... I do recommend setting these to "vim" if possible. If you are uncomfortable with vim(1), you can keep using mcedit(1) for most system maintenance tasks.
The internal viewer in MC Very smart viewer. This is a great tool for searching words in documents. I always use this for files in the "/usr/share/doc" directory. This is the fastest way to browse through masses of Linux information. This viewer can be directly started like so: $ mc -v path/to/filename_to_view $ mcview path/to/filename_to_view
Auto-start features of MC Press Enter on a file, and the appropriate program will handle the content of the file (see ). This is a very convenient MC feature. The reaction to the enter key in MC. file type reaction to enter key executable file Execute command man file Pipe content to viewer software html file Pipe content to web browser "*.tar.gz" and "*.deb" file Browse its contents as if subdirectory
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.
FTP virtual filesystem of MC MC can be used to access files over the Internet using FTP. Go to the menu by pressing F9, then type "p" to activate the FTP virtual filesystem. Enter a URL in the form "username:passwd@hostname.domainname", which will retrieve a remote directory that appears like a local one. Try "[http.us.debian.org/debian]" as the URL and browse the Debian archive.
The basic Unix-like work environment Although MC enables you to do almost everything, it is very important for you to learn how to use the command line tools invoked from the shell prompt and become familiar with the Unix-like work environment.
The login shell You can select your login shell with chsh(1). List of shell programs. package popcon size POSIX shell description bash &pop-bash; &size-bash; Yes Bash: the GNU Bourne Again SHell. (de facto standard) tcsh &pop-tcsh; &size-tcsh; No TENEX C Shell: an enhanced version of Berkeley csh. dash &pop-dash; &size-dash; Yes The Debian Almquist Shell. Good for shell script. zsh &pop-zsh; &size-zsh; Yes Z shell: the standard shell with many enhancements. pdksh &pop-pdksh; &size-pdksh; Yes A public domain version of the Korn shell. csh &pop-csh; &size-csh; No OpenBSD C Shell, a version of Berkeley csh. sash &pop-sash; &size-sash; Yes Stand-alone shell with builtin commands. (Not meant for standard "/bin/sh".) ksh &pop-ksh; &size-ksh; Yes The real, AT&T version of the Korn shell. rc &pop-rc; &size-rc; No An implementation of the AT&T Plan 9 rc shell. posh &pop-posh; &size-posh; Yes Policy-compliant Ordinary SHell. A pdksh derivative.
In this tutorial chapter, the interactive shell always means bash.
Customizing bash You can customize bash(1) behavior by "~/.bashrc". For example, I added followings to "~/.bashrc": # CD upon exiting MC . /usr/share/mc/bin/mc.sh # set CDPATH to good one CDPATH=.:/usr/share/doc:~/Desktop/src:~/Desktop:~ export CDPATH 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 You can find more bash customization tips, such as , in .
Special key strokes In the Unix-like environment, there are few key strokes which have special meanings. Please note that on a normal Linux character console, only the left-hand Ctrl and Alt keys work as expected. Here are few notable key strokes to remember. List of key bindings for bash. key key binding Ctrl-U Erase line before cursor. Ctrl-H Erase a character before cursor. Ctrl-D Terminate input. (exit shell if you are using shell) Ctrl-C Terminate a running program. Ctrl-Z Temporarily stop program by moving it to the background job Ctrl-S Halt output to screen. Ctrl-Q Reactivate output to screen. Ctrl-Alt-Del Reboot/halt the system, see inittab(5). Left-Alt-key (optionally, Windows-key) Meta-key for Emacs and the similar UI. Up-arrow Start command history search under bash. Ctrl-R Start incremental command history search under bash. Tab Complete input of the filename to the command line under bash. Ctrl-V Tab Input Tab without expansion to the command line under bash.
The terminal feature of Ctrl-S can be disabled using stty(1).
Unix style mouse operations Unix style mouse operations are based on the 3 button mouse system. List of Unix style mouse operations. action response Left-click-and-drag mouse Select and copy to the clipboard. Left-click Select the start of selection. Right-click Select the end of selection and copy to the clipboard. Middle-click 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.
The pager less(1) is the enhanced pager (file content browser). Hit "h" for help. It can do much more than more(1) and can be supercharged by executing "eval $(lesspipe)" or "eval $(lessfile)" in the shell startup script. See more in "/usr/share/doc/lessf/LESSOPEN". The "-R" option allows raw character output and enables ANSI color escape sequences. See less(1).
The text editor You should become proficient in one of variants of Vim or Emacs programs which are popular in the Unix-like system. I think getting used to Vim commands is the right thing to do, since Vi-editor is always there in the Linux/Unix world. (Actually, original vi or new nvi are programs you find everywhere. I chose Vim instead for newbie since it offers you help through F1 key while it is similar enough and more powerful.) 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-]. 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.
Setting a default text editor Debian comes with a number of different editors. We recommend to install the vim package, as mentioned above. Debian provides unified access to the system default editor via command "/usr/bin/editor" so other programs (e.g., reportbug(1)) can invoke it. You can change it by: $ sudo update-alternatives --config editor The choice "/usr/bin/vim.basic" over "/usr/bin/vim.tiny" is my recommendation for newbies since it supports syntax highlighting. Many programs use the environment variables "$EDITOR" or "$VISUAL" to decide which editor to use (see and ). For the consistency on Debian system, set these to "/usr/bin/editor". (Historically, "$EDITOR" was "ed" and "$VISUAL" was "vi".)
Customizing vim You can customize vim(1) behavior by "~/.vimrc". For example, I use: " ------------------------------- " Local configuration " set nocompatible set nopaste set pastetoggle=<f2> syn on if $USER == "root" set nomodeline set noswapfile else set modeline set swapfile endif " filler to avoid the line above being recognized as a modeline " filler " filler
Recording the shell activities The output of the shell command may roll off your screen and may be lost forever. It is good practice to log shell activities into the file for you to review them later. This kind of record is essential when you perform any system administration tasks. The basic method of recording the shell activity is to run it under script(1). $ script Script started, file is typescript do whatever shell commands … press Ctrl-D to exit script. $ vim typescript See .
Basic Unix commands Let's learn basic Unix commands. Here I use "Unix" in its generic sense. Any Unix clone OSs usually offer equivalent commands. The Debian system is no exception. Do not worry if some commands do not work as you wish now. If alias is used in the shell, its corresponding command outputs are different. These examples are not meant to be executed in this order. Try all following commands from the non-privileged user account: List of basic Unix commands. command description pwd Display name of current/working directory. whoami Display current user name. id Display current user identity (name, uid, gid, and associated groups). file <foo> Display a type of file for the file "<foo>". type -p <commandname> Display a file location of command "<commandname>". which <commandname> , , type <commandname> Display information on command "<commandname>". apropos <key-word> Find commands related to "<key-word>". man -k <key-word> , , whatis <commandname> Display one line explanation on command "<commandname>". man -a <commandname> Display explanation on command "<commandname>". (Unix style) info <commandname> Display rather long explanation on command "<commandname>". (GNU style) ls List contents of directory. (non-dot files and directories) ls -a List contents of directory. (all files and directories) ls -A List contents of directory. (almost all files and directories, i.e., skip ".." and ".") ls -la List all contents of directory with detail information. ls -lai List all contents of directory with inode number and detail information. ls -d List all directories under the current directory. tree Display file tree contents. lsof <foo> List open status of file "<foo>". lsof -p <pid> List files opened by the process ID: "<pid>". mkdir <foo> Make a new directory "<foo>" in the current directory. rmdir <foo> Remove a directory "<foo>" in the current directory. cd <foo> Change directory to the directory "<foo>" in the current directory or in the directory listed in the variable "$CDPATH". cd / Change directory to the root directory. cd Change directory to the current user's home directory. cd /<foo> Change directory to the absolute path directory "/<foo>". cd .. Change directory to the parent directory. cd ~<foo> Change directory to the home directory of the user "<foo>". cd - Change directory to the previous directory. </etc/motd pager Display contents of "/etc/motd" using the default pager. touch <junkfile> Create a empty file "<junkfile>". cp <foo> <bar> Copy a existing file "<foo>" to a new file "<bar>". rm <junkfile> Remove a file "<junkfile>". mv <foo> <bar> Rename an existing file "<foo>" to a new name "<bar>". The directory "<bar>" must not exist. mv <foo> <bar> Move an existing file "<foo>" to a new location "<bar>/<foo>". The directory "<bar>" must exist. mv <foo> <bar>/<baz> 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. chmod 600 <foo> Make an existing file "<foo>" to be non-readable and non-writable by the other people. (non-executable for all) chmod 644 <foo> Make an existing file "<foo>" to be readable but non-writable by the other people. (non-executable for all) chmod 755 <foo> Make an existing file "<foo>" to be readable but non-writable by the other people. (executable for all) find . -name <pattern> find matching filenames using shell "<pattern>". (slower) locate -d . <pattern> find matching filenames using shell "<pattern>". (quicker using regularly generated database) grep -e "<pattern>" *.html Find a "<pattern>" in all files ending with ".html" in current directory and display them all. top Display process information using full screen. Type "q" to quit. ps aux | pager Display information on all the running processes using BSD style output. ps -ef | pager Display information on all the running processes using Unix system-V style output. ps aux | grep -e "[e]xim4*" Display all processes running "exim" and "exim4". ps axf | pager Display information on all the running processes with ASCII art output. kill <1234> Kill a process identified by the process ID: "<1234>". gzip <foo> Compress "<foo>" to create "<foo>.gz" using the Lempel-Ziv coding (LZ77). gunzip <foo>.gz Decompress "<foo>.gz" to create "<foo>". bzip2 <foo> Compress "<foo>" to create "<foo>.bz2" using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. (Better compression than gzip) bunzip2 <foo>.bz2 Decompress "<foo>.bz2" to create "<foo>". tar -xvf <foo>.tar Extract files from "<foo>.tar" archive. tar -xvzf <foo>.tar.gz Extract files from gzipped "<foo>.tar.gz" archive. tar -xvf -j <foo>.tar.bz2 Extract files from "<foo>.tar.bz2" archive. tar -cvf <foo>.tar <bar>/ Archive contents of folder "<bar>/" in "<foo>.tar" archive. tar -cvzf <foo>.tar.gz <bar>/ Archive contents of folder "<bar>/" in compressed "<foo>.tar.gz" archive. tar -cvjf <foo>.tar.bz2 <bar>/ Archive contents of folder "<bar>/" in "<foo>.tar.bz2" archive. zcat README.gz | pager Display contents of compressed "README.gz" using the default pager. zcat README.gz > foo Create a file "foo" with the decompressed content of "README.gz". zcat README.gz >> foo Append the decompressed content of "README.gz" to the end of the file "foo". (If it does not exist, create it first.)
Unix has a tradition to hide filenames which start with ".". They are traditionally files that contain configuration information and user preferences. For cd command, see builtins(7). The default pager of the bare bone Debian system is more(1) which cannot scroll back. By installing the less package using command line "aptitude install less", less(1) becomes default pager and you can scroll back with cursor keys. 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, these commands are the good start: $ man man $ man bash $ man builtins $ man 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 will 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
The simple shell command Now you have some feel on how to use the Debian system. Let's look deep into the mechanism of the command execution in the Debian system. Here, I have simplified reality for the newbie. See bash(1) for the exact explanation. A simple command is a sequence of: variable assignments (optional) command name arguments (optional) redirections (optional: > , >> , < , << , etc.) control operator (optional: && , || , <newline> , ; , & , ( , ) )
Command execution and environment variable Values of some environment variables change the behavior of some Unix commands. Default values of environment variables are initially set by the PAM system and then some of them may be reset by some application programs: the display manager such as gdm, and the shell in its start up codes "~/bash_profile" and "~/.bashrc".
"$LANG" variable The full locale value given to "$LANG" variable consists of 3 parts: "xx_YY.ZZZZ". 3 parts of locale value. locale value meaning xx ISO 639 language codes (lower case) such as "en" YY ISO 3166 country codes (upper case) such as "US" ZZZZ codeset, always set to "UTF-8"
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 . The "LANG=en_US" is not "LANG=C" nor "LANG=en_US.UTF-8". It is "LANG=en_US.ISO-8859-1" (see ). List of locale recommendations. locale recommendation Language (area) en_US.UTF-8 English(USA) en_GB.UTF-8 English(Great_Britain) fr_FR.UTF-8 French(France) de_DE.UTF-8 German(Germany) it_IT.UTF-8 Italian(Italy) es_ES.UTF-8 Spanish(Spain) ca_ES.UTF-8 Catalan(Spain) sv_SE.UTF-8 Swedish(Sweden) pt_BR.UTF-8 Portuguese(Brasil) ru_RU.UTF-8 Russian(Russia) zh_CN.UTF-8 Chinese(P.R._of_China) zh_TW.UTF-8 Chinese(Taiwan_R.O.C.) ja_JP.UTF-8 Japanese(Japan) ko_KR.UTF-8 Korean(Republic_of_Korea) vi_VN.UTF-8 Vietnamese(Vietnam)
Typical command execution uses a shell line sequence like the following: $ 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 in the foreground job. The environment variable "$LANG" is: set to system default locale (such as "en_US.UTF-8" depending on your configuration) for the first command, and set to "fr_FR.UTF-8" (French UTF-8 locale assuming it is available on your system) for the second command. Most command executions usually do not have preceding environment variable definition. For the above example, you can alternatively execute: $ 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 using: $ export LANG 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. 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.
"$PATH" variable When you type a command into the shell, the shell searches the command in the list of directories contained in the "$PATH" environment variable. The value of the "$PATH" environment variable is also called the shell's search path. In the default Debian installation, the "$PATH" environment variable of user accounts may not include "/sbin" and "/usr/sbin". For example, the ifconfig command needs to be issued with full path as "/sbin/ifconfig". (Similar ip command is located in "/bin".) You can change the "$PATH" environment variable of Bash shell by "~/.bash_profile" or "~/.bashrc" files.
"$HOME" variable Many commands stores user specific configuration in the home directory and changes their behavior by their contents. The home directory is identified by the environment variable "$HOME": List of "<literal>$HOME</literal>" values. value of "$HOME" program execution situation / program run by the init process (daemon) /root program run from the normal root shell /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"
Shell expands "~/" to current user’s home directory, i.e., "$HOME/". Shell expands "~foo/" to foo's home directory, i.e., "/home/foo/".
Command line options Some commands take arguments. Arguments starting with "-" or "--" are called options and control the behavior of the command. $ date Mon Oct 27 23:02:09 CET 2003 $ date -R Mon, 27 Oct 2003 23:02:40 +0100 Here the command-line argument "-R" changes date(1) behavior to output RFC2822 compliant date string.
Shell glob Often you want a command to work with a group of files without typing all of them. The filename expansion pattern using the shell glob, (sometimes referred as wildcards), facilitate this need. Shell glob patterns. shell glob pattern match * This matches filename (segment) not started with ".". .* This matches filename (segment) started with ".". ? This matches exactly one character. […] This matches exactly one character with any character enclosed in brackets. [a-z] This matches exactly one character with any character between "a" and "z". [^…] This matches exactly one character other than any character enclosed in brackets (excluding "^").
For example, try the following and think for yourself: $ 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) for more. 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) 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).
Return value of the command Each command returns its exit status (variable: "$?") as the return value. Command exit codes. command exit status numeric return value logical return value success zero, 0 TRUE error non-zero, -1 FALSE
Thus: $ [ 1 = 1 ] ; echo $? 0 $ [ 1 = 2 ] ; echo $? 1 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.
Typical command sequences and shell redirection Let's try to remember following shell command idioms. Shell command idioms. command idiom (type in one line) description command & The command is executed in the subshell in the background. command1 | command2 The standard output of command1 is piped to the standard input of command2 . Both commands may be running concurrently. command1 2>&1 | command2 Both standard output and standard error of command1 are piped to the standard input of command2. Both commands may be running concurrently. command1 ; command2 The command1 and command2 are executed sequentially. command1 && command2 The command1 is executed. If successful, command2 is also executed sequentially. Return success if both command1 and command2 are successful. command1 || command2 The command1 is executed. If not successful, command2 is also executed sequentially. Return success if command1 or command2 are successful. command > foo Redirect standard output of command to a file foo. (overwrite) command 2> foo Redirect standard error of command to a file foo. (overwrite) command >> foo Redirect standard output of command to a file foo. (append) command 2>> foo Redirect standard error of command to a file foo. (append) command > foo 2>&1 Redirect both standard output and standard error of command to a file "foo". command < foo Redirect standard input of command to a file foo. command << delimiter Redirect standard input of command to the following lines until "delimiter" is met. (Here documents) command <<- delimiter Redirect standard input of command to the following lines until "delimiter" is met. The leading tab characters are stripped from input lines. (Here documents)
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). Let's try simple examples of redirection: $ </etc/motd pager $ pager </etc/motd $ pager /etc/motd $ cat /etc/motd | pager Although all 4 examples 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 # open files $ cat <&3 >&4 # redirect stdin to 3, stdout to 4 $ exec 3<&- 4>&- # close files $ cat bar Hello Here, "n<&-" and "n>&-" mean to close the file descriptor "n". The file descriptor 0-2 are predefined: Predefined file descriptors. device description file descriptor stdin standard input 0 stdout standard output 1 stderr standard error 2
Command alias You can set an alias for the frequently used command. For example: $ alias la='ls -la' Now, "la" works as a short hand for "ls -la" which lists all files in the long listing format. You can list any existing aliases: $ alias You can identity exact path or identity of the command using type builtins command. For example: $ type ls ls is hashed (/bin/ls) $ type la 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. See .
Unix-like text processing In Unix-like work environment, text processing is done by piping text through chains of standard text processing tools. This was another crucial Unix innovation.
Unix text tools There are few standard text processing tools which are used very often on the Unix-like system. No regular expression is used: cat(1) concatenates files and outputs the whole content. tac(1) concatenates files and outputs in reverse. cut(1) selects parts of lines and outputs. head(1) outputs the first part of files. tail(1) outputs the last part of files. sort(1) sorts lines of text files. uniq(1) removes duplicate lines from a sorted file. tr(1) translates or deletes characters. diff(1) compares files line by line. Basic regular expression (BRE) is used: grep(1) matches text with patterns. ed(1) is a primitive line editor. sed(1) is a stream editor. vim(1) is a screen editor. emacs(1) is a screen editor. (somewhat extended BRE) Extended regular expression (ERE) is used: egrep(1) matches text with patterns. awk(1) does simple text processing. tcl(3tcl) can do every conceivable text processing: re_syntax(3). Often used with tk(3tk). perl(1) can do every conceivable text processing. perlre(1). pcregrep(1) from the pcregrep package matches text with Perl Compatible Regular Expressions (PCRE) pattern. python(1) with the re module can do every conceivable text processing. See "/usr/share/doc/python/html/index.html". If you are not sure what exactly these commands do, please use "man command" to figure it out by yourself. 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 and ). 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.
Regular expressions Regular expressions are used in many text processing tools. They are analogous to the shell globs, but they are more complicated and powerful. The regular expression describes the matching pattern and is made up of text characters and metacharacters. The metacharacter is just a character with a special meaning. There are 2 major styles, BRE and ERE, depending on the text tools as described above. Metacharacters for BRE and ERE. BRE ERE The meaning of the regular expression \ . [ ] ^ $ * \ . [ ] ^ $ * Common metacharacters \+ \? \( \) \{ \} \|   BRE only "\" escaped metacharacters   + ? ( ) { } | ERE only non-"\" escaped metacharacters c c This matches the non-metacharacter "c". \c \c This sequence matches the literal character "c" even if "c" is metacharacter by itself. . . This matches any character including newline. ^ ^ This matches the beginning of a string. $ $ This matches the end of a string. \< \< This matches the beginning of a word. \> \> This matches the end of a word. \[abc…\] [abc…] This character list matches any characters "abc…". \[^abc…\] [^abc…] This negated character list matches any characters except "abc…". r* r* This matches zero or more regular expressions identified by "r". r\+ r+ This matches one or more regular expressions identified by "r". r\? r? This matches zero or one regular expressions identified by "r". r1\|r2 r1|r2 This matches one of the regular expressions identified by "r1" or "r2". \(r1\|r2\) (r1|r2) This matches one of the regular expressions identified by "r1" or "r2" and treats 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. For example, grep(1) can be used to perform the text search using the regular expression: $ 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 See .
Replacement expressions For the replacement expression, following characters have special meanings: The replacement expression. character meaning & This represents what the regular expression matched. (use \& in emacs) \n This represents what the n-th bracketed regular expression matched. ("n" being number)
For Perl replacement string, "$n" is used instead of "\n" and "&" has no special meaning. For example: $ 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.
Global substitution with regular expressions The ed(1) command can replace all instances of "FROM_REGEX" with "TO_TEXT" in "file" by: $ ed file <<EOF ,s/FROM_REGEX/TO_TEXT/g w q EOF 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 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 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. Use of argument "-i.bak" instead of "-i" will keep each original file by adding ".bak" to its filename. This makes recovery from errors easier for complex substitutions. While ed(1) and vim(1) are BRE, perl(1) is ERE.
Extract data from text file table Let's consider a text file called "DPL" in which some pre-2004 Debian project leader's names and their initiation days are listed in a space-separated format. Ian Murdock August 1993 Bruce Perens April 1996 Ian Jackson January 1998 Wichert Akkerman January 1999 Ben Collins April 2001 Bdale Garbee April 2002 Martin Michlmayr March 2003 See "A Brief History of Debian" for the latest Debian leadership history. Awk is frequently used to extract data from these types of files: $ 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: $ 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=":," # use ":" and "," as IFS $ echo IFS=$IFS, IFS="$IFS" # echo is a Bash builtin IFS= , IFS=:, $ date -R # just a command output Sat, 23 Aug 2003 08:30:15 +0200 $ echo $(date -R) # sub shell --> input to main shell Sat 23 Aug 2003 08 30 36 +0200 $ unset IFS # reset IFS to the default $ echo $(date -R) Sat, 23 Aug 2003 08:30:50 +0200
Script snippets for piping commands The following scripts will do nice things as a part of a pipe. List of script snippets for piping commands. script snippet (type in one line) effect of command find /usr -print find all files under "/usr". seq 1 100 print 1 to 100. | xargs -n 1 <command> run command repeatedly with each item from pipe as its argument. | xargs -n 1 echo split white-space-separated items from pipe into lines. | xargs echo merge all lines from pipe into a line. | grep -e <regex_pattern> extract lines from pipe containing <regex_pattern>. | grep -v -e <regex_pattern> extract lines from pipe not containing <regex_pattern>. | cut -d: -f3 - extract third field from pipe separated by ":" (passwd file etc.). | awk '{ print $3 }' extract third field from pipe separated by whitespaces. | awk -F'\t' '{ print $3 }' extract third field from pipe separated by tab. | col -bx remove backspace and expand tabs to spaces. | expand - expand tabs. | sort| uniq sort and remove duplicates. | tr 'A-Z' 'a-z' convert uppercase to lowercase. | tr -d '\n' concatenate lines into one line. | tr -d '\r' remove CR. | sed 's/^/# /' add "#" to the start of each line. | sed 's/\.ext//g' remove ".ext". | sed -n -e 2p print the second line. | head -n 2 - print the first 2 lines. | tail -n 2 - print the last 2 lines.
One-line shell script can loop over many files using find(1) and xargs(1) to perform quite complicated tasks. See and . When using the shell interactive mode becomes too complicated, please consider to write a shell script (see ).
Debian package management This chapter is written assuming the latest stable release is codename: &codename-stable;. Debian is a volunteer organization which builds consistent distributions of pre-compiled binary packages 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 &all-packages; packages available for the &arch; 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 aptitude(8) as the main front end program for the Debian package management activity. List of Debian package management tools. package popcon size description aptitude &pop-aptitude; &size-aptitude; terminal-based package manager (current standard, front-end for apt) apt &pop-apt; &size-apt; Advanced Packaging Tool (APT), front-end for dpkg providing "http", "ftp", and "file" archive access methods (apt-get/apt-cache commands included) tasksel &pop-tasksel; &size-tasksel; tool for selecting tasks for installation on Debian system (front-end for APT) unattended-upgrades &pop-unattendedupgrades; &size-unattendedupgrades; enhancement package for APT to enable automatic installation of security upgrades dselect &pop-dselect; &size-dselect; terminal-based package manager (previous standard, front-end for APT and other old access methods) dpkg &pop-dpkg; &size-dpkg; package management system for Debian dpkg-ftp &pop-dpkgftp; &size-dpkgftp; older ftp method for dselect synaptic &pop-synaptic; &size-synaptic; graphical package manager (GNOME front-end for APT) gnome-apt &pop-gnomeapt; &size-gnomeapt; graphical package manager (GNOME front-end for APT) kpackage &pop-kpackage; &size-kpackage; graphical package manager (KDE front-end for APT) apt-utils &pop-aptutils; &size-aptutils; APT utility programs: apt-extracttemplates(1), apt-ftparchive(1), and apt-sortpkgs(1) apt-listchanges &pop-aptlistchanges; &size-aptlistchanges; package change history notification tool apt-listbugs &pop-aptlistbugs; &size-aptlistbugs; lists critical bugs before each APT installation apt-file &pop-aptfile; &size-aptfile; APT package searching utility — command-line interface apt-rdepends &pop-aptrdepends; &size-aptrdepends; recursively lists package dependencies
The annoying bug #411123 for the mixed use of aptitude(8) and apt-get(8) commands has been resolved. If this kept you from using aptitude, please reconsider.
Debian package management prerequisites
Package configuration Here are some key points for package configuration on the Debian system: The manual configuration by the system administrator is respected. In other words, the package configuration system makes no intrusive configuration for the sake of convenience. Each package comes with its own configuration script with standardized user interface called debconf(7) to help initial installation process of the package. Debian Developers try their best to make your upgrade experience flawless with package configuration scripts. Full functionalities of packaged software are available to the system administrator. But ones with security risks are disabled in the default installation. If you manually activate a service with some security risks, you are responsible for the risk containment. Esoteric configuration may be manually enabled by the system administrator. This may creates interference with popular generic helper programs for the system configuration.
Basic precautions Do not install packages from random mixture of suites. It probably will break the package consistency which requires deep system management knowledge, such as compiler ABI, library version, interpreter features, etc. The newbie Debian system administrator should stay with the stable release of Debian while applying only 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: 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/", or Do not overwrite system files by installing software programs directly compiled from source. (Install them into "/usr/local" or "/opt".) 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. (Although Debian has been offering an extremely stable system for a long time, you as the system administrator are responsible for your system in the end.)
Life with eternal upgrades Despite my warnings above, I know many readers of this document wish to run the testing or unstable suites of Debian as their main system for self-administered Desktop environments. This is because they work very well, are updated frequently, and offer the latest features. 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: "&codename-testing;" or "&codename-unstable;". This will let 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. (optional) (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 will save a person from the eternal karmic struggle of upgrade hell and let him reach Debian nirvana.
Debian archive basics Let's look into the Debian archive from a system user's perspective. 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, e.g. for the current stable = &codename-stable; system: deb http://ftp.XX.debian.org/debian/ &codename-stable; main contrib non-free deb-src http://ftp.XX.debian.org/debian/ &codename-stable; main contrib non-free deb http://security.debian.org/ &codename-stable;/updates main contrib deb-src http://security.debian.org/ &codename-stable;/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 "&codename-stable;" 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: The "deb" line defines for the binary packages. The "deb-src" line defines for the source packages. The 1st argument is the root URL of the Debian archive. The 2nd argument is the distribution name: either the suite name or the codename. The 3rd and following arguments are the list of valid archive component 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 will speed up the updates of the archive meta data. The URL can be "http://", "ftp://", "file://", …. If "sid" is used in the above example instead of "&codename-stable;", the "deb: http://security.debian.org/" line for security updates in the "/etc/apt/sources.list" is not required. Security updates are only available for stable and testing (i.e., &codename-stable; and &codename-testing;). Here is the list of URL of the Debian archive sites and suite name or codename used in the configuration file: List of Debian archive sites. archive URL suite name (codename) purpose http://ftp.XX.debian.org/debian/ stable (&codename-stable;) stable (&codename-stable;) release http://ftp.XX.debian.org/debian/ testing (&codename-testing;) testing (&codename-testing;) release http://ftp.XX.debian.org/debian/ unstable (&codename-unstable;) unstable (&codename-unstable;) release http://ftp.XX.debian.org/debian/ experimental experimental pre-release (optional, only for developer) http://ftp.XX.debian.org/debian/ stable-proposed-updates Updates for the next stable point release (optional) http://security.debian.org/ stable/updates Security updates for stable release (important) http://security.debian.org/ testing/updates Security updates for testing release (important) http://volatile.debian.org/debian-volatile/ volatile Compatible updates for spam filter, IM clients, etc. http://volatile.debian.org/debian-volatile/ volatile-sloppy Non-compatible updates for spam filter, IM clients, etc. http://backports.org/debian/ &codename-stable;-backports Newer backported packages for &codename-stable;. (non-official, optional)
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. If you really need the latest version of some programs under stable release, please use packages from the debian-volatile project and backports.org (see ) services. These services must be used with extra care. 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 ). 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. Each Debian archive consists of 3 components. Components are alternatively called categories in "Debian Policy" or areas in "Debian Social Contract". The component is grouped by the compliance to "The Debian Free Software Guidelines" (DFSG): List of Debian archive components. component number of packages criteria main &main-packages; The package is fully compliant to DSFG and does not depend the non-free package. contrib &contrib-packages; The package is compliant to the DSFG but depends on the non-free package. non-free &non-free-packages; The package is not compliant to the DSFG but distributable and useful.
Here the number of packages in the above is for the &arch; architecture. Strictly speaking, only the main component 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 relationship between suite and codename. Timing suite = stable suite = testing suite = unstable after the &codename-stable; release codename = &codename-stable; codename = &codename-testing; codename = sid after the &codename-testing; release codename = &codename-testing; codename = &codename-nexttesting; codename = sid
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 section which provides the main component.) 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 will be 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: 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. 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. 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 definition of: "Sections", "Priorities", "Base system", and "Essential packages".
Package dependencies The Debian system offers a consistent set of binary packages through its versioned binary dependency declaration mechanism in the control file fields. Here is a bit over simplified definition for them. List of package dependencies. dependency meaning 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. 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.
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.
The event flow of the package management Here is a summary of the simplified event flow of the package management by APT. update ("aptitude update" or "apt-get update"): fetch archive metadata from remote archive. reconstruct and update local metadata for use by APT. upgrade ("aptitude safe-upgrade" and "aptitude full-upgrade", or "apt-get upgrade" and "apt-get dist-upgrade"): chose candidate version which is usually the latest available version for all installed packages. (See for exception.) make package dependency resolution. fetch selected binary packages from remote archive if candidate version is different from installed version. unpack fetched binary packages. run preinst script. install binary files. run postinst script. install ("aptitude install …" or "apt-get install …"): chose packages listed on the command line. make package dependency resolution. fetch selected binary packages from remote archive. unpack fetched binary packages. run preinst script. install binary files. run postinst script. remove ("aptitude remove …" or "apt-get remove …"): chose packages listed on the command line. make package dependency resolution. run prerm script. remove installed files except configuration files. run postrm script. purge ("aptitude purge …" or "apt-get purge …"): 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.
First response to package management troubles You should read the fine official documentation. The first document to read is the Debian specific "/usr/share/doc/<package_name>/README.Debian". Other documentation in "/usr/share/doc/<package_name>/" should be consulted too. If you set shell as , type: $ cd <package_name> $ pager README.Debian $ mc You may need to install the corresponding documentation package named with "-doc" suffix for detailed information. If you are experiencing problems with a specific package, make sure to check out these sites first: List of key web site to resolving problems with a specific package. site command Home page of the Debian bug tracking system (BTS). sensible-browser "http://bugs.debian.org/" The bug report of a known package name. sensible-browser "http://bugs.debian.org/<package_name>" The bug report of known bug number. sensible-browser "http://bugs.debian.org/<bug_number>"
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.
Basic package management operations Aptitude is the current preferred package management tool for the Debian system. It can be used as the commandline alternative to apt-get / apt-cache and also as the full screen interactive package management tool. For the package management operation which involves package installation or updates package metadata, you need to have root privilege.
Basic package management operations with commandline Here are package management operations with commandline using aptitude(8) and apt-get(8) /apt-cache(8). Package management operations with commandline using aptitude and apt-get / apt-cache. aptitude syntax apt-get/apt-cache syntax description aptitude update apt-get update Update package archive metadata. aptitude install foo apt-get install foo Install candidate version of "foo" package with its dependencies. aptitude safe-upgrade apt-get upgrade Install candidate version of installed packages without removing any other packages. aptitude full-upgrade apt-get dist-upgrade <package> Install candidate version of installed packages while removing other packages if needed. aptitude remove foo apt-get remove foo Remove "foo" package while leaving its configuration files. N/A apt-get autoremove Remove auto-installed packages which is no longer required. aptitude purge foo apt-get purge foo Purge "foo" package with its configuration files. aptitude clean apt-get clean Clear out the local repository of retrieved package files completely. aptitude autoclean apt-get autoclean Clear out the local repository of retrieved package files for outdated packages. aptitude show foo apt-cache show <package> Display detailed information about "foo" package. aptitude search <regex> apt-cache search <regex> Search packages which match <regex>. aptitude why <regex> N/A Explain the reason why <regex> matching packages should be installed. aptitude why-not <regex> N/A Explain the reason why <regex> matching packages can not be installed.
Although it is now safe to mix different package tools on the Debian system, it is best to continue using aptitude as much as possible. 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 will never 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". Notable command options for <literal>aptitude</literal>(8). command option description -s simulate the result of the command. -d download only but no install/upgrade. -D show brief explanations before the automatic installations and removals.
See aptitude(8) and "aptitude user's manual" at "/usr/share/doc/aptitude/README" for more. The dselect package is still available and was the preferred full screen interactive package management tool in previous releases.
Interactive use of aptitude For the interactive package management, you start aptitude in interactive mode from the console shell prompt as: $ sudo aptitude -u Password: This will update 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". 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. 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".
Key bindings of aptitude Notable key strokes to browse status of packages and to set "planned action" on them in this full screen mode are: List of key bindings for aptitude. key key binding F10 or Ctrl-t Menu ? Display help for keystroke (more complete listing) F10 → Help → User's Manual Display User's Manual u Update package archive information + Mark the package for the upgrade or the install - Mark the package for the remove (keep configuration files) _ Mark the package for the purge (remove configuration files) = Place the package on hold U Mark all upgradable packages (function as full-upgrade) g Start downloading and installing selected packages q Quit current screen and save changes x Quit current screen and discard changes Enter View information about a package C View a package's changelog l Change the limit for the displayed packages / Search for the first match \ Repeat the last search
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. 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.
Package views under aptitude In the interactive full screen mode of aptitude(8), packages in the package list are displayed like this by default: idA libsmbclient -2220kB 3.0.25a-1 3.0.25a-2 Here, this line means from the left as: The "current state" flag (the first letter) The "planned action" flag (the second letter) The "automatic" flag (the third letter) The package name The change in disk space usage attributed to "planned action" The current version of the package The candidate version of the package 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 ). Several types of package views are available under the menu "Views": List of views for aptitude. view status categorization Package View Good See . (default) Audit Recommendations Good Packages which are recommended by some installed packages but not yet installed are listed. Flat Package List Good Packages are listed without categorization (for use with regex). Debtags Browser Very usable Packages are categorized according to their debtags entries. Categorical Browser Deprecated (Use debtags!) Packages are categorized according to their category.
Please help us improving tagging packages with debtags! The standard "Package View" categorizes packages somewhat like dselect with few extra features. The categorization of standard package views. category organization Upgradable Packages Organized as section → component → package New Packages , , Installed Packages , , Not Installed Packages , , Obsolete and Locally Created Packages , , Virtual Packages You can pick a particular package from a set of packages with the same function. Tasks You can cherry pick particular packages from a set of packages of a task.
Search method options with aptitude Aptitude offers several options for you to search packages using its regex formula: "aptitude search '<aptitude_regex>'" to list installation status, package name and short description of matching packages. "aptitude show '<package_name>'" to list detailed description of the package. limit view to matching packages: Type "l" in the full screen mode. search the first found package: type "/" in the full screen mode. "n" for find-next, "\" for backward search. Here, 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.
The aptitude regex formula The aptitude regex formula is mutt-like extended ERE (see ) and the meanings of the aptitude specific special match rule extensions are as below: List of the aptitude regex formula. meaning of the extended match rule regex formula match on package name ~n<regex_name> match on description ~d<regex_description> match on task name ~t<regex_task> match on debtag ~G<regex_debtag> match on maintainer ~m<regex_maintainer> match on package section ~s<regex_section> match on package version ~V<regex_version> match archive ~A{sarge,etch,sid} match origin ~O{debian,…} match priority ~p{extra,important,optional,required,standard} match essential packages ~E match virtual packages ~v match new packages ~N match with pending action ~a{install,upgrade,downgrade,remove,purge,hold,keep} match installed packages ~i match installed packages with A-mark (auto installed package) ~M match installed packages without A-mark (administrator selected package) ~i!~M match installed and upgradable packages ~U match removed but not purged packages ~c match removed, purged or can-be-removed packages ~g match packages with broken relation ~b match packages with broken depends/predepends/conflict ~B<type> match packages whose control files define relation <type> to the <term> package ~D[<type>:]<term> match packages whose control files define broken relation <type> to the <term> package ~DB[<type>:]<term> match packages to which the <term> package defines relation <type> ~R[<type>:]<term> match packages to which the <term> package defines broken relation <type> ~RB[<type>:]<term> match packages to which some other installed packages depend on ~R~i match packages to which no other installed packages depend on !~R~i match packages to which some other installed packages depend or recommend on ~R~i|~Rrecommends:~i match <term> package with filtered version ~S filter <term> match all packages (true) ~T match no packages (false) ~F
Here, 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). relation <type> is one of (depends, predepends, recommends, suggests, conflicts, replaces, provides). the default relation type is "depends". When <regex_pattern> is a null string, place "~T" immediately after the command. Short cuts: "~P<term>" == "~Dprovides:<term>" "~C<term>" == "~Dconflicts:<term>" "…~W term" == "(…|term)" Users familiar with mutt will 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". 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.
Dependency resolution of aptitude The selection of a package in aptitude not only pulls in packages which are defined in its "Depends:" list but also defined in the "Recommends:" list if the menu "F10 → Options → Dependency handling" is set accordingly. These auto installed packages are removed automatically if they are no longer needed under aptitude. Before the lenny release, apt-get and other standard APT tools did not offer the autoremove functionality.
Package activity logs You can check package activity history in the log files. The log files for package activities. file content /var/log/dpkg.log Log of dpkg level activity for all package activities. /var/log/apt/term.log Log of generic APT activity. /var/log/aptitude Log of aptitude command activity.
In reality, it is not so easy to get meaningful understanding quickly out from these logs. See for easier way.
Aptitude advantages Aptitude has advantages over other APT based packaging systems (apt-get, apt-cache, synaptic, …): aptitude removes unused auto installed packages automatically using its own extra layer of package state file (/var/lib/aptitude/pkgstates). (For new "lenny", other APT does the same.) aptitude makes it easy to resolve package conflicts and to add recommended packages. aptitude makes it easy to keep track of obsolete software by listing under "Obsolete and Locally Created Packages". aptitude gives a log of its history in "/var/log/aptitude". aptitude offers access to all versions of the package if available. aptitude includes a fairly powerful regex based system for searching particular packages and limiting the package display. aptitude in the full screen mode has su functionality embedded and can be run from normal user until you really need administrative privileges. For the old etch release version, synaptic also gives you the history log; apt-get did not but you can rely on the log of dpkg. Anyway, aptitude is nice for interactive console use.
Examples of aptitude operations Here are few examples of aptitude(8) operations.
List packages with regex matching package name The following command lists packages with regex matching names. $ aptitude search '~n(pam|nss).*ldap' p libnss-ldap - NSS module for using LDAP as a naming service p libpam-ldap - Pluggable Authentication Module allowing LDAP interfaces This is quite handy for you to find the exact name of a package.
Browse with the regex matching The regex "~dipv6" in the "New Flat Package List" view with "l" prompt, limits view to packages with the matching description and let you browse their information interactively.
Purge removed packages for good You can purge all remaining configuration files of removed packages: # aptitude search '~c' check results # aptitude purge '~c' You may want to do the similar in the interactive mode for fine grained control. You provide the regex "~c" in the "New Flat Package List" view with "l" prompt. This limits the package view only to regex matched packages, i.e., "removed but not purged". All these regex matched packages can be shown by pressing "[" at top level headings. Then you press "_" at top level headings such as "Installed Packages". Only regex matched packages under the heading are marked to be purged by this. You can exclude some packages to be purged by pressing "=" interactively for each of them. This technique is quite handy and works for many other command keys.
Tidy auto/manual install status Here is how I tidy auto/manual install status for packages (after using non-aptitude package installer etc.): Start aptitude in interactive mode as root. Type "u", "U", "f" and "g" to update and upgrade package list and packages. Type "l" to enter the package display limit as "~i(~R~i|~Rrecommends:~i)" and type "M" over "Installed Packages" as auto installed. Type "l" to enter the package display limit as "~prequired|~pimportant|~pstandard|~E" and type "m" over "Installed Packages" as manual installed. Type "l" to enter the package display limit as "~i!~M" and remove unused package by typing "-" over each of them after exposing them by typing "[" over "Installed Packages". Type "l" to enter the package display limit as "~i" and type "m" over "Tasks" as manual installed. Exit aptitude. Start "apt-get -s autoremove|less" as root to check what are not used. Restart aptitude in interactive mode and mark needed packages as "m". Restart "apt-get -s autoremove|less" as root to recheck REMOVED contain only expected packages. Start "apt-get autoremove|less" as root to autoremove unused packages. The "m" action over "Tasks" is an optional one to prevent mass package removal situation in future.
System wide upgrade with aptitude When moving to a new release etc, you should consider to perform a clean installation of new system even though Debian is upgradable as described below. This provides you a 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 ) 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 "aptitude update; aptitude full-upgrade" command. To upgrade from stable to testing or unstable, you replace "&codename-stable;" in the "/etc/apt/sources.list" example of with "&codename-testing;" 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 some precautionary moves while gathering latest information from mailing list and using common sense: read previous "Release Notes". back up 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: oldstablestabletestingunstable. 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 "aptitude full-upgrade -s" command to assess impact. run the "aptitude full-upgrade" command. It is not wise to skip major Debian release when upgrading between stable releases. 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 .
Advanced package management operations
Advanced package management operations with commandline Here are list of other package management operations for which aptitude is too high-level or lacks required functionalities. List of advanced package management operations. command action COLUMNS=120 dpkg -l <package_name_pattern> list status of an installed package for the bug report. dpkg -L <package_name> list contents of an installed package. dpkg -L <package_name> | egrep '/usr/share/man/man.*/.+' list manpages for an installed package. dpkg -S <file_name_pattern> list installed packages which have matching file name. apt-file search <file_name_pattern> list packages in archive which have matching file name. apt-file list <package_name_pattern> list contents of matching packages in archive. dpkg-reconfigure <package_name> reconfigure the exact package . dpkg-reconfigure -p=low <package_name> reconfigure the exact package with the most detailed question. configure-debian reconfigure packages from the full screen menu. dpkg --audit audit system for partially installed packages. dpkg --configure -a configures all partially installed packages. apt-cache policy <binary_package_name> show available version, priority, and archive information of a binary package. apt-cache madison <package_name> show available version, archive information of a package. apt-cache showsrc <binary_package_name> show source package information of a binary package. apt-get build-dep <package_name> install required packages to build package. apt-get source <package_name> download a source. (from standard archive) dget <URL for dsc file> download a source packages. (from other archive) dpkg-source -x <package_name>_<version>-<debian_version>.dsc build a source tree from a set of source packages ("*.tar.gz" and "*.diff.gz"). debuild binary build package(s) from a local source tree. make-kpkg kernel_image build a kernel package from a kernel source tree. make-kpkg --initrd kernel_image build a kernel package from a kernel source tree with initramfs enabled. dpkg -i <package_name><version>-<debian_version><arch>.deb install a local package to the system. debi <package_name><version>-<debian_version><arch>.dsc install local package(s) to the system. dpkg --get-selection '*' >selection.txt save dpkg level package selection state information. dpkg --set-selection <selection.txt set dpkg level package selection state information.
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: All system configuration and installation commands require to be run from root. Unlike aptitude which uses regex (see ), other package management commands use pattern like shell glob (see ). 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 "deb-src" 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 . make-kpkg command requires the kernel-package package (see ). see for general packaging. The source package format described here as a set of source packages ("*.tar.gz" and "*.diff.gz") is format 1.0 which is still popular. See more on dpkg-source(1) for other newer formats.
Verify installed package files The installation of debsums enables verification of installed package files against MD5sum values in the "/var/lib/dpkg/info/*.md5sums" file with debsums(1). See for how MD5sum works. 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.
Safeguard for package problems Many users prefer to follow the unstable release of the Debian system for its new features and packages. This makes the system more prone to be hit by the critical package bugs. The installation of the apt-listbugs package will provide safeguard to the critical bugs by checking Debian BTS automatically for critical bugs when upgrading with APT system. The installation of the apt-listchanges package will provide important news in "NEWS.Debian" when upgrading with APT system.
Search on the package meta data Although visiting Debian site http://packages.debian.org/ facilitates easy ways to search on the package meta data these days, let's look into more traditional ways. The grep-dctrl(1), grep-status(1), and grep-available(1) commands can be used to search any file which has the general format of a Debian package control file. The "dpkg -S <file_name_pattern>" can be used search package names which contain files with the matching name installed by dpkg. But this overlooks files created by the maintainer scripts. 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 will let you identify: the package name which installs, creates or modifies particular file which match pattern. the package name which asks the installation query words which match pattern. If you wish to look up package dependency recursively, you should use apt-rdepends(8).
Debian package management internals Let's learn how the Debian package management system works internally. This should help you to create your own solution to some package problems.
Archive meta data Meta data files for each distribution are stored under "dist/<codename>" on each Debian mirror sites, e.g., "http://ftp.us.debian.org/debian/". Its archive structure can be browsed by the web browser. There are 6 types of key meta data: The content of the Debian archive meta data. file location content Release top of distribution archive description and integrity information Release.gpg top of distribution signature file for the "Release" file signed with the archive key Contents-<architecture> top of distribution list of all files for all the packages in the pertinent archive Release top of each distribution/component/architecture combination archive description used for the rule of apt_preferences(5) Packages top of each distribution/component/binary-architecture combination concatenated debian/control for binary packages Sources top of each distribution/component/source combination 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.
Top level "Release" file and authenticity The top level "Release" file is used for signing the archive under the secure APT system. Each suite of the Debian archive has a top level "Release" file, e.g., "http://ftp.us.debian.org/debian/dists/unstable/Release": Origin: Debian Label: Debian Suite: unstable Codename: sid Date: Sat, 26 Jan 2008 20:13:58 UTC Architectures: alpha amd64 arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc Components: main contrib non-free Description: Debian x.y Unstable - Not Released MD5Sum: e9f11bc50b12af7927d6583de0a3bd06 22788722 main/binary-alpha/Packages 43524d07f7fa21b10f472c426db66168 6561398 main/binary-alpha/Packages.gz ... Here, you can find my rationale to use the "suite", "codeneme", and "components" in . The "distribution" is used when referring to both "suite" and "codeneme". 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 ftp-master.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 . 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 ).
Archive level "Release" files The archive level "Release" files are used for the rule of apt_preferences(5). There are archive level "Release" files for all archive locations specified by "deb" line in "/etc/apt/sources.list", such as "http://ftp.us.debian.org/debian/dists/unstable/main/binary-amd64/Release" or "http://ftp.us.debian.org/debian/dists/sid/main/binary-amd64/Release": Archive: unstable Component: main Origin: Debian Label: Debian Architecture: amd64 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, volatile-sloppy, and &codename-stable;-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": 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 ).
Fetching of the meta data for the package When APT tools, such as aptitude, apt-get, synaptic, apt-file, auto-apt…, are used, we need to update the local copies of the meta data containing the Debian archive information. These local copies have file names corresponding to the specified distribution, component, and architecture names in the "/etc/apt/sources.list" (see ) as: "/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_Release", "/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_Release.gpg", "/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_<component>_binary-<architecture>_Packages", "/var/lib/apt/lists/ftp.us.debian.org_debian_dists_<distribution>_<component>_source_Sources", and "/var/cache/apt/apt-file/ftp.us.debian.org_debian_dists_<distribution>_Contents-<architecture>.gz" (for apt-file). First 4 types of files are shared by all the pertinent APT commands and updated from command line by "apt-get update" and "aptitude update". The "Packages" meta data are updated if there is the "deb" line in "/etc/apt/sources.list". The "Sources" meta data are updated if there is the "deb-src" line in "/etc/apt/sources.list". The "Packages" and "Sources" meta data contain "Filename:" stanza pointing to the file location of the binary and source packages. Currently, these packages are located under the "pool/" directory tree for the improved transition over the releases. Local copies of "Packages" meta data can be interactively searched with the help of aptitude. The specialized search command grep-dctrl(1) can search local copies of "Packages" and "Sources" meta data. Local copy of "Contents-<architecture>" meta data can be updated by "apt-file update" and its location is different from other 4 ones. See apt-file(1). (The auto-apt uses different location for local copy of "Contents-<architecture>.gz" as default.)
The package state for APT In addition to the remotely fetched meta data, the APT tool after lenny stores its locally generated installation state information in the "/var/lib/apt/extended_states" which is used by all APT tools to track all auto installed packages.
The package state for aptitude In addition to the remotely fetched meta data, the aptitude command stores its locally generated installation state information in the "/var/lib/aptitude/pkgstates" which is used only by it.
Local copies of the fetched packages All the remotely fetched packages via APT mechanism are stored in the "/var/cache/apt/packages" until they are cleaned.
The Debian package file name The Debian package files has particular name structures: The name structure of Debian packages. package type name structure The binary package (a.k.a deb) <package-name>_<epoch>:<upstream-version>-<debian.version>-<architecture>.deb The binary package for the debian-installer (a.k.a udeb) <package-name>_<epoch>:<upstream-version>-<debian.version>-<architecture>.udeb The source package (upstream source) <package-name>_<epoch>:<upstream-version>-<debian.version>.tar.gz The source package (Debian changes) <package-name>_<epoch>:<upstream-version>-<debian.version>.diff.gz The source package (description) <package-name>_<epoch>:<upstream-version>-<debian.version>.dsc
where, The usable characters for each component in the Debian package names. name component usable characters (regex) existance <package-name> [a-z,A-Z,0-9,.,,-] required <epoch>: [0-9]+: optional <upstream-version> [a-z,A-Z,0-9,.,,-,:] required <debian.version> [a-z,A-Z,0-9,.,,~] optional
You can check package version order by dpkg(1), e.g., "dpkg --compare-versions 7.0 gt 7.~pre1 ; echo $?" . 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 non-essential 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 dpkg command dpkg(1) is the lowest level tool for the Debian package management. This is very powerful and needs to be used with care. The fetched package is processed by dpkg in the following order: unpack the deb file ("ar -x" equivalent) preinst using debconf(1) install the package content to the system ("tar -x" equivalent) postinst using debconf(1) The debconf system provides standardized user interaction with I18N and L10N () supports. While installing package called "<package_name>", dpkg creates several files and executes several scripts. The notable files for dpkg. file contents /var/lib/dpkg/info/<package_name>.conffiles list of configuration files. (user modifiable) /var/lib/dpkg/info/<package_name>.list list of files and directories installed by the package. /var/lib/dpkg/info/<package_name>.md5sums list of MD5 hash values for files installed by the package. /var/lib/dpkg/info/<package_name>.preinst package script run before the package installation. /var/lib/dpkg/info/<package_name>.postinst package script run after the package installation. /var/lib/dpkg/info/<package_name>.prerm package script run before the package removal. /var/lib/dpkg/info/<package_name>.postrm package script run after the package removal. /var/lib/dpkg/info/<package_name>.config package script for debconf system. /var/lib/dpkg/alternatives/<package_name> the alternative information used by the update-alternatives command. /var/lib/dpkg/available the availability information for all the package. /var/lib/dpkg/diversions the diversions information used by dpkg(1) and set by`dpkg-divert`(8) /var/lib/dpkg/statoverride the stat override information used by dpkg(1) and set by`dpkg-statoverride`(8) /var/lib/dpkg/status the status information for all the packages. /var/lib/dpkg/status-old the first-generation backup of the "var/lib/dpkg/status" file. /var/backups/dpkg.status* 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. 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.
The update-alternative command The Debian system has mechanism to install somewhat overlapping programs peacefully using update-alternatives(8). For example, you can make the vi command select to run vim while installing both vim and nvi packages: $ ls -l $(type -p vi) lrwxrwxrwx 1 root root 20 2007-03-24 19:05 /usr/bin/vi -> /etc/alternatives/vi $ sudo update-alternatives --display vi ... $ sudo update-alternatives --config vi Selection Command ---------------------------------------------- 1 /usr/bin/vim *+ 2 /usr/bin/nvi Enter to keep the default[*], or type selection number: 1 The Debian alternatives system keeps its selection as symlinks in "/etc/alternatives/". The selection process uses corresponding file in "/var/lib/dpkg/alternatives/".
The dpkg-statoverride command Stat overrides provided by the dpkg-statoverride(8) command are a way to tell dpkg(1) to use a different owner or mode for a file when a package is installed. If "--update" is specified and file exists, it is immediately set to the new owner and mode. The direct alteration of owner or mode for a file owned by the package using chmod or chown commands by the system administrator will be reset by the next upgrade of the package. I use the word file here, but in reality this can be any filesystem object that dpkg handles, including directories, devices, etc.
The dpkg-divert command File diversions provided by the dpkg-divert(8) command are a way of forcing dpkg(1) not to install a file into its default location, but to a diverted location. The use of dpkg-divert is meant for the package maintenance scripts. Its use by the system administrator is deprecated.
Recovery from a broken system When running unstable system, the administrator is expected to recover from broken package management situation. Some methods described here are high risk actions. You have been warned!
Incompatibility with old user configuration If a desktop GUI program experienced instability after significant upstream version upgrade, you should suspect interferences with old local configuration files created by it. If it is stable under newly created user account, this hypothesis is confirmed. (This is a bug of packaging and usually avoided by the packager.) To recover stability, you should move corresponding local configuration files and restart the GUI program. You may need to read old configuration file contents to recover configuration information later. (Do not erase them too quickly.)
Different packages with overlapped files Archive level package management systems, such as aptitude(8) or apt-get(1), will not even try to install packages with overlapped files using package dependencies (see ). Errors by the package maintainer or deployment of inconsistently mixed source of archives (see ) by the system administrator may create situation with incorrectly defined package dependencies. When you install a package with overlapped files using aptitude(8) or apt-get(1) under such situation, dpkg(1) which unpacks package ensures to return error to the calling program without overwriting existing files. 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>
Fixing broken package script When a command in the package script returns error for some reason and the script exits with error, the package management system aborts their action and ends up with partially installed packages. When a package contains bugs in its removal scripts, the package may become impossible to remove and quite nasty. For the package script problem of "<package_name>", you should look for: "/var/lib/dpkg/info/<package_name>.preinst", "/var/lib/dpkg/info/<package_name>.postinst", "/var/lib/dpkg/info/<package_name>.prerm", and "/var/lib/dpkg/info/<package_name>.postrm". You edit the offending part of the script from the root: by prepending it with "#" or, by appending it with "|| true". Then configures all partially installed packages by: # dpkg --configure -a
Rescue using the dpkg command Since dpkg is very low level package tool, it can function under the very bad situation such as unbootable system without network connection. Let's assume foo package was broken and needs to be replaced. You may still find cached copies of older bug free version of foo package in the package cache directory: "/var/cache/apt/archives/". (If not, you can download it from archve of http://snapshot.debian.net/ or copy it from package cache of a functioning machine.) If you can boot the system, you may install it by: # dpkg -i /path/to/foo_<old_version>_<arch>.deb If system breakage is minor, you may alternatively downgrade the whole system as using the higher level APT system. If your system is unbootable from harddisk, you should seek other ways to boot it. For example, you can: boot the system using the debian-installer CD in rescue mode, mount the unbootable system on the harddisk to "/target", install older version of foo package by: # dpkg --root /target -i /path/to/foo_<old_version>_<arch>.deb This second example works even if the dpkg command on the harddisk is broken. Any GNU/Linux system started by another system on harddisk, 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", "--force-depends" and other options. If you do this, you need to make serious effort to restore proper dependency later. See dpkg(8) for details. When your system is seriously broken, you should make a full backup of system to a safe place (see ) and should perform a clean installation. This is less time consuming and produces better results in the end.
Recover package selection data If "/var/lib/dpkg/status" becomes corrupt for any reason, the Debian system loses package selection data and suffers severely. Look for the old "/var/lib/dpkg/status" file at "/var/lib/dpkg/status-old" or "/var/backups/dpkg.status.*". Keeping "/var/backups/" in a separate partition may be a good idea since this directory contains lots of important system data. For serious breakage, I recommend to make fresh re-install after making backup of the system. Even if everything in "/var/" is gone, you can still recover some information from directories in "/usr/share/doc/" to guide your new installation. reinstall minimal (desktop) system place old system at "/path/to/old/system/" # cd /path/to/old/system/usr/share/doc # ls -1 >~/ls1.txt # cd /usr/share/doc # ls -1 >>~/ls1.txt # cd # sort ls1.txt | uniq | less Then you will be presented with package names to install. (There may be some non-package names such as "texmf".)
Tips for the package management
How to pick Debian packages You can seek packages which satisfy your needs with aptitude from the package description or from the list under "Tasks". When you encounter more than 2 similar packages and wonder which one to install without "trial and error" efforts, you should use some common sense. I consider following points are good indications of preferred packages. essential: yes > no component: main > contrib > non-free priority: required > important > standard > optional > extra tasks: packages listed in tasks such as "Desktop environment" packages selected by the dependency package (e.g., python2.4 by python) popcon: higher in the vote and install number changelog: regular updates by the maintainer BTS: No RC bugs (no critical, no grave, and no serious bugs) BTS: responsive maintainer to bug reports BTS: higher number of the recently fixed bugs BTS: lower number of remaining non-wishlist bugs Debian being a volunteer project with distributed development model, its archive contains many packages with different focus and quality. You must make your own decision what to do with them.
Packages from mixed source of archives Installing packages from mixed source of archives is not supported by the official Debian distribution except for officially supported particular combinations of archives such as stable with security updates and volatile updates. Here is an example of operations to include specific newer upstream version packages found in unstable while tracking testing for single occasion: change the "/etc/apt/sources.list" file temporarily to single "unstable" entry run "aptitude update" run "aptitude install <package-name>" recover the original "/etc/apt/sources.list" file for testing run "aptitude update" 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. 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: 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 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. 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 ). You should consider chroot or similar techniques (see ) to run programs from different archives.
Tweaking candidate version In lenny, aptitude(8) has a bug for handling "/etc/apt/preferences" file. (Bug#514930) Without the "/etc/apt/preferences" file, APT system choses the latest available version as the candidate version using the version string. This is the normal state and most recommended usage of APT system. All officially supported combinations of archives do not require the "/etc/apt/preferences" file since some archives which should not be used as the automatic source of upgrades are marked as NotAutomatic and dealt properly. 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 ) 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. Use of apt-pinning by a novice user is sure call for major troubles. You must avoid using apt-pinning except when you absolutely need it. 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. Archive level Release files (see ) 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. 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. Even if you do not create the "/etc/apt/preferences" file, you can do fairly complex system operations (see and ) 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 ). Pin-Priority value of each package is defined by "Pin-Priority" entries in the "/etc/apt/preferences" file or uses its default value. List of the default Pin-Priority value for each package source type. default Pin-Priority package source type 990 the target release archive 500 the normal archive 100 the installed package 1 the NotAutomatic archive
The target release archive can be set: by "/etc/apt/apt.conf", e.g., "APT::Default-Release "stable";" line in it, or by "-t" option argument, e.g., "apt-get install -t testing some-package". The NotAutomatic archive can be set: by the archive level Release file (see ) containing "NotAutomatic: yes" in archive. 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.org etch-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: 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 and set the "/etc/apt/preferences" file as: 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" for squeeze) will upgrade packages which were installed from testing archive using current testing archive and packages which were installed from unstable archive using current unstable archive. Be careful not to remove "testing" entry from the "/etc/apt/sources.list" file. Without "testing" entry in it, APT system will upgrade packages using newer unstable archive. 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. 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 will never be 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 lists all those packages at the top of it as: Package: <package-1> Pin: release a=unstable Pin-Priority: 700 Package: <package-2> Pin: release a=unstable Pin-Priority: 700 ... These will 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 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: 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 ). 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.
Volatile and Backports.org There are debian-volatile project and backports.org archives which provide updgrade packages for stable. Do not use all packages available in the NotAutomatic archives such as &codename-stable;-backports and volatile-sloppy. Use only selected packages which fits your needs. backports.org is a non-Debian archive, although its packages are signed by Debian developers. Archive level Release files (see ) are used for the rule of apt_preferences(5). Thus apt-pinning works only with "code" name for volatile Debian archives. This is different from other Debian archives. For example, you can do "Pin: release a=&codename-stable;" but can not do "Pin: release a=stable" in the "/etc/apt/preferences" file for volatile Debian archives. Here is an example of apt-pinning technique to include specific newer upstream version packages found in &codename-stable;-backports while tracking &codename-stable; and volatile. You list all required archives in the "/etc/apt/sources.list" file as: deb http://ftp.us.debian.org/debian/ &codename-stable; main contrib non-free deb http://security.debian.org/ &codename-stable;/updates main contrib deb http://volatile.debian.org/debian-volatile/ &codename-stable;/volatile main contrib non-free deb http://volatile.debian.org/debian-volatile/ &codename-stable;/volatile-sloppy main contrib non-free deb http://backports.org/debian/ &codename-stable;-backports main contrib non-free The default Pin-Priority value for backports.org and volatile-sloppy archives are always 1 (<<100) since they are NotAutomatic archive (see ). There is no need to set Pin-Priority value explicitly in the "/etc/apt/preferences" file just to use for backports.org and volatile-sloppy archive unless you wish to track packages automatically for next upgrading. So whenever you wish to install a package named "<package-name>" with its dependency from &codename-stable;-backports archive, you use following command while switching target release with "-t" option: $ sudo apt-get install -t &codename-stable;-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: Package: <package-1> Pin: release o=Backports.org archive Pin-Priority: 700 Package: <package-2> Pin: release o=volatile.debian.org Pin-Priority: 700 ... Alternatively, with the "/etc/apt/preferences" file as: Package: * Pin: release a=stable , o=Debian Pin-Priority: 500 Package: * Pin: release a=&codename-stable;, o=volatile.debian.org Pin-Priority: 500 Package: * Pin: release a=&codename-stable;-backports, o=Backports.org archive Pin-Priority: 200 Package: * Pin: release a=&codename-stable;-sloppy, o=volatile.debian.org Pin-Priority: 200 execution of "apt-get upgrade" and "apt-get dist-upgrade" (or "aptitude safe-upgrade" and "aptitude full-upgrade" for squeeze) will upgrade 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.
Automatic download and upgrade of packages The apt package comes with its own cron script "/etc/cron.daily/apt" to support the automatic download of packages. This script can be enhanced to perform the automatic upgrade of packages by installing the unattended-upgrades package. These can be customized by parameters in "/etc/apt/apt.conf.d/02backup" and "/etc/apt/apt.conf.d/50unattended-upgrades" as described in "/usr/share/doc/unattended-upgrades/README". The unattended-upgrades package is mainly intended for the security upgrade for the stable system. If the risk of breaking an existing stable system by the automatic upgrade is smaller than that of the system broken by the intruder using its security hole which has been closed by the security update, you should consider using this automatic upgrade with configuration parameters: APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::Unattended-Upgrade "1"; If you are running an unstable system, you do not want to use the automatic upgrade since it will certainly break system some day. Even for such unstable case, you may still want to download packages in advance to save time for the interactive upgrade with configuration parameters: APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Download-Upgradeable-Packages "1"; APT::Periodic::Unattended-Upgrade "0";
Limit download bandwidth for APT If you want to limit the download bandwidth for APT to e.g. 800Kib/sec (=100kiB/sec), you should configure APT with its configuration parameter with: APT::Acquire::http::Dl-Limit "800";
Emergency downgrading Downgrading is not officially supported by the Debian by design. It should be done only as a part of emergency recovery process. Despite of this situation, it is known to work well in many incidents. For critical systems, You should backup all important data on the system after the recovery operation and re-install the new system from the scratch. You may be lucky to downgrade from newer archive to older archive to recover from broken system upgrade by manipulating candidate version (see ). This is lazy alternative to tedious actions of many "dpkg -i <broken-package>_<old-version>.deb" commands (see ). For downgrading system tracking unstable to testing, change the "/etc/apt/sources.list" file from: deb http://ftp.us.debian.org/debian/ &codename-unstable; main contrib non-free to: deb http://ftp.us.debian.org/debian/ &codename-testing; main contrib and set the "/etc/apt/preferences" file as: Package: * Pin: release a=testing Pin-Priority: 1010 Then run "apt-get dist-upgrade" to force downgrading of packages across the system. You should remove this special "/etc/apt/preferences" file after the downgrading. 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.
Who uploaded the package? Although the maintainer name listed in "/var/lib/dpkg/available" and "/usr/share/doc/package_name/changelog" provide some information on "who is behind the packaging activity", the actual uploader of the package is somewhat obscure. who-uploads(1) in the devscripts package identifies the actual uploader of Debian source packages.
The equivs package If you are to compile a program from source to replace the Debian package, it is best to make it into a real local debianized package (*.deb) and use private archive. If you chose to compile a program from source and to install them under "/usr/local" instead, you may need to use equivs as a last resort to satisfy the missing package dependency. Package: equivs Priority: extra 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.
Port a package to the stable system For partial upgrades of the stable system, rebuilding a package within its environment using the source package is desirable. This avoids massive package upgrades due to their dependencies. First, add the following entries to the "/etc/apt/sources.list" of a stable system: deb-src http://http.us.debian.org/debian unstable main contrib non-free Then install required packages for the compilation and download the source package by: # apt-get update # apt-get dist-upgrade # apt-get install fakeroot devscripts build-essential $ apt-get build-dep foo $ apt-get source foo $ cd foo* adjust package if needed. $ dch -i bump package version, e.g. one appended with "+bp1". $ debuild $ cd .. # debi foo*.changes
Proxy server for APT Since mirroring whole subsection of Debian archive wastes disk space and network bandwidth, deployment of a local proxy server for APT is desirable consideration when you administer many systems on LAN. APT can be configure to use generic web (http) proxy servers such as squid (see ) as described in apt.conf(5) and in "/usr/share/doc/apt/examples/configure-index.gz". The "$http_proxy" environment variable can be used to override proxy server setting in the "/etc/apt/apt.conf" file. There are proxy tools specially for Debian archive. You should check BTS before using them. List of the proxy tools specially for Debian archive package popcon size description approx &pop-approx; &size-approx; caching proxy server for Debian archive files (compiled OCaml program) apt-proxy &pop-aptproxy; &size-aptproxy; Debian archive proxy and partial mirror builder (Python program) apt-cacher &pop-aptcacher; &size-aptcacher; Caching proxy for Debian package and source files (Perl program) apt-cacher-ng &pop-aptcacherng; &size-aptcacherng; Caching proxy for distribution of software packages (compiled C++ program) debtorrent &pop-debtorrent; &size-debtorrent; Bittorrent proxy for downloading Debian packages (Python program)
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.
Small public package archive Here is an example for creating a small public package archive compatible with the modern secure APT system (see ). Let's assume few things: Account name: "foo" Host name: "www.example.com" Required packages: apt-utils, gnupg, and other packages. URL: "http://www.example.com/~foo/" displays "/home/foo/public_html/index.html" Architecture of packages: "amd64" One time setup of APT archive on your server system: Create an archive key of Foo on server system: $ ssh foo@www.example.com $ gpg --gen-key ... $ gpg -K ... sec 1024D/3A3CB5A6 2008-08-14 uid Foo (ARCHIVE KEY) <foo@www.example.com> ssb 2048g/6856F4A7 2008-08-14 $ gpg --export -a 3A3CB5A6 >foo.public.key The archive key of Foo is "3A3CB5A6" Publish "foo.public.key" file. Create an archive tree called "Origin: Foo": $ 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 Repetitive update of APT archive contents on your server system: 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: $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 foo@www.example.com 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: $ sudo bash # echo "deb http://www.example.com/~foo/debian/ unstable main" \ >> /etc/apt/sources.list # apt-key add foo.public.key If the archive is located on the local file system, you can use "deb file:///home/foo/debian/ …" instead.
Record/copy system configuration To make a local copy of the package and debconf selection states: # dpkg --get-selections '*' > selection.dpkg # debconf-get-selections > selection.debconf Here, "*" makes "selection.dpkg" to include package entries for "purge" too. You can transfer these 2 files to another computer, and install there with: # dselect update # debconf-set-selections < myselection.debconf # dpkg --set-selections < myselection.dpkg # apt-get -u dselect-upgrade # or dselect install 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.
Convert or install an alien binary package alien(1) enables the conversion of binary packages provided in Red Hat rpm, Stampede slp, Slackware tgz, and Solaris pkg file formats into a Debian deb package. If you want to use a package from another Linux distribution than the one you have installed on your system, you can use alien to convert it from your preferred package format and install it. alien also supports LSB packages. 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 binary-only packages which are LSB complient or statically linked. For free softwares, you should use their source packages to make real Debian packages.
Extract package without dpkg The current "*.deb" package contents can be extracted without using dpkg(1) on any Unix-like environment using standard ar(1) and tar(1). # ar x /path/to/dpkg_<version>_<arch>.deb # ls total 24 -rw-r--r-- 1 bozo bozo 1320 2007-05-07 00:11 control.tar.gz -rw-r--r-- 1 bozo bozo 12837 2007-05-07 00:11 data.tar.gz -rw-r--r-- 1 bozo bozo 4 2007-05-07 00:11 debian-binary # mkdir control # mkdir data # tar xvzf control.tar.gz -C control # tar xvzf data.tar.gz -C data You can also browse package content using the mc command.
More readings for the package management You should read: aptitude(8), dpkg(1), tasksel(8), apt-get(8), apt-config(8), apt-key(8), sources.list(5), apt.conf(5), and apt_preferences(5); "/usr/share/doc/apt-doc/guide.html/index.html" and "/usr/share/doc/apt-doc/offline.html/index.html" from the apt-doc package; and "/usr/share/doc/aptitude/html/en/index.html" from the aptitude-doc-en package. The official and detailed secondary information on the Debian archive are given by: "Debian Policy Manual Chapter 2 - The Debian Archive", "Debian Developer's Reference, Chapter 4 - Resources for Debian Developers 4.6 The Debian archive", and "The Debian GNU/Linux FAQ, Chapter 5 - The Debian FTP archives". The tutorial for building of a Debian package for Debian users is given by: "Debian New Maintainers' Guide".
The system initialization 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.
An overview of the boot strap process The computer system undergoes several phases of boot strap processes from the power-on event until it offers the fully functional operating system (OS) to the user. For simplicity, I will limit discussion to the typical PC platform with the default installation. The typical boot strap process is like a four-stage rocket. Each stage rocket hands over the system control to the next stage one. Here each stage corresponds to: Stage 1: the BIOS Stage 2: the boot loader Stage 3: the mini-Debian system Stage 4: the normal Debian system 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. 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 (). Please seek the platform specific documentations elsewhere for such a case.
Stage 1: the BIOS The BIOS is the 1st stage of the boot process which is started by the power-on event. The BIOS residing on the read only memory (ROM) is excuted from the particular memory address to which the program counter of CPU is initialized by the power-on event. This BIOS performs the basic initialization of the hardware (POST: power on self test) and hands the system control to the next step which you provide. The BIOS is usually provided with the hardware. The BIOS startup screen usually indicates what key(s) to press to enter the BIOS setup screen to configure the BIOS behavior. Popular keys used are F1, F2, F10, Esc, Ins, and Del. If your BIOS startup screen is hidden by a nice graphics screen, you may press some keys such as Esc to disable this. These keys are highly dependent on the hardware. The hardware location and the priority of the code started by the BIOS can be selected from the BIOS setup screen. Typically, the first few sectors of the first found selected device (hard disk, floppy disk, CD-ROM, …) are loaded to the memory and this initial code is executed. This initial code can be: the boot loader code, the kernel code of the stepping stone OS such as FreeDOS, or the kernel code of the target OS if it fits in this small space. Typically, the system is booted from the specified partition of the primary hard disk partition. First 2 sectors of the hard disk on legacy PC contain the master boot record (MBR). The disk partition information including the boot selection is recorded at the end of this MBR. The first boot loader code executed from the BIOS occupies the rest of this MBR.
Stage 2: the boot loader The boot loader is the 2nd stage of the boot process which is started by the BIOS. It loads the system kernel image and the initrd image to the memory and hands control over to them. This initrd image is the root filesystem image and its support depends on the bootloader used. The Debian system normally uses the Linux kernel as the default system kernel. The initrd image for the current 2.6 Linux kernel is technically the initramfs (initial RAM filesystem) image. The initramfs image is a gzipped cpio archive of files in the root filesystem. The default install of the Debian system places first-stage GRUB boot loader code into the MBR for the PC platform. There are many boot loaders and configuration options available. List of boot loaders. bootloader package popcon size initrd description GRUB Legacy grub &pop-grub; &size-grub; Supported This is smart enough to understand disk partitions and file systems such as vfat, ext3, …. (lenny default) GRUB 2 grub-pc &pop-grubpc; &size-grubpc; Supported This is smart enough to understand disk partitions and file systems such as vfat, ext3, …. GRUB 2 grub-rescue-pc &pop-grubrescuepc; &size-grubrescuepc; Supported This is GRUB 2 bootable rescue images (CD and floppy) (PC/BIOS version) Lilo lilo &pop-lilo; &size-lilo; Supported This relies on the sector locations of data on the hard disk. (Old) Isolinux syslinux &pop-syslinux; &size-syslinux; Supported This understands the ISO9660 file system. This is used by the boot CD. Syslinux syslinux &pop-syslinux; &size-syslinux; Supported This understands the MSDOS file system (FAT). This is used by the boot floppy. Loadlin loadlin &pop-loadlin; &size-loadlin; Supported New system is started from the FreeDOS/MSDOS system. MBR by Neil Turton mbr &pop-mbr; &size-mbr; Not supported This is free software which substitutes MSDOS MBR. This only understands disk partitions.
Do not play with boot loaders without having bootable rescue media (CD or floppy) created from images in the grub-rescue-pc package. It will let you boot your system even without functioning bootloader on the harddisk. For GRUB Legacy, the menu configuration file is located at "/boot/grub/menu.lst". For example, it has entries like: title Debian GNU/Linux root (hd0,2) kernel /vmlinuz root=/dev/hda3 ro initrd /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 like: menuentry "Debian GNU/Linux" { set root=(hd0,3) linux /vmlinuz root=/dev/hda3 initrd /initrd.img } For these examples, these GRUB parameters mean: The meaning of GRUB parameters. GRUB parameter meaning root Use 3rd partition on the primary disk by setting it as "(hd0,2)" in GRUB legacy or as "(hd0,3)" in GRUB 2. kernel Use kernel located at "/vmlinuz" with kernel parameter: "root=/dev/hda3 ro". initrd Use initrd/initramfs image located at "/initrd.img".
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. UUID (see ) may be used to identify a block special device instead of its file name such as "/dev/hda3", e.g."root=UUID=81b289d5-4341-4003-9602-e254a17ac232 ro". You can start a boot loader from another boot loader using techniques called chain loading. See "info grub" and grub-install(8).
Stage 3: the mini-Debian system The mini-Debian system is the 3rd stage of the boot process which is started by the boot loader. It runs the system kernel with its root filesystem on the memory. This is an optional preparatory stage of the boot process. 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 mini-Debian system offers flexibility to the boot process such as adding kernel modules before the main boot process or mounting the root file system 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). You need to use "-n" option for mount command when you are on the readonly root file system.
Stage 4: the normal Debian system 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 harddisk 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. Following is a simplified overview of this main boot process: The Debian system goes into runlevel N (none) to initialize the system by following the "/etc/inittab" description. The Debian system goes into runlevel S to initialize the system under the single-user mode to complete hardware initialization etc. 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 scripts executed by the init system are located in the directory "/etc/init.d/". For alternative boot mechanism to the sysv-rc package using a single configuration file "/etc/runlevel.conf", see the file-rc package. Both mechanisms are compatible through "/etc/init.d/rc", "/etc/init.d/rcS", "/usr/sbin/update-rc.d", and "/usr/sbin/invoke-rc.d" scripts.
The meaning of the runlevel Each runlevel uses a directory for its configuration and has specific meaning: List of runlevels and meanings. runlevel directory meaning N none System bootup (NONE). There is no "/etc/rcN.d/" directory. 0 /etc/rc0.d/ Halt the system. S /etc/rcS.d/ Single-user mode on boot. The lower case "s" can be used as alias. 1 /etc/rc1.d/ Single-user mode switched from multi-user mode. 2 /etc/rc2.d/ Multi-user mode. 3 /etc/rc3.d/ ,, 4 /etc/rc4.d/ ,, 5 /etc/rc5.d/ ,, 6 /etc/rc6.d/ Reboot the system. 7 /etc/rc7.d/ Valid multi-user mode but not normally used. 8 /etc/rc8.d/ ,, 9 /etc/rc9.d/ ,,
You can change the runlevel from the console to, e.g., 4 by: $ sudo telinit 4 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 …) 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.
The configuration of the runlevel The names of the symlinks in the runlevel directories have the form "S<2-digit-number><original-name>" or "K<2-digit-number><original-name>". The 2-digit-number is used to determine the order in which to run the scripts. "S" is for "Start" and "K" is for "Kill". When init(8) or telinit(8) commands goes into the runlevel to "<n>": the script names starting with a "K" in "/etc/rc<n>.d/" are executed in alphabetical order with the single argument "stop". (killing services) the script names starting with an "S" in "/etc/rc<n>.d/" are executed in alphabetical order with the single argument "start". (starting services) For example, if you had the links "S10sysklogd" and "S20exim4" in a runlevel directory, "S10sysklogd" would run before "S20exim4". It is not advisable to make any changes to symlinks in "/etc/rcS.d/" unless you know better than the maintainer.
The runlevel management example For example, let's set up runlevel system somewhat like Red Hat Linux, i.e.: to start the system in runlevel=3 as the default, not to start gdm(1) in runlevel=(0,1,2,6), and to start gdm(1) in runlevel=(3,4,5). This can be done by using editor on the "/etc/inittab" file to change starting runlevel and using user friendly runlevel management tools such as sysv-rc-conf or bum to edit the runlevel. If you are to use command line only instead, here is how you do it (after the default installation of the gdm package and selecting it to be the choice of display manager): # cd /etc/rc2.d ; mv S21gdm K21gdm # cd /etc ; perl -i -p -e 's/^id:.:/id:3:/' inittab Please note the "/etc/X11/default-display-manager" file is checked when starting the display manager daemons: xdm, gdm, kdm, and wdm. You can still start X from any console shell with the startx(1) command.
The default parameter for each init script The default parameter for each init script in "/etc/init.d/" is given by the corresponding file in "/etc/default/" which contains environment variable assignments only. This choice of directory name is specific to the Debian system. It is roughly the equivalent of the "/etc/sysconfig" directory found in Red Hat Linux and other distributions. For example, "/etc/default/cron" can be used to control how "/etc/init.d/cron" works. The "/etc/default/rcS" file can be used to customize boot-time defaults for motd(5), sulogin(8), etc. If you cannot get the behavior you want by changing such variables then you may modify the init scripts themselves. These are configuration files editable by system administrators.
The hostname The kernel maintains the system hostname. The initscript "/etc/init.d/hostname.sh" sets the system hostname at boot time (using the hostname command) to the name stored in "/etc/hostname". This file should contain only the system hostname, not a fully qualified domain name. To print out the current hostname run hostname(1) without an argument.
Network interface initialization Network interfaces are initialized under single-user mode on boot by the initscript "/etc/init.d/ifupdown-clean" and "/etc/init.d/ifupdown". See for how to configure them.
Network service initialization Many network services (see ) are started directly as daemon processes at boot time by the initscript, e.g., "/etc/rc2.d/S20exim4" (for RUNLEVEL=2) which is a symlink to "/etc/init.d/exim4". Some network services can be started on demand using the super-server, inetd (or its equivalents). The inetd is started at boot time by "/etc/rc2.d/S20inetd" (for RUNLEVEL=2) which is a symlink to "/etc/init.d/inetd". Essentially, inetd allows one running daemon to invoke several others, reducing load on the system. Whenever a request for service arrives, its protocol and service are identified by looking them up in the databases in "/etc/protocols" and "/etc/services". inetd then looks up a normal Internet service in the "/etc/inetd.conf" database, or a Open Network Computing Remote Procedure Call (ONC RPC)/Sun RPC based service in "/etc/rpc.conf". For system security, make sure to disable unused services in "/etc/inetd.conf". Sun-RPC services need to be active for NFS and other RPC-based programs. Sometimes, inetd does not start the intended server directly but starts the TCP wrapper, tcpd, with the intended server name as its argument in "/etc/inetd.conf". In this case, tcpd runs the appropriate server program after logging the request and doing some additional checks using "/etc/hosts.deny" and "/etc/hosts.allow". If you have problems with remote access in a recent Debian system, comment out "ALL: PARANOID" in "/etc/hosts.deny" if it exists. (But you must be careful on security risks involved with this kind of action.) For details, see inetd(8), inetd.conf(5), protocols(5), services(5), tcpd(8), hosts_access(5), and hosts_options(5). For more information on Sun-RPC, see rpcinfo(8), portmap(8), and "/usr/share/doc/portmap/portmapper.txt.gz".
The system message The system message can be customized by "/etc/syslog.conf" for both the log file and on-screen display. See syslogd(8) and syslog.conf(5). See also .
The kernel message The kernel message can be customized by "/etc/init.d/klogd" for both the log file and on-screen display. Set "KLOGD='-c 3'" in this script and run "/etc/init.d/klogd restart". See klogd(8). You may directly change the error message level by: # dmesg -n3 Here: List of kernel error levels. error level value error level name meaning 0 KERN_EMERG system is unusable 1 KERN_ALERT action must be taken immediately 2 KERN_CRIT critical conditions 3 KERN_ERR error conditions 4 KERN_WARNING warning conditions 5 KERN_NOTICE normal but significant condition 6 KERN_INFO informational 7 KERN_DEBUG debug-level messages
The udev system For Linux kernel 2.6, the udev system provides mechanism for the automatic hardware discovery and initialization (see udev(7)). Upon discovery of each device by the kernel, the udev system starts a user process which uses information from the sysfs filesystem (see ), loads required kernel modules supporting it using the modprobe(8) program (see ), and creates corresponding device nodes. 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 files in "/etc/udev/rules.d/" (see "/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.
The kernel module initialization The modprobe(8) program enables us to configure running Linux kernel from user process by adding and removing kernel modules. The udev system (see ) automates its invocation to help the kernel module initialization. There are non-hardware modules and special hardware driver modules, such as: TUN/TAP modules providing virtual Point-to-Point network device (TUN) and virtual Ethernet network device (TAP), netfilter modules providing netfilter firewall capabilities (iptables(8), ), watchdog timer driver modules need to be pre-loaded by listing them in the "/etc/modules" file (see modules(5)). The configuration files for the modprobe(8) program are located under the "/etc/modprobes.d/" directory as explained in modprobe.conf(5). (If you want to avoid some kernel modules to be auto-loaded, consider to blacklist them in the "/etc/modprobes.d/blacklist" file.) The "/lib/modules/<version>/modules.dep" file generated by the depmod(8) program describes module dependencies used by the modprobe(8) program. 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. You can identify exact hardware on your system. See . You may configure hardware at boot time to activate expected hardware features. See . You can add support for your device by recompiling kernel. See .
Authentication When a person (or a program) requests access to the system, authentication confirms the identity to be a trusted one. 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.
Normal Unix authentication Normal Unix authentication is provided by the pam_unix(8) module under the PAM (Pluggable Authentication Modules). Its 3 important configuration files, with ":" separated entries, are: 3 important configuration files for <literal>pam_unix</literal>(8). file permission user group description /etc/passwd -rw-r--r-- root root The (sanitized) user account information. /etc/shadow -rw-r----- root shadow The secure user account information. /etc/group -rw-r--r-- root root The group information.
"/etc/passwd" contains: ... 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: 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. The second entry content of "<literal>/etc/passwd</literal>". 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: ... 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: 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: ... group1:x:20:user1,user2 ... As explained in shadow(5), each ":" separated entry of this file means: group name encrypted password (not really used) numerical group ID. "," separated list of user names. "/etc/gshadow" provides the similar function as "/etc/shadow" for "/etc/group" but is not really used. 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). The base-passwd package contains an authoritative list of the user and the group: "/usr/share/doc/base-passwd/users-and-groups.html".
Manage account and password information Here are few notable commands to manage account information: List of commands to manage account information. command function 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 manage password for the account passwd -e set one-time password for the account activation chage 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. 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.
Good password When creating an account during your system installation or with the passwd(1) command, you should choose a good password which consists of 6 to 8 characters including one or more characters from each of the following sets according to passwd(1): lower case alphabetics digits 0 through 9 punctuation marks Do not chose guessable words for the password.
Creating encrypted password There are independent tools to generate encrypted password with salt: List of tools to generate password. package popcon size command function whois &pop-whois; &size-whois; mkpasswd over-featured front end to the crypt(3) library openssl &pop-openssl; &size-openssl; openssl passwd compute password hashes (OpenSSL). passwd(1ssl)
PAM and NSS Modern Unix-like systems such as the Debian system provide PAM (Pluggable Authentication Modules) and NSS (Name Service Switch) mechanism to the local system administrator to configure his system. The role of these can be summarizes as: PAM offers a flexible authentication mechanism used by the application software thus involves 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: List of notable PAM and NSS systems. package popcon size description libpam-modules &pop-libpammodules; &size-libpammodules; Pluggable Authentication Modules (basic service) libpam-ldap &pop-libpamldap; &size-libpamldap; Pluggable Authentication Module allowing LDAP interfaces libpam-cracklib &pop-libpamcracklib; &size-libpamcracklib; Pluggable Authentication Module to enable cracklib support libpam-doc &pop-libpamdoc; &size-libpamdoc; Pluggable Authentication Modules (documentation in html and text) libc6 &pop-libcg; &size-libcg; GNU C Library: Shared libraries which also provides "Name Service Switch" service glibc-doc &pop-glibcdoc; &size-glibcdoc; GNU C Library: Manpages glibc-doc-reference &pop-glibcdocreference; &size-glibcdocreference; GNU C Library: Reference manual in info, pdf and html format (non-free) libnss-mdns &pop-libnssmdns; &size-libnssmdns; NSS module for Multicast DNS name resolution libnss-ldap &pop-libnssldap; &size-libnssldap; NSS module for using LDAP as a naming service libnss-ldapd &pop-libnssldapd; &size-libnssldapd; NSS module for using LDAP as a naming service (new folk of libnss-ldap)
"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. 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". PAM is the most basic way to initialize environment variables for each program with the system wide default value.
Configuration files accessed by the PAM and NSS Here are few notable configuration files accessed by the PAM: List of configuration files accessed by the PAM. configuration file function /etc/pam.d/<program_name> set up PAM configuration for the "<program_name>" program. See pam(7) and pam.d(5). /etc/nsswitch.conf set up NSS configuration with the entry for each service. See nsswitch.conf(5). /etc/nologin limit the user login by the pam_nologin(8) module. /etc/securetty limit the tty for the root access by the pam_securetty(8) module. /etc/security/access.conf set access limit by the pam_access(8) module. /etc/security/group.conf set group based restraint by the pam_group(8) module. /etc/security/pam_env.conf set environment variables by the pam_env(8) module. /etc/environment set additional environment variables by the pam_env(8) module with the "readenv=1" argument. /etc/default/locale set locale by pam_env(8) module with the "readenv=1 envfile=/etc/default/locale" argument. (Debian) /etc/security/limits.conf set resource restraint (ulimit, core, …) by the pam_linits(8) module. /etc/security/time.conf set time restraint by the pam_time(8) module.
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. PAM modules use suffix ".so" for their filenames.
The modern centralized system management The modern centralized system management can be deployed using the centralized Lightweight Directory Access Protocol (LDAP) server to administer many Unix-like and non-Unix-like systems on the network. The 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". You change the NSS configuration in the "/etc/nsswitch.conf" file to use "ldap" instead of the default ("compat" or "file"). 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. 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: NIS (originally called YP) or NIS+ with older Unix-like systems. Winbind with Windows NT and SAMBA.
"Why GNU su does not support the wheel group" This is the famous phrase at the bottom of the old "info su" page by Richard M. Stallman. Not to worry: the current su command in Debian uses PAM, so that one can restrict the ability to use su to the root group by enabling the line with "pam_wheel.so" in "/etc/pam.d/su".
Stricter password rule Installing the libpam-cracklib package will enable you to force stricter password rule, for example, by having active lines in "/etc/pam.d/common-password" as: For lenny: password required pam_cracklib.so retry=3 minlen=9 difok=3 password required pam_unix.so use_authtok nullok md5 For squeeze: password required pam_cracklib.so retry=3 minlen=9 difok=3 password [success=1 default=ignore] pam_unix.so use_authtok nullok md5 password requisite pam_deny.so password required pam_permit.so
Other access controls See for restricting the kernel secure attention key (SAK) feature.
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 ) 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, following will change 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".
SELinux Security-Enhanced Linux (SELinux) is a framework to tighten privilege model tighter than the ordinary Unix-like security model with the mandatory access control (MAC) policies. The root power may be restricted under some conditions.
Restricting access to some server services The Internet super-server, inetd(8), is started at boot time by "/etc/rc2.d/S20inetd" (for RUNLEVEL=2), which is a symlink to "/etc/init.d/inetd". Essentially, inetd allows one running daemon to invoke several others, reducing load on the system. Whenever a request for service arrives, its protocol and service are identified by looking them up in the databases in "/etc/protocols" and "/etc/services". inetd then looks up a normal Internet service in "/etc/inetd.conf", or a Sun RPC based service in "/etc/rpc.conf". For system security, make sure to disable unused services in "/etc/inetd.conf". Sun RPC services need to be active for NFS and other RPC based programs. Sometimes, inetd does not start the intended server directly but starts the TCP wrapper program, tcpd(8), with the intended server name as its argument in "/etc/inetd.conf". In this case, tcpd runs the appropriate server program after logging the request and doing some additional checks using "/etc/hosts.deny" and "/etc/hosts.allow". If you have problems with remote access in a recent Debian system, comment out "ALL: PARANOID" in "/etc/hosts.deny" if it exists. For details, see inetd(8), inetd.conf(5), protocols(5), services(5), tcpd(8), hosts_access(5), and hosts_options(5). For more information on Sun RPC, see rpcinfo(8), portmap(8), and "/usr/share/doc/portmap/portmapper.txt.gz". There are also non-PAM based access control available for atd(8) and cron(8).
Security of authentication The information here may not be sufficient for your security needs but it should be a good start.
Secure password over the Internet Many popular transportation layer services communicate messages including password authentication in the plain text. It is very bad idea to transmit password in the plain text over the wild Internet where it can be intercepted. You can run these services over "Transport Layer Security" (TLS) or its predecessor, "Secure Sockets Layer" (SSL) to secure entire communication including password by the encryption. List of insecure and secure services and ports. insecure service name port secure service name port www (http) 80 https 443 smtp (mail) 25 ssmtp (smtps) 465 ftp-data 20 ftps-data 989 ftp 21 ftps 990 telnet 23 telnets 992 imap2 143 imaps 993 pop3 110 pop3s 995 ldap 389 ldaps 636
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.)
Secure Shell The Secure Shell (SSH) program provides secure encrypted communications between two untrusted hosts over an insecure network with the secure authentication. It consists of the OpenSSH client, ssh(1), and the OpenSSH daemon, sshd(8). This SSH can be used to tunnel the insecure protocol communication such as POP and X securely over the Internet with the port forwarding feature. The client tries to authenticate itself using host-based authentication, public key authentication, challenge-response authentication, or password authentication. The use of public key authentication enables the remote password-less login. See .
Extra security measures for the Internet Even when you run secure services such as Secure Shell (SSH) and Point-to-point tunneling protocol (PPTP) servers, there are still chances for the break-ins using brute force password guessing attack etc. from the Internet. Use of the firewall policy (see ) together with the following secure tools may improve the security situation. List of tools to provide extra security measures. package popcon size description knockd &pop-knockd; &size-knockd; small port-knock daemon knocked(1) and client konck(1) denyhosts &pop-denyhosts; &size-denyhosts; an utility to help sysadmins thwart ssh hackers fail2ban &pop-failcban; &size-failcban; bans IPs that cause multiple authentication errors libpam-shield &pop-libpamshield; &size-libpamshield; locks out remote attackers trying password guessing
Securing the root password To prevent people to access your machine with root privilege, you need to: prevent physical access to the hard disk. lock BIOS and prevent booting from the removable media. set password for GRUB interactive session. lock GRUB menu from editing. With physical access to hard disk, resetting the password is relatively easy; move the hard disk to a PC with CD bootable BIOS. boot system with a rescue media (Debian boot disk, Knopix CD, GRUB CD, …). mount root partition with read-write access. edit "/etc/passwd" in the root partition and make the second entry for the root account empty. If you have the edit access to the GRUB menu entry (see ) for grub-rescue-pc at the boot time, it is even easier: boot system with the kernel parameter changed to something like "root=/dev/hda6 rw init=/bin/sh". edit "/etc/passwd" and make the second entry for the root account empty. reboot system. The root shell of the system is now accessible without password. Once you have root shell access, you can compromise password for all user accounts using brute force password cracking tools such as john and crack packages (see ). 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 ). You always need password to boot the system, though.
Network setup For general guide to the GNU/Linux networking, read the Linux Network Administrators Guide. The traditional TCP/IP network setup on Debian system uses ifupdown package as a high level tool. There are 2 typical cases: For dynamic IP system such as mobile PCs, you should setup TCP/IP network with the resolvconf package and enable you to switch your network configuration easily (see ). For static IP system such as servers, you should setup TCP/IP network without the resolvconf package and keep your system simple (see ). We will describe these traditional cases in detail here. We will also touch on some alternative high level tools such as network-manager and wicd which ease configuration of wireless networks (see ).
The basic network infrastructure Let's review the basic network infrastructure on the modern Debian system.
The domain name 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. 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. Other popular choices for the invalid TLD seem to be "localdomain", "lan", "localnet", or "home" according to my incoming mail analysis.
The hostname resolution The hostname resolution is currently supported by the NSS (Name Service Switch) mechanism too. The flow of this resolution is: The "/etc/nsswitch.conf" file with stanza like "hosts: files dns" dictates the hostname resolution order. (This replaces the old functionality of the "order" stanza in "/etc/host.conf".) The files method is invoked first. If the hostname is found in the "/etc/hosts" file, it returns all valid addresses for it and exits. (The "/etc/host.conf" file contains "multi on".) The dns method is invoked. If the hostname is found by the query to the Internet Domain Name System (DNS) identified by the "/etc/resolv.conf" file, it returns all valid addresses for it and exits. The "/etc/hosts" file associates IP addresses with hostnames: 127.0.0.1 localhost 127.0.1.1 <host_name>.<domain_name> <host_name> # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts Here the <host_name> in this matches the own hostname defined in the "/etc/hostname". The <domain_name> in this is the fully qualified domain name (FQDN) of this host. For the mobile PC without real FQDN, you may pick a TLD such as bogus "invalid" or mDNS "local" as the TLD part of <domain_name> in this configuration. 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: 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.
The network interface name The network interface name, e.g. eth0, is assigned to each hardware in the Linux kernel through the user space configuration mechanism, udev (see ), as it is found. The network interface name is referred as physical interface in ifup(8) and interfaces(5). In order to ensure each network interface to be named persistently for each reboot using MAC address etc., there is a record file "/etc/udev/rules.d/70-persistent-net.rules". This file is automatically generated by the "/lib/udev/write_net_rules" program, probably run by the "persistent-net-generator.rules" rules file. You can modify it to change naming rule. 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.
The network address range for the LAN Let us be reminded of the IPv4 32 bit address ranges in each class reserved for use on the local area networks (LANs) by rfc1918. These addresses are guaranteed not to conflict with any addresses on the Internet proper. List of network address ranges. Class network addresses net mask net mask /bits # of subnets A 10.x.x.x 255.0.0.0 /8 1 B 172.16.x.x — 172.31.x.x 255.255.0.0 /16 16 C 192.168.0.x — 192.168.255.x 255.255.255.0 /24 256
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.
The network configuration infrastructure There are 2 types of low level networking programs for Linux networking system (see ). Old net-tools programs (ifconfig(8), …) are from the Linux NET-3 networking system. Most of these are obsolete now. New Linux iproute2 programs (ip(8), …) are the current Linux networking system. Although these low level networking programs are powerful, they are cumbersome to use. So high level network configuration systems have been created. The ifupdown package is the de facto standard for such high level network configuration system on Debian. It enables you to bring up network simply by doing , e.g., "ifup eth0". Its configuration file is the "/etc/network/interfaces" file and its typical contents are: auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp The resolvconf package was created to supplement ifupdown system to support smooth reconfiguration of network address resolution by automating rewrite of resolver configuration file "/etc/resolv.conf". Now, most Debian network configuration packages are modified to use resolvconf package (see "/usr/share/doc/resolvconf/README.Debian"). Helper scripts to the ifupdown package such as ifplugd, guessnet, ifscheme, etc. are created to automate dynamic configuration of network environment such as one for mobile PC on wired LAN. These are relatively difficult to use but play well with existing ifupdown system. Alternative high level network configuration systems, independent of ifupdown system, such as network-manager, wicd, etc. are created to ease configuration of network environment even for mobile PC on wireless network. Since these are relatively new system and their integration to Debian system is in progress, you may still need to disable the corresponding network interface configuration manually in "/etc/network/interfaces" to avoid conflicts between these and ifupdown (see ). List of network configuration tools. packages popcon size type function ifupdown &pop-ifupdown; &size-ifupdown; config::ifupdown Standardized tool to bring up and down the network (Debian specific) ifplugd &pop-ifplugd; &size-ifplugd; , , Manage the wired network automatically ifupdown-extra &pop-ifupdownextra; &size-ifupdownextra; , , Network testing script to enhance "ifupdown" package ifmetric &pop-ifmetric; &size-ifmetric; , , Set routing metrics for a network interface. guessnet &pop-guessnet; &size-guessnet; , , Mapping script to enhance "ifupdown" package via "/etc/network/interfaces" file ifscheme &pop-ifscheme; &size-ifscheme; , , Mapping scripts to enhance "ifupdown" package ifupdown-scripts-zg2 &pop-ifupdownscriptszgc; &size-ifupdownscriptszgc; , , Zugschlus' interface scripts for ifupdown's manual method network-manager &pop-networkmanager; &size-networkmanager; config::NetworkManager NetworkManager (daemon): Manage the network automatically network-manager-gnome &pop-networkmanagergnome; &size-networkmanagergnome; , , NetworkManager (GNOME frontend) network-manager-kde &pop-networkmanagerkde; &size-networkmanagerkde; , , NetworkManager (KDE frontend) wicd &pop-wicd; &size-wicd; config::wicd Wired and wireless network manager iptables &pop-iptables; &size-iptables; config::Netfilter Administration tools for packet filtering and NAT iproute &pop-iproute; &size-iproute; config::iproute2 IPv6 and other advanced network configuration: ip(8), tc(8), etc. ifrename &pop-ifrename; &size-ifrename; , , Rename network interfaces based on various static criteria: ifrename(8) ethtool &pop-ethtool; &size-ethtool; , , Display or change Ethernet device settings iputils-ping &pop-iputilsping; &size-iputilsping; test::iproute2 Tools to test network reachability of a remote host by hostname or IP address iputils-arping &pop-iputilsarping; &size-iputilsarping; , , Tools to test network reachability of a remote host specified by the ARP address iputils-tracepath &pop-iputilstracepath; &size-iputilstracepath; , , Tools to trace the network path to a remote host net-tools &pop-nettools; &size-nettools; config::net-tools The NET-3 networking toolkit (IPv4 network configuration): ifconfig(8) etc. inetutils-ping &pop-inetutilsping; &size-inetutilsping; test::net-tools Tools to test network reachability of a remote host by hostname or IP address (legacy, GNU) arping &pop-arping; &size-arping; , , Tools to test network reachability of a remote host specified by the ARP address (legacy) traceroute &pop-traceroute; &size-traceroute; , , Tools to trace the network path to a remote host (legacy, console) dhcp3-client &pop-dhcpdclient; &size-dhcpdclient; config::low-level DHCP client wpasupplicant &pop-wpasupplicant; &size-wpasupplicant; , , Client support for WPA and WPA2 (IEEE 802.11i) wireless-tools &pop-wirelesstools; &size-wirelesstools; , , Tools for manipulating Linux Wireless Extensions ppp &pop-ppp; &size-ppp; , , PPP/PPPoE connection with chat pppoeconf &pop-pppoeconf; &size-pppoeconf; config::helper Configuration helper for PPPoE connection pppconfig &pop-pppconfig; &size-pppconfig; , , Configuration helper for PPP connection with chat wvdial &pop-wvdial; &size-wvdial; , , Configuration helper for PPP connection with wvdial and ppp mtr-tiny &pop-mtrtiny; &size-mtrtiny; test::low-level Tools to trace the network path to a remote host (curses) mtr &pop-mtr; &size-mtr; , , Tools to trace the network path to a remote host (curses and GTK+) gnome-nettool &pop-gnomenettool; &size-gnomenettool; , , Tools for common network information operations (GNOME) nmap &pop-nmap; &size-nmap; , , Network mapper / port scanner (Nmap, console) zenmap &pop-zenmap; &size-zenmap; , , Network mapper / port scanner (GTK+) knmap &pop-knmap; &size-knmap; , , Network mapper / port scanner (KDE) tcpdump &pop-tcpdump; &size-tcpdump; , , Network traffic analyzer (Tcpdump, console) wireshark &pop-wireshark; &size-wireshark; , , Network traffic analyzer (Wireshark, GTK+) tshark &pop-tshark; &size-tshark; , , Network traffic analyzer (console) nagios3 &pop-nagiosd; &size-nagiosd; , , Monitoring and management system for hosts, services and networks (Nagios) tcptrace &pop-tcptrace; &size-tcptrace; , , Tool to produce a summarization of the connections from tcpdump output snort &pop-snort; &size-snort; , , Flexible network intrusion detection system (Snort) ntop &pop-ntop; &size-ntop; , , Display network usage in web browser dnsutils &pop-dnsutils; &size-dnsutils; , , Network clients provided with BIND: nslookup(8), nsupdate(8), dig(8) dlint &pop-dlint; &size-dlint; , , Checks DNS zone information using nameserver lookups dnstracer &pop-dnstracer; &size-dnstracer; , , Tool to trace a chain of DNS servers to the source
The network device support Although most hardware devices are supported by the Debian system, there are some network devices which require DSFG non-free external hardware drivers to support them. Please see .
The network connection method The connection test method described in this section are meant for testing purposes. It is not meant to be used directly for the daily network connection. You are advised to use them via the ifupdown package (see ). The typical network connection method and connection path for a PC can be summarized as: List of network connection methods and connection paths. PC connection method connection path Serial port (ppp0) PPP modem ⇔ POTS ⇔ dial-up access point ⇔ ISP Ethernet port (eth0) PPPoE/DHCP/Static ⇔ BB-modem ⇔ BB service ⇔ BB access point ⇔ ISP Ethernet port (eth0) DHCP/Static ⇔ LAN ⇔ BB-router with network address translation (NAT) (⇔ BB-modem …)
Here is the summary of configuration script for each connection method: List of network connection configurations. connection method configuration backend package(s) PPP pppconfig to create deterministic chat pppconfig, ppp PPP (alternative) wvdialconf to create heuristic chat ppp, wvdial PPPoE pppoeconf to create deterministic chat pppoeconf, ppp DHCP described in "/etc/dhcp3/dhclient.conf" dhcp3-client static IP (IPv4) described in "/etc/network/interfaces" net-tools static IP (IPv6) described in "/etc/network/interfaces" iproute
The network connection acronyms mean: List of network connection acronyms. acronym meaning POTS The plain old telephone service BB The 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 The local area network WAN The wide area network DHCP The dynamic host configuration protocol PPP The point-to-point protocol PPPoE The point-to-point protocol over Ethernet ISP The Internet service provider
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. 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.
The DHCP connection with the Ethernet The typical modern home and small business network, i.e. LAN, are connected to the WAN(Internet) using some consumer grade broadband router. The LAN behind this router is usually served by the dynamic host configuration protocol (DHCP) server running on the router. Just install the dhcp3-client package for the Ethernet served by the dynamic host configuration protocol (DHCP).
The static IP connection with the Ethernet No special action is needed for the Ethernet served by the static IP.
The PPP connection with pppconfig The configuration script pppconfig will configure the PPP connection interactively just by selecting: the telephone number, the ISP user name, the ISP password, the port speed, the modem communication port, and the authentication method. The configuration files are: List of configuration files for the <ulink url="&ppp;">PPP</ulink> connection with pppconfig. file function /etc/ppp/peers/<isp_name> The pppconfig generated configuration file for pppd specific to <isp_name> /etc/chatscripts/<isp_name> The pppconfig generated configuration file for chat specific to <isp_name> /etc/ppp/options The general execution parameter for pppd /etc/ppp/pap-secret Authentication data for the PAP (security risk) /etc/ppp/chap-secret Authentication data for the CHAP (more secure)
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: $ sudo pon <isp_name> ... $ sudo poff <isp_name> See "/usr/share/doc/ppp/README.Debian.gz" for more information.
The alternative PPP connection with wvdialconf A different approach to using pppd(8) is to run it from wvdial(1) which comes in the wvdial package. Instead of pppd running chat(8) to dial in and negotiate the connection, wvdial does the dialing and initial negotiating and then starts pppd to do the rest. The configuration script wvdialconf will configure the PPP connection interactively just by selecting: the telephone number, the ISP user name, and the ISP password. wvdial succeeds in making the connection in most cases and maintains authentication data list automatically. The configuration files are: List of configuration files for the PPP connection with wvdialconf. file function /etc/ppp/peers/wvdial The wvdialconf generated configuration file for pppd specific to wvdial /etc/wvdial.conf The wvdialconf generated configuration file /etc/ppp/options The general execution parameter for pppd /etc/ppp/pap-secret Authentication data for the PAP (security risk) /etc/ppp/chap-secret Authentication data for the CHAP (more secure)
You can test configuration using low level network configuration tools: $ sudo wvdial ... $ sudo killall wvdial See wvdial(1) and wvdial.conf(5) for more information.
The PPPoE connection with pppoeconf When your ISP serves you with PPPoE connection and you decide to connect your PC directly to the WAN, the network of your PC must be configured with the PPPoE. The PPPoE stand for PPP over Ethernet. The configuration script pppoeconf will configure the PPPoE connection interactively. The configuration files are: List of configuration files for the PPPoE connection with pppoeconf. file function /etc/ppp/peers/dsl-provider The pppoeconf generated configuration file for pppd specific to pppoe /etc/ppp/options The general execution parameter for pppd /etc/ppp/pap-secret Authentication data for the PAP (security risk) /etc/ppp/chap-secret Authentication data for the CHAP (more secure)
You can test configuration using low level network configuration tools: $ sudo /sbin/ifconfig eth0 up $ sudo pon dsl-provider ... $ sudo poff dsl-provider $ sudo /sbin/ifconfig eth0 down See "/usr/share/doc/pppoeconf/README.Debian" for more information.
The basic network configuration with ifupdown 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.
The command syntax simplified The ifupdown package contains 2 commands: ifup(8) and ifdown(8). They offer high level network configuration dictated by the configuration file "/etc/network/interfaces". List of basic network configuration commands with ifupdown. command action ifup eth0 To bring up a network interface eth0 with the configuration eth0 if "iface eth0" stanza exists. ifdown eth0 To bring down a network interface eth0 with the configuration eth0 if "iface eth0" stanza exists.
Do not use low level configuration tools such as ifconfig(8) and ip(8) commands to configure an interface in up state. There is no command ifupdown.
The basic syntax of "/etc/network/interfaces" The key syntax of "/etc/network/interfaces" as explained in interfaces(5) can be summarized as: List of stanzas in "<literal>/etc/network/interfaces</literal>" stanza meaning "auto <interface_name>" To start interface <interface_name> upon start of the system. "allow-auto <interface_name>" , , "allow-hotplug <interface_name>" To start interface <interface_name> when the kernel detects a hotplug event from the interface. Lines started with "iface <config_name> …" To define the network configuration <config_name>. Lines started with "mapping <interface_name_glob> " To define mapping value of <config_name> for the matching <interface_name>. A line starting with a hash "#" To be ignored as comments. (end-of-line comments are not supported) A line ending with a backslash "\" To extend the configuration to the next line.
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 ). Do not define duplicates of the "iface" stanza for a network interface in "/etc/network/interfaces".
The loopback network interface The following configuration entry in the "/etc/network/interfaces" file brings up the loopback network interface lo upon booting the system (via auto stanza). auto lo iface lo inet loopback This one always exists in the "/etc/network/interfaces" file.
The network interface served by the DHCP After prepairing the system by , the network interface served by the DHCP is configured by creating the configuration entry in the "/etc/network/interfaces" file as: allow-hotplug eth0 iface eth0 inet dhcp hostname "mymachine" When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza will cause ifup to bring up the interface and the iface stanza will cause ifup to use DHCP to configure the interface.
The network interface with the static IP The network interface served by the static IP is configured by creating the configuration entry in the "/etc/network/interfaces" file as, e.g.,: allow-hotplug eth0 iface eth0 inet static address 192.168.11.100 netmask 255.255.255.0 broadcast 192.168.11.255 gateway 192.168.11.1 dns-domain lan dns-nameservers 192.168.11.1 When the Linux kernel detects the physical interface eth0, the allow-hotplug stanza will cause ifup to bring up the interface and the iface stanza will cause ifup to use the static IP to configure the interface. Here, I assumed: IP address range of the LAN network: 192.168.11.0 - 192.168.11.255 IP address of the gateway: 192.168.11.1 IP address of the PC: 192.168.11.100 The resolvconf package is installed. The domain name as "lan". IP address of the DNS server: 192.168.11.1 When the resolvconf package is not installed, DNS related configuration needs to be done manually by editing the "/etc/resolv.conf" as: nameserver 192.168.11.1 domain lan 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.
The basics of wireless LAN interface The wireless LAN (WLAN for short) provides the fast wireless connectivity through the spread-spectrum communication of unlicensed radio bands based on the set of standards called IEEE 802.11. The WLAN interfaces are almost like normal Ethernet interfaces but require some network ID and encryption key data to be provided when they are initialized. Their high level network tools are exactly the same as that of Ethernet interfaces except interface names are a bit different like eth1, wlan0, ath0, wifi0, … depending on the kernel drivers used. 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: List of acronyms for WLAN. acronym full word meaning NWID Network ID The 16 bit network ID used by pre-802.11 WaveLAN network. Very much deprecated. (E)SSID (Extended) Service Set Identifier The network name of the Wireless Access Points (APs) interconnected to form an integrated 802.11 wireless LAN. Domain ID. WEP, (WEP2) Wired Equivalent Privacy The 1st generation 64-bit (128-bit) wireless encryption standard with 40-bit key. Deprecated. WPA Wi-Fi Protected Access The 2nd generation wireless encryption standard (most of 802.11i), compatible with WEP. WPA2 Wi-Fi Protected Access 2 The 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.
The wireless LAN interface with WPA/WPA2 You need to install the wpasupplicant package to support the WLAN with the new WPA/WPA2. In case of the DHCP served IP on WLAN connection, the "/etc/network/interfaces" file entry should be: allow-hotplug ath0 iface ath0 inet dhcp wpa-ssid homezone # hexadecimal psk is encoded from a plaintext passphrase wpa-psk 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f See more on "/usr/share/doc/wpasupplicant/README.modes.gz".
The wireless LAN interface with WEP You need to install the wireless-tools package to support the WLAN with the old WEP. (Your consumer grade router may still be using this insecure infrastructure but this is better than nothing.) 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: 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 more on "/usr/share/doc/wireless-tools/README.Debian".
The PPP connection You need to configure the PPP connection first as described before (see ). Then, add the "/etc/network/interfaces" file entry for the primary PPP device ppp0 as: iface ppp0 inet ppp provider <isp_name>
The alternative PPP connection You need to configure the alternative PPP connection with wvdial first as described before (see ). Then, add the "/etc/network/interfaces" file entry for the primary PPP device ppp0 as: iface ppp0 inet wvdial
The PPPoE connection For PC connected directly to the WAN served by the PPPoE, you need to configure system with the PPPoE connection as described before (see ). Then, add the "/etc/network/interfaces" file entry for the primary PPPoE device eth0 as: allow-hotplug eth0 iface eth0 inet manual pre-up /sbin/ifconfig eth0 up up ifup ppp0=dsl down ifdown ppp0=dsl post-down /sbin/ifconfig eth0 down # The following is used internally only iface dsl inet ppp provider dsl-provider
The network configuration state of ifupdown The "/etc/network/run/ifstate" file stores the intended network configuration states for all the currently active network interfaces managed by the ifupdown package are listed. Unfortunately, even if the ifupdown system fails to bring up the interface as intended, the "/etc/network/run/ifstate" file lists it active. Unless the output of the ifconfig(8) command for an interface does not have a line like following example, it can not be used as a part of IPV4 network: inet addr:192.168.11.2 Bcast:192.168.11.255 Mask:255.255.255.0 For the Ethernet device connected to the PPPoE, the output of the ifconfig(8) command lacks a line which looks like above example.
The basic network reconfiguration When you try to reconfigure the interface, e.g. eth0, you must disable it first with the "sudo ifdown eth0" command. This will remove the entry of eth0 from the "/etc/network/run/ifstate" file. (This may result in some error message if eth0 is not active or it is configured improperly previously. So far, it seems to be safe to do this for the simple single user work station at any time.) You are now free to rewrite the "/etc/network/interfaces" contents as needed to reconfigure the network interface, eth0. Then, you can reactivate eth0 with the "sudo ifup eth0" command. You can (re)initialize the network interface simply by "sudo ifdown eth0;sudo ifup eth0".
The ifupdown-extra package The ifupdown-extra package provides the easy network connection test for use with the ifupdown package by: the network-test(1) command from the shell, and the automatic scripts run for each ifup command execution. The network-test command frees you from the execution of cumbersome low level commands to analyze the network problem. The automatic scripts are installed in "/etc/network/*/" and: check the network cable connection, check duplicate use of IP address, setup system's static routes based on the "/etc/network/routes" definition, check if network gateway is reachable, and record results in the "/var/log/syslog" file. This syslog record is quite useful for administration of the network problem on the remote system. 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 bootup a little bit since it takes some time to listen for ARP replies.
The advanced network configuration with ifupdown The functionality of the ifupdown package can be improved beyond what was described in with the advanced knowledge. The functionalities described here are completely optional. I, being lazy and minimalist, rarely bother to use these. If you could not set up network connection by information in , you will make situation worse by using information below.
The ifplugd package The ifplugd package is older automatic network configuration tool which can manage only Ethernet connections. This solves unplugged/replugged Ethernet cable issues for mobile PC etc.. If you have NetworkManager or Wicd (see ) installled, you do not need this package. This package runs daemon and replaces auto or allow-hotplug functionalities (see ) and starts interfaces upon their connection to the network. Here is how to use the ifplugd package for the internal Ethernet port, e.g. eth0: Remove stanza in "/etc/network/interfaces": "auto eth0" or "allow-hotplug eth0", Keep stanza in "/etc/network/interfaces": "iface eth0 inet …" and "mapping …", Install the ifplugd package, Run "sudo dpkg-reconfigure ifplugd", and Put eth0 as the "static interfaces to be watched by ifplugd". 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 ). 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 will be brought up under the new network environment. The arguments for the ifplugd(8) command can set its behaviors such as the delay for reconfiguring interfaces.
The ifmetric package The ifmeric package enables us to manipulate metrics of routes a posteriori even for DHCP. The following will set the eth0 interface to be preferred over the wlan0 interface: Install the ifmetric package, and Add an option line with "metric 0" just below the "iface eth0 inet dhcp" line. 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).
The virtual interface A single physical Ethernet interface can be configured as multiple virtual interfaces with different IP addresses. Usually the purpose is to connect an interface to several IP subnetworks. For example, IP address based virtual web hosting by a single network interface is one such application. For example, let's suppose that a single Ethernet interface on your host is connected to a Ethernet hub (not to the broadband router), the Ethernet hub is connected to both the Internet and LAN network, the LAN network uses subnet 192.168.0.x/24, your host uses DHCP served IP address with the physical interface eth0 for the Internet, and your host uses 192.168.0.1 with the virtual interface eth0:0 for the LAN, then following stanzas in "/etc/network/interfaces" will configure your network: iface eth0 inet dhcp metric 0 iface eth0:0 inet static address 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 metric 1 Although this configuration example with network address translation (NAT) using netfilter/iptables (see ) 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.
The advanced command syntax The ifupdown package offers advanced network configuration using the network configuration name and the network interface name. I use slightly different terminology from one used in ifup(8) and interfaces(5). List of terminology for network devices. manpage terminology my terminology examples in the following text explanation physical interface name network interface name lo, eth0, <interface_name> A name given by the Linux kernel (using udev mechanism). logical interface name network configuration name config1, config2, <config_name> A name token following iface in the "/etc/network/interfaces".
Basic network configuration commands in 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": List of advanced network configuration commands with ifupdown. command action ifup eth0=config1 To bring up a network interface eth0 with the configuration config1. ifdown eth0=config1 To bring down a network interface eth0 with the configuration config1. ifup eth0 To bring up a network interface eth0 with the configuration selected by mapping stanza. ifdown eth0 To bring down a network interface eth0 with the configuration selected by mapping stanza.
The mapping stanza We skipped explaining the mapping stanza in the "/etc/network/interfaces" in to avoid complication. This stanza has the following syntax: mapping <interface_name_glob> script <script_name> 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>. When the "<interface_name_glob>" matches "eth0", the execution of $ sudo ifup eth0 will produce the execution of: $ sudo ifup eth0=$(echo -e '<script_input1> \n <script_input2> \n ...' | <script_name> eth0) to configure eth0 automatically. Here, lines with "map" are optional and can be repeated. The glob for mapping stanza works like shell filename glob (see ).
The manually switchable network configuration Here is how to switch manually among several network configurations without rewriting the "/etc/network/interfaces" file as in . For all the network configuration you need to access, you create a single "/etc/network/interfaces" file, e.g,: auto lo iface lo inet loopback iface config1 inet dhcp hostname "mymachine" iface config2 inet static address 192.168.11.100 netmask 255.255.255.0 broadcast 192.168.11.255 gateway 192.168.11.1 dns-domain lan dns-nameservers 192.168.11.1 iface pppoe inet manual pre-up /sbin/ifconfig eth0 up up ifup ppp0=dsl down ifdown ppp0=dsl post-down /sbin/ifconfig eth0 down # The following is used internally only iface dsl inet ppp provider dsl-provider iface pots inet ppp provider provider Please note the network configuration name which is the token after iface does not use the token for the network interface name. Also, there are no auto stanza nor allow-hotplug stanza to start the network interface eth0 automatically upon events. Now you are ready to switch the network configuration. Let's move your PC to a LAN served by the DHCP. You bring up the network interface (the physical interface) eth0 by assigning the network configuration name (the logical interface name) config1 to it: $ sudo ifup eth0=config1 Password: ... The interface eth0 is up, configured by DHCP and connected to LAN. $ sudo ifdown eth0=config1 ... The interface eth0 is down and disconnected from LAN. Let's move your PC to a LAN served by the static IP. You bring up the network interface eth0 by assigning the network configuration name config2 to it: $ sudo ifup eth0=config2 ... The interface eth0 is up, configured with static IP and connected to LAN. The additional parameters given as dns-* configures "/etc/resolv.conf" contents. This "/etc/resolv.conf" is better manged if the resolvconf package is installed. $ sudo ifdown eth0=config2 ... 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: $ 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: $ 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. You may need to adjust numbers at the end of eth*, ppp*, etc. if you have multiple network interfaces.
Scripting with the ifupdown system The ifupdown system automatically runs scripts installed in "/etc/network/*/" while exporting environment variables to scripts: List of environment variables passed by the ifupdown system environment variable value passed "$IFACE" physical name (interface name) of the interface being processed. "$LOGICAL" logical name (configuration name) of the interface being processed. "$ADDRFAM" <address_family> of the interface. "$METHOD" <method_name> of the interface. (e.g., "static") "$MODE" "start" if run from ifup, "stop" if run from ifdown. "$PHASE" as per "$MODE", but with finer granularity, distinguishing the pre-up, post-up, pre-down and post-down phases. "$VERBOSITY" indicates whether "--verbose" was used; set to 1 if so, 0 if not. "$PATH" the command search path: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" "$IF_<OPTION>" the value for the corresponding option under the iface stanza.
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. See for <address_family>, <method_name>, <option1> and <option2>. The ifupdown-extra package (see ) uses these environment variables to extend the functionality of the ifupdown package. The ifmetric package (see ) installs the "/etc/network/if-up.d/ifmetric" script which sets the metric via the "$IF_METRIC" variable. The guessnet package (see ), which provides simple and powerful framework for the auto-selection of the network configuration via the mapping mechanism, also uses these. 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 ifupdown-scripts-zg2 packages. These additional scripts have some overlaps of functinalities with basic ifupdown-extra and guessnet packages. If you install these additional scripts, you should customize these scripts to avoid interferences.
Mapping with guessnet Instead of manually choosing configuration as described in , you can use the mapping mechanism described in to select network configuration automatically with custom scripts. The guessnet-ifupdown(8) command provided by the guessnet package is designed to be used as a mapping script and provides powerful framework to enhance the ifupdown system. you list test condition as the value for guessnet options for each network configuration under iface stanza. mapping will chose the iface with first non-ERROR result as the network configuration. This dual usage of the "/etc/network/interfaces" file by the mapping script, guessnet-ifupdown, and the original network configuration infrastructure, ifupdown, does not cause negative impacts since guessnet options only export extra environment variables to scripts run by the ifupdown system. See details in guessnet-ifupdown(8). 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.
The network configuration for desktop
GUI network configuration tools The capability of default GUI network configuration tools for each desktop environments such as GNOME tends to be limited to basic configurations such as static IP or DHCP. They actually overwrite contents of "/etc/network/interfaces" file behind you. Please check how they change "/etc/network/interfaces" file by yourself. They may not understand complicated advanced configuration done manually in "/etc/network/interfaces" file.
Automatic network configuration There are independent automatic network configuration tools, such as NetworkManager (NM) (network-manager and associated packages) and Wicd (wicd package) which manage network connection via daemon independen of the ifupdown package. They allow easy management of wireless connections. These come with its own nice GUI user interfaces. Do not use these automatic network configuration tools for servers. These are aimed primarily for mobile desktop users on laptops. These automatic network configuration tools are moving targets and documentation here is likely to be incorrect for squeeze. So be warned. These automatic network configuration tools may not be compatible with esoteric configurations of ifupdown in "/etc/network/interfaces" such as ones in and . Having even "hostname" stanza for DHCP controlled interface as described in caused NM to ignore such interface in lenny. Check BTS of network-manager and BTS of wicd for current issues and limitations. The configuration of NM is described in "/usr/share/doc/network-manager/README.Debian". Essentially: Make desktop user, e.g. foo, belong to group "netdev" by: $ sudo adduser foo netdev Keep configuration of "/etc/network/interfaces" as simple as: auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp Restart NM by: $ sudo /etc/init.d/network-manager restart 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 options) are managed by NM to avoid conflict with ifupdown. The configuration of Wicd is described in "/usr/share/doc/wicd/README.Debian". Essentially: Make configuration in "/etc/network/interfaces" only as: auto lo iface lo inet loopback Restart Wicd. $ sudo /etc/init.d/wicd restart
The low level network configuration
Iproute2 commands Iproute2 commands offer complete low-level network configuration capabilities. Here is a translation table from obsolete net-tools commands to new iproute2 etc. commands. Translation table from obsolete <literal>net-tools</literal> commands to new <literal>iproute2</literal> commands. obsolete net-tools new iproute2 etc. manipulation ifconfig(8) ip addr protocol (IP or IPv6) address on a device. route(8) ip route routing table entry. arp(8) ip neigh ARP or NDISC cache entry. ipmaddr ip maddr multicast address. iptunnel ip tunnel tunnel over IP. nameif(8) ifrename(8) name network interfaces based on MAC addresses. mii-tool(8) ethtool(8) Ethernet device settings.
See ip(8) and IPROUTE2 Utility Suite Howto.
Safe low level network operations You may use low level network commands as follows safely since they do not change network configuration: List of low level network commands. command description ifconfig displays the link and address status of active interfaces ip addr show displays the link and address status of active interfaces route -n displays all the routing table in numerical addresses ip route show displays all the routing table in numerical addresses arp displays the current content of the ARP cache tables ip neigh displays the current content of the ARP cache tables plog display ppp daemon log ping yahoo.com check the Internet connection to "yahoo.com" whois yahoo.com check who registered "yahoo.com" in the domains database traceroute yahoo.com trace the Internet connection to "yahoo.com" tracepath yahoo.com trace the Internet connection to "yahoo.com" mtr yahoo.com trace the Internet connection to "yahoo.com" (repeatedly) dig [@dns-server.com] example.com [{a|mx|any}] check DNS records of "example.com" by "dns-server.com" for a "a", "mx", or "any" record iptables -L -n check packet filter netstat -a find all open ports netstat -l --inet find listening ports netstat -ln --tcp find listening TCP ports (numeric) dlint example.com check DNS zone information of "examle.org"
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".
Network optimization Generic network optimization is beyond the scope of this documentation. I will touch only subjects pertinent to the consumer grade connection. List of network optimization tools. packages popcon size description iftop &pop-iftop; &size-iftop; displays bandwidth usage information on an network interface iperf &pop-iperf; &size-iperf; Internet Protocol bandwidth measuring tool apt-spy &pop-aptspy; &size-aptspy; writes a "/etc/apt/sources.list" file based on bandwidth tests ifstat &pop-ifstat; &size-ifstat; InterFace STATistics Monitoring bmon &pop-bmon; &size-bmon; portable bandwidth monitor and rate estimator ethstatus &pop-ethstatus; &size-ethstatus; script that quickly measures network device throughput bing &pop-bing; &size-bing; Empirical stochastic bandwidth tester bwm-ng &pop-bwmng; &size-bwmng; small and simple console-based bandwidth monitor ethstats &pop-ethstats; &size-ethstats; console-based Ethernet statistics monitor ipfm &pop-ipfm; &size-ipfm; a bandwidth analysis tool
Finding optimal MTU The Maximum Transmission Unit (MTU) value can be determined experimentally with ping(8) with "-M do" option which sends ICMP packets with data size starting from 1500 (with offset of 28 bytes for the IP+ICMP header) and finding the largest size without IP fragmentation. For example: $ ping -c 1 -s $((1500-28)) -M do www.debian.org PING www.debian.org (194.109.137.218) 1472(1500) bytes of data. From 192.168.11.2 icmp_seq=1 Frag needed and DF set (mtu = 1454) --- www.debian.org ping statistics --- 0 packets transmitted, 0 received, +1 errors … try 1454 instead of 1500 The ping(8) command succeed This process is Path MTU (PMTU) discovery (RFC1191) and the tracepath(8) command can automate this. 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. Basic guide lines of the optimal MTU value network environment MTU rationale Dial-up link (IP: PPP) 576 standard Ethernet link (IP: DHCP or fixed) 1500 standard and default Ethernet link (IP: PPPoE) 1492 (=1500-8) 2 bytes for PPP header and 6 bytes for PPPoE header Ethernet link (ISP's backbone: ATM, IP: DHCP or fixed) 1462 (=48*31-18-8) author's speculation: 18 for Ethernet header, 8 for SAR trailer. Ethernet link (ISP's backbone: ATM, IP: PPPoE) 1454 (=48*31-8-18-8) see "Optimal MTU configuration for PPPoE ADSL Connections" for rationale.
In addtion to these basic guide lines, you should know: 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.
Setting MTU Here are examples for setting the MTU value from its default 1500 to 1454. For the DHCP (see ), you can replace pertinent iface stanza lines in the "/etc/network/interfaces" with, e.g.,: iface eth0 inet dhcp hostname "mymachine" pre-up /sbin/ifconfig $IFACE mtu 1454 For the static IP (see ), you can replace pertinent 'iface' stanza lines in the "/etc/network/interfaces" with, e.g.,: 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 ), you can replace pertinent "mtu" line in the "/etc/ppp/peers/dsl-provider" with: mtu 1454 The maximum segment size (MSS) is used as an alternative measure of packet size. The relationship between MSS and MTU are: MSS = MTU - 40 for IPv4 MSS = MTU - 60 for IPv6 The iptables(8) (see ) based optimization can clamp packet size by the MSS and is useful for the router.
WAN TCP optimization The TCP throughput can be maximized by adjusting TCP buffer size parameters as described in "TCP Tuning Guide" and "TCP tuning" for the modern high-bandwidth and high-latency WAN. So far, the current Debian default settings serve well even for my LAN connected by the fast 1G bps FTTP service.
Netfilter Netfilter provides infrastructure for stateful firewall and network address translation (NAT) with Linux kernel modules (see ). List of firewall tools. packages popcon size description iptables &pop-iptables; &size-iptables; administration tools for netfilter iptstate &pop-iptstate; &size-iptstate; Tool to continuously monitor netfilter state. (similar to top(1)) shorewall-perl &pop-shorewallperl; &size-shorewallperl; Shoreline Firewall, netfilter configuration file generator (Perl-based, recommended for lenny) shorewall-shell &pop-shorewallshell; &size-shorewallshell; Shoreline Firewall, netfilter configuration file generator (shell-based, alternative for lenny) ipmasq &pop-ipmasq; &size-ipmasq; Simple set of init script to configure netfilter (old)
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 documentation 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 Although these were written for Linux 2.4, both iptables(8) command and netfilter kernel function apply for current Linux 2.6.
Network applications After establishing network connectivity (see ), you can run verious network applications.
Web browsers There are many web browser packages to access remote contents with Hypertext Transfer Protocol (HTTP). List of web browsers. package popcon size description iceweasel &pop-iceweasel; &size-iceweasel; Web browser (X) (unbranded Mozilla Firefox, ) iceape-browser &pop-iceapebrowser; &size-iceapebrowser; Web browser (X) (unbranded Mozilla browser, removed due to security concerns bug#505565) epiphany-browser &pop-epiphanybrowser; &size-epiphanybrowser; Web browser (X) (GNOME HIG compliant browser, Epiphany) galeon &pop-galeon; &size-galeon; Web browser (X) (GNOME browser, Galeon was superseded by Epiphany) konqueror &pop-konqueror; &size-konqueror; Web browser (X) (KDE browser, Konqueror) w3m &pop-wdm; &size-wdm; Web browser (text) (w3m) lynx &pop-lynx; &size-lynx; , , elinks &pop-elinks; &size-elinks; , , links &pop-links; &size-links; , , links2 &pop-linksc; &size-linksc; , ,
Browser configuration You may be able to use following special URL strings for some browsers to confirm their settings. "about:" "about:config" "about:plugins" Debian offers many free browser plugin packages in the main component which can handle not only Java (software platform) and Flash but also MPEG, MPEG2, MPEG4, DivX, Windows Media Video (.wmv), QuickTime (.mov), MP3 (.mp3), Ogg/Vorbis files, DVDs, VCDs, etc. Debian also offers helper programs to install non-free browser plugin packages as contrib or non-free components. List of browser plugin packages. package popcon size component description icedtea-gcjwebplugin &pop-icedteagcjwebplugin; &size-icedteagcjwebplugin; main Java plugin using Hotspot JIT sun-java6-plugin &pop-sunjavagplugin; &size-sunjavagplugin; non-free Java plugin for Sun's Java SE 6 (i386 only) swfdec-mozilla &pop-swfdecmozilla; &size-swfdecmozilla; main Flash plugin based on libswfdec mozilla-plugin-gnash &pop-mozillaplugingnash; &size-mozillaplugingnash; main Flash plugin based on Gnash flashplugin-nonfree &pop-flashpluginnonfree; &size-flashpluginnonfree; contrib Flash plugin helper to install Adobe Flash Player (i386, amd64 only) mozilla-bonobo &pop-mozillabonobo; &size-mozillabonobo; main Mozilla plugin support for GNOME Bonobo components mozilla-plugin-vlc &pop-mozillapluginvlc; &size-mozillapluginvlc; main Multimedia plugin based on VLC media player totem-mozilla &pop-totemmozilla; &size-totemmozilla; main Multimedia plugin based on GNOME's Totem media player gecko-mediaplayer &pop-geckomediaplayer; &size-geckomediaplayer; main Multimedia plugin based on (GNOME) MPlayer nspluginwrapper &pop-nspluginwrapper; &size-nspluginwrapper; contrib A wrapper to run i386 Netscape plugins on amd64 architecture
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 exaple, 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. Spoofed user-agent string may cause bad side effects with Java.
The mail system If you are to set up the mail server to exchange mail directly with the Internet, you should be better than reading this elementary document.
Modern mail service basics In order to contain spam (unwanted and unsolicited e-mail) problems, many ISPs which provide consumer grade Internet connection are implementing counter measures: The smarthost service for their customers to send message uses the message submission port (587) specified in rfc4409 with the password (SMTP AUTH service) specified in rfc4954. The SMTP port (25) connection from their internal network hosts (except ISP's own outgoing mail server) to the Internet are blocked. The SMTP port (25) connection to the ISP's incoming mail server from some suspicious external network hosts are blocked. (The connection from hosts on the dynamic IP address range used by the dial-up and other consumer grade Internet connections are the first ones to be blocked.) When configuring your mail system or resolving mail delivery problems, you must consider these new limitations. In light of these hostile Internet situation and limitations, some independent Internet mail ISPs such as Yahoo.com and Gmail.com offer the secure mail service which can be connected from anywhere on the Internet using Transport Layer Security (TLS) and its predecessor, Secure Sockets Layer (SSL) : The smarthost service for their customers to send message uses the SMTP/SSL port (465) or the message submission port (587) with the password (SMTP AUTH service). The incoming mail is accessible at the TLS/POP3 port (995) with POP3. 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 will assume that the smarthost is located at "smtp.hostname.dom", requires SMTP AUTH, and uses the message submission port (587) in the following text.
The mail configuration strategy for workstation The most simple mail configuration is that the mail is sent to the ISP's smarthost and received from ISP's POP3 server by the MUA (see ) itself. This type of configuration is popular with full featured GUI based MUA such as icedove(1), evolution(1), etc.. If you need to filter mail by their types, you use MUA's filtering function. For this case, the local MTA (see ) need to do local delivery only. The alternative mail configuration is that the mail is sent via local MTA to the ISP's smarthost and received from ISP's POP3 by the mail retriever (see ) to the local mailbox. If you need to filter mail by their types, you use MDA with filter (see ) to filter mail into separate mailboxes. This type of configuration is popular with simple console based MUA such as mutt(1), gnus(1), etc., although this is possible with any MUAs (see ). For this case, the local MTA (see ) need to do both smarthost delivery and local delivery.
Mail transport agent (MTA) For normal workstation, the popular choice for Mail transport agent (MTA) is either exim4-* or postfix packages. It is really up to you. List of basic mail transport agent related packages for workstation. package popcon size description exim4-daemon-light &pop-eximedaemonlight; &size-eximedaemonlight; Exim4 mail transport agent (MTA: Debian default) exim4-base &pop-eximebase; &size-eximebase; Exim4 documentation (text) and common files exim4-doc-html &pop-eximedochtml; &size-eximedochtml; Exim4 documentation (html) exim4-doc-info &pop-eximedocinfo; &size-eximedocinfo; Exim4 documentation (info) postfix &pop-postfix; &size-postfix; Postfix mail transport agent (MTA: alternative) postfix-doc &pop-postfixdoc; &size-postfixdoc; Postfix documentation (html+text) sasl2-bin &pop-saslcbin; &size-saslcbin; Cyrus SASL API implementation (supplement postfix for SMTP AUTH) cyrus-sasl2-doc &pop-cyrussaslcdoc; &size-cyrussaslcdoc; 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 trasport agent (MTA) packages with different capability and focus in Debian archive. List of choices for mail transport agent (MTA) packages in Debian archive. package popcon size capability and focus exim4-daemon-light &pop-eximedaemonlight; &size-eximedaemonlight; full postfix &pop-postfix; &size-postfix; full (security) exim4-daemon-heavy &pop-eximedaemonheavy; &size-eximedaemonheavy; full (flexible) sendmail-bin &pop-sendmailbin; &size-sendmailbin; full (only if you are already familiar) nullmailer &pop-nullmailer; &size-nullmailer; strip down, no local mail ssmtp &pop-ssmtp; &size-ssmtp; strip down, no local mail nbsmtp &pop-nbsmtp; &size-nbsmtp; ? courier-mta &pop-couriermta; &size-couriermta; very full (web interface etc.) xmail &pop-xmail; &size-xmail; light masqmail &pop-masqmail; &size-masqmail; light esmtp &pop-esmtp; &size-esmtp; light esmtp-run &pop-esmtprun; &size-esmtprun; light (sendmail compatibility extension to esmtp) msmtp &pop-msmtp; &size-msmtp; light msmtp-mta &pop-msmtpmta; &size-msmtpmta; light (sendmail compatibility extension to msmtp)
The configuration of exim4 For the Internet mail via smarthost, you (re)configure exim4-* packages as follows: $ sudo /etc/init.d/exim4 stop $ sudo dpkg-reconfigure exim4-conf Chose "mail sent by smarthost; received via SMTP or fetchmail". Set "IP address or host name of the outgoing smarthost:" to "smtp.hostname.dom:587". Reply to "Keep number of DNS-queries minimal (Dial-on-Demand)?" as: "No" if the system is connected to the Internet while booting, or "Yes" if the system is not connected to the Internet while booting. $ sudo vim /etc/exim4/passwd.client Create password entries for the smarthost. $ cat /etc/exim4/passwd.client ^smtp.*\.hostname\.dom:username@hostname.dom:password $ sudo /etc/init.d/exim4 start The host name in "/etc/exim4/passwd.client" should not be the alias. You check the real host name with: $ host smtp.hostname.dom smtp.hostname.dom is an alias for smtp99.hostname.dom. smtp99.hostname.dom has address 123.234.123.89 I use regex in "/etc/exim4/passwd.client" to work around the alias issue so even if the ISP moves host pointed by the alias, SMTP AUTH will likely be working. You must execute update-exim4.conf(8) after manually updating exim4 configuration files in "/etc/exim4/". Starting exim4 will take 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. Please read the official guide at: "/usr/share/doc/exim4-base/README.Debian.gz" and update-exim4.conf(8). 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.
The configuration of postfix with SASL For the Internet mail via smarthost, you should first read postfix documentation and key manual pages: List of important postfix manual pages command function postfix(1) Postfix control program postconf(1) Postfix configuration utility postconf(5) Postfix configuration parameters postmap(1) Postfix lookup table maintenance postalias(1) Postfix alias database maintenance
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" $ sudo postconf -e 'smtp_sender_dependent_authentication = yes' $ sudo postconf -e 'smtp_sasl_auth_enable = yes' $ sudo postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd' $ sudo postconf -e 'smtp_sasl_type = cyrus' $ sudo 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 $ sudo /etc/init.d/postfix start Here the use of "[" and "]" in the dpkg-reconfigure dialogue 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 mail address configuration There are a few mail address configuration files for mail transport, delivery and user agents. List of mail address related configuration files. file function application /etc/mailname default host name for (outgoing) mail Debian specific, mailname(5) /etc/email-addresses host name spoofing for outgoing mail exim(8) specific, exim4-config_files(5) /etc/postfix/generic host name spoofing for outgoing mail postfix(1) specific, activated after postmap(1) command execution. /etc/aliases account name alias for incoming mail general, activated after newaliases(1) command execution.
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 both exim4-* and postfix.) 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. When setting the mailname to "hostname -f", the spoofing of the source mail address via MTA can be realized by: "/etc/email-addresses" file for exim4(8) as explained in the exim4-config_files(5), and "/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 check filters using: exim(8) with -brw, -bf, -bF, -bV, … options. postmap(1) with -q option. Exim comes with several utility programs such as exiqgrep(8) and exipick(8). See "dpkg -L exim4-base|grep man8/" for available commands.
Basic MTA operations There are several basic MTA operations. Some may be performed via sendmail(1) compatibility interface. List of basic MTA operation. exim command postfix command description sendmail sendmail Read mails from standard input and arrange for delivery. (-bm) mailq mailq List the mail queue with status and queue ID. (-bp) newaliases newaliases Initialize alias database. (-I) exim4 -q postqueue -f Flush waiting mails. (-q) exim4 -qf postsuper -r ALL deferred; postqueue -f Flush all mails. exim4 -qff postsuper -r ALL; postqueue -f Flush even frozen mails. exim4 -Mg queue_id postsuper -h queue_id Freeze one message by its queue ID. exim4 -Mrm queue_id postsuper -d queue_id Remove one message by its queue ID. --- postsuper -d ALL Remove all messages.
It may be a good idea to flush all mails by a script in "/etc/ppp/ip-up.d/*".
Mail user agent (MUA) If you subscribe to Debian related mailing list, it may be a good idea to use such MUA as mutt and gnus which are the de facto standard for the participant and known to behave as expected. List of mail user agent (MUA). package popcon size type iceweasel &pop-iceweasel; &size-iceweasel; X GUI program (unbranded Mozilla Firefox) evolution &pop-evolution; &size-evolution; X GUI program (part of a groupware suite) icedove &pop-icedove; &size-icedove; X GUI program (unbranded Mozilla Thunderbird) mutt &pop-mutt; &size-mutt; character terminal program probably used with vim gnus &pop-gnus; &size-gnus; character terminal program under (x)emacs
Basic MUA — Mutt Use mutt as the mail user agent (MUA) in combination with vim. Customize it with "~/.muttrc". For example: # use visual mode and "gq" to reformat quotes set editor="vim -c 'set tw=72 et ft=mail'" # # header weeding taken from the manual (Sven's Draconian header weeding) # ignore * unignore from: date subject to cc unignore user-agent x-mailer hdr_order from subject to cc date user-agent x-mailer set hostname=spoof.example.org set from="First Last <username@example.org>" .... Add the following to "/etc/mailcap" or "~/.mailcap" to display HTML mail and MS Word attachments inline: text/html; lynx -force_html %s; needsterminal; application/msword; /usr/bin/antiword '%s'; copiousoutput; description="Microsoft Word Text"; nametemplate=%s.doc
The remote mail retrieval and forward utility Although fetchmail(1) has been de facto standard for the remote mail retrieval on GNU/Linux, the authour likes getmail(1) now. If you want to reject mail before downloading to save bandwidth, mailfilter or mpop may be useful. Whichever mail retriever utilities are used, it is good idea to configure system to deliver retrieved mails to MDA, such as maildrop, via pipe. List of remote mail retrieval and forward utilities. package popcon size description fetchmail &pop-fetchmail; &size-fetchmail; mail retriever (POP3, APOP, IMAP) (old) getmail4 &pop-getmaile; &size-getmaile; mail retriever (POP3, IMAP4, and SDPS) (simple, secure, and reliable) mailfilter &pop-mailfilter; &size-mailfilter; mail retriever (POP3) with with regex filtering capability mpop &pop-mpop; &size-mpop; mail retriever (POP3) and MDA with filtering capability
getmail configuration getmail(1) configuration is described in getmail documentation. Here is my set up to access multiple POP3 accounts as user: Create "/usr/local/bin/getmails" as: #!/bin/sh set -e rcfiles="/usr/bin/getmail" for file in $HOME/.getmail/config/* ; do rcfiles="$rcfiles --rcfile $file" done exec $rcfiles $@ Execute as follows: $ 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 acconts as: [retriever] type = SimplePOP3SSLRetriever server = pop.example.com username = pop3_name@example.com password = secret [destination] type = MDA_external path = /usr/bin/maildrop unixfrom = True 'Spam' [options] verbose = 0 delete = True delivered_to = False message_log = ~/.getmail/log/pop3_name.log Execute as follows: $ 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 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".
fetchmail configuration fetchmail(1) configuration is set by "/etc/default/fetchmail", "/etc/fetchmailrc" and "$HOME/.fetchmailrc". See its example in "/usr/share/doc/fetchmail/examples/fetchmailrc.example".
Mail delivery agent (MDA) with filter Most MTA programs, such as postfix and exim4, function as MDA (mail delivery agent). There are specialized MDA with filtering capabilities. Although procmail(1) has been de facto standard for MDA with filter on GNU/Linux, authour likes maildrop(1) now. Whichever filtering utilities are used, it is good idea to configure system to deliver filtered mails to a qmail-style Maildir. List of MDA with filter. package popcon size description procmail &pop-procmail; &size-procmail; MDA with filter (old) mailagent &pop-mailagent; &size-mailagent; MDA with Perl filter maildrop &pop-maildrop; &size-maildrop; MDA with structured filtering language
maildrop configuration maildrop(1) configuration is described in maildropfilter documentation. Here is a configuration example for "$HOME/.mailfilter": logfile $HOME/.maildroplog # clearly bad looking mails: drop them into X-trash and exit if ( /^X-Advertisement/ ||\ /^Subject:.*BUSINESS PROPOSAL/ ||\ /^Subject:.*URGENT.*ASISSTANCE/ ||\ /^Subject: *I NEED YOUR ASSISTANCE/ ) to "$HOME/Maildir/X-trash/" # Delivering mailinglist messages if ( /^Precedence:.*list/ ||\ /^Precedence:.*bulk/ ||\ /^List-/ ||\ /^X-Distribution:.*bulk/ ) { if ( /^Resent-Sender.*debian-user-request@lists.debian.org/) to "$HOME/Maildir/debian-user/" if ( /^Resent-Sender.*debian-devel-request@lists.debian.org/) to "$HOME/Maildir/debian-devel/" if ( /^Resent-Sender.*debian-announce-request@lists.debian.org/) to "$HOME/Maildir/debian-announce/" to "$HOME/Maildir/mailing-list/" } to "$HOME/Maildir/Inbox/" exit Unlike procmail, maildrop does not create missing maildir directories automatically. You must create them manually using maildirmake(1) in advance.
procmail configuration Equivalent configurartion can be done with procmail(1) with "$HOME/.procmailrc" as: MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/Inbox/ LOGFILE=$MAILDIR/Maillog # clearly bad looking mails: drop them into X-trash and exit :0 * 1^0 ^X-Advertisement * 1^0 ^Subject:.*BUSINESS PROPOSAL * 1^0 ^Subject:.*URGENT.*ASISSTANCE * 1^0 ^Subject: *I NEED YOUR ASSISTANCE X-trash/ # Delivering mailinglist messages :0 * 1^0 ^Precedence:.*list * 1^0 ^Precedence:.*bulk * 1^0 ^List- * 1^0 ^X-Distribution:.*bulk { :0 * 1^0 ^Return-path:.*debian-devel-admin@debian.or.jp jp-debian-devel/ :0 * ^Resent-Sender.*debian-user-request@lists.debian.org debian-user/ :0 * ^Resent-Sender.*debian-devel-request@lists.debian.org debian-devel/ :0 * ^Resent-Sender.*debian-announce-request@lists.debian.org debian-announce :0 mailing-list/ } :0 Inbox/
Redeliver mbox contents You need to manually deliver mails to the sorted mailboxes in your home directory from "/var/mail/<username>" if your home directory became full and procmail(1) failed. After making disk space in the home directory, run: # /etc/init.d/${MAILDAEMON} stop # formail -s procmail </var/mail/<username> # /etc/init.d/${MAILDAEMON} start
POP3/IMAP4 server If you are to run a private server on LAN, you may consider to run POP3 / IMAP4 server for delivering mail to LAN clients. List of POP3/IMAP4 servers. package popcon size type description qpopper &pop-qpopper; &size-qpopper; POP3 Qualcomm enhanced BSD POP3 server courier-pop &pop-courierpop; &size-courierpop; POP3 Courier mail server - POP3 server (maildir format only) ipopd &pop-ipopd; &size-ipopd; POP3 The University of Washington POP2 and POP3 server cyrus-pop3d-2.2 &pop-cyruspopddcc; &size-cyruspopddcc; POP3 Cyrus mail system (POP3 support) xmail &pop-xmail; &size-xmail; POP3 ESMTP/POP3 mail server courier-imap &pop-courierimap; &size-courierimap; IMAP Courier mail server - IMAP server (maildir format only) uw-imapd &pop-uwimapd; &size-uwimapd; IMAP The University of Washington IMAP server cyrus-imapd-2.2 &pop-cyrusimapdcc; &size-cyrusimapdcc; IMAP Cyrus mail system (IMAP support)
The print server and utility In the old Unix-like system, the BSD Line printer daemon was the standard. Since the standard print out format of the free software is PostScript on the Unix like system, some filter system was used along with Ghostscript to enable printing to the non-PostScript printer. Recently, Common UNIX Printing System (CUPS) is the new de facto standard. The CUPS uses Internet Printing Protocol (IPP). The IPP is now supported by other OSs such as Windows XP and Mac OS X and has became new cross-platform de facto standard for remote printing with bi-directional communication capability. The standard printable data format for the application on the Debian system is the PostScript (PS) which is a page description language. The data in PS format is fed into the Ghostscript PostScript interpreter to produce the printable data specific to the printer. See . Thanks to the file format dependent auto-conversion feature of the CUPS system, simply feeding any data to the lpr command should generate the expected print output. (In CUPS, lpr can be enabled by installing the cups-bsd package.) The Debian system has some notable packages for the print servers and utilities: List of print servers and utilities. package popcon size port description lpr &pop-lpr; &size-lpr; printer (515) BSD lpr/lpd (Line printer daemon) lprng &pop-lprng; &size-lprng; , , , , (Enhanced) cups &pop-cups; &size-cups; IPP (631) Internet Printing CUPS server cups-client &pop-cupsclient; &size-cupsclient; , , System V printer commands for CUPS: lp(1), lpstat(1), lpoptions(1), cancel(1), lpmove(8), lpinfo(8), lpadmin(8), … cups-bsd &pop-cupsbsd; &size-cupsbsd; , , BSD printer commands for CUPS: lpr(1), lpq(1), lprm(1), lpc(8) cups-driver-gutenprint &pop-cupsdrivergutenprint; &size-cupsdrivergutenprint; Not applicable printer drivers for CUPS
You can configure CUPS system by pointing your web browser to "http://localhost:631/" .
The remote access server and utility (SSH) The Secure SHell (SSH) is the secure way to connect over the Internet. A free version of SSH called OpenSSH is available as openssh-client and openssh-server packages in Debian. List of remote access server and utilities. package popcon size tool description openssh-client &pop-opensshclient; &size-opensshclient; ssh(1) Secure shell client openssh-server &pop-opensshserver; &size-opensshserver; sshd(8) Secure shell server ssh-askpass-fullscreen &pop-sshaskpassfullscreen; &size-sshaskpassfullscreen; ssh-askpass-fullscreen(1) asks user for a pass phrase for ssh-add (GNOME2) ssh-askpass &pop-sshaskpass; &size-sshaskpass; ssh-askpass(1) asks user for a pass phrase for ssh-add (plain X)
See if your SSH is accessible from the Internet. Please use the screen(1) program to enable remote shell process to survive the interrupted connection (see ).
Basics of SSH "/etc/ssh/sshd_not_to_be_run" must not be present if one wishes to run the OpenSSH server. SSH has two authentication protocols: List of SSH authentication protocols and methods. SSH protocol SSH method description SSH-1 "RSAAuthentication" RSA identity key based user authentication , , "RhostsAuthentication" ".rhosts" based host authentication (insecure, disabled) , , "RhostsRSAAuthentication" ".rhosts" based host authentication combined with RSA host key (disabled) , , "ChallengeResponseAuthentication" RSA challenge-response authentication , , "PasswordAuthentication" password based authentication SSH-2 "PubkeyAuthentication" public key based user authentication , , "HostbasedAuthentication" "~/.rhosts" or "/etc/hosts.equiv" based host authentication combined with public key client host authentication (disabled) , , "ChallengeResponseAuthentication" challenge-response authentication , , "PasswordAuthentication" password based authentication
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: List of SSH configuration files. configuration file function /etc/ssh/ssh_config SSH client defaults. See ssh_config(5). /etc/ssh/sshd_config SSH server defaults. See sshd_config(5). ~/.ssh/authorized_keys the lists of the default public SSH keys that clients use to connect to this account on this host. ~/.ssh/identity secret SSH-1 RSA key of the user. ~/.ssh/id_rsa secret SSH-2 RSA key of the user. ~/.ssh/id_dsa secret SSH-2 DSA key of the user.
See ssh-keygen(1), ssh-add(1) and ssh-agent(1) for how to use public and secret SSH keys. Make sure to verify settings by testing the connection. In case of any problem, use "ssh -v". You can change the pass phrase to encrypt local secret SSH keys later with "ssh-keygen -p". 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 will start an ssh(1) connection from a client. List of SSH client startup examples. command description ssh username@hostname.domain.ext connect with default mode ssh -v username@hostname.domain.ext connect with default mode with debugging messages ssh -1 username@hostname.domain.ext force to connect with SSH version 1 ssh -1 -o RSAAuthentication=no -l username hostname.domain.ext force to use password with SSH version 1 ssh -o PreferredAuthentications=password -l username hostname.domain.ext force to use password with SSH 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: 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-]).
Port forwarding for SMTP/POP3 tunneling To establish a pipe to connect to port 25 of remote-server from port 4025 of localhost, and to port 110 of remote-server from port 4110 of localhost through ssh, execute on the local host: # ssh -q -L 4025:remote-server:25 4110:remote-server:110 username@remote-server This is a secure way to make connections to SMTP/POP3 servers over the Internet. Set the "AllowTcpForwarding" entry to "yes" in "/etc/ssh/sshd_config" of the remote host.
Connecting without remote passwords One can avoid having to remember passwords for remote systems by using "RSAAuthentication" (SSH-1 protocol) or "PubkeyAuthentication" (SSH-2 protocol). On the remote system, set the respective entries, "RSAAuthentication yes" or "PubkeyAuthentication yes", in "/etc/ssh/sshd_config". Then generate authentication keys locally and install the public key on the remote system: "RSAAuthentication": RSA key for SSH-1 (deprecated because it is superseded.) $ ssh-keygen $ cat .ssh/identity.pub | ssh user1@remote "cat - >>.ssh/authorized_keys" "PubkeyAuthentication": RSA key for SSH-2 $ ssh-keygen -t rsa $ cat .ssh/id_rsa.pub | ssh user1@remote "cat - >>.ssh/authorized_keys" "PubkeyAuthentication": DSA key for SSH-2 (deprecated because it is slow.) $ ssh-keygen -t dsa $ cat .ssh/id_dsa.pub | ssh user1@remote "cat - >>.ssh/authorized_keys" 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. 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.
Dealing with alien SSH clients There are some free SSH clients available for other platforms. List of free SSH clients for other platforms. environment free SSH program Windows puTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/) (GPL) 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)
Setting up ssh-agent It is safer to protect your SSH authentication secret keys with a pass phrase. If a pass phrase was not set, use "ssh-keygen -p" to set it. Place your public SSH key (e.g. "~/.ssh/id_rsa.pub") into "~/.ssh/authorized_keys" on a remote host using a password-based connection to the remote host as described above. $ ssh-agent bash $ ssh-add ~/.ssh/id_rsa Enter passphrase for /home/<username>/.ssh/id_rsa: Identity added: /home/<username>/.ssh/id_rsa (/home/<username>/.ssh/id_rsa) No remote password needed from here on, e.g.: $ scp foo <username>@remote.host:foo No password requested. Press ^D to terminating ssh-agent session. For the X server, the normal Debian startup script executes ssh-agent as the parent process. So you only need to execute ssh-add once. For more, read ssh-agent(1)and ssh-add(1).
Troubleshooting SSH If you have problems, check the permissions of configuration files and run ssh with the "-v" option. Use the "-P" option if you are root and have trouble with a firewall; this avoids the use of server ports 1 — 1023. If ssh connections to a remote site suddenly stop working, it may be the result of tinkering by the sysadmin, most likely a change in "host_key" during system maintenance. After making sure this is the case and nobody is trying to fake the remote host by some clever hack, one can regain a connection by removing the "host_key" entry from "~/.ssh/known_hosts" on the local host.
Other network application servers List of other network application servers. package popcon size protocol description telnetd &pop-telnetd; &size-telnetd; TELNET TELNET server telnetd-ssl &pop-telnetdssl; &size-telnetdssl; , , , , (SSL support) nfs-kernel-server &pop-nfskernelserver; &size-nfskernelserver; NFS Unix file sharing samba &pop-samba; &size-samba; SMB Windows file and printer sharing netatalk &pop-netatalk; &size-netatalk; ATP Apple/Mac file and printer sharing (AppleTalk) proftpd-basic &pop-proftpdbasic; &size-proftpdbasic; FTP General file download wu-ftpd &pop-wuftpd; &size-wuftpd; , , , , apache2-mpm-prefork &pop-apachecmpmprefork; &size-apachecmpmprefork; HTTP General web server apache2-mpm-worker &pop-apachecmpmworker; &size-apachecmpmworker; , , , , squid &pop-squid; &size-squid; , , General web proxy server squid3 &pop-squidd; &size-squidd; , , , , slpd &pop-slpd; &size-slpd; SLP OpenSLP Server as LDAP server bind9 &pop-bindj; &size-bindj; DNS IP address for other hosts dhcp3-server &pop-dhcpdserver; &size-dhcpdserver; DHCP IP address of client itself
Common Internet File System Protocol (CIFS) is the same protocol as Server Message Block (SMB) and is used widely by Microsoft Windows. 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.
Other network application clients List of network application clients. package popcon size protocol description netcat &pop-netcat; &size-netcat; TCP/IP TCP/IP swiss army knife stunnel4 &pop-stunnele; &size-stunnele; SSL Universal SSL Wrapper telnet &pop-telnet; &size-telnet; TELNET TELNET client telnet-ssl &pop-telnetssl; &size-telnetssl; , , , , (SSL support) nfs-common &pop-nfscommon; &size-nfscommon; NFS Unix file sharing smbclient &pop-smbclient; &size-smbclient; SMB MS Windows file and printer sharing client smbfs &pop-smbfs; &size-smbfs; , , Mount and umount commands for remote MS Windows file ftp &pop-ftp; &size-ftp; FTP FTP client lftp &pop-lftp; &size-lftp; , , , , ncftp &pop-ncftp; &size-ncftp; , , Full screen FTP client wget &pop-wget; &size-wget; HTTP and FTP Web downloader curl &pop-curl; &size-curl; , , , , dog &pop-dog; &size-dog; HTTP Web uploader (cat with URL support) bind9-host &pop-bindjhost; &size-bindjhost; DNS The host command from bind9. Priority: standard dnsutils &pop-dnsutils; &size-dnsutils; , , The dig command from bind. Priority: standard host &pop-host; &size-host; , , The host command from dnsutils. Priority: extra dhcp3-client &pop-dhcpdclient; &size-dhcpdclient; DHCP Obtain IP address ldap-utils &pop-ldaputils; &size-ldaputils; LDAP Obtain data from LDAP server
The diagnosis of the system daemons The telnet program enables manual connection to the system daemons and its diagnosis. E.g.: $ telnet mail.ispname.net pop3 The following RFCs provide required knowledge to each system daemon. List of popular RFCs. RFC description rfc1939 and rfc2449 POP3 service rfc3501 IMAP4 service rfc2821 (rfc821) SMTP service rfc2822 (rfc822) Mail file format rfc2045 Multipurpose Internet Mail Extensions (MIME) rfc819 DNS service rfc2616 HTTP service rfc2396 URI definition
The port usage is described in "/etc/services". For testing TLS/SSL services such as HTTPS, you need TLS/SSL enabled telnet program.
The X window system The X window system on the Debian system is based on the source from X.Org. As of July 2009, they are X11R7.1(etch), X11R7.3(lenny), X11R7.3(squeeze) and X11R7.4(sid).
Key packages There are a few (meta)packages provided to ease installation. List of key (meta)packages for X window. (meta)package popcon size description xorg &pop-xorg; &size-xorg; This metapackage provides the X libraries, an X server, a set of fonts, and a group of basic X clients and utilities. xserver-xorg &pop-xserverxorg; &size-xserverxorg; This package provides the full suits of the X server and its configuration. xbase-clients &pop-xbaseclients; &size-xbaseclients; This package provides a miscellaneous assortment of X clients. x11-common &pop-xbbcommon; &size-xbbcommon; This package contains the filesystem infrastructure for the X window system. xorg-docs &pop-xorgdocs; &size-xorgdocs; This package contains miscellaneous documentation for the X.Org software suite. xspecs &pop-xspecs; &size-xspecs; This package contains X protocol, extension, and library technical specifications. menu &pop-menu; &size-menu; This package generates the Debian menu for all menu-aware applications. gksu &pop-gksu; &size-gksu; This package provides a Gtk+ frontend to su(1) or sudo(8). menu-xdg &pop-menuxdg; &size-menuxdg; This package converts the Debian menu structure to the freedesktop.org xdg menu structure. xdg-utils &pop-xdgutils; &size-xdgutils; This package provides utilities to integrate desktop environment provided by the freedesktop.org. gnome-desktop-environment &pop-gnomedesktopenvironment; &size-gnomedesktopenvironment; metapackage for the stadard GNOME desktop environment. kde-core &pop-kdecore; &size-kdecore; metapackage for the core KDE desktop environment. xfce4 &pop-xfcee; &size-xfcee; metapackage for the Xfce lightweight desktop environment. lxde-core &pop-lxdecore; &size-lxdecore; metapackage for the LXDE lightweight desktop environment. fluxbox &pop-fluxbox; &size-fluxbox; Fluxbox: package for highly configurable and low resource X window manager.
For the basics of X, refer to X(7), the LDP XWindow-User-HOWTO.
Setting up desktop environment A desktop environment is usually a combination of a X window manager, a file manager, and a suite of compatible utility programs. You can setup a full desktop environment such as GNOME, KDE, Xfce, or LXDE, from the aptitude under the task menu. 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.
Debian menu Debian menu system provides a general interface for both text- and X-oriented programs with update-menus(1) from the menu package. Each package installs its menu data in the "/usr/share/menu/" directory. See "/usr/share/menu/README".
Freedesktop.org menu Each package which is compliant to Freedesktop.org's xdg menu system installs its menu data provided by "*.desktop" under "/usr/share/applications/". Modern desktop environments which are compliant to Freedesktop.org standard use these data to generate their menu using the xdg-utils package. See "/usr/share/doc/xdg-utils/README".
Debian menu under GNOME desktop environment In order to obtain access to the traditional Debian menu under GNOME desktop environment, you must install the menu-xdg package, click "System" → "Preference" → "Main Menu", and check the box for "Debian". You may need to do the similar for other modern desktop environments which are compliant to Freedesktop.org standard.
The server/client relationship The X window system is activated as a combination of the server and client programs. The meaning for the words server and client with respect to the words local and remote requires attention here: List of server/client terminology. type description X server a program run on a local host connected to the user's display and input devices. X client a program run on a remote host that processes data and talks to the X server. 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.
The X server See xorg(1) for X server information.
The (re)configuration of the X server X server (post-lenny) is rewitten to use more information from standardized OS services such as HAL and D-bus, for its configuration than that from "/etc/X11/xorg.conf". So contents in "/etc/X11/xorg.conf" are getting less. You may need to work around transitional problems of X server. The following will (re)configure an X server by generating a new "/etc/X11/xorg.conf" file using dexconf(1). # dpkg-reconfigure --priority=low x11-common # dpkg-reconfigure --priority=low xserver-xorg If you have manually edited this "/etc/X11/xorg.conf" file but would like it to be automatically updated again, run the following command: # 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. Be careful not to use too high refresh rate which may cause fatal hardware failure of your monitor system.
The connection methods to the X server There are several ways of getting the "X server" (display side) to accept connections from an "X client" (application side): List of connection methods to the X server. method package popcon size user encryption pertinent use xhost command xbase-clients &pop-xbaseclients; &size-xbaseclients; unchecked no deprecated xauth command xbase-clients &pop-xbaseclients; &size-xbaseclients; checked no for local connection via pipe ssh -X command openssh-client &pop-opensshclient; &size-opensshclient; checked yes for remote network connection GNOME display manager gdm &pop-gdm; &size-gdm; checked no(XDMCP) for local connection via pipe KDE display manager kdm &pop-kdm; &size-kdm; checked no(XDMCP) for local connection via pipe X display manager xdm &pop-xdm; &size-xdm; checked no(XDMCP) for local connection via pipe WindowMaker display manager wdm &pop-wdm; &size-wdm; checked no(XDMCP) for local connection via pipe LTSP display manager ldm &pop-ldm; &size-ldm; checked yes for remote SSH network connection (thin client)
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". Do not use XDMCP connection over unsecured network either. It sends data via UDP/IP without encryption and is prone to the eavesdropping attack. 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. LTSP stands for Linux Terminal Server Project.
Starting the X window system The X Window system is usually started as an X session which is the combination of an X server and connecting X clients. For the normal desktop system, both of them are executed on a workstation. The X session is started by: startx command started from the command line, or one of the X display manager daemon programs *dm started from the end of the start up script in "/etc/rc?.d/" ("?" corresponding to the runlevel) directory. 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. See 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 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: The script specified as the argument of "/etc/X11/Xsession" by the X display manager, if it is defined. The "~/.xsession" or "~/.Xsession" script, if it is defined. The "/usr/bin/x-session-manager" command, if it is defined. The "/usr/bin/x-window-manager" command, if it is defined. 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.
Starting X session with gdm gdm(1) lets you select the session type (or desktop environment: ), and language (or locale: ) of the X session from its menu. It keeps the selected default value in "~/.dmrc" as, e.g.: [Desktop] Session=default Language=ja_JP.UTF-8
Customizing the X session (classic method) On a system where "/etc/X11/Xsession.options" contains a line "allow-user-xsession" without preceding "#" characters, any user who defines "~/.xsession" or "~/.Xsession" will be able to customize the action of "/etc/X11/Xsession" by completely overiding the system code. The last command in the "~/.xsession" file should use form of "exec some-window/session-manager" to start your favorite X window/session managers.
Customizing the X session (new method) Here are new methods to customize the X session without completely overiding the system code as above. The display manager gdm can select a specific session and set it as the argument of "/etc/X11/Xsession". The "~/.xsessionrc" file is executed as a part of start up process (desktop independent.) The "~/.gnomerc" file is executed as a part of start up process. (GNOME desktop only) The GUI program based session management software can use the "~/.gnome2/session" file etc..
Connecting a remote X client via SSH The use of "ssh -X" enables a secure connection from a local X server to a remote application server. Set "X11Forwarding" entries to "yes" in "/etc/ssh/sshd_config" of the remote host, if you want to avoid "-X" command-line option. Start the X server on the local host. Open an xterm in the local host. Run ssh(1) to establish a connection with the remote site. localname @ localhost $ ssh -q -X loginname@remotehost.domain Password: ..... Run an X application command, e.g. "gimp", on the remote site. loginname @ remotehost $ gimp & This method allows the display of the remote X client output as if it were locally connected through a local UNIX domain socket.
Secure X terminal via the Internet Secure X terminal via the Internet, which displays remotely run entire X desktop environment, can easily achieved by using specialized package such as ldm. Your local machine becomes a secure thin client to the remote application server connected via SSH. If you want to add similar feature to your normal display manager gdm, create executable shell script at "/usr/local/bin/ssh-session" as: #!/bin/sh -e # Based on gdm-ssh-session in gdm source (GPL) ZENITY=$(type -p zenity) TARGETHOST=$($ZENITY --width=600 \ --title "Host to connect to" --entry \ --text "Enter the name of the host you want to log in to as user@host.dom:") TARGETSESSION=$($ZENITY --width=600 --height=400 \ --title "Remote session name" --list --radiolist --text "Select one" \ --column " " --column "Session" --column "description" --print-column 2 \ TRUE "/etc/X11/Xsession" "Debian" \ FALSE "/etc/X11/xinit/Xclients" "RH variants" \ 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" Then 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
Fonts in the X window X window on the Debian system support two mechanisms for font management: server side font management: the original core X11 font system and client side font management: the new Xft 2 font system. The core X11 font system provides backward compatibility with older applications such as Xterm with bitmap fonts. It is supported by installing pertinent font packages which trigger defoma(1) scripts to generate required files such as "fonts.dir". The Xft2 font system is used by all modern applications such as ones from GNOME, KDE, OpenOffice.org, etc.. It supports all fonts listed below (, , and ) with advanced features such as anti-aliasing. It has no configuration mechanism itself, rather it relies upon the fontconfig library to configure and customize fonts as described in fonts.conf(5). Actual rasterization is supported by the FreeType 2 font engine. These new X clients using Xft2 font system can talk to modern X server via the X Rendering Extension. Table of packages to support X window font systems. package popcon size description xfonts-utils &pop-xfontsutils; &size-xfontsutils; X Window System font utility programs libxft2 &pop-libxftc; &size-libxftc; Xft: FreeType-based font drawing library for X libfreetype6 &pop-libfreetypeg; &size-libfreetypeg; FreeType 2 font engine, shared library files fontconfig &pop-fontconfig; &size-fontconfig; generic font configuration library - support binaries fontconfig-config &pop-fontconfigconfig; &size-fontconfigconfig; generic font configuration library - configuration defoma &pop-defoma; &size-defoma; Debian Font Manager — automatic font configuration framework x-ttcidfont-conf &pop-xttcidfontconf; &size-xttcidfontconf; TrueType configuration for X (for CJK support)
You can check actual font path for: core X11 font path with "xset q" fontconfig font default: "fc-match" "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. You should rely on fontconfig infrastructure to configure fonts on the Debian system. Debian Font Manager (defoma(1)) is only useful as font installation such as X logical font description (XLFD) data.
Basic fonts There are 2 major types of computer fonts: bitmap fonts (good for low resolution rasterization) outline/stroke fonts (good for high resolution rasterization) While scaling of bitmap fonts causes jugged image, scaling of outline/stroke fonts produces smooth image. Bitmap fonts on the Debian system are provided by compressed X11 pcf bitmap font files having their file extension ".pcf.gz". Outline fonts on the Debian system are provided by: PostScript Type 1 font files having their file extension ".pfb" (binary font file) and ".afm" (font metrics file). TrueType font files having their file extension ".ttf". OpenType font files having their file extension ".ttf" or ".otf". OpenType is intended to supersede both the TrueType and the Type 1 ("PostScript") font formats. Table of corresponding <ulink url="&postscript;">PostScript</ulink> Type 1 fonts. font package popcon size sans-serif font serif font monospace font source of font PostScript N/A N/A Helvetica Times Courier Adobe gsfonts &pop-gsfonts; &size-gsfonts; Nimbus Sans L Nimbus Roman No9 L Nimbus Mono L URW (Adobe compatible size) gsfonts-x11 &pop-gsfontsxbb; &size-gsfontsxbb; Nimbus Sans L Nimbus Roman No9 L Nimbus Mono L X font support with PostScript Type 1 fonts. t1-cyrillic &pop-tbcyrillic; &size-tbcyrillic; Free Helvetian Free Times Free Courier URW extended (Adobe compatible size) lmodern &pop-lmodern; &size-lmodern; LMSans* LMRoman* LMTypewriter* scalable PostScript and OpenType fonts based on Computer Modern (from TeX)
Table of corresponding <ulink url="&truetype;">TrueType</ulink> fonts. font package popcon size sans-serif font serif font monospace font source of font ttf-mscorefonts-installer &pop-ttfmscorefontsinstaller; &size-ttfmscorefontsinstaller; Arial Times New Roman Courier New Microsoft (Adobe compatible size) (This installs non-free data) ttf-liberation &pop-ttfliberation; &size-ttfliberation; Liberation Sans Liberation Serif Liberation Mono Liberation Fonts project (Microsoft compatible size) ttf-freefont &pop-ttffreefont; &size-ttffreefont; FreeSans FreeSerif FreeMono GNU freefont (Microsoft compatible size) ttf-bitstream-vera &pop-ttfbitstreamvera; &size-ttfbitstreamvera; Bitstream Vera Sans Bitstream Vera Serif Bitstream Vera Sans Mono Bitstream, Inc. ttf-dejavu &pop-ttfdejavu; &size-ttfdejavu; DejaVu Sans DejaVu Serif DejaVu Sans Mono DejaVu, Bitstream with extended character code support ttf-dejavu-core &pop-ttfdejavucore; &size-ttfdejavucore; DejaVu Sans DejaVu Serif DejaVu Sans Mono DejaVu, basic font style variants ttf-dejavu-extra &pop-ttfdejavuextra; &size-ttfdejavuextra; DejaVu Sans DejaVu Serif DejaVu Sans Mono DejaVu, extra font style variants ttf-unifont &pop-ttfunifont; &size-ttfunifont; N/A N/A unifont GNU Unifont, with all printable character code in Unicode 5.1 Basic Multilingual Plane (BMP)
Additional fonts aptitude(8) will help you find additional fonts easily: by the short package list under "Packages which depend on defoma" under the defoma package list, by the short package list under "Tasks" → "Localization", by the filtered flat package list of font data with regex on debtag: "~Gmade-of::data:font", by the filtered flat package list of the BDF (bitmap) font packages with regex on package name: "~nxfonts-", or by the filtered flat package list of the TrueType (outline) font packages with regex on package name: "~nttf-". Since Free fonts are sometimes limited, installing or sharing some commercial TrueType fonts is an option for a Debian users. In order to make this process easy for the user, some convenience packages have been created: ttf-mathematica4.1 ttf-mscorefonts-installer You'll have a really good selection of TrueType fonts at the expense of contaminating your Free system with non-Free fonts.
CJK fonts Here are some key points focused on CJK issues. 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, ゴチック hei, gothic dodu m, gulim, gothic serif mincho, 明朝 so ng, ming ba tang
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 into: JIS X 0201 single-byte characters (191 characters), JIS X 0208 double-byte characters (6879 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. I order to cover complicated code space of characters, CID keyed Type 1 PostScript 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 ). 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.
X applications
X office applications Here is a list of basic office applications (OO is OpenOffice.org): List of basic X office applications package popcon package size type description openoffice.org-writer &pop-openofficeorgwriter; &size-openofficeorgwriter; OO word processor openoffice.org-calc &pop-openofficeorgcalc; &size-openofficeorgcalc; OO spreadsheet openoffice.org-impress &pop-openofficeorgimpress; &size-openofficeorgimpress; OO presentation openoffice.org-base &pop-openofficeorgbase; &size-openofficeorgbase; OO database management openoffice.org-draw &pop-openofficeorgdraw; &size-openofficeorgdraw; OO vector graphics editor (draw) openoffice.org-math &pop-openofficeorgmath; &size-openofficeorgmath; OO mathematical equation/formula editor abiword &pop-abiword; &size-abiword; GNOME word processor gnumeric &pop-gnumeric; &size-gnumeric; GNOME spreadsheet gimp &pop-gimp; &size-gimp; GTK bitmap graphics editor (paint) inkscape &pop-inkscape; &size-inkscape; GNOME vector graphics editor (draw) dia-gnome &pop-diagnome; &size-diagnome; GNOME flowchart and diagram editor mergeant &pop-mergeant; &size-mergeant; GNOME database management planner &pop-planner; &size-planner; GNOME project management kword &pop-kword; &size-kword; KDE word processor kspread &pop-kspread; &size-kspread; KDE spreadsheet kpresenter &pop-kpresenter; &size-kpresenter; KDE presentation kexi &pop-kexi; &size-kexi; KDE database management kivio &pop-kivio; &size-kivio; KDE flowchart and diagram editor karbon &pop-karbon; &size-karbon; KDE vector graphics editor (draw) krita &pop-krita; &size-krita; KDE bitmap graphics editor (paint) kplato &pop-kplato; &size-kplato; KDE project management kchart &pop-kchart; &size-kchart; KDE graph and chart drawing program kformula &pop-kformula; &size-kformula; KDE mathematical equation/formula editor kugar &pop-kugar; &size-kugar; KDE business quality report generator
X utility applications Here is a list of basic utility applications which caught my eyes: List of basic X utility applications package popcon package size type description evince &pop-evince; &size-evince; GNOME document(pdf) viewer kpdf &pop-kpdf; &size-kpdf; KDE3 document(pdf) viewer okular &pop-okular; &size-okular; KDE4 document(pdf) viewer evolution &pop-evolution; &size-evolution; GNOME Personal information Management (groupware and email) kontact &pop-kontact; &size-kontact; KDE Personal information Management (groupware and email) scribus &pop-scribus; &size-scribus; KDE desktop page layout editor glabels &pop-glabels; &size-glabels; GNOME label editor kbarcode &pop-kbarcode; &size-kbarcode; KDE barcode and label printing application gnucash &pop-gnucash; &size-gnucash; GNOME personal accounting homebank &pop-homebank; &size-homebank; GTK personal accounting kmymoney2 &pop-kmymoneyc; &size-kmymoneyc; KDE personal accounting xsane &pop-xsane; &size-xsane; GTK scanner frontend kooka &pop-kooka; &size-kooka; KDE scanner frontend
The poppler-data package (non-free, see ) needs to be installed for evince and okular to display CJK PDF documents using Cmap data (). 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 will clutter your menu.
The X trivia
Keymaps and pointer button mappings in X xmodmap(1) is a utility for modifying keymaps and pointer button mappings in the X window system. To get the keycode, run xev(1) in the X and press keys. To get the meaning of keysym, look into the MACRO definition in "/usr/include/X11/keysymdef.h" file. All "#define" statements in this file are named as "XK_" prepended to keysym names.
Classic X clients Most traditional X client programs, such as xterm(1), can be started with a set of standard command line options to specify geometry, font, and display. They also use the X resource database to configure their appearance. The system-wide defaults of X resources are stored in "/etc/X11/Xresources/*" and application defaults of them are stored in "/etc/X11/app-defaults/*". Use these settings as the starting points. The file "~/.Xresources" is used to store user resource specifications. This file is automatically merged into the default X resources upon login. To make changes to these settings and make them effective immediately, merge them into the database using the command: $ xrdb -merge ~/.Xresources See x(7) and xrdb(1).
The X terminal emulator — xterm Learn everything about xterm(1) at http://dickey.his.com/xterm/xterm.faq.html.
Running X clients as root 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 because it is considered unsafe (insecure), even when you plan to perform administrative activities. The entire X architecture is considered insecure if run as root. You must always use the lowest privilege level possible, like a regular user account. The easiest way to run a particular X client, e.g. "foo" as root is to use sudo(8): $ sudo foo & or $ sudo -s # foo & or $ gksu foo & or $ ssh -X root@localhost # foo & Use of ssh(1) just for this purpose as above is waste of resource. Please note, in order for the X client to connect to the X server, values of the old user's "$XAUTHORITY" and "$DISPLAY" environment variables must be copied to the new user's ones, and the file pointed by value of the "$XAUTHORITY" environment variable must be readable by the new user. The gksu package (popcon: &pop-gksu;) 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").
I18N and L10N Multilingualization (M17N) for an application software is done in 2 steps: Internationalization (I18N): To make a software potentially handle multiple locales. Localization (L10N): To make a software handle an specific locale. There are 17, 18, or 10 letters between "m" and "n", "i" and "n", or "l" and "n". 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 ). See Introduction to i18n for details. The international hardware support is enabled with localized hardware configuration data.
The keyboard input The Debian system can be configured to work with many international keyboard arrangements: List of keyboard reconfiguration methods. environment command Linux console dpkg-reconfigure --priority=low console-data X Window dpkg-reconfigure --priority=low xserver-xorg
This will support 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 SCIM discussed next.
The input method support with SCIM Setup of multilingual input for the Debian system is simplified by using the SCIM family of packages with the im-switch package. The list of SCIM packages are: List of input method supports with scim. package popcon size suported locale scim-anthy &pop-scimanthy; &size-scimanthy; Japanese scim-canna &pop-scimcanna; &size-scimcanna; , , scim-skk &pop-scimskk; &size-scimskk; , , scim-prime &pop-scimprime; &size-scimprime; , , scim-tables-ja &pop-scimtablesja; &size-scimtablesja; , , (not very useful) scim-tables-zh &pop-scimtableszh; &size-scimtableszh; Chinese (for zh_*) scim-pinyin &pop-scimpinyin; &size-scimpinyin; , , (for zh_CN) scim-chewing &pop-scimchewing; &size-scimchewing; , , (for zh_TW) scim-hangul &pop-scimhangul; &size-scimhangul; Korean scim-tables-ko &pop-scimtablesko; &size-scimtablesko; , , scim-thai &pop-scimthai; &size-scimthai; Thai scim-m17n &pop-scimmbhn; &size-scimmbhn; Multilingual: Indic, Arabic and others scim-tables-additional &pop-scimtablesadditional; &size-scimtablesadditional; , , scim-uim &pop-scimuim; &size-scimuim; , ,
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 uim tool chain is an alternative approach for the international input method for the modern UTF-8 X environment which is also capable for non-X environment.
An example for Japanese I find the Japanese input method started under English environment ("en_US.UTF-8") very useful. Here is how I did it with SCIM. Install the Japanese input tool package scim-anthy with its recommended packages such as im-switch. Execute "im-switch -c" from user's shell and select "scim". Relogin to user's account. Verify setting by "im-switch -l". Setup input method and mode by right clicking GUI toolbar. (You can reduce menu choice of input method) Start SCIM input method by CTRL-SPACE In order to start SCIM under the non-CJK and non-en_US locale, you need to add list of those locales in UTF-8 to the "~/.scim/global" or "/etc/scim/global" file as: /SupportedUnicodeLocales = en_US.UTF-8,en_GB.UTF_8,fr_FR.UTF-8 Please note: im-switch(8) behaves differently if command is executed from root or not. Input method started by im-switch depends on the locale. Use of new immodule mechanism (by setting "$GTK_IM_MODULE") may cause instability during the library transition in unstable. For the detail of setup, see "/usr/share/doc/im-switch/README.Debian.gz", "/usr/share/doc/scim/README.Debian.gz" or "/usr/share/doc/uim/README.Debian.gz". Here key points are described.
Disabling the input method If you wish to input without going through XIM, set "$XMODIFIERS" value to "none" while starting a program. This may be the case if you use Japanese input infrastructure egg on emacs(1). From shell, execute as: $ XMODIFIERS=none emacs In order to adjust the command executed by the Debian menu, place customized configuration in "/etc/menu/" following method described in "/usr/share/doc/menu/html".
The display output Linux console can only display limited characters. (You need to use special terminal program such as jfbterm(1) to display non-European languages on the non-X console.) X Window can display any characters in the UTF-8 as long as required font data exists. (The encoding of the original font data is taken care by the X Window system and transparent to the user.)
The locale The following will focus on the locale for applications run under X Window environment started from gdm(1).
Basics of encoding The environment variable "LANG=xx_YY.ZZZZ" sets the locale to language code "xx", country code "yy", and encoding "ZZZZ" (see ). Current Debian system normally sets the locale as "LANG=xx_YY.UTF-8". This uses the UTF-8 encoding with the Unicode character set. This UTF-8 encoding system is a multibyte code system and uses code points smartly. The ASCII data, which consist only with 7-bit range codes, are always valid UTF-8 data consisting only with 1 byte per character. Previous Debian system used to set the locale as "LANG=C" or "LANG=xx_YY" (without ".UTF-8"). The ASCII character set is used for "LANG=C" or "LANG=POSIX". The traditional encoding system in Unix is used for "LANG=xx_YY". Actual traditional encoding system used for "LANG=xx_YY" can be identified by checking "/usr/share/i18n/SUPPORTED". For example, "en_US" uses "ISO-8859-1" encoding and "fr_FR@euro" uses "ISO-8859-15" encoding. For meaning of encoding values, see .
Rationale for UTF-8 locale The UTF-8 encoding is the modern and sensible text encoding system for I18N and enables to represent Unicode characters, i.e., practically all characters known to human. UTF stands for Unicode Transformation Format (UTF) schemes. I recommend to use UTF-8 locale for your desktop, e.g., "LANG=en_US.UTF-8". The first part of the locale determines messages presented by applications. For example, gedit(1) (text editor for the GNOME Desktop) under "LANG=fr_FR.UTF-8" locale can display and edit Chinese character text data while presenting menus in French, as long as required fonts and input methods are installed. I also recommend to set the locale only using the "$LANG" environment variable. I do not see much benefit of setting a complicated combination of "LC_*" variables (see locale(1)) under UTF-8 locale. Even plain English text may contain non-ASCII characters, e.g. left and right quotation marks are not available in ASCII: “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 UTF-32(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.
The reconfiguration of the locale In order for the system to access a particular locale, the locale data must be compiled from the locale database. (The Debian system does not come with all available locales pre-compiled unless you installed the locales-all package.) The full list of supported locales available for compiling are listed in "/usr/share/i18n/SUPPORTED". This lists all the proper locale names. The following will list all the available UTF-8 locales already compiled to the binary form: $ locale -a The following command execution will reconfigure the locale package: to update the list of available locales, to compile them into the binary form, and to set the system wide default locale value in the "/etc/defaults/locale" for use by PAM (see ). # dpkg-reconfigure locales The list of available locale should include "en_US.UTF-8" and all the interesting languages with "UTF-8". The recommended default locale is "en_US.UTF-8" for US English. For other languages, please make sure to chose locale with "UTF-8". Any one of these settings can handle any international characters. Although setting locale to "C" will use US English message, it handles only ASCII characters.
Configuring system with "$LANG" The environment variable "$LANG" is: set initially by some display manager such as gdm(1) for all X programs, changed by the X session startup code via "~/.xsessionrc" for all X programs (lenny feature), set initially by the PAM mechanism of login(1) for the local Linux console programs, set initially by the PAM mechanism of ssh(1) for the remote console programs, or changed by the shell startup code, e.g. "~/.bashrc", for all console programs. It is good idea to install system wide default locale as "en_US.UTF-8" for maximum compatibility.
Specific locale only under X Window You can chose specific locale only under X Window irrespective of your system wide default locale. This should provide your best desktop experience with stability. This way, you can always access functioning character terminal with readable messages even when X Window system is not working. This becomes essential for languages which use non-roman characters such as Chinese, Japanese, and Korean. For gdm(1), you can select different locale for the X session from its menu independent of the system default locale value in the "/etc/defaults/locale". You can set the locale of the X session manager and the value for the default locale permanently using PAM customization (see ) as follows. (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.) First, change the following line defining language environment variable in its PAM configuration file, such as "/etc/pam.d/gdm": auth required pam_env.so read_env=1 envfile=/etc/default/locale into auth required pam_env.so read_env=1 envfile=/etc/default/locale-x Then create a "/etc/defaults/locale-gdm" file with "-rw-r--r-- 1 root root" permission containing, eg. for Japanese message: LANG="ja_JP.UTF-8" and keep the default "/etc/defaults/locale" file for other programs being: LANG="en_US.UTF-8" This is the most generic technique to customize locale. Alternatively for this case, you may simply change locale using the "~/.xsessionrc" file.
Filename encoding For cross platform data exchanges (see ), you may need to mount some file system with particular encodings. For example, mount(8) for vfat filesystem assumes CP437 if used without option. You need to provide explicit mount option to use UTF-8 or CP932 for filenames. 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. 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 . Samba uses Unicode for newer clients (Windows NT, 200x, XP) but uses CP850 as default for older clients (DOS and Windows 9x/Me clients). This default for older clients can be changed using "dos charset" in the "/etc/samba/smb.conf" file, e.g., to CP932 for Japanese.
Localized messages and translated documentation Translations exist for many of the text messages and documents that are displayed in the Debian system, such as error messages, standard program output, menus, and manual pages. GNU gettext(1) command tool chain is used as the backend tool for most translation activities. aptitude(8) lists under "Tasks" → "Localization" provide extensive list of useful binary packages which add localized messages to applications and provide translated documentation. For example, you can obtain the localized message for manpage by installing the manpages-<LANG> package. To read the Italian-language manpage for <programname>, execute LANG=it_IT.UTF-8 man <programname> to read it from "/usr/share/man/it/".
Effects of the locale The sort order of characters with sort(1) is affected by the language choice of the locale. Spanish and English locale sort differently. The date format of ls(1) is affected by the locale. The date format of "LANG=C ls -l" and "LANG=en_US.UTF-8" are different (see ). Number punctuation are different for locales. For example, in English locale, one thousand one point one is displayed as "1,000.1" while in German locale, it is displayed as "1.000,1". You see this difference in spreadsheet program.
System tips Here, I will describe basic tips to configure and manage systems, mostly from the console.
The screen program screen(1) is a very useful tool for people to access remote sites via unreliable or intermittent connections since it support interrupted network connections. List of programs to support interrupted network connections. package popcon size description screen &pop-screen; &size-screen; terminal multiplexer with VT100/ANSI terminal emulation
The use scenario for screen(1) screen(1) not only allows one terminal window to work with multiple processes, but also allows remote shell process to survive interrupted connections. Here is a typical use scenario of screen(1). You login to a remote machine. You start screen on a single console. You execute multiple programs in screen windows created with ^A c ("Control-A" followed by "c"). You switch among the multiple screen windows by ^A n ("Control-A" followed by "n"). Suddenly you need to leave your terminal, but you don't want to lose your active work by keeping the connection. You detach the screen session by any methods such as: brutally unplugging your network connection, typing ^A d ("Control-A" followed by "d") and manually logging out from the remote connection, or typing ^A DD ("Control-A" followed by "DD") to have screen detach and log you out. You log in again to the same remote machine (even from a different terminal). You start screen as "screen -r". screen will magically reattach all previous screen windows with all actively running programs. You can save connection fees for metered network connections such as dial-up and packet ones, because you can leave a process active while disconnected, and then re-attach it later when you connect again.
Key bindings for the screen command In a screen session, all keyboard inputs are sent to your current window except for the command keystroke, by default ^A ("Control-A"). All screen commands are entered by typing ^A plus a single key [plus any parameters]. Here are important ones to remember: List of key bindings for screen. key binding meaning ^A ? show a help screen (display key bindings) ^A c create a new window and switch to it ^A n go to next window ^A p go to previous window ^A 0 go to window number 0 ^A 1 go to window number 1 ^A w show a list of windows ^A a send a Ctrl-A to current window as keyboard input ^A h write a hardcopy of current window to file ^A H begin/end logging current window to file ^A ^X lock the terminal (password protected) ^A d detach screen session from the terminal ^A DD detach screen session and log out
See screen(1) for details.
Data recording and presentation
The log daemon Many programs record their activities under the "/var/log/" directory. The kernel log daemon: klogd(8) The system log daemon: syslogd(8) See and .
Log analyzer Here are notable log analyzers ("~Gsecurity::log-analyzer" in aptitude(8)). List of system log analyzers. package popcon size description logwatch &pop-logwatch; &size-logwatch; log analyser with nice output written in Perl fail2ban &pop-failcban; &size-failcban; bans IPs that cause multiple authentication errors analog &pop-analog; &size-analog; web server log analyzer awstats &pop-awstats; &size-awstats; powerful and featureful web server log analyzer sarg &pop-sarg; &size-sarg; squid analysis report generator pflogsumm &pop-pflogsumm; &size-pflogsumm; Postfix log entry summarizer syslog-summary &pop-syslogsummary; &size-syslogsummary; summarize the contents of a syslog log file lire &pop-lire; &size-lire; full-featured log analyzer and report generator fwlogwatch &pop-fwlogwatch; &size-fwlogwatch; Firewall log analyzer squidview &pop-squidview; &size-squidview; monitors and analyses squid access.log files visitors &pop-visitors; &size-visitors; fast web server log analyzer swatch &pop-swatch; &size-swatch; Log file viewer with regexp matching, highlighting, & hooks crm114 &pop-crmbbe; &size-crmbbe; The Controllable Regex Mutilator and Spam Filter (CRM114) icmpinfo &pop-icmpinfo; &size-icmpinfo; Interpret ICMP messages
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.
Recording the shell activities cleanly The simple use of script(1) (see ) to record shell activity produces a file with control characters. This can be avoided by using col(1): $ script Script started, file is typescript do whatever … Press Ctrl-D to exit script $ col -bx <typescript >cleanedfile $ vim cleanedfile If you don't have script (for example, during the boot process in the initramfs), you can use following instead: $ sh -i 2>&1 | tee typescript Some x-terminal-emulator such as gnome-terminal can record. You may wish to extend line buffer for scrollback. You may use screen(1) with "^A H" (see ) to perform recording of console. 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.
Customized display of text data Although pager tools such as more(1) and less(1) (see ) and custom tools for highlighting and formatting can display text data nicely, general purpose editors (see ) are most versatile and customizable. For vim(1) and its pager mode alias view(1), ":set hls" will enable highlighted search.
Customized display of time and date The default display format of time and date by the "ls -l" command depends on the locale (see value ). The "$LANG" variable is referred first and it can be overridden by the "$LC_TIME" variable. The actual default display format for each locale depends on the version of the standard C library (the libc6 package) used. I.e., different releases of Debian had different defaults. If you really wish to customize this display format of time and date beyond the locale, you should set the time style value by the "--time-style" argument or by the "$TIME_STYLE" value (see ls(1), date(1), "info coreutils 'ls invocation'"). Display examples of time and date for the "<literal>ls -l</literal>" command for <literal>lenny</literal>. time style value locale display of time and date iso any 01-19 00:15 long-iso any 2009-01-19 00:15 full-iso any 2009-01-19 00:15:16.000000000 +0900 locale C Jan 19 00:15 locale en_US.UTF-8 2009-01-19 00:15 locale es_ES.UTF-8 ene 19 00:15 +%d.%m.%y %H:%M any 19.01.09 00:15 +%d.%b.%y %H:%M C or en_US.UTF-8 19.Jan.09 00:15 +%d.%b.%y %H:%M es_ES.UTF-8 19.ene.09 00:15
You can eliminate typing long option on commandline using command alias, e.g. "alias ls='ls --time-style=+%d.%m.%y\ %H:%M'" (see ). ISO 8601 is followed for these iso-formats.
Colorized shell echo Shell echo to most modern terminals can be colorized using ANSI escape code (see "/usr/share/doc/xterm/ctlseqs.txt.gz"). E.g.: $ RED=$(printf "\x1b[31m") $ NORMAL=$(printf "\x1b[0m") $ REVERSE=$(printf "\x1b[7m") $ echo "${RED}RED-TEXT${NORMAL} ${REVERSE}REVERSE-TEXT${NORMAL}"
Colorized commands Colorized commands are handy for inspecting their output in the interactive environment. I include following in my "~/.bashrc". if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=always' alias ll='ls --color=always -l' alias la='ls --color=always -A' alias less='less -R' alias ls='ls --color=always' alias grep='grep --color=always' alias egrep='egrep --color=always' alias fgrep='fgrep --color=always' alias zgrep='zgrep --color=always' else alias ll='ls -l' alias la='ls -A' fi The use of alias limits color effects to the interactive command usage. It has advantage over exporting environment variable "export GREP_OPTIONS='--color=auto'" since color can be seen under pager programs such as less(1). If you wish to surpress color when piping to other programs, use "--color=auto" instead in the above example for "~/.bashrc". You can turn off these colorizing aliases in the interactive environment by invoking shell with "TERM=dumb bash".
Recording the graphic image of an X application There are few ways to record the graphic image of an X application, including an xterm display. List of graphic image manipulation tools. package popcon size command xbase-clients &pop-xbaseclients; &size-xbaseclients; xwd(1) gimp &pop-gimp; &size-gimp; GUI menu imagemagick &pop-imagemagick; &size-imagemagick; import(1) scrot &pop-scrot; &size-scrot; scrot(1)
Recording changes in configuration files There are specialized tools to record changes in configuration files with help of DVCS system. List of packages to record configuration history in VCS. package popcon size description etckeeper &pop-etckeeper; &size-etckeeper; store configuration files and its metadata with Git (default), Mercurial, or Bazaar. (new) changetrack &pop-changetrack; &size-changetrack; store configuration files with RCS. (old)
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 ) but with special hook scripts for more thorough setups. As you change your configuration, you can use git(1) normally to record them. It will automatically record changes nicely every time you run package management commands, too. 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.
Data storage tips Booting your system with Linux live CDs or debian-installer CDs in rescue mode make it easy for you to reconfigure data storage on your boot device. See also .
Partition configuration For partition configuration, although fdisk(8) has been considered standard, parted(8) deserves some attention. "Disk partitioning data", "partition table", "partition map", and "disk label" are all synonyms. Most PCs use the classic Master Boot Record (MBR) scheme to hold disk partitioning data in the first sector, i.e., LBA sector 0 (512 bytes). 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. List of disk partition management packages package pocon size GPT description util-linux &pop-utillinux; &size-utillinux; Not supported Miscellaneous system utilities including fdisk(8) and cfdisk(8) parted &pop-parted; &size-parted; Supported The GNU Parted disk partition resizing program gparted &pop-gparted; &size-gparted; Supported GNOME partition editor based on libparted qtparted &pop-qtparted; &size-qtparted; Supported KDE partition editor based on libparted gptsync &pop-gptsync; &size-gptsync; Supported Synchronize classic MBR partition table with the GPT one
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). In order to switch between GPT and MBR, you need to erase first few blocks of disk contents directly (see ) and use "parted /dev/sdx mklabel gpt" or "parted /dev/sdx mklabel msdos" to set it. Please note "msdos" is use here for MBR.
Accessing partition using UUID Although reconfiguration of your partition may yield different names for partitions, you can access them consistently. This is also helpful if you have multiple disks and your BIOS doesn't give them consistent device names. mount(8) with "-U" options can mount a block device using UUID, instead of using its file name such as "/dev/sda3". "/etc/fstab" (see fstab(5)) can use UUID. Boot loaders () may use UUID too. You can probe UUID of a block special device with vol_id(8).
Filesystem configuration For ext3 filesystem, the e2fsprogs package provides: mkfs.ext3(8) to create new ext3 filesystem, fsck.ext3(8) to check and to repair existing ext3 filesystem, and tune2fs(8) to configure superblock of ext3 filesystem. The mkfs(8) and fsck(8) commans are provided by the e2fsprogs package as front-ends to various filesystem dependent programs (mkfs.fstype and fsck.fstype). For ext3 filesystem, they are mkfs.ext3(8) and fsck.ext3(8) (they are hardlinked to mke2fs(8) and e2fsck(8)). Similar commands are available for each filesystem supported by Linux. List of filesystem management packages package popcon size description e2fsprogs &pop-ecfsprogs; &size-ecfsprogs; Utilities for the ext2/ext3/ext4 filesystems. reiserfsprogs &pop-reiserfsprogs; &size-reiserfsprogs; Utilities for the Reiserfs filesystem. dosfstools &pop-dosfstools; &size-dosfstools; Utilities for the FAT filesystem. (Microsoft: MS-DOS, Windows) xfsprogs &pop-xfsprogs; &size-xfsprogs; Utilities for the XFS filesystem. (SGI: IRIX) ntfsprogs &pop-ntfsprogs; &size-ntfsprogs; Utilities for the NTFS filesystem. (Microsoft: Windows NT, …) jfsutils &pop-jfsutils; &size-jfsutils; Utilities for the JFS filesystem. (IBM: AIX, OS/2) reiser4progs &pop-reisereprogs; &size-reisereprogs; Utilities for the Reiser4 filesystem. hfsprogs &pop-hfsprogs; &size-hfsprogs; Utilities for HFS and HFS Plus filesystem. (Apple: Mac OS) btrfs-tools &pop-btrfstools; &size-btrfstools; Utilities for the btrfs filesystem.
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.28 (Debian squeeze), ext4 filesystem will be 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. You might face some limtations with ext4 since it is new. For example, you must have Linux kernel 2.6.30 or later if you wish to resizean ext4 partition. Some tools allow access to filesystem without Linux kernel support (see ).
Filesystem creation and integrity check The mkfs(8) command creates the filesystem on a Linux system. The fsck(8) command provides the filesystem integrity check and repair on a Linux system. It is generally not safe to run fsck on mounted filesystems. Check files in "/var/log/fsck/" for the result of the fsck(8) command run from the boot script. Use "shutdown -F -r now" to force to run the fsck(8) command safely on all filesystems including root file system on reboot. See the shutdown(8) manpage for more.
Optimization of filesystem by mount options Performance and characteristics of a filesystem can be optimized by mount options used on it (see fstab(5) and mount(8)). For example: "defaults" option implies default options: "rw,suid,dev,exec,auto,nouser,async". (general) "noatime" or "relatime" option is very effective for speeding up the read access. (general) "user" option allows an ordinary user to mount the file system. This option implies "noexec,nosuid,nodev" option combination. (general, used for CD and floppy) "noexec,nodev,nosuid" option combination is used to enhance security. (general) "noauto" option limits mounting by explicit operation only. (general) "data=journal" option for ext3fs can enhance data integrity against power failure with some loss of write speed. You need to provide kernel boot parameter "rootflags=data=journal" to deploy "data=journal" option for the root file system formatted with ext3fs.
Optimization of filesystem via superblock Characteristics of a filesystem can be optimized via its superblock using the tune2fs(8) command. For example on "/dev/hda1": Execution of "sudo tune2fs -l /dev/hda1" will display the contents of its filesystem superblock. Execution of "sudo tune2fs -c 50 /dev/hda1" will change frequency of filesystem checks (fsck execution during boot-up) to every 50 boots. Execution of "sudo tune2fs -j /dev/hda1" will add journaling capability to the filesystem, i.e. filesystem conversion from ext2 to ext3. (Do this on the unmounted filesystem.) Execution of "sudo tune2fs -O extents,uninit_bg,dir_index /dev/hda1 && fsck -pf /dev/hda1" will convert it from ext3 to ext4. (Do this on the unmounted filesystem.) 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.28. Despite its name, tune2fs(8) works not only on the ext2 filesystem but also on the ext3 and ext4 filesystems.
Optimization of harddisk Please check your hardware and read manpage of hdparam(8) before playing with harddisk configuration because this may be quite dangerous for the data integrity. You can test disk access speed of a harddisk, e.g. "/dev/hda", by "hdparm -tT /dev/hda". For some harddisk connected with (E)IDE, you can speed it up with "hdparm -q -c3 -d1 -u1 -m16 /dev/hda" by enabling the "(E)IDE 32-bit I/O support", enabling the "using_dma flag", setting "interrupt-unmask flag", and setting the "multiple 16 sector I/O" (dangerous!). You can test write cache feature of a harddisk, e.g. "/dev/sda", by "hdparm -W /dev/sda". You can disable its write cache feature with "hdparm -W 0 /dev/sda". You may be able to read badly pressed CDROMs on modern high head CD-ROM drive by slowing it down with "setcd -x 2.
Using SMART to predict harddisk failure You can monitor and log your harddisk which is compliant to SMART with the smartd(8) daemon. Enable SMART feature in BIOS. Install the smartmontools package. Identify your harddisk drives by listing them with df(1). Let's assume a harddisk drive to be monitored as "/dev/hda". Check the output of "smartctl -a /dev/hda" to see if SMART feature is actually enabled. If not, enable it by "smartctl -s on -a /dev/hda". Enable smartd(8) daemon to run by: uncomment "start_smartd=yes" in the "/etc/default/smartmontools" file. restart the smartd(8) daemon by "sudo /etc/init.d/smartmontools restart". The smartd(8) daemon can be customized with the /etc/smartd.conf file including how to be notified of warnings.
Expand usable storage space via LVM For partitions created on Logical Volume Manager (Linux) at install time, they can be resized easily by concatenating extents onto them or truncating extents from them over multiple storage devices without major system reconfiguration. Deployment of the current LVM system may degrade guarantee against filesystem corruption offered by journaled file systems such as ext3fs unless their system performance is sacrificed by disabling write cache of harddisk.
Expand usable storage space by mounting another partition If you have an empty partition (e.g., "/dev/sdx"), you can format it with mkfs.ext3(1) and mount(8) it to a directory where you need more space. (You need to copy original data contents.) $ sudo mv work-dir old-dir $ sudo mkfs.ext3 /dev/sdx $ sudo mount -t ext3 /dev/sdx work-dir $ sudo cp -a old-dir/* work-dir $ sudo rm -rf old-dir
Expand usable storage space using aufs If you have usable space in another partition (e.g., "/path/to/"), you can create a directory in it and stack that on to a directory where you need space with aufs. $ sudo mv work-dir old-dir $ sudo mkdir -p /path/to/emp-dir $ sudo mount -t aufs -o br:/path/to/emp-dir:old-dir none work-dir Use of aufs for long term data storage is not good idea since it is under development and its design change may introduce issues. 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. aufs is used to provide writable root filesystem by many modern live CD projects.
Data encryption tips With physical access to your PC, anyone can easily gain root privilege and access all the files on your PC (see ). This means that login password system can not secure your private and sensitive data against possible theft of your PC. You must deploy data encryption technology to do it. Although GNU privacy guard (see ) can encrypt files, it takes some user efforts. dm-crypt and eCryptfs facilitates automatic data encryption natively via Linux kernel modules with minimal user efforts. List of data encryption utilities. package popcon size function cryptsetup &pop-cryptsetup; &size-cryptsetup; Utilities for encrypted block device (dm-crypt / LUKS) cryptmount &pop-cryptmount; &size-cryptmount; Utilities forencrypted block device (dm-crypt / LUKS) with focus on mount/unmount by normal users ecryptfs-utils &pop-ecryptfsutils; &size-ecryptfsutils; Utilities for encrypted stacked filesystem (eCryptfs)
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. Data encryption costs CPU time etc. Please weigh its benefits and costs. Entire Debian system can be installed on a encrypted disk by the debian installer (lenny or newer) using dm-crypt/LUKS and initramfs. See for user space encryption utility: GNU Privacy Guard.
Removable disk encryption with dm-crypt/LUKS You can encrypt contents of removable mass storage devices, e.g. USB memory stick on "/dev/sdx", using dm-crypt/LUKS. You simply formatting it as: # badblocks -c 10240 -s -w -t random -v /dev/sdx # shred -v -n 1 /dev/sdx # fdisk /dev/sdx ... "n" "p" "1" "return" "return" "w" # cryptsetup luksFormat /dev/sdx1 ... # cryptsetup luksOpen /dev/sdx1 sdx1 ... # ls -l /dev/mapper/ total 0 crw-rw---- 1 root root 10, 60 2008-10-04 18:44 control brw-rw---- 1 root disk 254, 0 2008-10-04 23:55 sdx1 # mkfs.vfat /dev/mapper/sdx1 ... # cryptsetup luksClose sdx1 Then, it can be mounted just like normal one on to "/media/<disk_label>", except for asking password (see ) under modern desktop environment, such as GNOME using gnome-mount(1). The difference is that every data written to it is encrypted. You may alternatively format media in different file format, e.g., ext3 with "mkfs.ext3 /dev/sdx1". 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.
Encrypted swap partition with dm-crypt If your original "/etc/fstab" contains: /dev/sda7 swap sw 0 0 then you can enable encrypted swap partition using dm-crypt by as # aptitude install cryptsetup # swapoff -a # echo "cswap /dev/sda7 /dev/urandom swap" >> /etc/crypttab # perl -i -p -e "s/\/dev\/sda7/\/dev\/mapper\/cswap/" /etc/fstab # /etc/init.d/cryptdisks restart ... # swapon -a
Automatically encrypting files with eCryptfs You can encrypt files written under "~/Private/" automatically using eCryptfs and the ecryptfs-utils package. run ecryptfs-setup-private(1) and set up "~/Private/" by following prompts. activate "~/Private/" by running ecryptfs-mount-private(1). move sensitive data files to "~/Private/" and make symlinks as needed. candidates: "~/.fetchmailrc", "~/.ssh/identity", "~/.ssh/id_rsa", "~/.ssh/id_dsa" and other files with "go-rwx". move sensitive data directories to a subdirectory in "~/Private/" and make symlinks as needed. candidates: "~/.gnupg" and other directories with "go-rwx". create symlink from "~/Desktop/Private/" to "~/Private/" for easier desktop operations. deactivate "~/Private/" by running ecryptfs-umount-private(1). activate "~/Private/" by issuing "ecryptfs-mount-private" as you need encrypted data. 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.
Automatically mounting eCryptfs If you use your login password for wrapping encryption keys, you can automate mounting eCryptfs via Pluggable Authentication Module by having a following line just before "pam_permit.so" in "/etc/pam.d/common-auth" as: auth required pam_ecryptfs.so unwrap and the last line in "/etc/pam.d/common-session" as: session optional pam_ecryptfs.so unwrap and the first active line in "/etc/pam.d/common-password" as: password required pam_ecryptfs.so This is quite convienient. Configuration errors of PAM may lock you out of your own system. See . If you use your login password for wrapping encryption keys, your encrypted data are as secure as your user login password (see ). Unless you are careful to set up a strong password, your data will be at risk when someone runs password cracking software after stealing your laptop (see ).
Monitoring, controlling, and starting program activities Program activities can be monitored and controlled using specialized tools. List of tools for monitoring and controlling program activities package popcon size description time &pop-time; &size-time; time(1) runs a program to report system resource usages with respect to time. coreutils &pop-coreutils; &size-coreutils; nice(1) runs a program with modified scheduling priority. bsdutils &pop-bsdutils; &size-bsdutils; renice(1) modifies the scheduling priority of a running process. powertop &pop-powertop; &size-powertop; powertop(1) gives information about system power use on Intel-based laptops. procps &pop-procps; &size-procps; The "/proc" file system utilities: ps(1), top(1), kill(1), watch(1), … psmisc &pop-psmisc; &size-psmisc; The "/proc" file system utilities: killall(1), fuser(1), pstree(1) cron &pop-cron; &size-cron; The cron(8) daemon runs processes according to a schedule (in background). at &pop-at; &size-at; at(1) or batch(1) commands run a job at a specified time or below certain load level. lsof &pop-lsof; &size-lsof; lsof(8) lists open files by a running process using "-p" option. strace &pop-strace; &size-strace; strace(1) traces system calls and signals. ltrace &pop-ltrace; &size-ltrace; ltrace(1) traces library calls. xtrace &pop-xtrace; &size-xtrace; xtrace(1) traces communication between X11 client and server.
Time a process Display time used by the process invoked by the command. # time some_command >/dev/null real 0m0.035s # time on wall clock (elapsed real time) user 0m0.000s # time in user mode sys 0m0.020s # time in kernel mode
The scheduling priority A nice value is used to control the scheduling priority for the process. List of nice values for the scheduling priority. nice value scheduling priority 19 lowest priority process (nice) 0 very high priority process for user. -20 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.
The ps command The ps(1) command on the Debian support both BSD and SystemV features and helps to identify the process activity statically. List of ps command styles. style typical command feature BSD ps aux display %CPU %MEM System V ps -efH display PPID
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.
The top command top(1) on the Debian has rich features and helps to identify what process is acting funny dynamically. List of commands for top. command key response h or ? To show help. f To set/reset display field. o To reorder display field. F To set sort key field. k To kill a process. r To renice a process. q To quit the top command.
List files opened by a process You can list all files opened by a process with a process ID (PID), e.g. 1 as: $ sudo lsof -p 1 PID=1 is usually init program.
Trace program activities You can trace program activity with strace(1), ltrace(1), or xtrace(1) for system calls and signals, library calls, or communication between X11 client and server. For example: $ sudo strace ls ...
Identify processes using files or sockets You can also identify processes using files or sockets by fuser(1). For example: $ sudo fuser -v /var/log/mail.log USER PID ACCESS COMMAND /var/log/mail.log: root 2946 F.... syslogd You see that file "/var/log/mail.log" is open for writing by the syslogd(8) command. $ sudo fuser -v smtp/tcp USER PID ACCESS COMMAND smtp/tcp: Debian-exim 3379 F.... exim4 Now you know your system runs exim4(8) to handle TCP connections to SMTP port (25).
Repeating a command with a constant interval watch(1) executes a program repeatedly with a constant interval while showing its output in fullscreen. $ watch w This will display who is logged on to the system updated every 2 seconds.
Repeating a command looping over files There are several ways to repeat a command looping over files matching some condition, e.g. matching glob pattern "*.ext". Shell for-loop method (see ): for x in *.ext; do if [ -f "$x"]; then command "$x" ; fi; done find(1) and xargs(1) combination: find . -type f -maxdepth 1 -name '*.ext' -print0 | xargs -0 -n 1 command find(1) with "-exec" option with a command: find . -type f -maxdepth 1 -name '*.ext' -exec command '{}' \; find(1) with "-exec" option with a short shell script: find . -type f -maxdepth 1 -name '*.ext' -exec sh -c "command '{}' && echo 'successful'" \; The above examples are written to ensure proper handling of funny file names such as ones containing spaces. See for more advance uses of find(1).
Starting a program from GUI You can set up to start a process from graphical user interface (GUI). Under GNOME desktop environment, a program program can be started with proper argument by drag-and-drop of an icon to the launcher icon or by "Open with …" menu with right clicking. KDE can do the equivalent, too. Here is an example for GNOME to set up mc(1) started in gnome-terminal(1): create an executable program "mc-term" as: # cat >/usr/local/bin/mc-term <<EOF #!/bin/sh gnome-terminal -e "mc \$1" EOF # chmod 755 /usr/local/bin/mc-term create a desktop launcher right clicking desktop space to select "Create Launcher …" set "Type" to "Application" set "Name" to "mc" set "Command" to "mc-term %f" click "OK" create an open-with association right click folder to select "Open with Other Application …" click open "Use a custom command" dialog and enter "mc-term %f" click "Open". Launcher is a file at "~/Desktop" with ".desktop" as its extension.
Customizing program to be started Some programs start another program automatically. Here are check points for customizing this process: application configuration menu: GNOME desktop: "System" → "Preferences" → "Preferred Application" KDE desktop: "K" → "Control Center" → "KDE Components" → "Component Chooser" Iceweasle browser: "Edit" → "Preferences" → "Applications" mc(1): "/etc/mc/mc.ext" environment variables such as "$BROWSER", "$EDITOR", "$VISUAL", and "$PAGER" (see eviron(7)). the update-alternatives(8) system for programs such as "editor", "view", "x-www-browser", "gnome-www-browser", and "www-browser" (see ). the "~/.mailcap" and "/etc/mailcap" file contents which associate MIME type with program (see mailcap(5)). the the "~/.mime.types" and "/etc/mime.types" file contents which associate file name extension with MIME type (see run-mailcap(1)). update-mime(8) updates the "/etc/mailcap" file using "/etc/mailcap.order" file (see mailcap.order(5)). 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 commands. In order to run a console application such as mutt under X as your prefered application, you should create an X application as following and set "/usr/local/bin/mutt-term" as your prefered 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
Kill a process Use kill(1) to kill (or send a signal to) a process by the process ID. Use killall(1) or pkill(1) to do the same by the process command name and other attributes. List of frequently used signals for kill command. signal value signal name function 1 HUP restart daemon 15 TERM normal kill 9 KILL kill hard
Schedule tasks once Run the at(1) command to schedule a one-time job: $ echo 'command -args'| at 3:40 monday
Schedule tasks regularly Use cron(8) to schedule tasks regularly. See crontab(1) and crontab(5). Run the command "crontab -e" to create or edit a crontab file to set up regularly scheduled events. Example of a crontab file: # use /bin/sh to run commands, no matter what /etc/passwd says SHELL=/bin/sh # mail any output to paul, no matter whose crontab this is MAILTO=paul # Min Hour DayOfMonth Month DayOfWeek command (Day... are OR'ed) # run at 00:05, every day 5 0 * * * $HOME/bin/daily.job >> $HOME/tmp/out 2>&1 # run at 14:15 on the first of every month -- output mailed to paul 15 14 1 * * $HOME/bin/monthly # run at 22:00 on weekdays(1-5), annoy Joe. % for newline, last % for cc: 0 22 * * 1-5 mail -s "It's 10pm" joe%Joe,%%Where are your kids?%.%% 23 */2 1 2 * echo "run 23 minutes after 0am, 2am, 4am ..., on Feb 1" 5 4 * * sun echo "run at 04:05 every sunday" # run at 03:40 on the first Monday of each month 40 3 1-7 * * [ "$(date +%a)" == "Mon" ] && command -args For the system not running continuously, install the anacron package to schedule periodic command at the specified intervals as closely as machine-uptime permits.
Alt-SysRq Insurance against system malfunction is provided by the kernel compile option "Magic SysRq key" (SAK key) which is now the default for the Debian kernel. Pressing Alt-SysRq followed by one of the following keys does the magic of rescuing control of the system: List of SAK command keys. key following Alt-SysRq function r Unraw restores the keyboard after things like X crashes. 0 Changing the console loglevel to 0 reduces error messages. k SAK (system attention key) kills all processes on the current virtual console. e Send a SIGTERM to all processes, except for init(8). i Send a SIGKILL to all processes, except for init(8). s Sync all mounted filesystems. u Remount all mounted filesystems read-only (umount). b 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". The Alt-SysRq feature may be considered a security risk by allowing users access to root-privileged functions. Placing "echo 0 >/proc/sys/kernel/sysrq" in "/etc/rc.local" or "kernel.sysrq = 0" in "/etc/sysctl.conf" will disable the Alt-SysRq feature. From SSH terminal etc., you can use the Alt-SysRq feature by writing to the "/proc/sysrq-trigger". For example, "echo s > /proc/sysrq-trigger; echo u > /proc/sysrq-trigger" from the root shell prompt will sync and umount all mounted filesystems.
System maintenance tips
Who is logged on You can check who is logged on to the system with w(1) or who(1).
Warn everyone You can send message to everyone who is logged on to the system with wall(1): $ echo "We are shutting down in 1 hour" | wall
Hardware identification For the PCI-like devices (AGP, PCI-Express, CardBus, ExpressCard, etc.), lspci(8) (probably with "-nn" option) is a good start for the hardware identification Alternatively, you can identify the hardware by reading contents of "/proc/bus/pci/devices" or browsing directory tree under "/sys/bus/pci" (see ). List of hardware identification tools. package popcon size description pciutils &pop-pciutils; &size-pciutils; Linux PCI Utilities, lspci(8) usbutils &pop-usbutils; &size-usbutils; Linux USB utilities, lsusb(8) pcmciautils &pop-pcmciautils; &size-pcmciautils; PCMCIA utilities for Linux 2.6, pccardctl(8) scsitools &pop-scsitools; &size-scsitools; Collection of tools for SCSI hardware management, lsscsi(8) pnputils &pop-pnputils; &size-pnputils; Plug and Play BIOS utilities, lspnp(8) procinfo &pop-procinfo; &size-procinfo; Displays system information from "/proc", lsdev(8) lshw &pop-lshw; &size-lshw; Information about hardware configuration, lshw(1) discover &pop-discover; &size-discover; Hardware identification system, discover(8)
Hardware configuration Although most of the hardware configuration on modern GUI desktop systems such as GNOME and KDE can be managed through accompanying GUI configuration tools, it is a good idea to know some basics methods to configure them. List of hardware configuration tools. package popcon size description hal &pop-hal; &size-hal; Hardware Abstraction Layer, lshal(1) console-tools &pop-consoletools; &size-consoletools; Linux console font and keytable utilities. x11-xserver-utils &pop-xbbxserverutils; &size-xbbxserverutils; X server utilities. xset(1) and xmodmap(1). acpid &pop-acpid; &size-acpid; Daemon to manage events delivered by the Advanced Configuration and Power Interface (ACPI) acpi &pop-acpi; &size-acpi; Utilities for ACPI devices apmd &pop-apmd; &size-apmd; Daemon to manage events delivered by the Advanced Power Management (APM) powersaved &pop-powersaved; &size-powersaved; Daemon to manage battery, temperature, ac, cpufreq (SpeedStep, Powernow!) control and monitor with ACPI and APM supports. noflushd &pop-noflushd; &size-noflushd; Allow idle hard disks to spin down sleepd &pop-sleepd; &size-sleepd; Puts a laptop to sleep during inactivity hdparm &pop-hdparm; &size-hdparm; Hard disk access optimization. Very effective but dangerous. You must read hdparm(8) first. smartmontools &pop-smartmontools; &size-smartmontools; Control and monitor storage systems using S.M.A.R.T. setserial &pop-setserial; &size-setserial; Collection of tools for serial port management. memtest86+ &pop-memtestig; &size-memtestig; Collection of tools for memory hardware management. scsitools &pop-scsitools; &size-scsitools; Collection of tools for SCSI hardware management. tpconfig &pop-tpconfig; &size-tpconfig; A program to configure touchpad devices setcd &pop-setcd; &size-setcd; Compact disc drive access optimization. big-cursor &pop-bigcursor; &size-bigcursor; Larger mouse cursors for X
Here, ACPI is a newer framework for the power management system than APM.
System and hardware time The following will set system and hardware time to MM/DD hh:mm, CCYY. # date MMDDhhmmCCYY # hwclock --utc --systohc # hwclock --show Times are normally displayed in the local time on the Debian system but the hardware and system time usually use UTC. If the hardware (BIOS) time is set to GMT, change the setting to "UTC=yes" in the "/etc/default/rcS". If you wish to update system time via network, consider to use the NTP service with the packages such as ntp, ntpdate, and chrony. See: Managing Accurate Date and Time HOWTO. NTP Public Services Project. The ntp-doc package ntptrace(8) in the ntp package can trace a chain of NTP servers back to the primary source.
The terminal configuration There are several components to configure character console and ncurses(3) system features: the "/etc/terminfo/*/*" file (terminfo(5)) the "$TERM" environment variable (term(7)) setterm(1), stty(1), tic(1), and toe(1) If the terminfo entry for xterm doesn't work with a non-Debian xterm, change your terminal type, "$TERM", from "xterm" to one of the feature-limited versions such as "xterm-r6" when you log in to a Debian system remotely. See "/usr/share/doc/libncurses5/FAQ" for more. "dumb" is the lowest common denominator for "$TERM".
The sound infrastructure Device drivers for sound cards for current Linux 2.6 are provided by Advanced Linux Sound Architecture (ALSA). ALSA provides emulation mode for previous Open Sound System (OSS) for compatibility. Run "dpkg-reconfigure linux-sound-base" to select the sound system to use ALSA via blacklisting of kernel modules. Unless you have very new sound hardware, udev infrastructure should configure your sound system. Use "cat /dev/urandom > /dev/audio" or speaker-test(1) to test speaker. (^C to stop) 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. List of sound packages package pocon size description linux-sound-base &pop-linuxsoundbase; &size-linuxsoundbase; Base package for ALSA and OSS sound systems alsa-base &pop-alsabase; &size-alsabase; ALSA driver configuration files alsa-utils &pop-alsautils; &size-alsautils; Utilities for configuring and using ALSA oss-compat &pop-osscompat; &size-osscompat; OSS compatibility under ALSA preventing "/dev/dsp not found" errors esound-common &pop-esoundcommon; &size-esoundcommon; Enlightened Sound Daemon (ESD) common (Enlightenment and GNOME) esound &pop-esound; &size-esound; Enlightened Sound Daemon (ESD) server (Enlightenment and GNOME) esound-clients &pop-esoundclients; &size-esoundclients; Enlightened Sound Daemon (ESD) client (Enlightenment and GNOME) libesd-alsa0 &pop-libesdalsaa; &size-libesdalsaa; Enlightened Sound Daemon (ESD) library Enlightenment and GNOME) libesd0 &pop-libesda; &size-libesda; Enlightened Sound Daemon (ESD) library (Enlightenment and GNOME) - OSS arts &pop-arts; &size-arts; aRts server (KDE) libarts1c2a &pop-libartsbcca; &size-libartsbcca; aRts library (KDE) libartsc0 &pop-libartsca; &size-libartsca; aRts library (KDE) jackd &pop-jackd; &size-jackd; JACK Audio Connection Kit. (JACK) server (low latency) libjack0 &pop-libjacka; &size-libjacka; JACK Audio Connection Kit. (JACK) library (low latency) libjack0.100.0-0 &pop-libjackabaaaa; &size-libjackabaaaa; JACK Audio Connection Kit. (JACK) library (low latency) nas &pop-nas; &size-nas; Network Audio System (NAS) server libaudio2 &pop-libaudioc; &size-libaudioc; Network Audio System (NAS) library pulseaudio &pop-pulseaudio; &size-pulseaudio; PulseAudio server, replacement for ESD libpulse0 &pop-libpulsea; &size-libpulsea; PulseAudio client library, replacement for ESD libpulsecore9 &pop-libpulsecorej; &size-libpulsecorej; PulseAudio server library, replacement for ESD libgstreamer0.10-0 &pop-libgstreamerabaa; &size-libgstreamerabaa; GStreamer: GNOME sound engine libxine1 &pop-libxineb; &size-libxineb; xine: KDE older sound engine libphonon4 &pop-libphonone; &size-libphonone; 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.
Disable the screen saver For disabling the screen saver, use following commands. List of commands for disabling the screen saver. environment command The Linux console setterm -powersave off The X Window by turning off screensaver xset s off The X Window by disabling dpms xset -dpms The X Window by GUI configuration of screen saver xscreensaver-command -prefs
Disable the sound (beep) One can always unplug the PC speaker. ;-) Removing pcspkr kernel module does this for you. The following will prevent the readline(3) program used by bash(1) to beep when encountering "\a" (ASCII=7): $ echo "set bell-style none">> ~/.inputrc
Memory usage The kernel boot message in the "/var/log/dmesg" contains the total exact size of available memory. 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 For my MacBook with 1GB=1048576k DRAM (video system steals some of this): List of memory sizes reported. report size Total size in dmesg 1016784k = 1GB - 31792k Free in dmesg 990528k Total under shell 997184k Free under shell 20256k
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.
System security and integrity check Poor system maintenance may expose your system to external exploitation. For system security and integrity check, you should start with: the debsums package: See debsums(1) and . the chkrootkit package: See chkrootkit(1). the clamav package family: See clamscan(1) and freahclam(1). Debian security FAQ. Securing Debian Manual. List of tools for system security and integrity check package popcon size description logcheck &pop-logcheck; &size-logcheck; This mails anomalies in the system logfiles to the administrator debsums &pop-debsums; &size-debsums; This verifies installed package files against MD5 checksums. chkrootkit &pop-chkrootkit; &size-chkrootkit; Rootkit detector. clamav &pop-clamav; &size-clamav; Anti-virus utility for Unix - command-line interface. tiger &pop-tiger; &size-tiger; Report system security vulnerabilities tripwire &pop-tripwire; &size-tripwire; File and directory integrity checker john &pop-john; &size-john; Active password cracking tool aide &pop-aide; &size-aide; Advanced Intrusion Detection Environment - static binary bastille &pop-bastille; &size-bastille; Security hardening tool integrit &pop-integrit; &size-integrit; A file integrity verification program crack &pop-crack; &size-crack; Password guessing program
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 \) Since the debsums package uses MD5 checksums stored locally, it can not be fully trusted as the system security audit tool against malicious attacks.
The kernel Debian distributes modularized Linux kernel as packages for supported architectures.
Linux kernel 2.6 There are few notable features on Linux kernel 2.6 compared to 2.4. Devices are created by the udev system (see ). Read/write accesses to IDE CD/DVD devices do not use the ide-scsi module. Network packet filtering functions use iptable kernel modules.
Kernel headers Most normal programs don't need kernel headers and in fact may break if you use them directly for compiling. They should be compiled against the headers in "/usr/include/linux" and "/usr/include/asm" provided by the libc6-dev package (created from the glibc source package) on the Debian system. 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.
Kernel and module compile Debian has its own method of compiling the kernel and related modules. List of key packages to be installed for the kernel recompilation on the Debian system package popcon size description build-essential &pop-buildessential; &size-buildessential; essential packages for building Debian packages: make, gcc, … bzip2 &pop-bzipc; &size-bzipc; compress and decompress utilities for bz2 files libncurses5-dev &pop-libncursesfdev; &size-libncursesfdev; developer's libraries and docs for ncurses git-core &pop-gitcore; &size-gitcore; git: distributed revision control system used by the Linux kernel fakeroot &pop-fakeroot; &size-fakeroot; provide fakeroot environment for building package as non-root initramfs-tools &pop-initramfstools; &size-initramfstools; tool to build an initramfs (Debian specific) kernel-package &pop-kernelpackage; &size-kernelpackage; tool to build Linux kernel packages (Debian specific) module-assistant &pop-moduleassistant; &size-moduleassistant; tool to help build module packages (Debian specific) devscripts &pop-devscripts; &size-devscripts; helper scripts for a Debian Package maintainer (Debian specific) linux-tree-2.6.* N/A N/A Linux kernel source tree meta package (Debian specific)
If you use initrd in , make sure to read the related information in initramfs-tools(8), update-initramfs(8), mkinitramfs(8) and initramfs.conf(5). 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.) When compiling the latest Linux kernel on the Debian stable system, the use of backported latest tools from the Debian unstable may be needed.
Kernel source compile: Debian standard method The Debian standard method for compiling kernel source to create a custom kernel package uses make-kpkg(1). The official documentation is in (the bottom of) "/usr/share/doc/kernel-package/README.gz". See kernel-pkg.conf(5) and kernel-img.conf(5) for customization. Here is an example for amd64 system: # aptitude install linux-tree-<version> $ cd /usr/src $ tar -xjvf linux-source-<version>.tar.bz2 $ cd linux-source-<version> $ cp /boot/config-<oldversion> .config $ make menuconfig ... $ make-kpkg clean $ fakeroot make-kpkg --append_to_version -amd64 --initrd --revision=rev.01 kernel_image modules_image $ cd .. # dpkg -i linux-image*.deb reboot to new kernel with "shutdown -r now" . 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.
Module source compile: Debian standard method The Debian standard method for creating and installing a custom module package for a custom kernel package uses module-assistant(8) and module-source packages. For example, following will build the unionfs kernel module package and installs it. $ sudo aptitude install module-assistant ... $ sudo aptitude install unionfs-source unionfs-tools unionfs-utils $ sudo m-a update $ sudo m-a prepare $ sudo m-a auto-install unionfs ... $ sudo apt-get autoremove
Kernel source compile: classic method You can still build Linux kernel from the pristine sources with the classic method. You must take care the details of the system configuration manually. $ cd /usr/src $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-<version>.tar.bz2 $ tar -xjvf linux-<version>.tar.bz2 $ cd linux-<version> $ cp /boot/config-<version> .config $ make menuconfig ... $ make dep; make bzImage $ make modules # cp ./arch/x86_64/boot/bzImage /boot/vmlinuz-<version> # make modules_install # depmod -a # update-initramfs -c -k <version> set up bootloader edit "/etc/lilo.conf" and run "/sbin/lilo", if you use lilo. edit "/boot/grub/menu.lst", if you use grub. reboot to new kernel with "shutdown -r now".
Non-free hardware drivers Although most of hardware drivers are available as free software and as a part of the Debian system, you may need to load some non-free external drivers to support some hardwares, such as Winmodem, on your system. Check pertinent resources: http://en.wikipedia.org/wiki/Softmodem http://en.wikipedia.org/wiki/Comparison_of_open_source_wireless_drivers Google or other search engines with keyword "Linmodem". http://ndiswrapper.sourceforge.net http://linuxwireless.org http://madwifi-project.org (there is ath5k which contains free drivers)
Virtualized system Use of virtualized system enables us to run multiple instances of system simultaneously on a single hardware.
Virtualization tools Virturization involves 2 steps: create file system populated with required package data. Programs such as debootstrap and cdebootstrap helps this process. run a program under virturized environment. Most basic method is provided by chroot. There are several system virtualization and emulation related packages in Debian beyond simple chroot. Some packages also help you to setup such system. List of virtualization tools package pocon size description schroot &pop-schroot; &size-schroot; Specialized tool for executing Debian binary packages in chroot sbuild &pop-sbuild; &size-sbuild; Tool for building Debian binary packages from Debian sources pbuilder &pop-pbuilder; &size-pbuilder; Personal package builder for Debian packages debootstrap &pop-debootstrap; &size-debootstrap; Bootstrap a basic Debian system (written in sh) cdebootstrap &pop-cdebootstrap; &size-cdebootstrap; Bootstrap a Debian system (written in C) rootstrap &pop-rootstrap; &size-rootstrap; A tool for building complete Linux filesystem images user-mode-linux &pop-usermodelinux; &size-usermodelinux; User-mode Linux (kernel) xen-tools &pop-xentools; &size-xentools; Tools to manage debian XEN virtual server bochs &pop-bochs; &size-bochs; Bochs: IA-32 PC emulator qemu &pop-qemu; &size-qemu; Qemu: fast generic processor emulator virtualbox-ose &pop-virtualboxose; &size-virtualboxose; VirtualBox: x86 virtualization solution on i386 and amd64 wine &pop-wine; &size-wine; Wine: Windows API Implementation (standard suite) dosbox &pop-dosbox; &size-dosbox; DOSBox: x86 emulator with Tandy/Herc/CGA/EGA/VGA/SVGA graphics, sound and DOS util-vserver &pop-utilvserver; &size-utilvserver; Linux-VServer virtual private servers - user-space tools vzctl &pop-vzctl; &size-vzctl; OpenVZ server virtualization solution - control tools vzquota &pop-vzquota; &size-vzquota; OpenVZ server virtualization solution - quota tools
See Wikipedia article Comparison of virtual machines for detail comparison of different virtualization solutions.
Chroot system chroot(8) offers most basic way to run different instances of the GNU/Linux environment on a single system simultaneously without rebooting. 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 will see how debootstrap(8) or debootstrap(1) populate system data for sid environment under "/sid-root". These debootstrap(8) or debootstrap(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 will see how a system shell running under sid environment is created: copying local configuration ("/etc/hosts", "/etc/hostname", "/etc/resolv.conf") mounting "/proc" filesystem mounting "/dev/pts" filesystem "/usr/sbin/policy-rc.d" created (this always exits with 101) run "chroot /sid-root bin/bash -c 'exec -a -bash bin/bash'" 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. 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". 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 will not exist in the resulting package. Similar schroot package may give you an idea to run i386 chroot system under amd64 parent system. By installing a system into a separate partition using the installer of other distributions and using this system for chroot(8), you can run other distributions under chroot(8).
Setting up login for chroot You can run another login process on a separate virtual terminal where you can log in to the chroot system directly. Since on default Debian systems tty1 to tty6 run Linux consoles and tty7 runs the X Window System, let's set up tty8 for a chrooted console as an example. After creating a sid chroot system under "/sid-root" by following steps you learned from pbuilder(8), type from the root shell of the main system: main # echo "8:23:respawn:/usr/sbin/chroot /sid-root /sbin/getty 38400 tty8" >> /etc/inittab main # init q reload init
Data management Tools and tips for managing binary and text data on the Debian system are described.
Sharing, copying, and archiving The security of the data and its controlled sharing have several aspects: the creation of data archive, the remote storage access, the duplication, the tracking of the modification history, the facilitation of data sharing, the prevention of unauthorized file access, and the detection of unauthorized file modification. These can be realized by using some combination of: the archive and compression tools, the copy and synchronization tools, the network file system, the removable storage media, the secure shell, the authentication system, the version control system tools, and hash and cryptographic encryption tools.
Archive and compression tools Here is a summary of archive and compression tools available on the Debian system: List of archive and compression tools. package popcon size command extension comment tar &pop-tar; &size-tar; tar(1) .tar the standard archiver (de facto standard) cpio &pop-cpio; &size-cpio; cpio(1) .cpio Unix System V style archiver, use with find(1) binutils &pop-binutils; &size-binutils; ar(1) .ar archiver for the creation of static libraries fastjar &pop-fastjar; &size-fastjar; fastjar(1) .jar archiver for Java (zip like) pax &pop-pax; &size-pax; pax(1) .pax new POSIX standard archiver, compromise between tar and cpio afio &pop-afio; &size-afio; afio(1) .afio extended cpio with per-file compression etc. gzip &pop-gzip; &size-gzip; gzip(1), zcat(1), … .gz GNU LZ77 compression utility (de facto standard) bzip2 &pop-bzipc; &size-bzipc; bzip2(1), bzcat(1), …