LPI Linux Certification in a Nutshell (52 page)

Read LPI Linux Certification in a Nutshell Online

Authors: Adam Haeder; Stephen Addison Schneiter; Bruno Gomes Pessanha; James Stanger

Tags: #Reference:Computers

BOOK: LPI Linux Certification in a Nutshell
9.85Mb size Format: txt, pdf, ePub
Name

at

Syntax
at [-f
file
]
time
at [
options
]
Description

In the first form, enter commands to the
at
queue for execution at
time
.
at
allows
fairly complex time specifications. It accepts times of the form
HH:MM
to run a job at a specific time of
day. (If that time is already past, the next day is assumed.) You
may also specify
midnight
,
noon
, or
teatime
(4 p.m.), and you suffix a time of
day with
AM
or
PM
for running in the morning or evening.
You can also say what day the job will be run by giving a date in
month-day form, with the year being optional, or by giving a date in
MMDDYY
,
MM/DD/YY
, or
DD.MM.YY
form. The date specification
must follow the time-of-day specification. You can also give times
such as
now +
count
time-units
, where
time-units
can be minutes, hours, days,
or weeks. You can tell
at
to run
the job today by suffixing the time with
today
, and you can tell it to run the job
tomorrow by suffixing the time with
tomorrow
.

If
-f
file
is
given, commands are taken from the
file
;
otherwise,
at
will prompt the user for
commands.

In the second form, list or delete jobs from the
at
queue.

Frequently used options
-d
job1
[,
job2
,
...]

Delete jobs from the
at
queue by
number (same as the
atrm
command).

-l

List items in the
at
queue (same as
the
atq
command).

Example1

Run
myprogram
once at 6:15
p.m. tomorrow:

$
at 6:15pm tomorrow
at> myprogram
at>
^D

In the previous code listing,
^D
indicates that the user typed Ctrl-D on
the keyboard, sending the end-of-file character to terminate the
at
command.

Example2

Run commands that are listed in the file
command_list
at 9 p.m. two days from
now:

$
at -f command_list 9pm + 2 days

List items in the
at
queue
(
root
sees all users’ entries):

$
at -l

Remove job number 5 from the
at
queue:

$
at -d 5

Using
at
to schedule jobs for delayed
execution, such as while you’re asleep or on vacation, is simple and
doesn’t require creation of a recurring
cron
entry.

Objective 3: Localization and Internationalization

In computing, internationalization and localization are
means of adapting computer software to different languages and regional
differences. Internationalization is the process of designing a software
application so that it can be adapted to various languages and regions
without engineering changes. Localization is the process of adapting
internationalized software for a specific region or language by adding
locale
-specific components and
translating text.

The terms are frequently abbreviated to the numeronyms i18n (where
18 stands for the number of letters between the first “i” and last “n” in
internationalization, a usage coined at Digital Equipment Corporation in
the 1970s or 1980s) and L10n respectively, due to the length of the words.
The capital “L” in L10n helps to distinguish it from the lowercase “i” in
i18n.

Since open source software can generally be freely modified and
redistributed, it is more amenable to internationalization. The KDE
project, for example, has been translated into over 100 languages.

The time zone under Linux is set by a symbolic link from
/etc/localtime
to a file in the
/usr/share/zoneinfo
directory that corresponds to
your specific time zone. Generally this is defined during the installation
process in order to provide the correct information to the system.
However, manually running the command
tzconfig
can
also do the job, and you won’t have to remember the path to the time
zones.

The
tzselect
program is a menu-based script
that asks the user for information about the current location, and then
sends the resulting time zone description to standard output. The output
is suitable as a value for the
TZ
environment
variable:

$
tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
1) Africa
2) Americas
3) Antarctica
4) Arctic Ocean
5) Asia
6) Atlantic Ocean
7) Australia
8) Europe
9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#?

The
date
command can be used to print the
current Coordinated Universal Time (UTC):

$
date -u

and also to show the time zone abbreviation:

$
date +%Z
CET

A locale is a set of information that most programs use for
determining country- and language-specific settings. The following
environment variables are used to store locale
settings:

LANG

Defines all locale settings at once, while allowing further
individual customization via the
LC_*
settings
described next.

LC_COLLATE

Defines alphabetical ordering of strings. This affects the
output of sorted directory listings, for example.

LC_CTYPE

Defines the character-handling properties for the system. This
determines which characters are seen as alphabetic, numeric, and so
on. This also determines the character set used, if
applicable.

LC_MESSAGES

This defines the programs’ localizations for applications that
use a message-based localization scheme. This includes the majority
of GNU programs.

LC_MONETARY

Defines currency units and the formatting of currency type
numeric values.

LC_NUMERIC

Defines formatting of numeric values that aren’t monetary.
This affects things such as the thousands separator and decimal
separator.

LC_TIME

Defines the formatting of dates and times.

LC_PAPER

Defines the default paper size.

LC_ALL

A special variable for overriding all other settings.

