ubuntu

Ubuntu is a relatively new flavour of Linux. Since the release of ‘Warty Warthog’ in October 2004, Ubuntu has become the most popular Linux distribution worldwide.

Similar to its parent, Debian GNU/Linux, Ubuntu is based entirely on free software. It inherits outstanding package management and provides one-click access to thousands of downloadable software applications. Ubuntu is for everyone and supports the architectures x86 and x86-64.

The latest version of Ubuntu is 8.04 (Hardy Heron), which was released to the community on 21 April 2008.
www.ubuntu.com

Long Term Support

Ubuntu 6.06 and 8.04 have been labelled LTS (Long Term Support). This is to indicate that from the date of their initial release, these versions will receive security updates for three years on the desktop and five years on the server.

Articles

Hardy Heron Makes Linux Worth Another Look

“If you’ve flirted with the idea of switching your desktop operating system to Linux but never took the leap, the time is now.” Kevin Purdy highlights key features of the latest Ubuntu release.

lifehacker.com

Ubuntu Dapper: Ready for the Long Haul

“Overall, I’ve found Ubuntu 6.06 LTS to be a solid operating system. It’s easy to use, has a great selection of software available, and generally ‘just works’.” Joe Brockmeier reviews Ubuntu 6.06 Long Term Support.
www.linux.com

Open Source Ubuntu

“Ubuntu has been the most popular distro of Linux since 2005, and since I made the switch last year those tearful evenings in front of the computer screen have become a distant memory.” Becky Hogges describes how Ubuntu has put a smile back on her face.

www.opendemocracy.net

Thoughts on Moving from Debian to Ubuntu Server

“If Canonical keeps its update schedule and support commitments along with the legendary Debian robustness, we may have a keeper.” Staff at Advosys Consulting are considering Ubuntu for entirely practical reasons.
www.advosys.ca

Setup

Notes on installing and configuring Ubuntu 6.06 LTS.

Editing Configuration Files with Nano

There are many different tools that you can use to edit configuration files. Because of its simplicity, I personally like to use Nano:

user@ubuntu:~$ sudo nano /path/to/the/file

You can change the default settings for nano by editing its configuration file. For example, to stop nano from wrapping text simply make the following changes to /etc/nanorc:

## Don't wrap text at all.
set nowrap

www.nano-editor.org

Redirecting Mail for the Local Root User

Postfix is Ubuntu’s default mail transfer agent (MTA) and can be configured to deliver mail using a relay host that requires SMTP authentication.

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install postfix mailx

Begin to configure your Postfix installation by choosing satellite system as the general type of configuration. Enter the local machine name as the mail name (eg mycomputer.edafe.org) and the SMTP server address of your email service provider as the SMTP relay host (eg smtp.relayhost.com).

Edit the file /etc/postfix/main.cf and add the following:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
relay_domains =

Create the file /etc/postfix/sasl_passwd and make the following entries:

smtp.relayhost.com user:password

Substitute smtp.relayhost.com with the address of the SMTP relay host and user:password with your login details.

Continue by executing the following three commands:

user@ubuntu:~$ sudo chown root.root /etc/postfix/sasl_passwd
user@ubuntu:~$ sudo chmod 600 /etc/postfix/sasl_passwd
user@ubuntu:~$ sudo postmap hash:/etc/postfix/sasl_passwd

Instruct Postfix to reload its settings with the following command:

user@ubuntu:~$ sudo /etc/init.d/postfix reload

Making Changes to the Alias Table

The aliases table provides a system-wide mechanism to redirect mail for local recipients.

Edit the file /etc/aliases to contain the following entries:

postmaster: root
root: user@yourdomain.com

Substitute user@yourdomain.com with the email address that you would like mail for the root user to be redirected to.

Finally, update /etc/aliases.db using the following command:

user@ubuntu:~$ sudo newaliases

Mail for the local root user from now on will automatically be forwarded to user@yourdomain.com , using smtp.relayhost.com as the relay host.
www.postfix.org, help.ubuntu.com

Public/Private Key Authentication with SSH

SSH is a protocol that enables secure logins to your computer over a network. SSH supports the use of public/private key pairs for user authentication. Private keys are kept locally, while public keys are stored on the remote machine.

On the Local Machine

Use the command ssh-keygen -t dsa to generate a key pair for the local user. Use an appropriate passphrase to secure your private key (don’t be tempted to use an empty passphrase).
Set the permissions for the private key file with the following command:

user@ubuntu:~$ chmod 600 ~/.ssh/id_dsa

On the Remote Machine

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install ssh

