Slackware Linux Basics

For Slackware Linux 10.2

Daniël de Kok

License

Redistribution and use in textual and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of this book must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. All advertising materials mentioning features or use of this book must display the following acknowledgement: This product includes content written by Daniël de Kok.

  3. The name of the author may not be used to endorse or promote products derived from this book without specific prior written permission.

THIS BOOK IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS BOOK, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Linux is a registered trademark of Linus Torvalds. Slackware Linux is a registered trademark of Patrick Volkerding and Slackware Linux, Inc. UNIX is a registered trademark of The Open Group.


Published Tue Jan 17 20:27:54 CET 2006

Table of Contents
Preface
I. Getting started
1. About this book
1.1. Availability
1.2. Conventions
2. An introduction to Slackware Linux
2.1. What is Linux?
2.2. What is GNU/Linux?
2.3. What is Slackware Linux?
2.4. The UNIX philosophy
2.5. Free and open source software
2.6. Slackware Linux 10.2 features
2.7. Getting Slackware Linux
3. Sources of help
3.1. On your system
3.2. On the Internet
4. General concepts
4.1. Multitasking
4.2. Filesystem hierarchy
4.3. Devices
5. Installing Slackware Linux
5.1. Booting the installation CD-ROM
5.2. Partitioning a hard disk
5.3. Installing Slackware Linux
6. Custom installation
6.1. Partitioning a hard disk
6.2. Initializing and mounting filesystems
6.3. Installing packages
6.4. Post-install configuration
6.5. Automated installation script
II. GNU/Linux Basics
7. The Bash shell
7.1. Introduction
7.2. Starting the shell
7.3. Shell basics
8. Files and directories
8.1. Introduction
8.2. The basics
8.3. Permissions
8.4. Archives
8.5. Extended attributes
8.6. Mounting filesystems
8.7. Encrypting and signing files
9. Text Utilities
9.1. Introduction
9.2. The basics
10. Process management
10.1. Introduction
10.2. Process basics
10.3. Advanced process management
III. Editing and typesetting
11. LaTeX
11.1. Introduction
11.2. Preparing basic LaTeX documents
IV. Electronic mail
12. Reading and writing e-mail with mutt
12.1. Introduction
12.2. Usage
12.3. Basic setup
12.4. Signing/encrypting e-mails
13. Sendmail
13.1. Introduction
13.2. Installation
13.3. Configuration
14. Spamassassin
14.1. Introduction
14.2. Installing spamassasin
14.3. Using spamassassin with procmail
V. System administration
15. User management
15.1. Introduction
15.2. Adding and removing users
15.3. Avoiding root usage with su
15.4. Disk quota
16. Printer configuration
16.1. Introduction
16.2. Preparations
16.3. Configuration
16.4. Access control
16.5. Ghostscript paper size
17. X11
17.1. X Configuration
17.2. Window manager
18. Package Management
18.1. Pkgtools
18.2. Slackpkg
18.3. Using rsync
18.4. Tagfiles
19. Building a kernel
19.1. Introduction
19.2. Configuration
19.3. Compilation
19.4. Installation
20. System initialization
20.1. The bootloader
20.2. init
20.3. Initialization scripts
20.4. Hotplugging
21. Security
21.1. Introduction
21.2. Closing services
22. Miscellaneous
22.1. Scheduling tasks with cron
22.2. Hard disk parameters
22.3. Monitoring memory usage
VI. Network administration
23. Networking configuration
23.1. Hardware
23.2. Configuration of interfaces
23.3. Configuration of interfaces (IPv6)
23.4. Wireless interfaces
23.5. Resolving
23.6. IPv4 Forwarding
24. IPsec
24.1. Theory
24.2. Kernel configuration
24.3. Installing IPsec-Tools
24.4. Setting up IPsec with manual keying
24.5. Setting up IPsec with automatic key exchanging
25. The Internet super server
25.1. Introduction
25.2. Configuration
25.3. TCP wrappers
26. Apache
26.1. Introduction
26.2. Installation
26.3. User directories
26.4. Virtual hosts
27. BIND
27.1. Introduction
27.2. Making a caching nameserver
List of Tables
5-1. Alternative kernels
7-1. Bash wildcards
8-1. Archive file extensions
9-1. Special tr character sequences
11-1. LaTeX document classes
11-2. LaTeX font styles
18-1. Tagfile fields
20-1. Hotplug device classes
23-1. Important IPv6 Prefixes
27-1. DNS records
List of Figures
4-1. Forking of a process
4-2. The filesystem structure
5-1. The cfdisk parition tool
5-2. The setup tool
5-3. Setting up the swap partition
5-4. Selecting a partition to initialize
5-5. Formatting the partition
5-6. Selecting a filesystem type
5-7. Selecting the source medium
5-8. Selecting the disk sets
5-9. Installing the kernel
5-10. Creating a bootdisk
5-11. Selecting the default modem
5-12. Enabling hotplugging
5-13. Selecting the kind of LILO installation
5-14. Choosing the framebuffer resolution
5-15. Adding kernel parameters
5-16. Choosing where LILO should be installed
5-17. Configuring a mouse
5-18. Choosing whether GPM should be started or not
5-19. Choosing whether you would like to configure network connectivity
5-20. Setting the host name
5-21. Setting the domain name
5-22. Manual or automatic IP address configuration
5-23. Setting the IP addres
5-24. Setting the netmask
5-25. Setting the gateway
5-26. Choosing whether you want to use a nameserver or not
5-27. Setting the nameserver(s)
5-28. Confirming the network settings
5-29. Enabling/disabling startup services
5-30. Choosing whether the clock is set to UTC
5-31. Setting the timezone
5-32. Choosing the default window manager
5-33. Setting the root password
5-34. Finished
7-1. Standard input and output
7-2. A pipeline
23-1. The anatomy of an IPv6 address
23-2. Router example

Preface

This book aims to provide an introduction to Slackware Linux. It addresses people who have little or no GNU/Linux experience, and covers the Slackware Linux installation, basic GNU/Linux commands and the configuration of Slackware Linux. After reading this book, you should be prepared to use Slackware Linux for your daily work, and more than that.