The
locale
utility writes information about
the current locale environment, or all public locales, to the standard
output. For the purposes of this section, a public locale is one provided
by the implementation that is accessible to the application. Issuing the
locale
command without any flags will output the
current configuration:

$
locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

The C locale, also known as the POSIX locale, is the POSIX system
default locale for all POSIX-compliant systems.

The
iconv
utility converts the encoding of
characters in a file from one codeset to another and writes the results to
standard output.

The following example converts the contents of the file
in.txt
from the ISO/IEC 6937:1994 standard
codeset to the ISO/IEC 8859-1:1998 standard codeset, and stores the
results in the file
out.txt
:

$
iconv -f IS6937 -t IS8859 in.txt > out.txt
Chapter 16. Essential
System Services
(Topics 108.1 and
108.2)

As a system administrator in a multiuser environment, much of
your activity is related to maintaining various system services. These
services include accurate system time and logging of system events. The
following two Objectives are covered in this chapter:

Objective 1: Maintain System Time

Candidates should be able to properly maintain the system time
and synchronize the clock over NTP. Tasks include setting the system
date and time, setting the hardware clock to the correct time in UTC,
configuring the correct time zone for the system, and configuring the
system to correct clock drift to match the NTP clock. Weight:
3.

Objective 2: System Logging

Candidates should be able to configure system logs. This
Objective includes managing the type and level of information logged,
manually scanning logfiles for notable activity, monitoring logfiles,
arranging for automatic rotation and archiving of logs, and tracking
down problems noted in logs. Weight: 2.

Objective 1: Maintain System Time

An accurate system clock is important on a Linux system for
a variety of reasons. Log entries need to be accurate so you can
accurately determine what system events occurred. Programs such as
make
and
anacron
require
accurate modification times on files. Network file sharing (such as NFS)
requires both client and server to keep accurate time so file operations
are kept in sync.

The most popular way to keep accurate time on an Internet-connected
Linux system is to use the
Network Time Protocol (NTP) and the NTP software package
from
http://www.ntp.org
.

NTP Concepts

NTP is used to set and synchronize the internal clocks of
network-connected systems. When properly configured, systems running the
NTP daemon can be synchronized within a few milliseconds (or better),
even over relatively slow WAN connections.

The NTP daemon also supports synchronization with an external time
source, such as a GPS receiver. Systems directly connected to an
external time source (and properly configured) are the most accurate, so
they are designated
stratum 1
servers. Systems
synchronizing to stratum 1 servers are designated
stratum
2
, and so on, down to stratum 15.

Note

The NTP software package has support for cryptographic key-based
authentication, although setting this up is outside the scope of the
LPI Level 1 Exams and will not be covered here.

The NTP Software Package Components

The NTP software package consists of several programs, including
the NTP daemon and a number of programs used to configure and query NTP
servers. The more commonly used programs from the package are listed
here.

The Hardware Clock

Computer motherboards all contain a small battery that is
used to power the hardware clock. This ensures that the computer can
successfully keep track of the time even when it is powered off. In
Linux, you can configure this hardware clock and synchronize your system
clock to it (or vice versa). The importance of the hardware clock has
been somewhat minimized with the widespread use of NTP and easily
available, reliable time servers. However, for systems that aren’t
always connected to the Internet, an accurate hardware clock is an
important thing to have. Syncing a hardware clock is also required when
working with old hardware that suffers from time issues, such as BIOSes
that are not Y2K-aware.

Hardware clocks can suffer from the same drifts that system clocks
experience, causing them to slowly lose (or gain) time over a certain
period. The
hwclock
command is used in Linux to
control the hardware clock.

Time Zones

As stated previously, a time zone is just a positive or negative
value combined with UTC. Once you set the time zone on a Linux system,
applications will honor that positive or negative offset when they need
to use a timestamp. The time zone on a Linux system is identified by the
file
/etc/localtime
. This can be
either a data file itself or a symbolic link to a data file in the
directory
/usr/share/zoneinfo
.

/usr/share/zoneinfo
contains files that
represent every time zone. In order to set the time zone on your Linux
system, you must either copy one of these files to
/etc/localtime
or create a symbolic link from
/etc/localtime
to one of these files. For
example
, if your system is in the United
States in the Central time zone, your
/etc/localtime
file would look like this:

$
ls –l /etc/localtime
lrwxrwxrwx 1 root root 30 Sep 12 13:56 \
/etc/localtime -> /usr/share/zoneinfo/US/Central

On the Exam

Make sure you understand the difference between system time and
the hardware clock, and the importance of keeping good system time.
Also remember the difference between local time and UTC, and how it
affects the time configuration on your Linux system.

Other books

Back to the Moon-ARC by Travis S. Taylor, Les Johnson
Bitten to Death by Jennifer Rardin
On a Balcony by David Stacton
The Wolf Wants Curves by Arwen Rich
Girls Only! by Beverly Lewis
Morgan's Rescue by Lindsay McKenna
The Summer of Me & You by Hachton, Rae