Copy the public key file ~/.ssh/id_dsa.pub from the local to the remote machine.

On the remote machine, move and rename the file with the following command:

user@ubuntu:~$ mv id_dsa.pub .ssh/authorized_keys2

Set the permissions for the file with the following command:

user@ubuntu:~$ chmod 600 ~/.ssh/authorized_keys2

Add the user to the group ssh:

user@ubuntu:~$ sudo adduser user ssh

Get the file sshd_config and move it to /etc/ssh/:

user@ubuntu:~# sudo wget "http://www.edafe.org/ubuntu/ssh/sshd_config"
user@ubuntu:~# sudo mv sshd_config /etc/ssh/

The downloaded file contains the following changes from the Ubuntu default configuration:

LogLevel VERBOSE

AllowGroups ssh
LoginGraceTime 60
PermitRootLogin no

MaxAuthTries 1

RSAAuthentication no

PasswordAuthentication no

X11 Forwarding no

KeepAlive no
ClientAliveInterval 10
ClientAliveCountMax 3

MaxStartups 1

UsePAM no

Setting these options makes root logins impossible. Only users belonging to the group ssh may establish a connection. Access to the remote machine is strictly tied to the private key and the passphrase used to encrypt it.

Next, restart the SSH server on the remote machine with the following command:

user@ubuntu:~$ sudo /etc/init.d/ssh restart

You should now be able to log into the remote machine using the private key stored on the local machine:

user@ubuntu:~$ ssh remote.machine
Enter passphrase for key '/home/user/.ssh/id_dsa':

Let me recommend the book SSH The Secure Shell to you. It is a good reference text and offers information on other clever stuff you can do with SSH.
www.ibm.com/developerworks/linux/

Samba as a File Server

Samba enables Linux to speak the Server Message Block (SMB) protocol, which is also used by Windows and Mac OS X to exchange data over a network.

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install swat netkit-inetd

For an initial configuration, edit the file /etc/samba/smb.conf to contain the following entries:

[global]
  workgroup = SAMBA

[homes]
  comment = Home Directories
  valid users = %S
  read only = No
  create mask = 0640
  directory mask = 0750
  browseable = No

Continue by adding local users to the smbpasswd file:

user@ubuntu:~$ sudo smbpasswd -a user

Restart the Samba server with the following command:

user@ubuntu:~$ sudo /etc/init.d/samba restart

The server ubuntu now joins the SAMBA workgroup, giving users who have been added to the smbpasswd file access to their respective home directories.

Using SWAT

Using the Samba Web Administration Tool (SWAT), you can access help, obtain status information and change the configuration of your Samba server. Use a web browser to access http://localhost:901/ and log in as the local root user.
In principle, SWAT can also be reached from other machines on your local network. However, such connections are vulnerable to password sniffing because of the clear text protocol that SWAT uses to authenticate users.
www.samba.org, copia.ogbuji.net

Creating a Software RAID-1 Array

RAID stands for Redundant Array of Inexpensive Disks and refers to the use of multiple hard disks to share or replicate data between drives.

For RAID-1, you need two partitions of identical size on two separate disks which are not connected to the same IDE/Parallel ATA-bus.

Use cfdisk to create the two partitions /dev/hdb1 and /dev/hdc1. Set their respective types to FD and do not set their bootable flags. Create the RAID-1 array with the following command:

user@ubuntu:~$ sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/hd[bc]1

Create a filesystem on the RAID device with the following command:

user@ubuntu:~$ sudo mke2fs -j /dev/md0

Create an empty directory /raid as a mount point and add the following line to /etc/fstab:

/dev/md0 /raid ext3 defaults 0 2

Mount your RAID array and check its status with the following commands:

user@ubuntu:~$ sudo mount /raid
user@ubuntu:~$ sudo mdadm --detail /dev/md0

Monitoring the RAID Array

If required, start by configuring Postfix to redirect mail for the local root user.

Obtain the UUID of your RAID device with the following command:

user@ubuntu:~$ sudo mdadm -D /dev/md0

Create the file /etc/mdadm/mdadm.conf and add the following three lines, replacing 47d1eee2:2cbfr68v:34x75168:142ef912 with the UUID of your RAID:

DEVICE /dev/hdb1 /dev/hdc1
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=
47d1eee2:2cbfr68v:34x75168:142ef912
MAILADDR root

Edit the file /etc/init.d/mdadm and append --test to the line beginning with start-stop-daemon -S:

start-stop-daemon -S -q -p $PIDFILE -x $MDADM -- -F -i $PIDFILE -m $MAIL_TO -f -s --test