Thanks to the rapid development of open source software, there are now comprehensive desktop environments and applications for GNU/Linux. Most current distributions and books focus on using GNU/Linux with such environments. I chose to ignore most of the graphical applications for this book, and tried to focus this book on helping you, as a reader, to learn using GNU/Linux in a more traditional UNIX-like way. I am convinced that this approach is often more powerful, and helps you to learn GNU/Linux well, and not just one distribution or desktop environment. The UNIX philosophy is described in Section 2.4.

I wish everybody a good time with Slackware Linux, and I hope that you will find this book is useful for you.

Daniël de Kok

Chapter 1. About this book

Table of Contents
1.1. Availability
1.2. Conventions

1.1. Availability

This book was written in DocBook/XML, and converted to HTML and PDF with Jade. The latest version of the book is always available from: http://www.slackbasics.org/.

1.2. Conventions

This section gives a short summary of the conventions in this book.

1.2.1. File names

File or directory names are printed as: /path/to/file. For example: /etc/fstab

1.2.2. Commands

Commands are printed as bold text. For example: ls -l

1.2.3. Screen output

Screen output is printed like this:


Hello world!

If commands are being entered in the screen output the commands will be printed as bold text:


$ command
Output

If a command is executed as root, the shell will be displayed as "#". If a command is executed as a normal non-privileged user, the shell will be displayed as "$".

1.2.4. Notes

Some sections contain extra notes. It is not necessary to know the information in notes, but notes may provide valuable information, or pointers to information. Notes are printed like this:

Note

This is a note.

Chapter 2. An introduction to Slackware Linux

2.1. What is Linux?

Linux is a UNIX-like kernel, which is written by Linus Torvalds and other developers. Linux runs on many different architectures, for example on IA32, IA64, Alpha, m68k, SPARC and PowerPC machines. The latest kernel and information about the Linux kernel can be found on the Linux kernel website: http://www.kernel.org.

The Linux kernel is often confused with the GNU/Linux operating system. Linux is only a kernel, not a complete operating system. GNU/Linux consists of the GNU operating system with the Linux kernel. The following section gives a more extensive description of GNU/Linux.

2.2. What is GNU/Linux?

In 1984 Richard Stallman started an ambitious project with the goal to write a free UNIX-like operating system. The name of this system is GNU, which is an acronym of "GNU's Not UNIX". Around 1990, all major components of the GNU operating system were written, except the kernel. Two years earlier, in 1988, it was decided that the GNU project would use the Mach 3.0 microkernel as the foundation of its kernel. However, it took until 1991 for Mach 3.0 to be released under a free software license. In the the same year Linus Torvalds started to fill the kernel gap in the GNU system by writing the Linux kernel. GNU/Linux thus refers to a GNU system running with the GNU/Linux kernel.

The GNU kernel, named "HURD" was still under development when this book was written, and is available as the GNU/HURD operating system. There are some other kernels that are ported to the GNU operating system as well. For instance, the Debian project has developed a version of the GNU operating system that works with the NetBSD kernel.

2.3. What is Slackware Linux?

Slackware Linux is a GNU/Linux distribution, which is maintained and developed by Patrick Volkerding. A distribution is a coherent collection of software that provides a usable GNU/Linux system. Volkerding started using GNU/Linux because he needed a LISP interpreter for a project. At the time the dominant GNU/Linux distribution was Softlanding System Linux (SLS Linux). Slackware Linux started out as a private collection of Volkerding's patches for SLS Linux. The first publicly available Slackware Linux release was 1.0, which was released on July 16, 1993.

In contrast to many other GNU/Linux distributions, Slackware Linux adheres to the so-called KISS (Keep It Simple Stupid) principle. This means that Slackware Linux does not have complex graphical tools to configure the system. As a result the learning curve of Slackware Linux can be high for inexperienced GNU/Linux users, but it provides more transparency and flexibility. Besides that you get a deeper understanding of GNU/Linux with no-frills distributions like Slackware Linux.

Another distinguishing aspect of Slackware Linux, that also "complies" with the KISS principle, is the Slackware Linux package manager. Slackware Linux does not have a complex package manager like RPM or dpkg. Packages are normal tgz (tar/gzip) files, often with an additional installation script and a package description file. For novice users tgz is much more powerful than RPM, and avoids dependency problems. Another widely known feature of Slackware Linux is its initialization scripts. In contrast to most other GNU/Linux distributions Slackware Linux does not have a directory for each runlevel with symbolic links to services that have to be started or killed in that runlevel. It uses a simpler approach in which you can enable or disable services by twiddling the executable bit of an initialization script.

The packages in Slackware Linux are compiled with as little modifications as possible. This means you can use most general GNU/Linux documentation.

2.4. The UNIX philosophy

Since GNU/Linux is a free reimplementation of the UNIX operating system, it is a good idea to look at the philosophy that made UNIX widely loved. Doug McIlroy summarized the UNIX philosophy in three simple rules:

  • Write programs that do one thing and do it well.

  • Write programs to work together.

  • Write programs to handle text streams, because that is a universal interface.

Odds are that you do not intend to write programs for GNU/Linux. However, even as a user these basic UNIX rules can mean a lot to you. Once you get to know the essential commands that have been part of UNIX for many years, you will be able to combine simple programs to solve complex problems. Keep this in mind while you learn Slackware Linux; try to get a feeling for how you can divide complex tasks in simple combined operations.

2.5. Free and open source software

Most packages in Slackware Linux are published under a free software or open source license. Under these licenses software may be used, studied, changed and distributed freely. Practically, this means that the software is available and redistributable in source and binary form. Although the free software and open source software movements share many licenses and principles, there are subtle differences between both movements. The open source movement tends to focus on the economic and technical advantages of sharing source code, while the free software movement puts accent on the ethical side of providing sources and binaries freely. As the GNU website puts it: "Free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer. [1]" In the spirit of free and open source software the source code of almost all packages is included on the third and fourth CDs in the Slackware Linux CD set.

