System Administration

Matthew West


Table of Contents

1. General Hints for System Administrators
Introduction
Reading list for administrators
Installation and Configuration Checklist
Administrators file summary
Keeping a record of your system
System Log
Hardware Configuration and Compatibility
Software Checklist
Backup Log
A review of some of basic commands
2. Installation and Bootup
Installation
Planning and Preparation
Starting the Installation
Language and "dbootstrap"
Main Menu
Select a keyboard
Partition hard disk
Hard drive device names
Large disks in older machines
cfdisk
Initialize and activate swap
Initialize a Linux partition
Found a Debian CD-ROM
Configure device driver modules
Configure the network
Install the base system
Make system bootable
Make a boot floppy
Reboot
Troubleshooting - Whoops, it didn't work, now what?
Post-installation configuration
Time Zone
MD5 passwords
Shadow passwords
Root password
Create a normal user account
ACACIA
PPP dial-up configuration
Configuring APT
tasksel and dselect
Logging In
Bootup
The X11 system
Changing your bootloader from LILO to GRUB
Debian Package Management
RPM Package Management:
Upgrading your Linux kernel in Debian
Configuring X Windows
networked installations:
3. File Types and File Systems
Let's review the different file types
Regular files
Directory files
Device files
Interprocess communication Devices
Inodes
A detailed look at the filesystem in Debian
What is a filesystem?
Types of filesystems
The layout of a filesystem
Using Filesystems
mount and unmount
/proc
file system monitoring
Advanced file permissions
file attributes on the ext2 file system
4. Backups
Introduction
Backup media
Magnetic Tape
CD-ROM
Hard Disk
Which form of Media to use?
Securing your backup
Backup concepts
Backup software
mt
tar
cpio
dump and restore
dd
Open source backup solutions
AMANDA -- http://www.amanda.org/
Roll your own
Performing a backup
Verifying Backups
Restore from backup
5. User Information and Administration
Introduction
useradd
groupadd
groupmod
groups
usermod
userdel
groupdel
adduser, addgroup, deluser and delgroup
chfn and chsh
Debian and disk quotas:
initial setup
repquota
edquota
quota
6. Process Accounting
Introduction
Installing the accounting package
ac
lastcomm
sa
last
7. Managing Processes
Introduction
The process table and the nice command
Process creation
System Processes
Scheduling Command execution with batch (cron) jobs
Monitoring system resources
ulimit:
Working with log files
8. Hardware Installation
Adding a new drive to a Linux system:
Does the kernel detect the drive?
Partition the new drive
Build Linux filesystem on any relevant partitions
Decide on a mountpoint and create it
Add the new filesystem to /etc/fstab
Print configuration
BSD Print Spooler (lpr)
/etc/printcap
Explanation of the legend used
Explaining the Generic entry
CUPS - Common Unix Printing System
installation
lpinfo
lpadmin
Removing a printer:
9. Configuration of the Kernel
The /proc filesystem:
A. Troubleshooting
Log files
Common problems:
Lost root password:
Troubleshooting LILO:
B. Additional exercises:
C. Practical lab
Index

List of Figures

2.1. The Bootup sequence
2.2. XWindow client/server model

List of Tables

2.1. Navigation Keys(dbootstrap)
2.2. Disk Device Names
2.3. Navigation Keys in cfdisk
2.4. Runlevels
2.5. apt-get commands
4.1. mt commands
5.1. useradd options
7.1. crontab options
7.2. procs
7.3. memory
7.4. swap
7.5. io
7.6. system
7.7. cpu

Chapter 1. General Hints for System Administrators

Introduction

To define the responsibilities of an administrator 100% at this time would be impossible for us to do, the scope of this job would have to depend on the size of the system or network that you are working with, the numbers of users involved, the amount of resources available to you and the type of applications that the users would be using.

However one thing is for sure and that is that doing the work of a system administrator is fairly time consuming - look at the shell scripting course and get a good idea of how to automate some of the processes.

If we were to itemize the type of jobs that you may have to do the first would have to be to analyze the system(s) that you are working with and the users needs.

The second could very well be to install the operating system or to install some of the desktops and the third and maybe most important to automate would be to maintain the system that you have established.

In order to ensure that your foundation installation is solid check the following guidelines and fill in the missing information where required.

Remember that "Knowledge is power" and when installing a system the more knowledge you have the better the installation will be.

Reading list for administrators

The job of a system's administrator involves continually learning and keeping up to date with technology which affects their work. Thus, it's a good idea to have a handful of resources to refer to in order to track what's happening out there.

Some good web sites to become familiar with include:

http://www.freshmeat.net/

Lots of software, both new and updated releases, are announced here.

http://www.slashdot.org/

"News for Nerds. Stuff that Matters."

http://www.sage.org/

The System Administrator's Guild, affiliated with the Usenix Association. They have several nice booklets and a hard copy magazine, called ";login:", specifically for system administrators!

Installation and Configuration Checklist

To Install the hardware

  1. Take a note of device compatibility

  2. Take a note of the address information (the section called “Hardware Configuration and Compatibility”).

  3. Make sure that you know your system thoroughly e.g. How much memory do you have?

Prepare to install the operating system and software

  1. Calculate the amount of disk space that you will need for each application or additional software that you are intending to install.

  2. Also note in the installation guides for this additional software if they have recommendations for allocating kernel resources or installation tips.

  3. Prepare the materials required for the installation (CDROM etc.)

  4. Read any installation guide that is available to you

Install Operating System

  1. Consider the defaults supplied throughout the installation process. Not all are applicable to your installation

  2. Determine the hardware interrupts and install the devices

  3. Follow the installation process carefully and make notes of all the settings that you configure and the decisions that you make, any error messages or areas of concern that we may have to go back to.

Configure the system and software

  1. Look at the security requirements that you are going to have and implement the relevant solutions.

  2. Install the application software and make changes to resources if required.

  3. Install users, passwords and make other changes to the system profile files.

  4. Follow the process in chapter two for post installation configuration.

  5. Verify your set-up.

  6. Make a backup of the clean system.

  7. Create a system log.

On-going

  1. Follow system resources versus system needs and change if affecting performance

  2. Create and keep organizing the filesystems and files

  3. Manage the users processes

  4. Administrate and monitor system security and closely follow the log files

  5. Maintain the network and access to the Internet if required

  6. Educate the users and hand over some responsibility e.g. log in and lo out procedures and appoint/train a junior printer administrator or backup administrator or user administrator per floor or division.

Administrators file summary

If you've been put in charge of a system which was previously looked after by someone else, there are several files and commands with which it is a good idea to familiarize yourself, so that you can tell how the system has been set up.

Obviously, most of the files in the /etc directory fall into this category, specifically /etc/passwd and the associated /etc/shadow file, as well as /etc/group. On a Debian system, you should also familiarize yourself with a list of the currently installed packages and their versions; you can use the dpkg -list command to achieve this. This command is covered in more detail later.

Keeping a record of your system

System Log

Record all system modifications and other events

DateSystem ModificationSystem Event
...

Diagnose any system problems

DateSystem ProblemSolution used
...

Make a note of system usage and any growth

DateDescription
..

