• No results found

Chapter Review

In document Managing Network Services on Linux (Page 38-46)

In this chapter, we looked at several different network services that can be implemented on Linux. First we looked at configuring printing using CUPS. The CUPS service is pro- vided using the cupsd daemon. CUPS can announce the availability of its printers on the local network. Other Linux systems can listen for these announcements, connect to the CUPS service, and send print jobs to its printers. The CUPS system is made up of the following components: • CUPS scheduler • CUPS filters • CUPS backends • PPD files • Web-based configuration utility • Print queue (/var/spool/cups) The CUPS service is configured using the /etc/cups/cupsd.conf file. One of the tasks you need to complete when setting up CUPS is to configure a CUPS administrator. To Figure 16-18

Viewing data using SQL commands

do this, enter lppasswd –g sys –a user_name at the shell prompt. After doing so, you

can use the web-based configuration utility to create your printers. You do this by open- ing a web browser and navigating to http://localhost:631.

After creating your printer, you can send print jobs by selecting File | Print in your graphical Linux applications. You can also send print jobs from the shell prompt using the lp command. You can use the following command-line utilities to manage your CUPS system:

lpstat –t Displays information about CUPS printers on the system

cancel Cancels a print job

lpoptions –d Sets the default printer for the system

cupsaccept/cupsreject Enables or disables a CUPS print queue

cupsenable/cupsdisable Enables or disables a CUPS printer

You can also manage Linux printing using the Line Printer Daemon (lpd). You can use lpd commands to do the following:

lpr –P printer_name filename Prints a document

lpc status View a printer’s status

lpq View pending print jobs

lprm job_number Delete a pending print job from the queue

These commands also work with CUPS printers and print queues.

I also reviewed a standardized process you can use to troubleshoot printing prob- lems. We also looked at some commonly encountered printing problems and how to resolve them.

We then shifted gears and looked at managing time on Linux. I first reviewed the differ- ence between the hardware clock and the system time on Linux and how each is used. We then looked at how you can use the hwclock command to manage the hardware clock.

To synchronize time between networked Linux systems, you can use the netdate command at the shell prompt. The syntax is netdate time_server, where time_server is

the IP address or DNS name of another Linux system on the network that is running the time service on UDP port 37. After syncing the system time with netdate, you may want to synchronize the system time with your hardware clock using the hwclock --systohc

command.

The netdate command works reasonably well to synchronize time on a network. However, a better way to keep time synchronized on a regular schedule is to use the Network Time Protocol (NTP). NTP manages time in a much cleaner fashion than net- date. NTP adjusts time in a much gentler manner. If there is a time differential between the time provider and the time consumer (your local system), it adjusts time gradually in small increments until time is eventually synchronized. NTP is also widely support- ed by most operating systems.

You can use the ntpd daemon on Linux to synchronize time with another NTP time provider. A system running ntpd can function as both a time consumer and a time pro- vider at the same time. The NTP protocol operates over IP port 123. The time consum-

provider sends its time to the consumer, and the system time on the consumer is ad- justed according to the NTP algorithm.

Several key NTP concepts that you need to be familiar with include the following: • Stratum • Stepping and slewing • Insane time • Drift • Jitter

Once NTP is installed on your system, you can edit the /etc/ntp.conf file in a text editor to specify which system it should get time from. The syntax is as follows:

server time_server_IP_address_or_DNS_name

If desired, you can use an NTP pool time server. The pool.ntp.org domain uses DNS round robin to make a random selection from a pool of time providers who have vol- unteered to be in the pool.

Before you actually start the ntpd daemon, you need to do a quick, one-time syn- chronization with your NTP time provider to avoid insane time issues. This is done by entering ntpdate address_of_time_provider at the shell prompt. This will perform an

initial synchronization to get time close before you start the daemon. You may actually need to run the command multiple times if time is really far apart between your system and the NTP time provider. Once done, you can then start the ntpd daemon using its init script in the appropriate init script directory used by your distribution.

Once the NTP daemon has been started, you can use two commands to keep track of how the ntpd daemon is working:

• ntpq –p • ntptrace

With NTP under our belts, we then looked at managing Linux MTAs. I started by re- viewing how e-mail works. We looked at the roles of the MUA, MTA, and MDA as well as the IMAP and POP3 daemons. We then looked at several commonly used Linux MTAs:

• sendmail • postfix • qmail • Exim

These MTAs can be used to receive sent e-mail messages from MUAs via SMTP. However, they can’t download messages to e-mail clients via POP3 or IMAP. To do this, you must install the imap package on your system.

We then looked at the mail command-line utility that you can use to read e-mail stored in the local MTA at the shell prompt. To send a message, you can enter mail re-

cipient_address at the shell prompt. To view a list of unread messages in your mail queue, you can enter mailq at the shell prompt.

You can also configure aliases for the MTA running on your Linux system. Mail aliases redirect mail addressed to one user to another user’s account. You use the /etc/ aliases file to configure aliases. This file defines one alias per line. The alias you define must point to an existing e-mail address. This is the syntax for this file:

alias: list of real e-mail addresses

When done configuring aliases, you must run the newaliases command at the shell prompt as root to enable them.

You can also use the ~/.forward file in your user’s home directory to configure forward- ing. Most Linux MTAs check for the existence of this file in the user’s home directory to configure forwarding of messages. You can open/create the file in a text editor and enter the e-mail address to which you want to forward e-mail.

At this point, we shifted our attention to managing SQL data. I began by discussing how databases work to store information. Two database services are commonly imple- mented on Linux:

• MySQL • PostgreSQL

SQL defines statements that can be used to retrieve and update data in a database, such as SELECT, UPDATE, DELETE, INSERT, and WHERE. A relational database is orga- nized using fields, records, and tables. A field is a single piece of information. A record is one complete set of fields, and a table is collection of records. Each table is identified by a name, such as Customers. Each table contains records (each one a single row) that contain one or more fields that in turn contain the actual database data. You can use the following commands to manage data in an SQL database: • SELECT • UPDATE • DELETE • INSERT INTO • CREATE TABLE • ALTER TABLE • DROP TABLE

I then reviewed how to implement the MySQL database service on Linux. Once installed, you can use an SQL client to manage the data in the SQL server. I reviewed how to do this using the mysql command at the shell prompt. The syntax is mysql –h

host_name –u user_name –p. I then discussed how to use the following commands

within the mysql client: • CREATE DATABASE • USE

• SHOW TABLES • CREATE TABLE

• DESCRIBE • SELECT • FROM • WHERE • DELETE • UPDATE • JOIN

Accelerated Review

• Most Linux distributions use CUPS to provide local and network printing. • The CUPS service is provided by the cupsd daemon. • CUPS can announce the availability of its printers on the local network. • Other Linux systems can listen for these announcements, connect to the CUPS

service, and send print jobs to its printers.

• The CUPS system is made up of the CUPS scheduler, CUPS filters, CUPS backends, PPD files, the web-based configuration utility, and the Print queue (/var/spool/cups).

• The CUPS service is configured with the /etc/cups/cupsd.conf file.

• To enable other Linux systems to print through your CUPS printers, you must uncomment the BrowseAddress directive in the /etc/cups/cupsd.conf file. • Use the lppasswd –g sys –a user_name command at the shell prompt to create

a CUPS administrative user.

• You use the web-based configuration utility to configure your printers. It is accessed at http://localhost:631.

• After creating your CUPS printer, you can send print jobs by selecting File | Print in a graphical Linux application.

• You can send print jobs from the shell prompt using the lp command. • You can use the following command-line utilities to manage your CUPS system: • lpstat –t • cancel • lpoptions –d • cupsaccept/cupsreject • cupsenable/cupsdisable • You can also manage Linux printing using the Line Printer Daemon (lpd). • You can use lpd commands to do the following: • lpr –P printer_name filename