2.6. Slackware Linux 10.2 features

  • Linux 2.4.31 - Slackware Linux uses the proven 2.4 Linux kernel as the default kernel. Slackware Linux 10.2 provides Linux 2.6.13 as an option. When a 2.6 kernel is booted, Slackware Linux will automatically use udev, which is a daemon that automatically generates /dev device entries.

  • X11R6.8.2 - This is the second Slackware Linux to provide the X Window System provided by the X.org Foundation.

  • GCC 3.3.6 - Version 3.3.6 of the GNU Compiler Collection is provided. GCC provides C, C++, Objective-C, Fortran-77, and Ada 95 compilers.

  • The K Desktop Environment (KDE) 3.4.2 - The full KDE environment is provided, which includes KOffice, the Konqueror web browser, multimedia programs, development tools, and many more useful applications.

  • XFce 4.2.2 - XFce is a lightweight desktop environment based on GTK2. It embodies the UNIX spirit of modularity and reusability.

  • glibc support for NPTL - NPTL (Native POSIX Thread Library) is a threading implementation that replacess linuxthreads. In combination with a 2.6 Linux kernel, threading performance can improve dramatically. Linuxthreads is still available for compatibility and 2.4 kernels.

2.7. Getting Slackware Linux

Slackware Linux is freely downloadable from the official Slackware Linux mirrors. The list of Slackware mirrors is available at http://www.slackware.com/getslack/.

You can also order Slackware Linux as a CD set from the Slackware Store. Many Internet shops also provide Slackware Linux cheaply on CD-ROM, but you are only supporting Slackware Linux financially if you buy an official CD set. The Slackware Store also offers Slackware Linux subscriptions. A subscriber automatically receives new Slackware Linux releases at a reduced price.

If you would like to have more information about purchasing Slackware Linux, visit the Slackware Store website at http://store.slackware.com/.

Chapter 3. Sources of help

Table of Contents
3.1. On your system
3.2. On the Internet

There is a wealth of information available about many subjects related to GNU/Linux. Most general documentation applies to Slackware Linux, because the software in the distribution has been compiled from source code that has been altered as little as possible. This chapter provides some pointers to information and documentation that can be found on an installed Slackware Linux system, and on the Internet.

3.1. On your system

3.1.1. Linux HOWTO's

The Linux HOWTOs are a collection of documents which cover specific subjects related to GNU/Linux. Most Linux HOWTOs are not tailored to a specific distribution, therefore they are very useful for Slackware Linux users. The linux-howtos package in the "f" software set contains the HOWTO collection. After installing this package the HOWTOs are available from the /usr/doc/Linux-HOWTOs/ directory. Slackware Linux also contains a small collection of Linux-related FAQs (FAQs are documents that answer Frequently Asked Questions). The Linux FAQs are installed to the /usr/doc/Linux-FAQs/ directory, and are available from the linux-faqs package, which is also part of the "I" software set.

3.1.2. Manual pages

Most UNIX-like commands are covered by a traditional UNIX help system called the manual pages. You can read the manual page of a program with the man(1) command. Executing man with the name of a command as a parameter shows the manual page for that command. For instance,


$ man ls
      

shows the manual page of the ls command.

If you do not know the exact name of a manual page or command, you can search through the manual pages with a keyword. The (-k) parameter is provided to make use of this facility:


$ man -k rmdir
hrmdir               (1)  - remove an empty HFS directory
rmdir                (1)  - remove empty directories
rmdir                (2)  - delete a directory
      

The manual page collection is very extensive, and covers more subjects than just commands. The following sections of manual pages are available:


1   Executable programs or shell commands
2   System calls (functions provided by the kernel)
3   Library calls (functions within program libraries)
4   Special files (usually found in /dev)
5   File formats and conventions eg /etc/passwd
6   Games
7   Miscellaneous  (including  macro  packages and conven-
    tions), e.g. man(7), groff(7)
8   System administration commands (usually only for root)
9   Kernel routines [Non standard]
      

If there is more than one section that has a manual page with a specific name, as with for instance rmdir, you can choose what page you want to see by adding the section number of the manual page before the manual page name. For example:


man 2 rmdir
      

If you would like to print a manual page to a printer that you have set up, you can pipe the output of man to the lpr(1) command. When the -t parameter of the man command is used, man will output the manual page in Postscript format, rather than ASCII. For example, you can use the following command to print the tar(1) manual page:


$ man -t tar | lpr
      

3.2. On the Internet

There are many websites and forums related to GNU/Linux and Slackware Linux on the Internet. But many sites often disappear as fast as they appeared, and the information on many web sites is fragmentary. The following resources have been around for a longer time, and provide good content.

3.2.1. The Slackware Linux website

The Slackware Linux website may be a bit outdated at times, but it provides many useful resources:

  • A news page that announces new releases and lists other important news that is relevant to Slackware Linux.

  • An overview of the changes to the distribution is provided in a structured format called a ChangeLog. ChangeLogs are provided for the current development version, as well as the latest stable release.

  • There are two mailing lists to which you can subscribe. The slackware-announce list is used to announce new Slackware Linux releases, and security updates are announced on the slackware-security list.

  • A list of mirrors where you can download Slackware Linux. The mirrors are indexed per country. Additional information such as the download protocols the mirrors support, and the speed of the mirrors is also included.

  • Documentation of various kinds, including a list of frequently asked questions and the Slackware Linux Essentials book.

The Slackware Linux website is available at: http://www.slackware.com/.

3.2.2. LinuxQuestions

LinuxQuestions is a large GNU/Linux forum with many helpful members. Particularly interesting is the Slackware Linux subforum, where you can seek assistance to help you with problems that you may have with Slackware Linux. The LinuxQuestions forum is available at: http://www.linuxquestions.org/.

3.2.3. alt.os.linux.slackware

alt.os.linux.slackware is a Slackware Linux newsgroup. You can read newsgroups with a newsreader like tin or slrn, through the newsgroup server of your Internet service provider. On this newsgroup it is expected that you have read all necessary documentation before posting questions. If you have not done that, the chance of getting "flamed" is large.

Chapter 4. General concepts

Table of Contents
4.1. Multitasking
4.2. Filesystem hierarchy
4.3. Devices

This chapter gives an introduction to some general UNIX and GNU/Linux concepts. It is important to read this chapter thoroughly if you do not have any UNIX or GNU/Linux experience. Many concepts covered in this chapter are used in this book and in GNU/Linux.