Make a note of the security implementation and its success, remember not to keep these records in an unsafe place.

Hardware Configuration and Compatibility

List your system hardware components and as suggested in the course material, check the hardware's compatibility with the operating system that you are installing.

For each hardware component record the following information:

Item.
Manufacturer.
Serial #.
DMA.
IRQ.
Base Address.
Description (any further relevant driver information)Is it compatible with the operating system that you are installing and where did you find the compatibility information. Anything to be careful of in future or in the case of a re-install? .

Software Checklist

ApplicationDescription 
Software-NameShort description of the installation, problems, resources allocated, serial numbers, licenses and any other pertinent information. 

Backup Log

Decide on your backup procedure whether full or incremental, daily, weekly etc. Then create a log that you can refer to especially at restore time or if handing over the system to someone else (see Chapter 4).

A review of some of basic commands

Check in the man or info pages if you do not know these commands:

For managing files we covered ls, mv, cp, rm, grep, file and find.

We displayed files with cat, more, pg, less, head and tail.

Managed directory files with cd, mkdir, rmdir, pwd and copy.

Used input/output redirection with >, <, >> and |

Download the vi-referance card from this page

Chapter 2. Installation and Bootup

Installation

Planning and Preparation

In this course we are going to go through a complete installation of Debian Linux. You will require at least the first Debian installation CD to do a Debian installation.

Only the first CD is required to turn your computer into a fully working Linux system, although there are lots of useful packages on the other 7 (!) CDs.

You should consult the Debian web site[1] for a list of places where you can get your hands on a copy.

This document covers Debian version 3.0r2, but is applicable to most other versions.

You will need to configure your system's CMOS to tell it that you wish to boot off the CD-ROM drive.

Before attempting the installation make an inventory of the hardware components of your machine. Although the Debian installation system will attempt to automatically detect your hardware, it may not always be successful. Probably the most important pieces of information to record are the IRQ and IO addresses for your ISA/EISA cards, if you have any.

If you're going to be doing the installation onto a machine, which already contains data, and you wish to preserve this data then make a backup!