• lpq • lprm job_number • You should use a standardized process to troubleshoot printing problems. • You should document the flow of print jobs to help you troubleshoot printing problems. • Commonly encountered printing problems include • Is the printer out of paper? • Is the printer turned on? • If it’s a networked printer, is it connected to the network? • Is the network up? • Can you ping the printer from the user’s workstation? • Did the user select the correct printer when sending the print job? • Has the correct printer driver been configured for the printer? • You can use the hwclock command to manage the hardware clock. • To synchronize time between networked Linux systems, you can use the

netdate command at the shell prompt.

• The syntax is netdate time_server where time_server is the IP address or DNS

name of another Linux system on the network that is running the time service on UDP port 37.

• After syncing the system time with netdate, you may want to synchronize the system time with your hardware clock using the hwclock --systohc command.

• A better way to keep time synchronized on a regular schedule is to use the Network Time Protocol (NTP). • NTP manages time in a much cleaner fashion than netdate. • If there is a time differential between the time provider and the time consumer (your local system) it adjusts time gradually in small increments until time is eventually synchronized. • NTP is widely supported by most operating systems. • A system running ntpd can function as both a time consumer and a time provider at the same time.

• The NTP protocol operates over IP port 123. The time consumer sends a time synchronization request to the time provider on port 123.

• The time provider sends its time to the consumer, and the system time on the consumer is adjusted according to the NTP algorithm.

• Several key NTP concepts that you need to be familiar with include the following:

• Stratum

• Insane time • Drift • Jitter

• You can edit the /etc/ntp.conf file in a text editor to specify which system it should get time from.

• The pool.ntp.org domain uses DNS round robin to make a random selection from a pool of time providers who have volunteered to be in the pool. • Before you actually start the ntpd daemon, you need to do a quick, one-time

synchronization with your NTP time provider to avoid insane time issues by entering ntpdate address_of_time_provider at the shell prompt.

• You can start the ntpd daemon using its init script in the appropriate init script directory used by your distribution.

• E-mail messages are created and transferred using the MUA, MTA, and MDA as well as the IMAP or POP3 daemons.

• Several commonly used Linux MTAs include the following: • sendmail • postfix • qmail • Exim • MTAs can’t download messages to e-mail clients via POP3 or IMAP. • To do this, you must install the imap package on your system. • You can use the mail command-line utility to read e-mail stored in the local MTA at the shell prompt.

• To send a message, you can enter mail recipient_address at the shell prompt.

• To view a list of unread messages in your mail queue, you can enter mailq at

the shell prompt.

• You can configure aliases for the MTA running on your Linux system. • Mail aliases redirect mail addressed to one user to another user’s account. • You use the /etc/aliases file to configure aliases. • This file defines one alias per line. • The alias you define must point to an existing e-mail address. • When done configuring aliases, you must run the newaliases command at the shell prompt as root to enable them.

• You can also use the ~/.forward file in your user’s home directory to configure forwarding.

• Most Linux MTAs check for the existence of this file in the user’s home directory to configure forwarding of messages.

• You can open/create the file in a text editor and enter the e-mail address to which you want to forward e-mail.

• Two database services commonly implemented on Linux are • MySQL • PostgreSQL • SQL defines statements that can be used to retrieve and update data in a database, such as SELECT, UPDATE, DELETE, INSERT, and WHERE. • A relational database is organized using fields, records, and tables. • A field is a single piece of information. • A record is one complete set of fields, and a table is collection of records. • Each table is identified by a name, such as Customers. • Each table contains records (each one a single row) that contain one or more fields that in turn contain the actual database data.

• You can use the following commands to manage data in an SQL database: • SELECT • UPDATE • DELETE • INSERT INTO • CREATE TABLE • ALTER TABLE • DROP TABLE • You can use the mysql command at the shell prompt to connect to a MySQL database.

• The syntax is mysql –h host_name –u user_name –p.

• You can use the following commands within the mysql client: • CREATE DATABASE • USE • SHOW TABLES • CREATE TABLE • DESCRIBE • SELECT • FROM • WHERE • DELETE • UPDATE • JOIN

In document Managing Network Services on Linux (Page 38-46)

Related documents