4.1. Multitasking

4.1.1. Introduction

One of UNIX's traditional strengths is multitasking. Multitasking means that multiple programs can be run at the same time. You may wonder why this is important, because most people use only one application at a time. Multitasking is a bare necessity for UNIX-like systems. Even if you have not started any applications, there are programs that run in the background. For instance, some programs provide network services, while others show a login prompt and wait until a user logs in on a (virtual) terminal. Programs that are running in the background are often called daemon processes[2].

4.1.2. Processes and threads

After a program is loaded from a storage medium, an instance of the program is started. This instance is called a process. A process has its own protected memory, named the process address space. The process address space has two important areas: the text area and the data area. The text area is the actual program code; it is used to tell the system what to do. The data area is used to store constant and runtime data. The operating system gives every process time to execute. On single processor systems processes are not really running simultaneously. In reality a smart scheduler in the kernel divides CPU time among processes, giving the illusion that processes run simultaneously. This process is called time-sharing. On systems with more than one CPU or CPU cores, more than one process can run simultaneously, but time-sharing is still used to divide the available CPU time among processes.

New processes are created by duplicating a running process with the fork(2) system call. Figure Figure 4-1 shows a fork() call in action schematically. The parent process issues a fork() call. The kernel will respond to this call by duplicating the process, and naming one process the parent, and the other process the child.

Figure 4-1. Forking of a process

Forking can be used by a program to create two processes that can run simultaneously on multiprocessor machines. However, this is often not ideal, because both processes will have their own process address space. The initial duplication of the process memory takes relatively much time, and it is difficult to share data between two processes. This problem is solved by a concept named multithreading. Multithreading means that multiple instances of the text area can run at the same time, sharing the data area. These instances, named threads, can be executed in parallel on multiple CPUs.

4.2. Filesystem hierarchy

4.2.1. Structure

Operating systems store data in filesystems. A filesystem is basically a tree-like structure of directories that hold files, like the operating system, user programs and user data. Most filesystems can also store various metadata about files and directories, for instance access and modification times. In GNU/Linux there is only one filesystem hierarchy, this means GNU/Linux does not have drive letters (e.g. A:, C:, D:) for different filesystems, like DOS and Windows. The filesystem looks like a tree, with a root directory (which has no parent directory), branches, and leaves (directories with no subdirectories). The root directory is alway denoted with a slash ("/"). Directories are separated by the same character.

Figure 4-2. The filesystem structure

Figure 4-2 shows the structure of a filesystem. You can see that the root directory / has two child directories: bin and home. The home directory has two child directories, joe and jack. The diagram shows the full pathname of each directory. The same notation is used for files. Suppose that there is a file named memo.txt in the /home/jack directory, the full path of the file is /home/jack/memo.txt.

Each directory has two special entries, ".", and "..". The first refers to the directory itself, the second to the parent directory. These entries can be used for making relative paths. If you are working in the jack directory, you can refer to the the /home/joe directory with ../joe.

4.2.2. Mounting

You might wonder how it is possible to access other devices or partitions than the hard disk partition which holds the root filesystem. Linux uses the same approach as UNIX for accessing other filesystems. Linux allows the system administrator to connect a device to any directory in the filesystem structure. This process is named mounting. For example, one could mount the CD-ROM drive to the /cdrom directory. If the mount is correct, the files on the CD-ROM can be accessed through this directory. The mounting process is described in detail in Section 8.6.

4.2.3. Common directories

The Filesystem Hierarchy Standard Group has attempted to create a standard that describes which directories should be available on a GNU/Linux system. Currently, most major distributions use the Filesystem Hierarchy Standard (FHS) as a guideline. This section describes some mandatory directories on GNU/Linux systems.

Please note that GNU/Linux does not have a separate directory for each application (like Windows). Instead, files are ordered by function and type. For example, the binaries for most common user programs are stored in /usr/bin, and their libraries in /usr/lib. This is a short overview of the important directories on a Slackware Linux system:

  • /bin: essential user binaries that should still be available in case the /usr is not mounted.

  • /dev: device files. These are special files used to access certain devices.

  • /etc: the /etc directory contains all important configuration files.

  • /home: contains home directories for individual users.

  • /lib: essential system libraries (like glibc), and kernel modules.

  • /root: home directory for the root user.

  • /sbin: essential binaries that are used for system administration.

  • /tmp: a world-writable directory for temporary files.

  • /usr/X11R6: the X Window System.

  • /usr/bin: stores the majority of the user binaries.

  • /usr/lib: libraries that are not essential for the system to boot.

  • /usr/sbin: nonessential system administration binaries.

  • /var: variable data files, like logs.

4.3. Devices

4.3.1. Introduction

In GNU/Linux virtually everything is represented as a file, including devices. Every GNU/Linux system has a directory with special files, named /dev. Each file in the /dev directory represents a device or pseudo-device. A device file has two special numbers associated with it, the major and the minor device number. The kernel knows which device a device file represents by these device numbers. The following example shows the device numbers for the /dev/zero device file:


$ file /dev/zero
/dev/zero: character special (1/5)
      

The file(1) command can be used to determine the type of a file. This particular file is recognized as a device file that has 1 as the major device number, and 5 as the minor device number.

If you have installed the kernel source package, you can find a comprehensive list of all major devices with their minor and major numbers in /usr/src/linux/Documentation/devices.txt. An up-to-date list is also available on-line at through the Linux Kernel Archives[3].

The Linux kernel handles two types of devices: character and block devices. Character devices can be read byte by byte, block devices can not. Block devices are read per block (for example 4096 bytes at a time). Whether a device is a character or block device is determined by the nature of the device. For example, most storage media are block devices, and most input devices are character devices. Block devices have one distinctive advantage, namely that they can be cached. This means that commonly read or written blocks are stored in a special area of the system memory, named the cache. Memory is much faster than most storage media, so much performance can be gained by performing common block read and write operations in memory. Of course, eventually changes have to be written to the storage media to reflect the changes that were made in the cache.

4.3.2. ATA and SCSI devices

