1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4
<!ENTITY % globalent SYSTEM "../../libs/global.ent">
6
<!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
8
<!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
10
<!ENTITY language "&EnglishAmerican;">
12
<chapter id="other-useful-applications" status="review">
13
<title>Other Useful Applications</title>
16
There are many very useful applications developed by the Ubuntu Server Team,
17
and others that are well integrated with Ubuntu Server Edition, that might
18
not be well known. This chapter will showcase some useful applications that can
19
make administering an Ubuntu server, or many Ubuntu servers, that much easier.
22
<sect1 id="update-motd" status="review">
23
<title>Update MOTD</title>
26
When logging into an Ubuntu server you may have noticed the informative Message Of The Day (MOTD). This information
27
is obtained and displayed using a couple of packages:
33
<emphasis>landscape-common:</emphasis> provides the core libraries of <application>landscape-client</application>,
34
which can be used to manage systems using the web based <emphasis>Landscape</emphasis> application. The package includes
35
the <application>/usr/bin/landscape-sysinfo</application> utility which is used to gather the information displayed
41
<emphasis>update-motd:</emphasis> is used to automatically update the MOTD via <application>cron</application>.
47
The <application>update-motd</application> utility has several options to further customize the MOTD:
53
<emphasis>--disable:</emphasis> prevents automatic updates of the MOTD. Using this option creates the
54
<filename>/var/lib/update-motd/disabled</filename> file, which if present stops <application>update-motd</application>
55
from modifying <filename>/etc/motd</filename>.
60
<emphasis>--enable:</emphasis> enables the automatic MOTD updates. If <filename>/var/lib/update-motd</filename>
61
is present it will be removed.
66
<emphasis>--force:</emphasis> does a one time update of <filename>/etc/motd</filename>, overriding <application>update-motd</application>
67
if it has been disabled.
72
<emphasis>d, hourly, weekly, monthly:</emphasis> option will run the scripts in <filename>/etc/update-motd.d/</filename> (default),
73
<filename>/etc/update-motd.d/hourly</filename>, <filename>/etc/update-motd.d/weekly</filename>, or
74
<filename>/etc/update-motd.d/monthly</filename> respectively.
80
<application>update-motd</application> executes the scripts in <filename>/etc/update-motd.d</filename> in order based on the number
81
prepended to the script. Separate <application>cron</application> scripts execute every ten minutes, hourly, weekly, and monthly
82
running the corresponding scripts in <filename>/etc/update-motd.d</filename>. The output of the scripts is written to
83
<filename>/var/run/update-motd/</filename>, keeping the numerical order, then concatenated with
84
<filename>/etc/motd.tail</filename> and written to <filename>/etc/motd</filename>.
88
You can add your own dynamic information to the MOTD. For example, to add local weather information:
94
First, install the <application>weather-util</application> package:
98
<command>sudo apt-get install weather-util</command>
104
The <application>weather</application> utility uses METAR data from the National Oceanic and Atmospheric Administration
105
and forecasts from the National Weather Service. In order to find local information you will need the 4-character ICAO
106
location indicator. This can be determined by browsing to the
107
<ulink url="http://www.weather.gov/tg/siteloc.shtml">National Weather Service</ulink> site.
111
Although the National Weather Service is a United States government agency there are weather stations available world wide.
112
However, local weather information for all locations outside the U.S. may not be available.
117
Create <filename>/usr/local/bin/local-weather</filename>, a simple shell script to use
118
<application>weather</application> with your local ICAO indicator:
123
##########################################################################
125
# Prints the local weather to /var/run/update-motd/60-local-weather
128
##########################################################################
130
# Replace KINT with your local weather station.
131
# Local stations can be found here: http://www.weather.gov/tg/siteloc.shtml
133
echo "" > /var/run/update-motd/60-local-weather
134
weather -i KINT >> /var/run/update-motd/60-local-weather
140
Make the script executable:
144
<command>sudo chmod 755 /usr/local/bin/local-weather</command>
149
Next, create a symlink to <filename>/etc/update-motd.d/60-local-weather</filename>:
153
<command>sudo ln -s /usr/local/bin/local-weather /etc/update-motd.d/60-local-weather</command>
158
Finally, update the MOTD:
162
<command>sudo update-motd</command>
168
You should now be greeted with some useful information, and some information about the local weather that may not be
169
quite so useful. Hopefully the <application>local-weather</application> example demonstrates the flexibility of
170
<application>update-motd</application>.
174
<sect1 id="etckeeper" status="review">
175
<title>etckeeper</title>
178
<application>etckeeper</application> allows the contents of <filename role="directory">/etc</filename> be easily stored in
179
Version Control System (VCS) repository. It hooks into <application>apt</application> to automatically commit changes to
180
<filename>/etc</filename> when packages are installed or upgraded. Placing <filename>/etc</filename> under version control
181
is considered an industry best practice, and the goal of <application>etckeeper</application> is to make this process as
182
painless as possible.
186
Install <application>etckeeper</application> by entering the following in a terminal:
190
<command>sudo apt-get install etckeeper</command>
194
The main configuration file, <filename>/etc/etckeeper/etckeeper.conf</filename>, is fairly simple. The main options being which
195
VCS and which package management system to use. By default <application>etckeeper</application> is configured to use
196
<application>bzr</application> for version control, <application>apt</application> for high level package mangement, and
197
<application>dpkg</application> for low level package management.
201
With the package installed, it is time to initialize the repository. In a terminal enter:
205
<command>sudo etckeeper init</command>
209
Next, commit the files to the repository:
213
<command>sudo etckeeper commit "initial import"</command>
217
Using the VCS commands you can view log information about files in <filename>/etc</filename>:
221
<command>sudo bzr log /etc/passswd</command>
225
To demonstrate the integration with the package management system, install <application>postfix</application>:
229
<command>sudo apt-get install postfix</command>
233
When the installation is finished, all the <application>postfix</application> configuration files should be committed to the
238
<computeroutput>Committing to: /etc/
252
added network/if-down.d/postfix
253
added network/if-up.d/postfix
254
added postfix/dynamicmaps.cf
255
added postfix/main.cf
256
added postfix/master.cf
257
added postfix/post-install
258
added postfix/postfix-files
259
added postfix/postfix-script
262
added ppp/ip-down.d/postfix
263
added ppp/ip-up.d/postfix
264
added rc0.d/K20postfix
265
added rc1.d/K20postfix
266
added rc2.d/S20postfix
267
added rc3.d/S20postfix
268
added rc4.d/S20postfix
269
added rc5.d/S20postfix
270
added rc6.d/K20postfix
271
added resolvconf/update-libc.d
272
added resolvconf/update-libc.d/postfix
273
added rsyslog.d/postfix.conf
274
added ufw/applications.d/postfix
275
Committed revision 2.</computeroutput>
279
For an example of how <application>etckeeper</application> tracks manual changes, add new a host to <filename>/etc/hosts</filename>.
280
Using <application>bzr</application> you can see which files have been modified:
284
<command>sudo bzr status /etc/</command>
285
<computeroutput>modified:
286
hosts</computeroutput>
290
Now commit the changes:
294
<command>sudo etckeeper commit "new host"</command>
298
For more information on <application>bzr</application> see <xref linkend="bazaar"/>.
302
<sect1 id="screen-profiles" status="review">
303
<title>Screen Profiles</title>
306
One of the most useful applications for any system administrator is <application>screen</application>. It allows the execution
307
of multiple shells in one terminal. To make some of the advanced <application>screen</application> features more
308
user friendly, and provide some useful information about the system, the <application>screen-profiles</application> package was
313
When executing <application>screen</application> for the first time you will be presented with the
314
<application>screen-profiles-helper</application> menu. This menu will allow you to:
318
<listitem><para>View the Help menu</para></listitem>
319
<listitem><para>Change the key binding set</para></listitem>
320
<listitem><para>Change screen profiles</para></listitem>
321
<listitem><para>Change the escape sequence</para></listitem>
322
<listitem><para>Create new screen windows</para></listitem>
323
<listitem><para>Manage the default windows</para></listitem>
324
<listitem><para>Install screen by default at login</para></listitem>
328
The <emphasis>key bindings</emphasis> determine such things as the escape sequence, new window, change window, etc. There
329
are two key binding sets to choose from <emphasis>common</emphasis> and <emphasis>none</emphasis>. If you wish to use the
330
original key bindings choose the <emphasis>none</emphasis> set.
334
The Ubuntu <application>screen-profiles</application> provide a menu which displays the Ubuntu release, processor information,
335
memory information, and the time and date. The effect is similar to a desktop menu. When a profile is selected it will be
336
symlinked to <filename>~/.screenrc</filename>. The <application>select-screen-profile</application> utility can also be used
337
to change profiles, in a terminal enter:
341
<command>select-screen-profile -s ubuntu-light</command>
345
The <emphasis>plain</emphasis> profile will change <application>screen</application> back to the defaults, which does not include
346
the information menu at the bottom.
350
Using the <emphasis>"Install screen by default at login"</emphasis> option will cause screen to be executed any time a terminal is opened.
351
Changes made to <application>screen</application> are on a per user basis, and will not affect other users on the system.
355
One difference when using screen is the <emphasis>scrollback</emphasis> mode. If you are using one of the Ubuntu profiles press the
356
<emphasis>F7</emphasis>, or <emphasis>Ctrl+a+[</emphasis> if not, to enter scrollback mode. Scrollback mode allows you to navigate
357
past output using <emphasis>vi</emphasis> like commands. Here is a quick list of movement commands:
361
<listitem><para><emphasis>h</emphasis> - Move the cursor left by one character</para></listitem>
362
<listitem><para><emphasis>j</emphasis> - Move the cursor down by one line</para></listitem>
363
<listitem><para><emphasis>k</emphasis> - Move the cursor up by one line</para></listitem>
364
<listitem><para><emphasis>l</emphasis> - Move the cursor right by one character</para></listitem>
365
<listitem><para><emphasis>0</emphasis> - Move to the beginning of the current line</para></listitem>
366
<listitem><para><emphasis>$</emphasis> - Move to the end of the current line</para></listitem>
367
<listitem><para><emphasis>G</emphasis> - Moves to the specified line (defaults to the end of the buffer)</para></listitem>
368
<listitem><para><emphasis>C-u</emphasis> - Scrolls a half page up</para></listitem>
369
<listitem><para><emphasis>C-b</emphasis> - Scrolls a full page up</para></listitem>
370
<listitem><para><emphasis>C-d</emphasis> - Scrolls a half page down</para></listitem>
371
<listitem><para><emphasis>C-f</emphasis> - Scrolls the full page down</para></listitem>
372
<listitem><para><emphasis>/</emphasis> - Search forward</para></listitem>
373
<listitem><para><emphasis>?</emphasis> - Search backward</para></listitem>
374
<listitem><para><emphasis>n</emphasis> - Moves to the next match, either forward or backword</para></listitem>
378
<sect1 id="other-app-references" status="review">
379
<title>References</title>
384
See the <ulink url="http://manpages.ubuntu.com/manpages/jaunty/en/man1/update-motd.1.html">update-motd man page</ulink> for
385
more options available to <application>update-motd</application>.
390
The Debian Package of the Day
391
<ulink url="http://debaday.debian.net/2007/10/04/weather-check-weather-conditions-and-forecasts-on-the-command-line/">weather</ulink>
392
article has more details about using the <application>weather</application>utility.
397
See the <ulink url="http://kitenet.net/~joey/code/etckeeper/">etckeeper</ulink> site for more details on using
398
<application>etckeeper</application>.
403
For the latest news and information about <application>bzr</application> see the <ulink url="http://bazaar-vcs.org/">bzr</ulink> web site.
408
For more information on <application>screen</application> see the <ulink url="http://www.gnu.org/software/screen/">screen web site</ulink>.
413
Also, see the <application>screen-profiles</application> <ulink url="https://launchpad.net/screen-profiles">project page</ulink> for more