Restart the mdadm daemon with the following command:

user@ubuntu:~$ sudo /etc/init.d/mdadm restart

Verify that the local root user has received a test message from the mdadm daemon.

From now on, the mdadm daemon will monitor the integrity of the RAID array and, in the event of any problems, alert the local root user by email.
users.piuha.net/martti, www.tldp.net

Monitoring Hard Disks with Smartmontools

SMART stands for Self-Monitoring, Analysis and Reporting Technology and is built into most modern hard disks. The smartd daemon is part of Smartmontools and monitors a disk’s SMART data for any signs of hardware problems. SMART works with Parallel ATA and Serial ATA disks, drives appearing as either /dev/hd* or /dev/sd*.

If required, start by configuring Postfix to redirect mail for the local root user.

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install smartmontools mailx

Edit the file /etc/smartd.conf and comment out any lines beginning with DEVICESCAN. Add the following line for the smartd daemon to monitor the device /dev/hda:

/dev/hda -a -d ata -n never -o on -S on -s (L/../../7/04|S/../.././02) -m root -M daily -M test

Edit the file /etc/default/smartmontools and uncomment the line containing start_smartd=yes.

Restart the smartd daemon with the following command:

user@ubuntu:~$ sudo /etc/init.d/smartmontools restart

Verify that the local root user has received a test message from the smartd daemon.

From now on, the smartd daemon will monitor the disk and, in the event of impending disk failure, alert the local root user by email.

Sharing a PostScript Printer with CUPS and Samba

Using Samba and CUPS, the Common UNIX Printing System, Ubuntu can easily be configured to provide printing services to a heterogeneous network of Windows, Macintosh and Linux clients.

Printing with CUPS

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install cupsys foomatic-filters-ppds

Add the user cupsys to the group shadow:

user@ubuntu:~$ sudo adduser cupsys shadow

Get the file cupsd.conf and move it to /etc/cups/:

user@ubuntu:~# sudo wget "http://www.edafe.org/ubuntu/cups/cupsd.conf"
user@ubuntu:~# sudo mv cupsd.conf /etc/cups/

The downloaded file contains the following changes from the Ubuntu default configuration:

# Default authentication type, when authentication is required...
DefaultEncryption IfRequested

# Restrict access to the admin pages...
<Location /admin>
  Allow @LOCAL
</Location>

Setting these options enables members of the admin group to modify the configuration of the CUPS server from clients sharing the same local network.

Modify the file /etc/cups/cups.d/ports.conf to read:

Port 631
Listen localhost
Listen 192.168.0.123
Listen /var/run/cups/cups.sock

For 192.168.0.123, substitute the IP address of your machine on the local network.

Restart cupsd with the following command:

user@ubuntu:~$ sudo /etc/init.d/cupsys restart

Use a web browser to access http://localhost:631/admin (or http://192.168.0.123:631/admin from another machine on your local network). Go to Administration > Add Printer and begin to set up your printer. When prompted by the system, authenticate yourself as a member of the admin group. If necessary, obtain the correct PostScript Printer Description (PPD) file for your printer model. Print a test page to confirm that your printer is working properly with CUPS.

Making Printers Available over the Network

Install and configure a Samba server and then add the following options to /etc/samba/smb.conf:

[global]
  printing = cups
  load printers = Yes
  printcap name = cups

[printers]
  comment = All Printers
  printable = Yes
  path = /var/spool/samba/print
  browseable = No
  guest ok = Yes
  read only = Yes

Create the directory /var/spool/samba/print and set its permissions with the following two commands:

user@ubuntu:~$ sudo mkdir -p /var/spool/samba/print
user@ubuntu:~$ sudo chmod 1777 /var/spool/samba/print

Restart the Samba server with the following command:

user@ubuntu:~$ sudo /etc/init.d/samba restart

Set your Samba clients to use a printer driver that outputs generic PostScript. Use the the Apple LaserWriter driver on Windows, the Generic PostScript driver on Mac OS X or the Raw Standard driver on Ubuntu.
wiki.ubuntuusers.de, www.samba.org

Installing VMware Tools for a Ubuntu Guest

VMware Tools is a suite of utilities that enhances the performance of a virtual machine’s guest operating system.

Begin by setting up a new virtual machine and installing Ubuntu 6.06 LTS as the guest operating system. Start the virtual machine and log in as a user belonging to the admin group. You are now ready to install VMware Tools.

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install build-essential linux-headers-`uname -r`

Become root and create a symbolic link with the following commands:

user@ubuntu:~$ sudo su root@ubuntu:/home/user# ln -s /usr/src/linux-headers-`uname -r` /usr/src/linux

On the host, select Virtual Machine > Install VMware Tools… from the VMware Workstation menu.

After the guest has mounted the VMware Tools installation virtual CD, change the active directory and copy the VMware Tools archive with the following commands:

root@ubuntu:/home/user# cd /root/ root@ubuntu:~# cp /media/cdrom/VMwareTools-7.6.3-87978.tar.gz /root/

Extract the contents of the archive and then change the active directory with the following commands:

root@ubuntu:~# tar -zxvf VMwareTools-7.6.3-87978.tar.gz root@ubuntu:~# cd vmware-tools-distrib/

Invoke the install script with the following command, choose to install the binary files in /usr/local/bin and and set your desired screen resolution:

root@ubuntu:~/vmware-tools-distrib# ./vmware-install.pl

Restart your virtual machine.

www.townx.org, www.tech-recipes.com

Setting the Time Zone

Set the local time zone with the following command:

user@ubuntu:~$ sudo tzconfig

www.debian-administration.org

Time Synchronisation with NTP

The NTP protocol allows you to synchronise the clock of your computer with that of dedicated time servers on the Internet.

Get the necessary packages with the following command:

user@ubuntu:~$ sudo apt-get install ntp-simple ntpdate

Stop the ntpd daemon and manually synchronise your computer’s clock with the following two commands:

user@ubuntu:~$ sudo /etc/init.d/ntp-server stop
user@ubuntu:~$ sudo ntpdate pool.ntp.org

Modify the file /etc/ntp.conf to read:

# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

#server ntp.ubuntu.com

server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

Start the ntpd daemon with the following command:

user@ubuntu:~$ sudo /etc/init.d/ntp-server start

After about one minute, query the status of the ntpq daemon with the following command:

user@ubuntu:~$ sudo ntpq -p

You can further increase the accuracy of time synchronisation by using the time servers in your continental or country zone.

Enabling the Root Account

Consider the implications of enabling the root account, and then proceed with:

user@ubuntu:~$ sudo passwd root

To disable the root account again, use the following command:

user@ubuntu:~$ sudo passwd -l root

Configuring a Static IP Address

Edit the file /etc/network/interfaces to contain the following entries:

# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.0.20
  netmask 255.255.255.0
  broadcast 192.168.0.255
  gateway 192.168.0.1

Reconfigure the network interfaces with the following command:

user@ubuntu:~$ sudo /etc/init.d/networking restart

www.ubuntuforums.org

Allowing Other Users to Run Sudo

user@ubuntu:~$ sudo adduser username admin

Changing the Default Permissions

Change the default permissions for your installation by editing the value for umask in /etc/profiles and /etc/login.defs.
lists.ubuntu.com

Online Books

The Official Ubuntu Book

Full-text version of The Official Ubuntu Book, written by Benjamin Mako Hill, Jono Bacon, Corey Burger, Jonathan Jesse and Ivan Krstic.
book.opensourceproject.org.cn

Ubuntu GNU/Linux

In German

Full-text version of Ubuntu GNU/Linux, written by Marcus Fischer.
www.galileocomputing.de

Ubuntu Unleashed

Full-text version of Ubuntu Unleashed, written by Andrew and Paul Hudson.
book.opensourceproject.org.cn

Ubuntu Hacks

Full-text version of Ubuntu Hacks, written by Bill Childers, Jonathan Oxer and Kyle Rankin.
book.opensourceproject.org.cn

Moving to Ubuntu Linux

Full-text version of Moving to Ubuntu, written by Marcel Gagné
book.opensourceproject.org.cn

Other Documentation

Documentation for Ubuntu 8.04 LTS

Access the official documentation maintained by the Ubuntu Documentation Project.
help.ubuntu.com

Restricted Formats

“Patent and copyright restrictions complicate free operating systems distributing software to support proprietary formats.” This page will show you how to enable support for the most popular non-free media formats.
help.ubuntu.com

Tools

Ubuntu Packages

Get more detailed information on individual Ubuntu packages.
packages.ubuntu.com

Bugs in Ubuntu

Help to further improve Ubuntu by reporting any bugs that you may come across.
bugs.launchpad.net

Help

Ubuntu Forums

Official forums dedicated to all things Ubuntu. If you have got a question related to Ubuntu, this is the best place to ask.
www.ubuntuforums.org

Other Free Stuff

Free Stickers

Send in a self-addressed stamped envelope and receive your ‘Powered by Ubuntu’ stickers for free.
www.system76.com