There are two kinds of block devices that we are going to look into in detail, because understanding the naming of these devices is crucial for partitioning a hard disk and mounting. Almost all modern computers with an x86 architecture use ATA hard disks and CD-ROMs. Under Linux these devices are named in the following manner:


/dev/hda - master device on the first ATA channel
/dev/hdb - slave device on the first ATA channel
/dev/hdc - master device on the second ATA channel
/dev/hdd - slave device on the second ATA channel
      

On most computers with a single hard disk, the hard disk is the master device on the first ATA channel (/dev/hda), and the CD-ROM is the master device on the second ATA channel. Hard disk partitions are named after the disk that holds them plus a number. For example, /dev/hda1 is the first partition of the disk represented by the /dev/hda device file.

SCSI hard disks and CD-ROM drives follow an other naming convention. SCSI is not commonly used in most low-end machines, but USB drives and Serial ATA (SATA) drives are also represented as SCSI disks. The following device notation is used for SCSI drives:


/dev/sda - First SCSI disk
/dev/sdb - Second SCSI disk
/dev/sdc - Third SCSI disk
/dev/scd0 - First CD-ROM
/dev/scd1 - Second CD-ROM
/dev/scd2 - Third CD-ROM
      

Partitions names are constructed in the same way as ATA disks; /dev/sda1 is the first partition on the first SCSI disk.

If you use the software RAID implementation of the Linux kernel, RAID volumes are available as /dev/mdn, in which n is the volume number starting at 0.

Chapter 5. Installing Slackware Linux

5.1. Booting the installation CD-ROM

The easiest method for booting the installation system is by using the installation CD-ROM. The Slackware Linux installation CD-ROM is a bootable CD, which means that the BIOS can boot the CD, just like it can boot, for example, a floppy disk. Most modern systems have a BIOS which supports CD-ROM booting.

If the CD is booted when you have the CD inserted in the CD-ROM drive during the system boot, the boot sequence is probably not correctly configured in the BIOS. Enter the BIOS setup (usually by this can be done by holding the <Del> or <Esc> key when the BIOS screen appears) and make sure the CD-ROM is on the top of the list in the boot sequence. If you are using a SCSI CD-ROM you may have to set the boot sequence in the SCSI BIOS instead of the system BIOS. Consult the SCSI card manual for more information.

When the CD-ROM is booted, a pre-boot screen will appear. Normally you can just press <ENTER> to proceed loading the default (bare.i) Linux kernel. If want to install Slackware Linux to a disk that is attached to a SCSI or SATA controller, you have to boot an alternative kernel. You can boot an alternative kernel by entering the kernel name on the prompt, and pressing <ENTER>. The following table lists some of the alternative kernels, for a full list of kernels, refer to the Slackware-HOWTO file on the CD-ROM.

Table 5-1. Alternative kernels

Kernel Description
adaptec.s This kernel provides support for most Adaptec SCSI controllers, including VLB and EISA models aside from the more modern PCI controllers.
bareacpi.i This kernel is similar to the bare.i kernel, but provides support for the Advanced Configuration and Power Interface (ACPI).
ataraid.i This kernel provides support for some commonly used ATA RAID controllers.
sata.i This kernel is similar to the bare.i kernel, but provides support for commonly used SATA controllers.
scsi.s/scsi2.s/scsi3.s These kernels provide support for various SCSI controllers. Refer to the Slackware-HOWTO on the CD-ROM for a list of controllers supported by each kernel.

After booting the installation system, you will be asked whether you are using a special (national) keyboard layout or not. If you have a normal US/International keyboard, which are the most common, you can just press <Enter> at this question. After that the login prompt will appear. Log on as "root", no password will be requested. After logging on the shell is started, and you can start installing Slackware Linux. The installation procedure will be explained briefly in this chapter.

5.2. Partitioning a hard disk

Installing Slackware Linux requires at least one Linux partition, creating a swap partition is also recommended. To be able to create a partition there has to be free unpartitioned space on the disk. There are some programs that can resize partitions. For example, FIPS can resize FAT partitions. Commercial programs like Partition Magic can also resize other partition types.

After booting the Slackware Linux CD-ROM and logging on, there are two partitioning programs at your disposal: fdisk and cfdisk. cfdisk is the easiest of both, because it is controlled by a menu interface. This section describes the cfdisk program.

To partition the first harddisk you can simply execute cfdisk. If you want to partition another disk or a SCSI disk you have to specify which disk you want to partition (cfdisk /dev/device). An ATA hard disks have the following device naming: /dev/hdn, "n" is replaced by a character. E.g. the "primary master" is named /dev/hda, the "secondary slave" is named /dev/hdd. SCSI disks are named in the following way: /dev/sdn, "n" is replaced by the device character (the first SCSI disk = a, the fourth SCSI disk = d).

Figure 5-1. The cfdisk parition tool

After starting cfdisk currently existing partitions are shown, as well as the amount of free space. The list of partitions can be navigated with the "up" and "down" arrow keys. At the bottom of the screen some commands are displayed, which can be browsed with the "left" and "right" arrow keys. A command can be executed with the <Enter> key.

You can create a Linux partition by selecting "Free Space" and executing the "New" command. cfdisk will ask you whether you want to create a primary or logical partition. The number of primary partitions is limited to four. Linux can be installed on both primary and logical partitions. If you want to install other operating systems besides Slackware Linux that require primary partitions, it is a good idea to install Slackware Linux onto a logical partition. The type of the new partition is automatically set to "Linux Native", so it is not necessary to set the partition type.

The creation of a swap partition involves the same steps as a normal Linux partition, but the type of the partition has to be changed to "Linux Swap" after the partition is created. The suggested size of the swap partition depends on your own needs. The swap partition is used to store programs if the main (RAM) memory is full. If you have a harddisk of a reasonable size, it is a good idea to make a 256MB or 512MB swap partition, which should be enough for normal usage. After creating the partition the partition type can be changed to "Linux Swap", by selecting the "Type" command. The cfdisk program will ask for the type number, "Linux Swap" partitions have type number 82. Normally number 82 is already selected, so you can go ahead by pressing the <Enter> key.

