[Войти] [Зарегистрироваться]

Наши друзья и партнеры

Беспроводные выключатели nooLite

Lines Club

Ищем достойных соперников.

Книги по Linux (с отзывами читателей)

Библиотека сайта или "Мой Linux Documentation Project"

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A. Administrative 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 root account.

If you're new to Linux administration, you may want to consult the help resources listed in If You Need More Help.

A.1 Linux and Hardware Compatibility  Making sure your hardware is Linux-compatible.
A.2 Shutting Down the System  Shuttind down the system.
A.3 Installing Software  All about installing software.
A.4 Administrating Users  Administrating users.
A.5 Displaying Information about the System  Displaying information about the system.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.1 Linux and Hardware Compatibility

@sf{WWW}: http://www.thedukeofurl.org/

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, including corporations like Dell Computers and IBM.(44)

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.

To find out whether your hardware will work under Linux, try the following:

  • Read the Linux Hardware Compatibility HOWTO (see section Reading System Documentation and Help Files), an up-to-date list of hardware that is compatible with Linux.

  • Visit the Linux Hardware Database and Linux Hardware.Net sites, which provide reviews and information about hardware that works with Linux.

  • Search the Internet--particularly Usenet news and the linux.com site--for the hardware you intend to buy. Read any trouble reports people may have written about getting it to work with Linux, so that you won't be writing the next report about it.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.2 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.

A.2.1 Shutting Down Immediately  Shutting down the system right away.
A.2.2 Shutting Down at a Certain Time  Telling the system to shut down later.
A.2.3 Cancelling a Shutdown  Cancelling a shutdown request.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.2.1 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

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.2.2 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

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.2.3 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, type:

    # 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 shutdown and 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.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3 Installing Software

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.

A.3.1 Getting and Installing Debian  Obtaining and installing Debian.
A.3.2 Installing a Debian Package  Installing Debian packages.
A.3.3 Upgrading a Debian Package  Upgrading Debian packages.
A.3.4 Installing a Shell Script  Installing shell scripts.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3.1 Getting and Installing Debian

@sf{WWW}: http://www.cheapbytes.com/
@sf{WWW}: http://www.debian.org/
@sf{WWW}: http://www.debian.org/releases/stable/

You can get a copy of Debian GNU/Linux on CD-ROM from local or online vendors, or you can download the installation files from the Internet (recommended only if you have a fast Internet connection, of course).

If you choose to buy a copy of Debian in a local computer store, be sure you get the most recent version. If a store only carries an older version, the software might not work with your brand-new hardware! (Visit the Debian Web site to find the number of the latest version.)

If you'd rather buy a copy online, Cheap*Bytes sells affordable Debian GNU/Linux CD-ROMs. The Debian Project maintains a full list of vendors at http://www.debian.org/distrib/vendors/.

The precise details of installation are out of the scope of this book, but the Debian installation guide comes on the CD-ROM. It contains step-by-step instructions and the latest release notes.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3.2 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 `miscfiles' package, type:

    # 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 `miscfiles-1.1.7.deb' file, type:

    # 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."

NOTE: If you're new to Debian, I recommend consulting Dselect Documentation for Beginners.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3.3 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 `sview' package, type:

    # 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...

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3.4 Installing a Shell Script

A shell script is a file that contains commands written in a shell command language (see section The Shell). You run (or "execute") a script as you would any other command (see section Running a Command). First, make sure that the script file is executable; if it isn't, you won't be able to execute it (see section Making a File Executable).

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 (see section Adding 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 `/usr/local/bin/perl'.

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 perl is 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 perl software.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.4 Administrating Users

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.

A.4.1 Making a User Account  How to make a new user account.
A.4.2 Letting Users Access Hardware Peripherals  Letting users access hardware.
A.4.3 Letting Users Mount Drives  Letting users mount drives.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.4.1 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 bucky, type:

    # 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 `/home/bucky'.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.4.2 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 (see section Groups and How to Work in Them).

The groups that regular users might want to be part of include floppy (the floppy disk drive), audio (the soundcard), and dialout and dip (modem dial-out privileges).

Use 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 doug to the audio group, type:

    # addgroup doug audio RET

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.4.3 Letting Users Mount Drives

The `/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

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5 Displaying Information about the System

The following recipes describe ways of displaying information about the system you are running.

A.5.1 How Long Has the System Been Up?  How long has the system been up?
A.5.2 What Version of Linux Am I Running?  What version of Linux am I running?
A.5.3 What Version of Debian Am I Running?  What version of Debian am I running?

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5.1 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 last (see section Listing the Last Times a User Logged In).

  • 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!

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5.2 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 uname information for the system you are on, type:

    $ uname -a RET

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5.3 What Version of Debian Am I Running?

On a Debian system, the file `/etc/debian_version' (see section Files and Directories) contains the release name of the Debian installed.

Use cat to output the contents of this file (see section Concatenating Text).

  • To output the release name of the Debian system you are on, type:

    $ cat /etc/debian_version RET

NOTE: Debian releases have historically been named after characters from the motion picture Toy Story.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

Эта статья еще не оценивалась
Вы сможете оценить статью и оставить комментарий, если войдете или зарегистрируетесь.
Только зарегистрированные пользователи могут оценивать и комментировать статьи.

Комментарии отсутствуют