Debian requires that there be some unused partition space on which it can be installed. Please note that this is not the same as having free space on your C: drive (assuming you're running DOS or Windows).

A typical desktop Debian installation requires about 600MB of disk space, but this can obviously change depending on what additional software you intend to install, as well as the amount of data that you are going to be storing.

It is highly recommended that you also review the installation documentation available on the Debian CDs, as this will cover specific configuration problems in depth, as well as last minute "gotchas" that might have crept into the release.

Debian Linux is a community driven operating system like most open source projects. A way to get the most out of using the software is to become involved with the community. If you're running a Debian system, it is definitely recommended that you subscribe to some of the Debian mailing lists, you can subscribe to these mailing lists on this page

As someone looking after a Debian system, you should at least subscribe to "announce" and "security announce" mailing lists. These are low volume, but they will keep you up to date with what's happening with the Debian project, and, very importantly, about any security related information that becomes available.

During an installation of any operating system, it's a good idea to note down what it is you've done and what choices you've made, and possibly even your reasons. This can prove invaluable when reviewing a system, and especially if you have to re-install it due to a system failure!

Some of the other obvious things that you should do prior to an installation are to make an inventory of the hardware that the system contains, and then to check up online whether or not that specific hardware combination is supported by the operating system and applications that you are going to be installing.

Starting the Installation

Once you've booted off the installation CD, your screen should appear as follows:

Note that it is important to read and note everything that is displayed during the installation. If you skim over something, you may miss a critical piece of information and end up having to start the installation from scratch again!

Once you've read what's on the screen, feel free to use the function keys to investigate the other screens. Once you're ready to begin press Enter.

You should notice a lot of text scroll off the screen. Don't worry if it goes past too quickly for you to read, we can come back to it later.

Language and "dbootstrap"

If all goes well while booting off the CD, you should be presented with the following screen:

The application that is now running is called "dbootstrap"; it is responsible for the installation and initial configuration of the system.

You can use the following keys to navigate in dbootstrap:

Table 2.1. Navigation Keys(dbootstrap)

right arrow, or Tabmove forward between buttons and selections
left arrow, or Shift-Tabmove backward between buttons and selections
Up/Down arrowhighlight items within a scroll list
Spacebarselect an item, such as a check box
Enteractivate current choice
Alt-F1view dbootstrap screen
Alt-F2view virtual console
Alt-F3view error messages
Alt-F4package unpacking and setup messages

Now that you know how to find your way around, use the arrow keys to move the selection bar (the yellow text on a red background) down to your preferred language choice (probably "en"). Once your choice is highlighted, as in the screenshot, press the Enter key.

You may be prompted to further refine your choice, as below:

Once you've done that successfully, you will be presented with the "Release Notes" display:

Once you've read this, press Enter again to continue.

Main Menu

From here, you can jump to most parts of the installation. For the purposes of a standard installation though, you should simply concentrate on the top grouped choices; in this case Next, "Alternate" and "Alternate1".

The Next choice is the next logical step in the installation procedure, and is usually always the one you will want. The "Alternate" options allow you to chose an alternative installation path. This is sometimes useful if you want to skip a section which doesn't make sense for your particular installation.

Make sure that the highlight bar is on "Next: Configure the Keyboard", and then press the Enter key.

Select a keyboard

Select your keyboard type, and then press Enter. If you're not sure which keyboard you have, then go with the default "qwerty/us" selection.

Partition hard disk

Debian needs at least one partition in order to run. However, you can also create a swap partition.

Why create a swap partition?

A swap partition allows the operating system to treat some of the disk space as "virtual memory". If your system has less than 16MB of RAM, then you will have to create a swap partition in order for the system to work. If you have more RAM than that, then a swap partition is not required, but is still recommended.

Generally, the cost of RAM is a lot higher than the cost of disk space. For this reason, it is often useful to be able to use part of the hard disk as if it were memory. This is what a swap partition allows the operating system to do. The kernel will be able to "swap" current unneeded data out of RAM and write it to the swap partition on the disk. When the data is needed by the kernel again, it will be read off the disk, and placed back into RAM.

The benefit is that you get away with not having to have the full amount of physical RAM required to run a specific application. One important point to remember though is that accessing the hard drive is a lot slower than accessing RAM, and so you will incur a speed penalty.

A good rule of thumb is to have the amount of swap that you have equal to twice the amount of RAM that you have, but no more than 1GB. Obviously, this might vary depending on what you're wanting to use the system for.

In our example, we're going to create a 64MB swap partition.

Select "Partition hard disk" and then press Enter.

You will then be prompted to select which hard disk you wish to partition:

Hard drive device names

The Linux kernel assigns short names to the storage devices that it finds on your system. It's important to know what naming scheme it uses, so that you can correctly chose which disks to partition:

Table 2.2. Disk Device Names

devicedescription
hdaprimary master IDE hard disk
hdbprimary slave IDE hard disk
hdcsecondary master IDE hard disk
hddsecondary slave IDE hard disk
sd0first SCSI hard disk
xdafirst XT disk
fd0first floppy drive
scd0first SCSI CD-ROM

In our example, there is only one drive installed in the system; a primary master IDE drive (hda).

Press Enter to select this drive, and continue.

Large disks in older machines

If you have a large HDD, but an old machine, you may encounter problems booting a Linux system. Please read the notes on this screen carefully. If your machine is from 1998 or later, then you shouldn't be affected by this problem. Press Enter to continue.

cfdisk

The dbootstrap application has now launched another application called "cfdisk". This is the actual tool that you will use to partition your hard drive. If you are installing onto a new disk, you will be presented with a prompt as above. Simply press "Y" and then Enter to continue.

You will then be presented with the cfdisk main screen, which should look like this:

You can use the following keys to navigate around cfdisk:

Table 2.3. Navigation Keys in cfdisk

left/right arrow keysmove menu selection highlight
Up/Down arrow keysmove partition selection highlight
Enterselect current menu and partition options

The first thing you should do is press Enter and read through the help section to familiarize yourself with its contents.

Once you have read the help section return to the main screen, press the right arrow key to highlight the "New" menu option, and then press Enter.

You will then be prompted to chose which type of partition you wish to create; either a primary one or a logical one. Unless you already have four primary partitions on your system, select "primary" and press Enter.

You will then be prompted for the size of the partition, given in MB.

We will create a 64MB sized one, so type "64" and press Enter.

Now you can choose whether you wish to add this partition to the beginning of your free space, or to the end. Select "Beginning" and press Enter.

You screen should now look something like this:

You'll see that the partition you've just created is now displayed. It's called "hda1". As mentioned previously "hda" is your primary master IDE drive; the "1" signifies that it is the first partition.

You'll see that it's also a "Primary" partition, that it's a "Linux" filesystem type and that it's 64MB in size.

You'll also see that we still have some free space left, 983.68MB worth in the screenshot.

However, we don't want this to be a "Linuxv" partition, we want it to be a "Linux swap" partition. Use the right arrow key to move the cursor all the way from "Bootable" over to "Type", and then press Enter.

You'll be presented with two pages worth of partition types, and their associated partition type numbers.

At the end of that, you'll be prompted to enter the number of the partition type that you want.

The two numbers that you'll be most interested in remembering are:


82 - Linux swap
83 - Linux

The rest might be useful if you're having to recover your partition table at some point in time, but they're not necessary for a standard Linux installation.

Enter the number "82" (for "Linux swap") and press Enter.

You should now see that the main screen has been updated to reflect your choice, and that the FS Type for hda1 is set to "Linux swap".

Now we want to create another partition out of the remaining free space. Press the down arrow key to move the highlight bar onto the "Free Space" section, and then press the right arrow key to select "New".

Press Enter, and you should be presented with the now familiar menu asking you to select between creating a Primary or a Logical partition. Just press Enter again to select Primary.

As before, you'll be prompted to select the size of the partition. Just hit Enter to select the default, which is to use all the available free space.

Since this is the partition you'll be wanting to boot from, press the Enter key again to toggle the partition's "Bootable" flag. This tells your computer than that partition can be booted from. The main screen should now look something like this:

You can see that you now have two partitions; "hda1" is the previously created Linux swap partition, while "hda2" is your newly created Linux partition. You'll note that the "hda2" partition has its "Boot" flag enabled.

Phew! Now we can finally write this partition table to the hard drive.

Use the right arrow key to move the highlight over to the Write option, and press Enter.

You will be prompted as to whether you do indeed wish to perform this operation:

Type out the full word "yes" if you are sure that you are happy with this.

Once the partition table has been written out successfully, you can move the highlight over to Quit using the arrow keys, and then press Enter.

You have now completed the hardest part of the installation and the rest is relatively easy from here.

Initialize and activate swap

As the display tells you, you've created a swap partition, but you haven't initialized and activated it yet. Press Enter to opt to do this now.

As explained in the write-up on dbootstrap, you can skip this step if you have a relatively modern HDD, as it is able to handle bad blocks on its own.

Select No and press Enter to continue.

Last chance! Are you sure that this is the correct partition (hda1 in our example)? Once you select Yes and press Enter, any information stored on that part of the disk will now be overwritten.

Now your system has that disk space available as virtual memory. This is very useful if you're installing on a machine with a small amount of RAM, as dbootstrap can now make use of this resource.

Initialize a Linux partition

Now we need to Initialize ("format" in DOS parlance) your Linux partition, and then mount it so that we can access it to install Debian onto it.

Press Enter to begin this process now.

Depending on the size of your partition, and the speed of your system and drive, this may take a few moments.

The root ("/") is the base of your filesystem; for our example installation, we will only have this single partition. You may wish to make use of a more complicated layout if you have special needs.

For example, if you have a Samba file server sharing user's home directories, you might well want to have the system ("/", /usr, etc.) on a separate disk to your data (/home). This will allow you to upgrade your system without interfering with the user data, and, likewise, allow you to expand the amount of data storage space easily, without having to re-install the system from scratch.

However, a single filesystem is usually sufficient for a workstation or similar installation.

Select Yes to mount the root filesystem onto our hda2 device.

Now that you have mounted your root filesystem, you may choose to mount additional filesystems, or continue on and install the Linux kernel and driver modules.

For our example, as we only have one partition, we chose to do the later.

You might want to mount additional filesystems to install additional software, or if you are attempting to use the installation program to rescue or upgrade your system.

Press Enter.

Found a Debian CD-ROM

The installation program has detected your Debian CD-ROM and is asking whether or not you wish to install the packages from it.

Alternatives would be to install packages from another source, such as over the network or from another hard disk in the system.

We want to use the CD though, so just select Yes and press Enter.

Configure device driver modules

This section lets you configure which Linux kernel modules, or device drivers, you wish to use. This is useful if you have a network card which is not automatically detected, or, if you're installing on a laptop, if you have any ACACIA devices which you wish to use.

Select Next and press Enter.

If you have a supported PCI network card, support for it will already exist in the Linux kernel, so you won't have to select a kernel module for it. However, if you have one of the older ISA/EISA network cards, (e.g. an NE2000 compatible one), then you may well have to select a driver for it.

[Tip]Tip

One handy way of doing this is seeing what settings the hardware is detected as having by other operating systems.

Configure the network

If Linux has detected a network card, or if you have selected a network card module, you will be presented with the option of configuring it.

If you don't have a network card, or if you do but don't wish to configure it, you can skip ahead to the next section, otherwise press Enter to begin the configuration.

You'll be prompted for a name for your machine; you can call it whatever you like, as long as the name conforms to the rules mentioned on the screen. The default name is "debian", so we'll just stick with that.

Press Enter to continue.

Here you'll have to know a little bit about your network. If you're putting your machine on a live network, and you know that your network has a DHCP server, then you can tell Debian to behave as a DHCP client. This is useful as it will automatically configure your network settings for you.

However, if your machine isn't on a network, or your network doesn't support DHCP, then you'll have to do it manually. For this example, we'll do it manually.

Use the arrow keys to select No, and then press Enter.

You'll need to provide an IP address here; the default is "192.168.1.1", which is a private IP address. We'll use this one for our example, but you may need to specify a real one depending on your own network configuration.

Install the base system

This step will install the "base system", or, put another way, just enough to get your system up and functioning.

Press Enter to continue.

This step will take awhile, as it will have to copy a large number of files off the CD-ROM, extract them and install them on your Linux partition.

Make system bootable

Once the installation has finished, you'll be asked whether you wish to make the system bootable.

Press Enter to continue with this step.

For our example installation, we'll install the LILO boot loader in the MBR (Master Boot Record) of the hard drive. If you were installing onto a disk which already had a boot loader, you might opt to instead install LILO in the root partition (hda2, remember?) instead.

[Note]Note

The space on your hard disk can be partitioned into a maximum of four (4) "primary partitions". Sometimes, your configuration requires that you have more than 4 partitions available. To address this problem, you can convert one of the 4 primary partitions into an "extended partition", within which you can create "logical partitions", which allows you to have more than 4 partitions on a single disk. Each partition can hold a different operating system, or your operating system may be spread over several partitions, each acting as a different drive letter (Windows) or mount point (Linux).

Press Enter to install LILO in the MBR.

If you're interested in keeping your machine secure from physical access, you should read this notice carefully.

Make a boot floppy

It's recommended that you make a boot floppy, it is a very useful troubleshooting tool; you could use the floppy disk to boot your Debian system if it has problems booting from the hard drive as an example.

Press Enter.

Now insert a blank floppy disk, and hit Enter again.

Once you've made a boot floppy, you're ready to reboot the system and see if it works. Make sure that you remove the floppy that you have made as well as the installation CD.

Once that's all done, press Enter to reboot.

Reboot

Your system should then reboot, and you will hopefully be presented with a screen which looks like this:

Congratulations!

Troubleshooting - Whoops, it didn't work, now what?

If you aren't presented with the "Congratulations" screen when you reboot, then something unfortunately must have gone wrong. The first thing I would suggest is attempting to boot off the boot floppy that you made earlier.

Some systems have problems with the LILO boot loader on the hard disk.

Post-installation configuration

Once you've successfully booted your system for the first time, Debian will ask you several questions to configure the packages that you have installed. You can revisit this process at any time by issuing the /usr/sbin/base-config command as root.

Time Zone

You will be asked whether you wish to set your hardware clock to GMT. As noted on the screen, if you are only running one operating system on your machine, then this setting is usually fine. However, if you are using a multi-boot system, you may wish to leave the hardware clock set at local time.

You will then be asked to select your time zone.

You can use the "arrow keys" and the Enter key to make your selections.

MD5 passwords

You will be prompted about whether or not to enable MD5 passwords. If this is going to be a stand-alone system, then MD5 passwords should work fine. If you are going to be integrating this system into an already existing network of Unix machines, you may wish to use the older DES encryption method. Again, make your selection with the "arrow keys" and then the Enter key.

The differences between MD5 and DES password encryption is covered in the Fundamentals section.

Shadow passwords

You should always enable shadow passwords unless you have a very good reason for doing otherwise. Not using shadow passwords leaves your system very vulnerable to local attacks.

Root password

You need to set a password for the "root" or administrator account. Read the instructions on the screen carefully and chose a password.

You'll be prompted to enter the password twice to verify that you didn't make any typos.

[Note]Note

Choose a really good password for the root user? Remember that a person having access to the root account would have full permissions on the system.

Create a normal user account

It's usually always a good idea to create a normal user account. For our example, we'll create one called "student", but you can choose whatever your preferred username is.

Again, choose a good password for your normal user account.

ACACIA

If you're not installing on a laptop, Debian will detect this and ask if you wish to remove the ACACIA packages. This is safe to do, unless you know you'll be wanting ACACIA support for something.

PPP dial-up configuration

If you have a modem connected to your machine, and want to enable your Debian system to use it to connect to the Internet, then select Yes.

If you don't have a modem, or don't wish to connect to the Internet via PPP (perhaps you have a network card), then you can select No.

If you selected Yes, you'll be taken through the PPP Configuration Utility. You'll need to know your dial-up number, username and password. Your ISP should be able to provide you with these.

Configuring APT

APT is part of the Debian package management system.

You need to tell APT where it can obtain Debian packages from. If you have a permanent Internet connection, then it's usually a good idea to select a local Debian mirror to obtain packages from. If you don't have an Internet connection, then you can tell Debian to obtain its packages from CD-ROM instead.

APT is clever enough to be able to handle multiple CDs, so you could load all 7 official CD images into its database if necessary.

Since we've just installed off CD-ROM, this is probably the easiest way to continue, so insert the CD and then just select "cdrom" and press Enter.

APT will then prompt you for further CDs. If you have them, then feel free to load them in. Otherwise, select No and press Enter.

APT will then prompt you to select any additional package sources.

Select No and press Enter.

You'll also be asked if you wish to track security updates from the official Debian security site. If you have a connection to the Internet, this option is definitely recommended.

You can get back to this section after you've finished your installation by running the apt-setup command.

tasksel and dselect

You'll be asked if you wish to use "tasksel" (task select), which will allow you to tailor your system to perform specific tasks by installing the correct packages.

Select Yes and press Enter.

You can use the Up/Down arrow keys to scroll through the list of "tasks" in tasksel, and you can use the left/right arrow keys to select either the selection screen, the Finish, Task info or Help buttons.

While the selection screen is active, you can use either the Spacebar or Enter key to toggle which options you wish to install.

For a first time desktop installation, it is recommended that you select the "X window system" and "desktop environment" options.

Once you've toggle what you want, you can select the Finish button and hit Enter.

You'll now be prompted about whether you wish to use dselect. This is similar tool to "tasksel", but allows your more control over what software packages you're going to install. You can safely skip this step for now though.

Select No and press Enter.

You will then be presented with a long list of packages that are now going to be installed, as well as the summary on the disk space that will be required to perform this operation. You can select Y and Enter to continue, or N and Enter if you wish to abort the installation.

APT will then proceed to load the packages that it requires from the various sources that you'd told it about previously. If you told it to load packages off the CD-ROM, it will prompt you to make sure that the relevant CD is inserted, and to then press Enter.

Do this now.

binutils

You may receive an error message about the "binutils" package and a "Kernel link failure". You can just press Enter and safely ignore the message, as it is only pertinent if you are performing an upgrade of your system, rather than an installation.

less

You will be prompted to configure the less command; you can also safely just press Enter here.

locale

You will be prompted to chose which locale(s) you wish to support.

statd and tcpwrappers

You will be notified that the statd daemon uses tcpwrappers. Again, just hit Enter.

OpenSSH

You will be prompted about whether to allow only SSH protocol 2.

Again, just hit Enter to select Yes.

You will also be notified about OpenSSH's privilege separation, and be given the option of installing ssh-keysign with the SUID bit set.

You can hit Enter through these two options.

You will also be prompted about whether you wish to run the OpenSSH server. If you intend to remotely access this machine, then you should enable the server. Otherwise, you can leave this off.

psfontmgr and paper size

Enable this if you have a PostScript printer. Most modern printers are.

You will also be prompted for your default paper size.

GDM

You'll be asked to select a default X Windows display manager. You can just select the default.

Mozilla

You should enable TrueType fonts for Mozilla. It looks prettier.

You can leave the "tsp wrapper" set to "none".

Xserver

You should opt to have your X server wrapper managed by "debconf".

You should opt to have your X server configuration file managed by "debconf".

You'll need to select which X server you wish to use, based on your video card. Select "vesa" if you're unsure. Don't worry, you can always come back here and try later.

You can opt to use the kernel framebuffer device interface.

For a beginner, it's easiest to use the Simple option to configure your X Windows System.

Select your monitor size, resolution and color depth.

You should now see quite a few lines of text scrolling up your display. These are the individual packages being unpacked and installed on your system.

Once this has been done, the newly installed packages will be configured. Some of this configuration will require your input.

ispell

You'll be asked which dictionaries you wish to use, select either 1 or 2, and then press Enter.

You'll be asked if you wish to erase and previously downloaded .deb files. You can just press Enter here.

exim

The default MTA[2] that comes with Debian is Exim. You'll be prompted to let Debian know what sort of mail system configuration your environment uses.

You can safely choose "4) Local delivery only".

Provide your normal user account as the address which should receive postmaster-mail.

You should, finally, be presented with a "Have fun!" screen.

Well done, your Debian system is up and running and ready to use!

Logging In

Now you should be ready to finally log in! You should make your initial login with the normal user account that you created earlier.

Once you've logged in under your normal user account, you can then use the "su" (substitute user) command to become the super user, also called the "root user", if you are going to be performing any administration tasks.

Linux baloo.zoo.org.za 2.2.20-idepci #1 Sat Apr 20 12:45:19 EST 2002 i686 unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; 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.

student@debian:~$ su 
Password: 
debian:/home/student#
                

Bootup

Figure 2.1. The Bootup sequence

The Bootup sequence

This chapter will describe the steps that your machine takes from the time that it is turned on up until your operating system is fully loaded.

[Note]Note

This only covers the sequence of events on x86 (Intel 80x86 or compatible). If you are using a Sparc or Alpha architecture machine, the process will be similar, but not identical.

Switch on BIOS and CMOS

When you start your machine, it goes through a process known as "bootstrapping", or "booting".

Simply put, your computer doesn't know what to do when you turn it on, so it has to go and fetch some instructions from somewhere. It will initially start the BIOS[3] off your machines CMOS[4] chip.

As the name implies, the BIOS can handle very simple read and write procedures on your machine, usually the system's hard drive.

Before the BIOS does anything else, it will initiate what is known as POST[5]. These are a series of very simple tests to check that the hardware connected to the system (such as RAM, hard drives, video) are functional.

If you system fails POST, it will emit a series of beeps. You can usually look up the meaning of these beeps in your motherboard's manual.

Master Boot Record

Once POST has been passed, the CMOS will then examine the first sector of your hard disk for the Master Boot Record (MBR), which will contain a boot loader. If it cannot find the MBR, or cannot find a boot loader, the CMOS will halt with an error.

Remember that the space on your hard disk can be partitioned into a maximum of four (4) "primary partitions". Sometimes, your configuration requires that you have more than 4 partitions available. To address this problem, you can convert one of the 4 primary partitions into an "extended partition", within which you can create "logical partitions", which allows you to have more than 4 partitions on a single disk.

Each partition can hold a different operating system, or your operating system may be spread over several partitions, each acting as a different drive letter (Windows) or mount point (Linux).

Boot Loader (LILO)

Once the boot loader has been loaded off the MBR, it will take over control of the machine.

The boot loader may have been configured to boot a single operating system, or it may provide the user with a choice of operating systems to choose from. Such functionality is available from the *Li*nux Boot *Lo*ader, LILO.

Once the boot loader knows which partition you want to boot, it will examine the first sector of that partition, also known as the boot sector, for the boot program. If you're booting Linux, this will also be LILO.

Once the boot program has been loaded, it will be able to examine the Linux filesystem and be able to load the Linux kernel into memory and execute it. It will also be able to pass instructions on to the Linux kernel.

The Linux kernel will then proceed to probe the hardware in the machine based on the setting the kernel was compiled with. These will include the device drivers, which enable to kernel to read from the hard disk.

"init" and Run Levels

The default instruction will be for the kernel to load up the "init" process.

The init process is known as the parent of all processes and is generally stored in the /sbin directory.

The kernel will tell "init" what "runlevel" to start the system at. Runlevel 2 is the default runlevel for Debian.

The runlevels, and what happens at each level, are configured in the /etc/inittab file.

Table 2.4. Runlevels

Runlevelaction
0halt the system
1single user or maintenance mode
2-5multi-user mode
6reboot

The init process will then call a shell script called "rc"[6], with the runlevel as its parameter, which will then start up various system services, based on the runlevel that init was given.

The "rc" script will examine the following directory[7]:

/etc/rc#.d/

Where the "#" is replaced by the current runlevel. For a machine, which is booting normally, this would be runlevel 2, so rc would be examining the contents of:

/etc/rc2.d/

In that directory are a collection of scripts.

What is important is their names and the first letter of the name must be a capital "K" (short for kill, used when shutting down the system) or a capital "S" (short for start, used when booting up the system).

Anything else is ignored.

debian:~# ls /etc/rc2.d/
S10sysklogd  S19nfs-common  S20lpd    
S20ssh  S89cron S99rmnologin
S11klogd     S20exim        S20makedev
S20xfs  S99gdm S99xdm
S14ppp       S20inetd       S20nfs-kernel-server
S89atd  S99kdm
                    

The "rc" script will call all "K" scripts with the "stop" parameter, this instructing those processes to stop. It will then call all "S" scripts with the "start" parameter, instructing those processes to start up.

The second and third characters of the script names are usually numbers. Since "rc" executes the scripts in order, you can use this number to determine the order in which processes are started and stopped.

This is useful for doing things like making sure that the network is up and configured before starting your web server, etc.

One of the rc2.d scripts will examine a file called "fstab" (short for file system table) in your /etc directory. This file lists all the filesystems that you want your system to mount at boot time.

Mounting Filesystems

The script will then examine this file, and mount the filesystems if appropriate.

debian:~# cat /etc/fstab 
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>	 <dump>  <pass>
/dev/hdb2       /               ext2    errors=remount-ro       0       1
/dev/hdb1       none            swap    sw                      0       0
proc            /proc           proc    defaults                0       0
/dev/fd0        /floppy         auto    user,noauto             0       0
/dev/cdrom      /cdrom          iso9660 ro,user,noauto          0       0
                    
  • The "file system" column contains the device, or special name in the case of proc, for the file system.

  • The "mount point" specifies where that file system will be mounted.

  • The "type" column indicates what type of file system it is. The standard type under Debian Linux is "ext2".

  • The "options" column specifies any special options that are to be used for this filesystem.

    • ro = read only

    • noauto = don't mount at boot time

  • The "dump" number indicates the level the drive should be dumped, or backed up at. A level 0 means a full backup, while higher numbers mean incremental backups.

  • The "pass" number indicates the order that the file systems should be checked with "fsck" when the system boots. The root ("/") file system should always be checked first, and so should have a pass number of 1. A pass number of "0" means that the file system won't be checked with "fsck"

Obviously, some of the files may exist in more than one rc#.d directory. So, in order to ease administration (imagine having to make a change in a file common to all run levels), and to save space, the actual scripts live in the /etc/init.d/ directory, and are then symlinked into their relevant /etc/rc#.d directories.

debian:~# ls -la /etc/rc2.d
total 8
drwxr-xr-x    2 root  root  4096 Mar 12 08:46 .
drwxr-xr-x   59 root  root  4096 Mar 12 09:08 ..
lrwxrwxrwx    1 root  root  18 Mar 12  2004 
	S10sysklogd -> ../init.d/sysklogd
lrwxrwxrwx    1 root  root  15 Mar 12  2004 
	S11klogd -> ../init.d/klogd
lrwxrwxrwx    1 root  root  13 Mar 12  2004 
	S14ppp -> ../init.d/ppp
lrwxrwxrwx    1 root  root  20 Mar 12 08:44
	S19nfs-common -> ../init.d/nfs-common
lrwxrwxrwx    1 root  root  14 Mar 12  2004
	S20exim -> ../init.d/exim
lrwxrwxrwx    1 root  root  15 Mar 12  2004
	S20inetd -> ../init.d/inetd
lrwxrwxrwx    1 root  root  13 Mar 12 08:44 
	S20lpd -> ../init.d/lpd
lrwxrwxrwx    1 root  root  17 Mar 12  2004
	S20makedev -> ../init.d/makedev
lrwxrwxrwx    1 root  root  27 Mar 12 08:44 
	S20nfs-kernel-server -> ../init.d/nfs-kernel-server
lrwxrwxrwx    1 root  root  13 Mar 12 08:44 
	S20ssh -> ../init.d/ssh
lrwxrwxrwx    1 root  root  13 Mar 12 08:46 
	S20xfs -> ../init.d/xfs
lrwxrwxrwx    1 root  root  13 Mar 12  2004 
	S89atd -> ../init.d/atd
lrwxrwxrwx    1 root  root  14 Mar 12  2004 
	S89cron -> ../init.d/cron
lrwxrwxrwx    1 root  root  13 Mar 12 08:45
	S99gdm -> ../init.d/gdm
lrwxrwxrwx    1 root  root  13 Mar 12 08:46 
	S99kdm -> ../init.d/kdm
lrwxrwxrwx    1 root  root  19 Mar 12  2004
	S99rmnologin -> ../init.d/rmnologin
lrwxrwxrwx    1 root  root  13 Mar 12 08:46
	S99xdm -> ../init.d/xdm
                    

Once the system has reached the state required by the contents of the rc#.d directory, the user will be presented with a login screen.

Getty, issue and motd

The text-based login screen is an application called "getty", which displays the contents of /etc/issue, which is a file that usually holds the name of the operating system, as well as the terminal name.

Debian GNU/Linux 3.0 baloo.zoo.org.za
baloo.zoo.org.za login: root
                    

One you provide your username, the getty process then spawns another process called "login".

This asks you for your password, and then checks your answer against the contents of /etc/passwd, or equivalent authentication mechanism.

If the match succeeds, the login program displays the contents of the /etc/motd file, and then replaces itself (using the exec( ) system call) with a copy of your shell, running under your user id.

Password:
Last login: Wed Mar 24 10:02:19 2004 on tty2
Linux baloo.zoo.org.za 2.2.20-idepci #1 Sat Apr 20 12:45:19 EST 2002 i686 
unknown

Most of the programs included with the Debian GNU/Linux system are
freely redistributable; 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.
                    

Your shell will then process the /etc/profile file, and, if your shell is bash, the /etc/bashrc and $HOME/.bash_login files.

debian:~# pstree
init-+-atd
���� |-bash---pstree
���� |-cron
���� |-5*[getty]
���� |-inetd
���� |-keventd
���� |-kflushd
���� |-klogd
���� |-kswapd
���� |-kupdate
���� |-lpd
���� |-sshd---sshd---bash---top
���� `-syslogd 
                    

The Message of the Day (/etc/motd) file is useful for system announcements that you want your users to see when they log in. This could be something like your company policy on the use of the computing facilities, to a "Joke of the Day".

Shutting down:

You can use the "shutdown" command to gracefully shut the system down.

SYNTAX:
shutdown [ -r | -h ] time [ message ]
                    

The "-r" flag tells the system that you wish to reboot once everything's been shut down. The "-h" flag instead tells the system that you wish to simply halt it. Once a system is halted, you will have to power it off and then on again manually.

If you don't specify either of these flags, the system will be brought down into maintenance, or single user mode.

The "time" parameter specifies when the shutdown is to take place. This can be specified either in HH:MM format (i.e., 01:00 means shut down at 1AM), or in "+minutes", where minutes is the number of minutes from the time the command is issued until the shutdown process begins. You can also specify "now" to shut down the system immediately.

The "message" options specifies an optional message which will be broadcast to all shell users currently logged onto the system.

Examples:

Shutdown the system now, for a reboot:

debian:~# shutdown -r now

Broadcast message from root (pts/0) (Sat Mar 20 03:34:37 2004):

The system is going down for reboot NOW!
                    

You can use the "shutdown" and "reboot" commands to gracefully shutdown the

The X11 system

The standard graphical user interface (GUI) that comes with Debian is called XFree86. This is a free implementation of the X Windows System (X11R6), written for the x86 architecture.

The X Windows System uses the client/server architecture. The server runs on the machine which has the video display hardware, while the clients run can run on the same machine, or on a remote system.

Figure 2.2. XWindow client/server model

XWindow client/server model

This means that your X Windows server must know how to handle your video display hardware.

Your X Windows clients are your graphical applications; examples include "xterm", "mozilla" and "openoffice".

In addition, you usually need a system to manage to each of the "windows" that your applications generate. This system is called your "window manager". It is responsible for putting borders around your application windows, and allowing you to perform actions such altering the size (know as "geometry" in X11 parlance) and location of the window on the screen.

Some of the popular window managers include "fluxbox", "fvwm" and "afterstep".

In addition to window managers, you also get "integrated desktop environments". These are a collection of applications, usually including a menu system, a window manager and a graphical file manager that supports drag'drop between the various desktop elements.

Examples of popular desktop environments include KDE, Gnome and XFCE.

You can find a good summary of available window managers and desktop environments here

There are two ways of allowing access to your X Windows system.

You can make use of the startx command from a local console, after you've logged in.

Alternatively, you can configure an X Windows Display Manager. The default display manager that comes with XFree86 is called plain "XDM".

There is a KDE specific one called "KDM" and a Gnome specific one called "GDM"; the KDE and GNOME Display Managers, respectively.

All three of these applications provide a graphical login screen, and can be accessed either via the local console, or via the network by means of the XDMCP protocol.

You can use the following command under Debian to configure XFree86 (as root):

dpkg-reconfigure xserver-xfree86

This will take you through the same configuration procedure as when you first installed it earlier (see the section called “Configuring X Windows”).

Changing your bootloader from LILO to GRUB

The default Debian installation uses the Linux Boot Loader (LILO), and it performs perfectly for simple boot configurations. However, a lot of people find the GRand Unified Bootloader (GRUB) easier to use and more powerful and thus better suited for their needs.

Switching from LILO to GRUB on Debian is a relatively easy process.

First, you'll need to install the GRUB package:

debian:~# apt-get install grub
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  grub 
0 packages upgraded, 1 newly installed, 0 to remove and 2  not upgraded.
Need to get 0B/247kB of archives. After unpacking 504Kb will be used.
Media Change: Please insert the disc labeled &apos;Debian GNU/Linux 3.0 r2 _Woody_ 
- Official i386 Binary-1 (20031201)&apos; in the drive &apos;/cdrom/&apos; 
and press enter

Selecting previously deselected package grub.
(Reading database ... 9857 files and directories currently installed.)
Unpacking grub (from .../g/grub/grub_0.91-2_i386.deb) ...
Setting up grub (0.91-2) ...
                

Once that's done, you'll need to install the boot loader code on the device that you boot from.

In our example system, that's the second IDE drive on the system ("/dev/hdb"), so the command you would issue would be:

debian:~# grub-install /dev/hdb
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install&apos;.

(fd0)   /dev/fd0
(hd0)   /dev/hda
(hd1)   /dev/hdb
                

Once that's done, you'll need to run the update-grub command, which is Debian specific, and which will generate a GRUB menu configuration file for you, called /boot/grub/menu.lst.

debian:~# update-grub
Searching for GRUB installation directory ... found: /boot/grub .
Testing for an existing GRUB menu.list file... 

Could not find /boot/grub/menu.lst file. Would you like one generated 
for you? (y/N) y
Updating /boot/grub/menu.lst ... done


Please note that configuration parameters for GRUB are stored in
/boot/grub/menu.lst . You must edit this file in order to set the 
options which GRUB passes to the kernel, as well as the drive which 
GRUB looks in to for the kernel.

Everything on the line after &quot;kopt=&quot; is passed to the kernel
as parameters, and &quot;groot=&quot; must be set to the partition
(in GRUB terms, such as &quot;(hd0,0)&quot;) which GRUB will load the 
kernel from.

After you have edited /boot/grub/menu.lst , please re-run 
&apos;update-grub&apos;.
                

As the instructions tell you, you will need to edit the "kopt" and "groot" parameters in that file. You should use "vi" to do this:

debian:~# vi /boot/grub/menu.lst
                
(hd0,0) refers to the first hard disk's first partition
(hd1,0) refers to the second hard disk's first partition
(hd1,1) refers to the second hard disk's second partition
etc.
                

Once you've edited the menu.lst file to your satisfaction, you will need to re-run the update-grub command:

debian:~# update-grub
Searching for GRUB installation directory ... found: /boot/grub .
Testing for an existing GRUB menu.list file... found: /boot/grub/menu.lst .
Updating /boot/grub/menu.lst ... done
                

Now reboot, and see if it has worked!

debian:~# shutdown -r now
                

Debian Package Management

Unlike the RPM package management system which RedHat Linux uses, Debian's packages files have a .deb extension.

Debian uses three different, but related, sets of tools to manage its packages: dpkg, dselect and apt.

dkpg

The dpkg command is the most analogous to RPM's "rpm" command; it allows you to add and remove packages, and to query currently installed packages, check their integrity and dependencies.

List installed packages:

dpkg --list

debian:~# dpkg --list
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name           Version        Description
+++-======================================
ii  aalib1         1.4p5-13       ascii art library
ii  abiword        1.0.2+cvs.2002 Dummy package providing abiword
ii  abiword-common 1.0.2+cvs.2002 WYSIWYG word processor
ii  abiword-gtk    1.0.2+cvs.2002 WYSIWYG word processor based on GTK
ii  adduser        3.47           Add and remove users and groups
ii  apt            0.5.4          Advanced front-end for dpkg
ii  apt-utils      0.5.4          APT utility programs
ii  ark            2.2.2-9        An archiver for KDE
ii  asclock-themes 2.0.12-5       Theme files for ASclock, a clock applet
ii  at             3.1.8-11       Delayed job execution and batch processing
ii  base-config    1.33.18        Debian base configuration package
ii  base-files     3.0.2          Debian base system miscellaneous files
ii  base-passwd    3.4.1          Debian Base System Password/Group Files
[ ... ]
ii  xlibs          4.1.0-16woody1 X Window System client libraries
ii  xnest          4.1.0-16woody1 nested X server
ii  xprt           4.1.0-16woody1 X print server
ii  xserver-common 4.1.0-16woody1 files and utilities common to all X servers
ii  xserver-xfree8 4.1.0-16woody1 the XFree86 X server
ii  xspecs         4.1.0-16woody1 X protocol, extension, and library technical
ii  xterm          4.1.0-16woody1 X terminal emulator
ii  xutils         4.1.0-16woody1 X Window System utility programs
ii  xvfb           4.1.0-16woody1 virtual framebuffer X server
ii  zlib1g         1.1.4-1.0woody compression library - runtime
                        
Information about a .deb file:

dpkg --info package.deb

Install a .deb file:

dpkg --install package.deb

Example Installation

We'll install the "bsdgames" package.

debian:~# mount /cdrom
debian:~# dpkg --info /cdrom/pool/main/b/bsdgames/bsdgames_2.13-7_i386.deb
 new debian package, version 2.0.
 size 791782 bytes: control archive= 6220 bytes.
     841 bytes,    20 lines      control              
   10117 bytes,   158 lines      md5sums              
    1791 bytes,    56 lines   *  postinst             #!/bin/sh
     969 bytes,    32 lines   *  postrm               #!/bin/sh
    1580 bytes,    55 lines   *  preinst              #!/bin/sh
     198 bytes,     7 lines   *  prerm                #!/bin/sh
 Package: bsdgames
 Version: 2.13-7
 Section: games
 Priority: optional
 Architecture: i386
 Depends: libc6 (>= 2.2.4-4), libncurses5 (>= 5.2.20020112a-1),
 wenglish | wordlist
 Suggests: wenglish
 Conflicts: bsdgames-nonfree (<< 2.5), suidmanager (<< 0.50)
 Replaces: bsdgames-nonfree (<< 2.5)
 Installed-Size: 2064
 Maintainer: Joey Hess <joeyh@debian.org>
 Description: collection of text games from BSD systems
  This is a collection of some of the text-based games and amusements that have
  been enjoyed for decades on unix systems.
  .
  Includes these programs: adventure, arithmetic, atc, backgammon, battlestar,
  bcd, boggle, caesar, canfield, countmail, cribbage, fish, gomoku, hangman,
  hunt, mille, monop, morse, number, pig, phantasia, pom, ppt, primes, quiz,
  random, rain, robots, sail, snake, tetris, trek, wargames, worm, worms,
  wump, wtf
debian:~# dpkg --install /cdrom/pool/main/b/bsdgames/bsdgames_2.13-7_i386.deb 
Selecting previously deselected package bsdgames.
(Reading database ... 36337 files and directories currently installed.)
Unpacking bsdgames (from .../bsdgames_2.13-7_i386.deb) ...
Setting up bsdgames (2.13-7) ...

debian:~# _
                        
List files installed by a specific package:

dpkg --listfiles package

Let's list all the files which we've just installed that were part of the "bsdgames" package.

debian:~# dpkg --listfiles bsdgames
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/bsdgames
/usr/share/doc/bsdgames/BUGS.atc
/usr/share/doc/bsdgames/ChangeLog.gz
/usr/share/doc/bsdgames/README.linux.hunt
/usr/share/doc/bsdgames/README.phantasia
/usr/share/doc/bsdgames/README.boggle
/usr/share/doc/bsdgames/README.linux.boggle
/usr/share/doc/bsdgames/TODO.gz
/usr/share/doc/bsdgames/ChangeLog.0
/usr/share/doc/bsdgames/trek.me.gz
[ ... ]
/var/games
/var/games/bsdgames
/var/games/bsdgames/phantasia
/var/games/bsdgames/sail
/usr/share/doc/bsdgames/NEWS.gz
/usr/share/man/man6/teachgammon.6.gz
/usr/share/man/man6/rot13.6.gz
/usr/share/man/man6/morse.6.gz
/usr/share/man/man6/ppt.
                        
Find out which package a specific file belongs to:

dpkg --search filename

debian:~# dpkg --search /usr/games/wtf
bsdgames: /usr/games/wtf
                        

This is useful if you're going to be upgrading a package and want to preserve its existing configuration information.

Uninstall an installed package:

dpkg --remove package

Uninstall an installed package _and_ its associated configuration files:

dpkg --purge package

debian:~# dpkg --purge bsdgames
(Reading database ... 36513 files and directories currently installed.)
Removing bsdgames ...
dpkg - warning: while removing bsdgames, directory 
`/var/games/bsdgames/phantasia&apos; not empty so not removed.
dpkg - warning: while removing bsdgames, directory 
`/var/games/bsdgames' not empty so not removed.
dpkg - warning: while removing bsdgames, directory 
`/var/games' not empty so not removed.
Purging configuration files for bsdgames ...
                        

You'll notice the warnings about "/var/games" not being empty, but if you check now, you'll see that the directory has indeed been deleted:

debian:~# ls /var/games
ls: /var/games: No such file or directory
                        

This is because the directory was removed as part of the "purging configuration files" step.

You should consult the dpkg(8) manual page for further information about this command.

dselect

The dselect command is a frontend to the dpkg command and APT system, and lets you access all its functions through a text based menu system.

apt

The APT (Advanced Package Tool) system is probably one of the reasons that Debian has gained such popularity as a Linux distribution.

Unlike dpkg and dselect, APT is able to handle dependencies and makes upgrading the software on your system very easy.

APT maintains a listing of packages and their locations.

You can use the apt-cdrom command to add a CD to the current listing. So, for example, you could insert the second Debian CD, and add the packages on it to the list of the ones available:

debian:~# apt-cdrom add
Using CD-ROM mount point /cdrom/
Unmounting CD-ROM
Please insert a Disc in the drive and press enter 
Mounting CD-ROM
Identifying.. [580650a473d808bc27074b25dff224f7-2]
Scanning Disc for index files..  Found 4 package indexes and 0 source
indexes.
This Disc is called:
 &apos;Debian GNU/Linux 3.0 r2 _Woody_ - Official i386 Binary-1 (20031201)&apos;
Reading Package Indexes... Done
Wrote 1167 records.
Writing new source list
Source List entries for this Disc are:
deb cdrom:[Debian GNU/Linux 3.0 r2 _Woody_ - Official i386 Binary-1 (20031201)]
/ unstable contrib main non-US/contrib non-US/main
Repeat this process for the rest of the CDs in your set.
debian:~# 
                    

You can likewise use the apt-ftp command to add a remote FTP archive to your list of package sources.

To actually download and/or install packages, you can use the apt-get command, which takes the following parameters as commands:

Table 2.5. apt-get commands

UpdateRetrieve new lists of packages
UpgradePerform an upgrade
InstallInstall new packages
RemoveRemove packages
CheckVerify that there are no broken dependencies

So, to install the "bsdgames" package, we would run:

debian:~# apt-get install bsdgames
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  bsdgames 
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/792kB of archives. After unpacking 2114Kb will be used.
Media Change: Please insert the disc labeled &apos;Debian GNU/Linux 3.0 
r2 _Woody_ - Official i386 Binary-1 (20031201)&apos; in the drive
&apos;/cdrom/&apos; and press enter

Selecting previously deselected package bsdgames.
(Reading database ... 36340 files and directories currently installed.)
Unpacking bsdgames (from .../bsdgames_2.13-7_i386.deb) ...
Setting up bsdgames (2.13-7) ...

debian:~# _
                    

As you can see, APT is clever enough to know which CD the package is on, and will prompt you for the correct media when you ask it to install something.

You can also use the apt-setup command to configure the list of sources for packages.

RPM Package Management:

RPM, a cyclic acronym for RPM Package Management, forms the base of the RedHat Linux package management system, as well as several other distributions. Although it is not used for the base package management system in Debian Linux, you can still make use of it if required.

RPM packages are given a ".rpm" extension, but otherwise follow a naming scheme very similar to .deb packages. Although the package files are in a different format, the same basic operations are common to the different package management systems:

List installed packages:

rpm -qa

Information about a .rpm file:

rpm -qi package.rpm

Install a .rpm file:

rpm -U package.rpm

List files installed by a specific package:

rpm -ql package

Find out which package a specific file belongs to:

rpm -qf filename

Uninstall an installed package:

rpm -e package

Upgrading your Linux kernel in Debian

Debian makes it very easy to upgrade your kernel by using kernel packages.

We're going to attempt something more challenging though, and try to build a kernel of our own.

We are currently running Linux 2.2.20:

debian:~# uname -a
Linux debian 2.2.20-idepci #1 Sat Apr 20 12:45:19 EST 2002 i686 unknown
                

We're going to upgrade to Linux 2.4.18, so we need to install the following packages:

  • ncurses-dev

  • kernel-package

  • kernel-source-2.4.18

  • fakeroot

debian:~# apt-get install kernel-package kernel-source-2.4.18 ncurses-dev
Reading Package Lists... Done
Building Dependency Tree... Done
The following NEW packages will be installed:
  kernel-package kernel-source-2.4.18 
0 packages upgraded, 2 newly installed, 0 to remove and 0  not upgraded.
Need to get 0B/24.1MB of archives. After unpacking 24.9MB will be used.
Media Change: Please insert the disc labeled &apos;Debian GNU/Linux
3.0 r2 _Woody_ - Official i386 Binary-1 (20031201)&apos; in the drive
&apos;/cdrom/&apos; and press enter

Selecting previously deselected package kernel-package.
(Reading database ... 36515 files and directories currently installed.)
Unpacking kernel-package (from .../kernel-package_7.107_all.deb) ...
Selecting previously deselected package kernel-source-2.4.18.
Unpacking kernel-source-2.4.18 
(from .../kernel-source-2.4.18_2.4.18-13_all.deb) ...
Selecting previously deselected package libncurses5-dev.
Unpacking libncurses5-dev 
(from .../libncurses5-dev_5.2.20020112a-7_i386.deb)