If you are satisfied with the partitioning you can save the changes by executing the "Write" command. This operation has to be confirmed by entering yes. After saving the changes you can quite cfdisk with the Quit command. It is a good idea to reboot the computer before starting the installation, to make sure that the partitioning changes are active. Press <ctrl> + <alt> + <del> to shut Linux down and restart the computer.

5.3. Installing Slackware Linux

The Slackware Linux installer is started by executing setup in the installation disk shell. Setup will show a menu with several choices, you can see a screenshot of the installer in Figure 5-2. Every option has to be completed to do a complete Slackware Linux installation, but once you start the setup guide will guide you through the options.

Figure 5-2. The setup tool

The first part of the installation is named "ADDSWAP". The setup tool will look for a partition with the "Linux Swap" type, and ask you if you want to format and activate the swap partition (see figure Figure 5-3). Normally you can just answer "Yes".

Figure 5-3. Setting up the swap partition

After setting the swap up space the "TARGET" menu is launched, which you can see in Figure 5-4. It is used to initialize the Slackware Linux partitions. Setup will display all partitions with the "Linux native" type.

Figure 5-4. Selecting a partition to initialize

After selecting one partition, the setup tool will ask whether you want to format a partition or not, and if you want to format it, whether you want to check the disk for bad sectors or not (Figure 5-5). Checking the disk can take a lot of time.

Figure 5-5. Formatting the partition

After selecting whether you want to filesystem or not, you can specify which filesystem should be used (Figure 5-6). Normally you can choose the ext2, ext3 and reiserfs filesystems. Ext2 was the standard Linux filesystem for many years, the disadvantage is that Ext2 does not support journaling. A journal is a special file or area of a partition in which all filesystem operations are logged. When the system crashes the filesystem can be repaired rapidly, because the kernel can use the log to see what disk operations were performed. Ext3 is the same filesystem as Ext2, but adds journaling. Reiserfs is a newer filesystem, that also provides journaling. Besides that Reiserfs uses balanced trees, which make many filesystem operations, especially when you are working with many small files, faster than with Ext2 or Ext3. A disadvantage is that Reiserfs is newer, that is why it can be a bit more unstable.

Figure 5-6. Selecting a filesystem type

The first initialized partition is automatically mounted as the root (/) partition. For other partitions the mount point can be selected after the initialization. You could, for example make separate partitions for /, /var, /tmp, /home and /usr. This provides extra protection against crashes. For example the, / partition is barely changed after the installation if you create these partitions. So, on the occasion of a crash, the chance that the / partition was in the middle of a write operation is much smaller.

The next step is to select the source medium (Figure 5-7). This dialog offers several choices, like installing Slackware Linux from a CD-ROM or installing Slackware Linux via NFS. Most of the times Slackware Linux is installed from CD-ROM, so this is what we are going to look at. After selecting "CD-ROM" you will be asked whether you want to let setup look for the CD-ROM itself ("Auto") or you want to select the CD-ROM device yourself ("Manual"). If you select "Manual" the setup tool will show a list of devices. Select the device holding the Slackware Linux CD-ROM.

Figure 5-7. Selecting the source medium

After choosing an installation source the setup tool will ask you which disk sets (series) you want to install packages from (Figure 5-8). A short description of each disk set is listed.

Figure 5-8. Selecting the disk sets

Now it is almost time to start the real installation. The next screen asks how you would like to install. The most obvious choices are "full", "menu" or "expert". Selecting "full" will install all packages in the selected disk sets. This is the easiest way of installing Slackware Linux. The disadvantage of this choice is that it can take quite much disk space. The "menu" option will ask you for each disk set which packages you want to install. The "expert" option is almost equal to the "menu" option, but allows you to deselect some very important packages from the "a" disk set.

After the completion of the installation the setup tool will allow you to configure some parts of the system. The first dialog will ask you where you would like to install the kernel from (see Figure 5-9). Normally it is a good idea to install the kernel from the Slackware Linux CD-ROM, this will select the kernel you installed Slackware Linux with. You can confirm this, or select another kernel.

Figure 5-9. Installing the kernel

At this point you can choose to make a bootdisk (Figure 5-10). It is a good idea to make a bootdisk, you can use it to boot Slackware Linux if the LILO configuration is botched.

Figure 5-10. Creating a bootdisk

The following dialog can be used to make a link, /dev/modem, that points to your modem device. (Figure 5-11). If you do not have a modem you can select no modem.

Figure 5-11. Selecting the default modem

The next step is to select whether you would like to use hotplug (Figure 5-12). Hotplug is used for automatically configuring pluggable USB, PCMCIA and PCI devices. Generally speaking it is a good idea to enable hotplugging, but some systems may have problems with the probing of the hotplug scripts.

Figure 5-12. Enabling hotplugging

The following steps are important, the next dialogs will assist you with installing LILO, the Linux bootloader. Unless you have experience in configuring LILO it is a good idea to choose to use the simple option for configuration of LILO, which tries to configure LILO automatically (Figure 5-13).

Figure 5-13. Selecting the kind of LILO installation

After selecting the simple option the LILO configuration utility will asks you whether you would like to use a framebuffer or not (Figure 5-14). Using a framebuffer will allow you to use the console in several resolutions, with other dimensions than the usual 80x25 characters. Some people who use the console extensively prefer to use a framebuffer, which allows them to keep more text on the screen. If you do not want a framebuffer console, or if you are not sure, you can choose standard here.

Figure 5-14. Choosing the framebuffer resolution

After setting the framebuffer you can pass extra parameters to the kernel (Figure 5-15). This is normally not necessary, if you do not want to pass extra parameters you can just press the <Enter> key.

Figure 5-15. Adding kernel parameters

The last step of the LILO configuration is selecting where LILO should be installed (Figure 5-16). MBR is the master boot record, the main boot record of PCs. Use this option if you want use Slackware Linux as only OS, or if you want to use LILO the boot other operating systems. The Root option will install LILO in the boot record of the Slackware Linux / partition. Use this option if you use another bootloader.

Figure 5-16. Choosing where LILO should be installed

You will now be asked to configure your mouse. Select the mouse type from the dialog that appears (Figure 5-17).

Figure 5-17. Configuring a mouse

You will then be asked whether the gpm program should be loaded at boot time or not (Figure 5-18). gpm is a daemon that allows you to cut and paste text on the console.

