Linux:9 Linux System Administration
- 1 Linux System Administration Issues
- 2 Linux and Hardware Compatibility
- 3 Shutting Down the System
- 4 Installing Software
- 5 Administrating Users
- 6 Displaying Information about the System
Linux System Administration Issues
Every Linux system has an administrator---someone who installs the hardware and software, maintains the system, and generally keeps things running smoothly. A single-user home Linux system, once installed and running, needs little administration--but the occasional upgrade or maintenance task is necessary.
This appendix exists as a reference for those users who will also be performing the administrative duties on their system. While a complete administrative guide is out of the scope of this book, the goal of this appendix is to point the new Linux administrator in the right direction, giving tips on how to choose the computer you'll use for Linux, install Debian GNU/Linux on it, and get it ready for use.
Unlike the rest of this book, this chapter contains recipes describing commands to be run by
root, the superuser account. Many of these commands cannot be run by an ordinary user; instead of the normal shell prompt used for examples throughout the rest of the book (`$'), the examples in these recipes use a pound sign (`#'), which is the default prompt for the
Linux and Hardware Compatibility
In days gone by, Linux enthusiasts had to piece together computer systems from individual components, since the salesmen at computer stores had never even heard of Linux or the free software movement. But no more. Today, many dealers sell complete systems with Linux pre-installed.
The Duke of URL reviews the latest hardware as it performs with Linux. His periodic "Linux Buyer's Guide" feature lists current hardware that works well on a Linux-based system, and it gives sample configurations (with prices and links to vendors) for putting together a complete system--from low-end budget system to a blazing, dual-processor rig.
Since Linux runs on many different computers and supports a wide range of hardware, and because everyone has different needs, I won't make too many recommendations as to which specific hardware to buy. (Systems change too fast for such a list to be useful, anyway.)
Before you make a hardware purchase, though, make sure that it's compatible with Linux--that bargain video-capture board will be worthless if it has a proprietary interface that only works with a certain non-free operating system.
Shutting Down the System
To shut down the system properly, use
shutdown. It notifies all users and processes of the impending shutdown, blocks new logins, and brings the system down cleanly. (Just cutting power to the system without cleanly stopping processes and unmounting filesystems could result in the loss or corruption of data.)
To halt the system once the shutdown is complete, use the `-h' option; to reboot the system after shutdown, use `-r' instead.
The following recipes describe ways of using
shutdown to do useful things.
Shutting Down Immediately
To shut down the system at a certain time, you normally give that time as an argument; use the special `now' argument to begin the shutdown process immediately.
To immediately shut down and halt the system, type:
# shutdown -h now RET
To immediately shutdown the system, and then reboot, type:
# shutdown -r now RET
You can follow the `now' argument with a quoted message that will be displayed on all terminals of all users currently logged in.
To immediately shut down and halt the system, and send a warning message to all users, type:
# shutdown -h now "The system is being shut down now!" RET
Shutting Down at a Certain Time
To shut down the system at a certain time, give that time (in 24-hour format) as an argument.
To shut down and then reboot the system at 4:23 a.m., type:
# shutdown -r 4:23 RET
To shut down and halt the system at 8:00 p.m., type:
# shutdown -h 20:00 RET
To shut down the system in a certain number of minutes, give that number of minutes prefaced by a plus sign (`+').
To shut down and halt the system in five mintues, type:
# shutdown -h +5 RET
Follow the time with a quoted message to display it on the terminals of all logged in users.
To shut down and halt the system at midnight, and give a warning message to all logged-in users, type:
# shutdown -h 00:00 "The system is going down for maintenance at midnight" RET
Cancelling a Shutdown
If you have given a
shutdown and decide that you don't actually want to shut the system down, run
shutdown again with the `-c' option. This command stops any
shutdowns in progress.
To cancel any pending
# shutdown -c RET
As with a normal system shutdown, you can send out an explanatory message with the cancel that will be shown to all users.
To cancel any pending
shutdownand send an explanatory message to all logged in users, type:
# shutdown -c "Sorry, I hit the wrong key!" RET
This command cancels any pending system shutdown and displays the message, `Sorry, I hit the wrong key!' on all the terminals of anyone logged in.
All Linux distributions come with a multitude of software programs (also called "binaries"). But sooner or later, you will want to install more programs, or you will want to upgrade your existing software when newer versions are available. The following sections talk about installing the Debian GNU/Linux distribution itself, installing and upgrading software when from Debian packages, and how to install stand-alone shell scripts.
Getting and Installing Debian
Installing a Debian Package
Debian makes the software programs available in
`.deb' packages, files that contain everything necessary for the installation of a given software program.
There are different methods of installing packages on a Debian system: via
dselect, where you select packages from a menu;
dpkg, a command-line tool for installing packages; and
apt-get, part of Debian's new "Advanced Package Tool" system.
To install a package when you know the package name, mount your Debian distribution (for example, if you install Debian via CD-ROM, put the first Debian CD-ROM disc in your CD-ROM drive). Then run
apt-get with the `install' command option, and give the name of the package to install as an argument. Should there be additional packages that must be installed first (called dependencies), or should the package conflict with others already installed, an action will be presented to fix this, and you will be prompted to confirm or abort the operation.
To install the
# apt-get install miscfiles RET
If you already have the
`.deb' file, use
dpkg to install it. Use the `-i' option and give the name of the file as an option. Any conflicts or dependencies will have to be resolved by you before the package is installed. If a problem is detected,
dpkg will report it and exit without installing the package.
To install the package in the
# dpkg -i miscfiles-1.1.7.deb RET
Finally, to peruse available packages and choose them from a menu, use
dselect, the Debian package selection tool. A word of caution: its menu interface is different from most programs you have probably encountered, and its usage is unfortunately an acquired skill. Even the
man page makes note of this: "The
dselect package selection interface is confusing or even alarming to the new user."
Upgrading a Debian Package
People are constantly contributing to the free software movement. This means that new software programs are constantly being added to Linux distributions, and current software programs are continually being improved--new features to match new hardware, faster program execution, security updates, and so forth. A Linux system, therefore, needs to be kept up to date in order to reap the benefits of the latest free software.
To upgrade a single package, use
apt-get with the `install' argument, and follow that with the name of the package to upgrade.
To upgrade the
# apt-get install sview RET
This command will upgrade the
`sview' package to the most current version available, if greater than the version already installed on your system. If additional packages must be upgraded first in order for this new package upgrade to function properly, this command will fetch and upgrade those packages, too. Before downloading any packages,
apt-get will show the list of packages that will be installed, replaced, or otherwise changed, and wait for confirmation first.
To bring your entire Debian system up to date, use the
apt-get tool with the following command arguments. First, use the `update' argument to update your system's list of available software packages. Then run
apt-get again, using either the `upgrade' argument to upgrade all of the installed packages to their most recently available versions, or use the `dist-upgrade' argument when a new version of the Debian system is announced, to upgrade to that new version.
To upgrade all of the software on your system to their most recent versions, type:
# apt-get update RET ...processing messages... # apt-get upgrade RET ...processing messages... #
To upgrade your Debian system to the most recent release, type:
# apt-get update RET ...processing messages... # apt-get dist-upgrade RET ...processing messages... #
Installing a Shell Script
A shell script is a file that contains commands written in a shell command language. You run (or "execute") a script as you would any other command. First, make sure that the script file is executable; if it isn't, you won't be able to execute it.
Generally, the administrator installs new shell scripts in the
`/usr/local/bin' directory. If you are on a multi-user system and you are the only user liable to run a particular script, you can put it in a special directory in your home directory tree--the
`~/bin' directory is the standard recommendation here--and then add that directory to your path.
Not all executable script files are shell scripts. The first line of a script contains the full path name of the shell or other program that is to interpret and execute the script; sometimes, the path may differ on your system from the one the script was written on, and so you may have to change this line.
For example, a script may start with the following line:
This line means that the script is written in the
perl language; the text after the `#!' is the full path name of the
perl program, which in this case is
If you try to execute this script and the system reports an error finding the file, you'll have to change that first line to correspond to the location of the
perl binary on your system. The
which tool will output this location.
To find out where
perlis installed on your system, type:
$ which perl RET
If that command returns
`/usr/bin/perl' or some path name other than
/usr/local/bin/perl, you'll have to change the location in the first line of the script to the path name given:
NOTE: If the output of the
which command returns nothing, that means that the
perl program is not installed on your system at all; in that case, you should install the
This section describes some of the things the system administrator will have to do in administrating the system's users. All of these commands must be run by the superuser, using the
root account--these commands edit system files.
Making a User Account
To make a new user account, use
adduser. It takes as an argument the username to use for the new account. It will prompt for default setup information, including the user's full name and an initial password to use.
To create a new user with a username of
# adduser bucky RET
NOTE: By default, the name of the user's home directory will be the same as the username. So, for example, the user
bucky will have a home directory of
Letting Users Access Hardware Peripherals
Certain hardware peripherals, like CD-ROM drives and soundcards, normally require superuser privileges in order to access them. These devices also have groups of their own, so a regular user can also access them by having membership to their groups.
The groups that regular users might want to be part of include
floppy (the floppy disk drive),
audio (the soundcard), and
dip (modem dial-out privileges).
addgroup to add a user to the group associated with a hardware device. Give as arguments the username to add and the name of the group to add to.
To add the user
# addgroup doug audio RET
Letting Users Mount Drives
`/etc/fstab' file specifies the details about the filesystems in use on a system, including those that may be mounted by floppy or CD-ROM drive. In order to let users mount disks on these drives, make sure that there is a line in
`/etc/fstab' for both the floppy and CD-ROM drives, each containing the `user' flag:
/dev/fd0 /floppy auto defaults,noauto,user 0 0 /dev/cdrom /cdrom auto defaults,noauto,user 0 0
Displaying Information about the System
The following recipes describe ways of displaying information about the system you are running.
How Long Has the System Been Up?
To find out how long the system has been running, use the
uptime tool. When you run it as a command, it outputs the current time, how long the system has been running, how many users are logged on, and what the system "load averages" have been for the past one, five, and fifteen minutes.
To find out how long the system has been up, type:
$ uptime RET 3:34pm up 4:31, 4 users, load average: 0.01, 0.05, 0.07 $
To get a list of the times and dates when the system was recently rebooted, give `reboot' as an argument to
To output a list of times when the system was rebooted, type:
$ last reboot RET
NOTE: An operating system capable of running constantly for a long time without crashes or freeze-ups is a good one, and so having a high
uptime value is a matter of pride for many Linux users. It is not uncommon to hear of systems that have been running for months and sometimes even years non-stop--one Linux administrator reported on the Internet about one of his work systems, which had been running continuously without reboot for three years!
What Version of Linux Am I Running?
Use the GNU
uname tool to see what version of Linux you are running. By default, it outputs the name of the operating system; the `-r' option outputs the operating system release number.
To output the name of the operating system, type:
$ uname RET
To output the release number of the operating system, type:
$ uname -r RET
You can also use
uname to output the CPU processor type of the system (such as i586, PowerPC, etc.); specify this with the `-m' option. The `-a' option is also useful; it outputs all information about the system that it can, including all of the mentioned options, plus the version date and number of the operating system and the machine's hostname.
To output the CPU processor type of the system, type:
$ uname -m RET
To output all of the
unameinformation for the system you are on, type:
$ uname -a RET
What Version of Debian Am I Running?
On a Debian system, the file
`/etc/debian_version' contains the release name of the Debian installed.
cat to output the contents of this file.
To output the release name of the Debian system you are on, type:
$ cat /etc/debian_version RET