Figure 5-18. Choosing whether GPM should be started or not

The next few steps will configure network connectivity. This is required on almost every networked system. The Slackware Linux setup will ask you if you want to set up network connectivity (Figure 5-19). If you answer "No" you can skip the next few network-related steps.

Figure 5-19. Choosing whether you would like to configure network connectivity

You will now be asked to set the hostname (Figure 5-20). Please note that this is not the fully qualified domain name (FQDN), just the part that represents the host (normally the characters before the first dot in a FQDN).

Figure 5-20. Setting the host name

After setting the host name you can set the domain name part of the fully qualified domain name (FQDN) (Figure 5-21).

Figure 5-21. Setting the domain name

The rest of the network configuration depends on how the IP address is set on the network the machine is connected to. Some networks have a DHCP server that automatically assigns an IP address to hosts in the network. If this is the case for the network the machine select DHCP during this step of the installation (Figure 5-22). When DHCP is selected you will only be asked whether a host name should be sent to the server, normally you can leave this blank. If you use DHCP you can skip the rest of the network configuration described below.

If the network does not have a DHCP server you can choose the static IP option, which will allow you to set the IP address and related settings manually.

Figure 5-22. Manual or automatic IP address configuration

The first step of the manual configuration is to set the IP address of the first interface (eth0) of the machine (Figure 5-23).

Figure 5-23. Setting the IP addres

After setting the IP address you will be asked to enter the netmask. The netmask is usually dependent on the IP address class (Figure 5-24).

Figure 5-24. Setting the netmask

You will then be asked to set the address of the gateway (Figure 5-25). The gateway is the machine on the network that provides access to other networks by routing IP packets. If your network has no network you can just hit the <ENTER> key.

Figure 5-25. Setting the gateway

The next dialog will ask you whether you want to use a nameserver or not (Figure 5-26). A nameserver is a server that can provide the IP address for a hostname. For example, if you surf to www.slackbasics.org, the nameserver will "convert" the www.slackbasics.org name to the corresponding IP address.

Figure 5-26. Choosing whether you want to use a nameserver or not

If you chose to use a nameserver, you will be given the opportunity to set the IP address of the nameserver (Figure 5-27).

Figure 5-27. Setting the nameserver(s)

The final network settings screen provides an overview of the settings, giving you the opportunity to correct settings that have errors (Figure 5-28).

Figure 5-28. Confirming the network settings

After the network configuration you can set which services should be started (Figure 5-29). You can mark/unmark services with the <SPACE> key.

Figure 5-29. Enabling/disabling startup services

Traditionally the system clock is set to the UTC timezone on UNIX(-like) systems. If this is the case, select Yes during the next step (Figure 5-30). If you also use a non-UNIX(-like) OS on the same system, like Windows, it is usually a good idea to choose No, because some PC operating systems do not work with a separate system clock and software clock.

Figure 5-30. Choosing whether the clock is set to UTC

You will then be given the opportunity to select the time zone (Figure 5-31). This is especially important on systems that have their system clock set to UTC, without selecting the correct timezone the software clock will not match the local time.

Figure 5-31. Setting the timezone

If you installed the X Window System you can now set the default window manager (Figure 5-32). The most basic functionality of a window manager is to provide basic window managing functionality like title bars. But some options, like KDE provide a complete desktop environment.

Figure 5-32. Choosing the default window manager

The final step is to set the root password (Figure 5-33). The setup will ask you whether you would like to set it or not. There is no reason not to do this, and without a root password your system is dangerously insecure.

Figure 5-33. Setting the root password

At this point you have completed the Slackware Linux installation. You can now reboot the system to start your fresh new Slackware Linux system. It was not that hard, was is? ;-)

Figure 5-34. Finished

Chapter 6. Custom installation

Sometimes you may want to do a custom installation of Slackware Linux, for example to get better understanding of how GNU/Linux systems work, or to prepare an automatic installation script. This chapter outlines the steps that are required to install Slackware Linux manually. A sample installation script is also provided in Section 6.5.

6.1. Partitioning a hard disk

If you have performed a normal installation, you should not have any problems partitioning a disk. You can use the fdisk(8) and cfdisk(8) commands to partition disks. If you are scripting the installation of Slackware Linux it is useful to know that you can pipe fdisk commands to the fdisk binary. For example:


# fdisk /dev/hda << EOF
n
p
1

+10000M
n
p
2

+512M
t
2
82
w
EOF
    

These commands create a primary Linux partition of 10000MB, and a primary Linux swap partition of 512MB. You could store the fdisk commands in different disk profiles, and use one of the profiles based on the specific deployment (e.g. the disk size). For example:


# cat /usr/share/fdisk-profiles/smalldisk | fdisk
    

6.2. Initializing and mounting filesystems

After making at least a swap and a Linux partition, you can initialize the filesystem and swap space and make use of this storage. On systems that are short on memory, you should initialize, and use swap first. We will use the partition layout used in the partitioning example listed above in the following examples. To set up and use swap, execute:


# mkswap /dev/hda2
# swapon /dev/hda2
    

The meaning of these commands is quite obvious. mkswap(8) initializes the swap space, and swapon(8) puts it to use. You will only have to execute mkswap once, but swapon has to be executed during every system boot. This can be done automatically by adding an entry for the swap partition to /etc/fstab, which we will do during a later step.

For now, it is important to initialize the target partitions. This can be done with the mkfs(8) command. You can specify which filesystem should be used by adding the -t parameter. mkfs will automatically invoke a mkfs.filesystem command based on the filesystem that you have chosen. Be aware that the filesystems that can be used depends on the installation kernel that you have booted. If you have booted the bare.i kernel, you can use the ext2, ext3 and reiserfs filesystems.

To initialize an ext3 filesystem, and mount it, you should execute the following commands:


# mkfs -t ext3 /dev/hda1
# mount /dev/hda1 /mnt
    

If you have made separate partitions for certain directories in the root filesystem, e.g. /home, you can also initialize them and mount them at this point. For example:


# mkfs -t ext3 /dev/hda2
# mkdir /mnt/home
# mount /dev/hda2 /mnt/home
    

Finally, you will have to mount your source medium. If you use a CD-ROM, this is easy. Suppose that /dev/hdc is the CD-ROM device file, you can mount the CD-ROM with:


# mount /dev/hdc /var/log/mount
    

Using NFS as the installation medium requires some more steps. First of all, you will have to load the network disk. You can do this by running the network command and inserting a network disk. You can also load this disk from another medium, for example from an USB memory stick. Suppose that you have mounted a USB memory stick on /var/log/mount, you can load the network disk with: network /var/log/mount/network.dsk. After loading the network disk, you will have to configure the network interface. If the NFS server is on the same network, you will only have to assign an IP address to the network interface. For example, to use the address 192.168.2.201, you could execute the following command:


# ifconfig eth0 192.168.2.201
    

You can then load the portmapper, which is necessary for the NFS client to function correctly:


# /sbin/rpc.portmap
    

If the portmapper started correctly, you can mount the NFS volume. But, first make sure that you unmount any filesystem that you have previously mounted at /var/log/mount. If no other filesystems are mounted at /var/log/mount, you can proceed with mounting the NFS volume. Suppose, that you want to mount 192.168.2.1:/home/pub/slackware-current, you should issue the following command:


# mount -r -t nfs -o nolock 192.168.2.1:/home/pub/slackware-current /var/log/mount
    

If no errors where printed when the volume was mounted, it should be accessible through /var/log/mount

6.3. Installing packages

Everything is now set up to start installing packages from the installation medium. Since installpkg(8) is available from the installation system, you can use it to install Slackware Linux packages. To install packages to the target partition(s) mounted on /mnt, add the -root. The following command installs all packages from the source medium:


# installpkg -root /mnt /var/log/mount/slackware/*/*.tgz
    

If you have created tagfiles to define which packages should be installed, then you can use them now (tagfiles are described in Section 18.4). Suppose that you have stored a tagfile for each disk set in /usr/share/tagfiles/small-desktop, you can install packages based on the tagfiles in the following manner:


# for p in [a-z]*; do
        installpkg -root /mnt -tagfile /usr/share/tagfiles/small-desktop/$p/tagfile /var/log/mount/slackware/$p/*.tgz
done
    

6.4. Post-install configuration

The next sections describe the bare minimum of configuration that is necessary to get a running system.

6.4.1. fstab

One of the necessary configuration steps is to create a fstab(5) file, so that the system can look up what partitions or volumes have to be mounted. The format of the /etc/fstab file is described in Section 8.6.4. As a bare minimum you will have to add entries for the / filesystem, the /proc pseudo-filesystem, the devpts pseudo-filesystem, and the swap partition.

With the sample partitioning used earlier in this chapter, you could create a /etc/fstab like this:


#  cat > /mnt/etc/fstab << EOF
/dev/hda2        swap             swap        defaults         0   0
/dev/hda1        /                ext3        defaults         1   1
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
      

6.4.2. LILO

To make the system bootable you will have to configure and install the Linux Loader (LILO). The configuration of LILO is covered in Section 20.1. For this section we will just show a sample LILO configuration, that can be used with the partition layout described in this chapter. The first step is to create the /etc/lilo.conf file:


# cat > /mnt/etc/lilo.conf << EOF
boot = /dev/hda
vga = normal
timeout = 50
image = /boot/vmlinuz
        root = /dev/hda1
        label = Slackware
        read-only
EOF
      

You can then install LILO with /mnt as the LILO root. With /mnt set as the root, LILO will use /etc/lilo.conf from the target partition:


# lilo -r /mnt
      

6.4.3. Networking

The configuration of networking in Slackware Linux is covered in Chapter 23. This section will cover one example of a host that will use DHCP to get an IP address.

The /etc/networks file contains information about known Internet networks. Because we will get network information via DHCP, we will just use 127.0.0.1 as the local network.


# cat > /mnt/etc/networks << EOF
loopback        127.0.0.0
localnet        127.0.0.0
EOF
      

Although we will get a hostname via DHCP, we will still set up a temporary hostname:


# cat > /mnt/etc/HOSTNAME << EOF
sugaree.example.net
EOF
      

Now that the hostname is configured, the hostname and localhost should also be made resolvable, by creating a /etc/hosts database:


# cat > /mnt/etc/hosts << EOF
127.0.0.1       localhost
127.0.0.1       sugaree.example.net     sugaree 
EOF
      

We do not have to create a /etc/resolv.conf, since it will be created automatically by dhcpcd, the DHCP client. So, finally, we can set up the interface in /etc/rc.d/rc.inet1.conf:


# cat > /mnt/etc/rc.d/rc.inet1.conf << EOF
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""
EOF
      

6.4.4. Tuning initialization scripts

Depending on the purpose of the system that is being installed, it should be decided which initialization scripts should be started. The number of services that are available depends on what packages you have installed. You can get get a list of available scripts with ls(1):


# ls -l /mnt/etc/rc.d/rc.*
      

If the executable bits are set on a script, it will be started, otherwise it will not. Obviously you should keep essential scripts executable, including the runlevel-specific scripts. You can set the executable bit on a script with:


# chmod +x /etc/rc.d/rc.scriptname
      

Or remove it with:


# chmod -x /etc/rc.d/rc.scriptname
      

6.4.5. Configuring the dynamic linker run-time bindings

GNU/Linux uses a cache for loading dynamic libraries. Besides that many programs rely on generic version numbers of libraries (e.g. /usr/lib/libgtk-x11-2.0.so, rather than /usr/lib/libgtk-x11-2.0.so.0.600.8). The cache and library symlinks can be updated in one ldconfig(8) run:


# chroot /mnt /sbin/ldconfig
      

You may not know the chroot(1) command; it is a command that executes a command with a different root than the active root. In this example the root directory is changed to /mnt, and from there chroot(1) runs /sbin/ldconfig binary. After the command has finished the system will return to the shell, which uses the original root. To use chroot(1) with other commands this ldconfig(8) command has to be executed once first, because without initializing the dynamic linker run-time bindings most commands will not execute, due to unresolvable library dependencies.

6.4.6. Setting the root password

Now that the dynamic library cache and links are set up, you can execute commands on the installed system. We will make use of this to set the root password. The