Linux:8 Productivity

From HandWiki
Jump to: navigation, search

Contents

Disk Storage

All files and directories on a Linux-based system are stored on a Linux filesystem, which is a disk device (such as a hard drive) that is formatted to store a directory tree (see section Files and Directories).

There are two kinds of disk storage on a Linux system: fixed and removable. Fixed storage refers to a disk that is firmly attached to the computer system, and is not intended for casual removal (except when upgrading). Your hard drive (sometimes called "hard disk"), used to store the operating system, application software, and user data, is the prime example of a fixed disk.

The second kind of disk storage is removable storage, disks that are intended to be removed for archiving or transfer to another system. Common examples of removable storage are floppy disk (or "diskette") and CD-ROM drives, where you typically remove the storage media from its drive bay when you're done using it.

On Linux systems, disks are used by mounting them to a directory, which makes the directory tree the disk contains available at that given directory mount point. Disks can be mounted on any directory on the system, but any divisions between disks are transparent--so a system which has, aside from the root filesystem disk mounted on `/', separate physical hard disks for the `/home', `/usr', and `/usr/local' directory trees will look and feel no different from the system that only has one physical disk.

System administrators often mount high-capacity drives on directory trees that will contain a lot of data (such as a `/home' directory tree on a system with a lot of users), and for purposes of fault tolerance, administrators often use several physical hard disks on one system--if there is a disk failure, only the data in that disk is lost.

This chapter describes tools and techniques for manipulating disks and storage media.

Listing a Disk's Free Space

To see how much free space is left on a disk, use df. Without any options, df outputs a list of all mounted filesystems. Six columns are output, displaying information about each disk: the name of its device file in `/dev'; the number of 1024-byte blocks the system uses; the number of blocks in use; the number of blocks available; the percent of the device used; and the name of the directory tree the device is mounted on.

  • To see how much free space is left on the system's disks, type:

    $ df RET
    Filesystem         1024-blocks  Used Available Capacity Mounted on
    /dev/hda1             195167   43405   141684     23%   /
    /dev/hda2            2783807  688916  1950949     26%   /usr
    /dev/hdb1            2039559 1675652   258472     87%   /home/webb
    $

This example shows that three filesystems are mounted on the system--the filesystem mounted on `/' is at 23 percent capacity, the filesystem mounted on `/usr' is at 26 percent capacity, and the filesystem mounted on `/home/webb', a home directory, is at 87 percent capacity.

Listing a File's Disk Usage

Use du to list the amount of space on disk used by files. To specify a particular file name or directory tree, give it as an argument. With no arguments, du works on the current directory.

It outputs a line for each subdirectory in the tree, listing the space used and the subdirectory name; the last line lists the total amount of space used for the entire directory tree.

  • To output the disk usage for the directory tree whose root is the current directory, type:

    $ du RET
    8       ./projects/documentation
    12      ./projects/source
    4       ./projects/etc
    24      ./projects
    3       ./tmp
    27      .
    $

This example shows two subdirectories in the directory tree: `projects' and `tmp'; `projects' contains three additional directories. The amount of disk space used by the individual directories is the total on the last line, 27K.

By default, output is in 1K blocks, but you can specify another unit to use as an option: `-k' for kilobytes and `-m' for megabytes.

  • To output the disk usage, in kilobytes, of the `/usr/local' directory tree, type:

    $ du -k /usr/local RET
  • To show the number of megabytes used by the file `/tmp/cache', type:

    $ du -m /tmp/cache RET

Use the `-s' option ("summarize") to output only the last line containing the total for the entire directory tree. This is useful when you are only interested in the total disk usage of a directory tree.

  • To output only the total disk usage of the `/usr/local' directory tree, type:

    $ du -s /usr/local RET
  • To output only the total disk usage, in kilobytes, of the `/usr/local' directory tree, type:

    $ du -s -k /usr/local RET


Reminders

If you're working on a system on a regular basis, it can be very useful to have the system remind you when you should be doing something else. This chapter describes software tools that provide reminders--clocks, calendars, address books, and tools for tracking appointments.

Displaying the Date and Time

Use date to output the current system date and time.

  • To output the current system date and time, type:

    $ date RET
    Fri May 11 11:10:29 EDT 2001
    $

The default format of the output is to display the day of the week; the month name; the day of the month; the 24-hour time in hours, minutes, and seconds; the time zone; and the year.

Use the `-u' option to output the current date and time in Greenwich Mean Time (also known as Coordinated Universal Time, or UTC).

  • To output the current date and time in UTC, type:

    $ date -u RET
    Fri May 11 15:10:29 UTC 2001
    $

Use the `-R' option to output the date in the format described before; day of week followed by day of month, month name, year, time, and time zone in numeric format. This is the date format used in email messages.

  • To output the current date and time in RFC822 format, type:

    $ date -R RET
    Fri, 11 May 2001 11:10:29 -0400
    $

You can also use the `-d' option to specify the precise fields to output, and the order in which to output them. One useful example is given next. To output the number of days into the year for a particular date, use `-d' with 'DD MMM' +%j, where `DD' is the day of month and `MMM' is the name of month.

  • To output the numeric day of the year that 21 June falls on in the current year, type:

    $ date -d '21 Jun' +%j RET
    172
    $

This command outputs the number 172, which indicates that 21 June of the current year is the 172nd day of the current calendar year.

NOTE: To ensure that the time on your system clock remains as accurate as possible, your system administrator should install the `chrony' package; it periodically adjusts the time on the system clock according to measurements obtained from other servers on the Internet via "Network Time Protocol."

Playing an Audible Time Announcement

Use the saytime command to output the current system time in an audible message in a male voice. You must have a sound card installed on your system, and it must be set up with speakers or some other output mechanism at an appropriate volume level in order for you to hear it.

  • To hear the current system time, type:

    $ saytime RET

NOTE: If you're feeling adventurous, you can record another voice--like your own--and use that voice instead of the default voice; the sound files used are Sun `.au' files and are kept in the `/usr/share/saytime' directory.

Calendars

The following recipes describe a few of the basic tools for displaying calendars in Linux.

Displaying a Calendar

The cal tool outputs a calendar to the standard output. By default, it outputs a calendar of the current month.

  • To output a calendar for the current month, type:

    $ cal RET

To output a calendar for a specific year, give just the year as an option.

  • To output a calendar for the year 2001, type:

    $ cal 2001 RET
                                  2001                              
    
          January               February               March        
     S  M Tu  W Th  F  S   S  M Tu  W Th  F  S   S  M Tu  W Th  F  S
        1  2  3  4  5  6               1  2  3               1  2  3
     7  8  9 10 11 12 13   4  5  6  7  8  9 10   4  5  6  7  8  9 10
    14 15 16 17 18 19 20  11 12 13 14 15 16 17  11 12 13 14 15 16 17
    21 22 23 24 25 26 27  18 19 20 21 22 23 24  18 19 20 21 22 23 24
    28 29 30 31           25 26 27 28           25 26 27 28 29 30 31
    
           April                  May                   June        
     S  M Tu  W Th  F  S   S  M Tu  W Th  F  S   S  M Tu  W Th  F  S
     1  2  3  4  5  6  7         1  2  3  4  5                  1  2
     8  9 10 11 12 13 14   6  7  8  9 10 11 12   3  4  5  6  7  8  9
    15 16 17 18 19 20 21  13 14 15 16 17 18 19  10 11 12 13 14 15 16
    22 23 24 25 26 27 28  20 21 22 23 24 25 26  17 18 19 20 21 22 23
    29 30                 27 28 29 30 31        24 25 26 27 28 29 30
    
            July                 August              September      
     S  M Tu  W Th  F  S   S  M Tu  W Th  F  S   S  M Tu  W Th  F  S
     1  2  3  4  5  6  7            1  2  3  4                     1
     8  9 10 11 12 13 14   5  6  7  8  9 10 11   2  3  4  5  6  7  8
    15 16 17 18 19 20 21  12 13 14 15 16 17 18   9 10 11 12 13 14 15
    22 23 24 25 26 27 28  19 20 21 22 23 24 25  16 17 18 19 20 21 22
    29 30 31              26 27 28 29 30 31     23 24 25 26 27 28 29
                                                30
          October               November              December      
     S  M Tu  W Th  F  S   S  M Tu  W Th  F  S   S  M Tu  W Th  F  S
        1  2  3  4  5  6               1  2  3                     1
     7  8  9 10 11 12 13   4  5  6  7  8  9 10   2  3  4  5  6  7  8
    14 15 16 17 18 19 20  11 12 13 14 15 16 17   9 10 11 12 13 14 15
    21 22 23 24 25 26 27  18 19 20 21 22 23 24  16 17 18 19 20 21 22
    28 29 30 31           25 26 27 28 29 30     23 24 25 26 27 28 29
                                                30 31
    
    $

Use the `-y' option to output a calendar for the current year.

  • To output a calendar for the current year, type:

    $ cal -y RET
  • So, to print out a calendar for the current year to the default printer, type:

    cal -y | lpr RET

To output a calendar for a specific month, give both the numeric month and year as arguments.

  • To output a calendar for June 1991, type:

    $ cal 06 1991 RET
         June 1991
     S  M Tu  W Th  F  S
                       1
     2  3  4  5  6  7  8
     9 10 11 12 13 14 15
    16 17 18 19 20 21 22
    23 24 25 26 27 28 29
    30
    $

Managing Appointments

The calendar tool is a reminder service that you can use to manage your appointments. It reads a calendar file, which is a text file in the current directory containing a list of appointments and reminders; then it outputs those entries from the file that have today or tomorrow's date. (On a Friday, it outputs entries for that weekend and for the following Monday.)

For example, if today is Friday, June 16, and you run calendar in the same directory as your calendar file, typical output might look like this:


$ calendar RET
6/16    Finish draft of book
        Party at Jack's
Fri     Lunch with Kim and Jo, 12:30
Mon     Book manuscript due
$


The calendar tool reportedly first appeared in Version 7 of AT&T UNIX, and was rewritten early on for the BSD family of Unix. While the BSD derivate is available for Debian as part of the bsdmainutils package, this tool isn't yet standard on all Linux distributions.

The following are recipes for writing your calendar files, including other calendar files in your own calendar file, and for automating the delivery of your reminders.

NOTE: Emacs has its own equivalent to this tool, which it calls the "Diary." See Info file `emacs-e20.info', node `Diary' for more information on this feature.

Making an Appointment File

To begin using calendar, you need to make a "calendar file" where you can enter your appointments. It's just a plain text file, and can be called either `calendar' or `.calendar'; the latter makes it a "hidden" file.

Write each appointment or calendar entry on a line by itself; blank lines in the file are ignored. The format of a calendar entry is as follows:

[date] [tab or spaces] [text of reminder itself]

Just about every common date style is recognized. For example, the following are all valid dates for the fourth of July:

7/4
July 4
4 July
Jul. 4
Jul 4

Entries aren't constrained to a single day, either; you can have entries for a day of the week or for a certain month---`Mon' or `Monday' for every Monday; `Jun' or `June' for the first day of every June. You can use an asterisk as a wildcard: `*/13' reminds you of something on the thirteenth of every month. When the date is omitted on a line, the date of the preceding appointment is assumed.

For example, suppose you have a file called `calendar' in your home directory that looks like this:

6/16    Finish draft of book
        Party at Jack's
6/20    Gallery reading
Fri     Lunch with Kim and Jo, 12:30
Mon     Book manuscript due

If the current date is 16 June, a Friday, and you run calendar in your home directory, you'll get the same output as in the example in the previous section.

NOTE: In the example above, the entry for the party doesn't have a date on it--it used the date of the preceding entry, `6/16'.

Including Holidays in Your Reminders

The calendar package comes with a collection of prepared calendar files for many kinds of holidays and other occasions, which you can reference in your own calendar file to include their entries in your own reminders.

The prepared files are stored in `/usr/share/calendar'. The following table gives the name of each calendar file and describes its contents.

CALENDAR - FILE DESCRIPTION

calendar.birthday Births and deaths of famous people.

calendar.christian Christian holidays.

calendar.computer Significant dates in the history of computing.

calendar.history Dates of U.S. historical events.

calendar.holiday Standard and obscure holidays.

calendar.judaic Jewish holidays.

calendar.music Dates related to music, mostly 1960s rock and roll.

calendar.usholiday U.S. holidays.

calendar.hindu Hindu holidays.

To have calendar output dates from one of these files along with your usual appointments, put the following in your calendar file, where file is the name of the particular calendar file you want to include:

#include <file>

For example, to output both US holidays and famous births and deaths when you run calendar, put these lines somewhere in your calendar file:

#include <calendar.usholiday>
#include <calendar.birthday>

NOTE: You can, of course, share your own calendar files with other users; this is useful for making special calendars for a group or organization. If the calendar file is in the current directory or `/usr/share/calendar', you can just give the file name; otherwise, give its full path name in the include statement.

Automatic Appointment Delivery

You can automate your appointment service so that your appointments and reminders are delivered each time you log in or start a new shell, or you can have the day's reminders emailed to you each morning.

Add calendar to your `.bashrc' file to output the day's appointments and reminders every time you log in or start a new shell.

If you keep your calendar file in a directory other than your home directory, make sure that calendar (the tool) is called from that directory. For example, if your calendar file is in your `~/doc/etc' directory, you'd put the following line in your `.bashrc' file:

cd ~/doc/etc; calendar; cd

To have the system send you the day's appointments in email, use crontab to schedule a daily cron job process which runs calendar and, if there is any output, mails it to you with mail.

To do this, add the following line to your `crontab' file (if you don't have one, just put this line in a text file called `crontab' somewhere in your home directory):

45 05 * * 1-5 calendar | mail -s 'Your Appointments' joe@example.org

The `45 05 * * 1-5' specifies that these commands be run at 5:45 a.m. on every weekday. The rest of the line is the series of actual commands that are run: the calendar tool is run on your personal calendar file, and if there is any output, it's mailed to joe@example.org (replace that with your actual email address, or with your username on your local system if you check mail there).

Add this new crontab entry to the cron schedule by running the crontab tool with the name of your `crontab' file as an argument.

  • To add the new entry in the file `crontab' to the cron schedule, type:

    $ crontab crontab RET

NOTE: The name of the command, crontab, is the same as the file, `crontab'.

Contact Managers

Loosely put, a contact manager is a piece of software that helps you keep track of information about people you may need to contact in the future. In the past, people often called the physical embodiment of these things a "rolodex," which incidentally was a brand name for the Cadillac of such contact managers, the circular Rolodex file that sat atop the desk of every successful 20th century businessman. I hear that many people use them even today; the following recipes show how it can be done in Linux with less desk space and faster search times.

Keeping a Free-Form Address List

The simplest way to keep names and addresses in Linux is to keep them in a text file as a free-form address list; to find an entry, use the search capabilities of tools like grep, less, and Emacs.

This method is useful for when you need to keep track of name and address information of many parties, and don't always keep the same kind of information for each--maybe sometimes a name and phone number, sometimes just a mailing address, sometimes a name and email address. With a free-form address list, each entry contains whatever information you have in the format you want.

Separate the entries with a delimiter line of your preference. I happen to use `###', but you can use whatever characters you're comfortable with--just make it a combination that won't appear in the text for any of the entries themselves.

For example, suppose you have a text file, `rolo', containing three entries:

John Dos Passos
1919 America Ave.
New York City

###

Scott F. - 602 555 1803
(don't call after 12)

###

T. Wolfe's new email has changed.
The new one is: tw@example.com

Notice that each entry contains varied information, and is in no particular format. That's the benefit of a free-form list--you don't have to type in the entries in any particular order, and you're not bound by a given set of "fields"; you can even cut and paste text into it from email, the Web, or other windows.

There are several ways to find text in such a file. Suppose, for example, you want to contact your friend Scott, and you need his telephone number.

  • To output the line in the file containing the text `scott', regardless of case, type:

    $ grep -i scott rolo RET
    Scott F. - 602 555 1803
    $

This works nicely when the information you need is on the same line as the information you search for--here, the name Scott is on the same line as the telephone number; however, the output did not show the warning that appears on the next line in the file. And what about when the term you search for and the information you need are on adjacent lines?

Use the `-C' option with grep to output several lines of context before and after matched lines.

  • To output the several lines around the line matching the text `olfe', type:

    $ grep -C olfe rolo RET
    
    T. Wolfe's new email has changed.
    The new one is: tw@example.com
    
    $

Another way to search such a file is to open it as a buffer in Emacs and use any of the Emacs searches. The Emacs incremental-search function, C-s, is very useful for such files--even for very large ones. If you do such a search on a large file, and the first result doesn't turn up the right record, just keep typing C-s until the right one appears. If you type the letters to search for in all lowercase, Emacs matches those letters regardless of case.

  • To search through the current buffer in Emacs for the first entry containing the text `New York', regardless of case, type:

    C-s new york
  • To search for the next entry containing the text `New York', regardless of case, type:

    C-s

You can repeat the second example as many times as you wish to show all entries in the entire buffer with the text `New York' in them. Once you reach the end of the buffer, type C-s again to loop around to the beginning of the buffer and continue the search from there. (The minibuffer will tell you when you've reached the end of the buffer, and will remind you to type this if you want to loop the search.)

Keeping a Contact Manager Database

The Insidious Big Brother Database is a contact manager tool for use with Emacs. You can use it with Emacs email and news readers; it stores contact information in records, and allows you to search for records that match a regular expression, as well as records whose particular fields match a regular expression.

There are several ways to add a record to the database. Use the bbdb-create function to manually add a record (when you run this command, bbdb prompts you to enter the relevant information for each field). When in a mail reader inside Emacs, type a colon (`:') to display the record for the author of the current message; if there is none, bbdb asks whether or not one should be created.

  • To create a new bbdb record from scratch, type:

    M-x bbdb-create RET
  • To add a new bbdb record for the author of the current email message, type:

    :

Use the bbdb function to search for records--it takes as an argument the pattern or regexp to search for.

  • To output records containing the text `scott' anywhere in the record, type:

    M-x bbdb RET scott RET

There are additional functions that let you narrow your search to a particular field: bbdb-name, bbdb-company , bbdb-net, and bbdb-notes, which respectively search the name, company, email address, and notes fields.

  • To output records matching the regexp `*\.edu' in the email address, type:

    M-x bbdb-net RET *\.edu RET

Reminding Yourself of Things

Sometimes, it's useful to make a reminder for yourself that you'll see either later in your current login session, or the next time you log in. These recipes describe the best ways to do this.

Sending Yourself Email Reminders

Sending yourself a short email message is often effective for reminding yourself to do something during your next workday or next time you read mail; keeping a message in your INBOX works as a constant reminder to get something done--provided you don't abuse it and fill your INBOX with lots of these "urgent" mails!

To quickly send an email reminder, give your email address (or just your username on your local system, if you check mail there) as an argument to mail tool. You'll be prompted to give a subject for the message, and if that isn't enough space for the reminder, you can write as many lines as you need below it as the message body text; type C-d on a line by itself to send the mail.

Reminding Yourself When You Have to Leave

Use the leave tool to remind yourself when you have to leave. Give as an argument the time when you have to go, using the format of hhmm, where hh is hours in 24-hour format and mm is minutes.

  • To remind yourself to leave at 8:05 p.m., type:

    $ leave 2005 RET

When you run leave with no arguments, it prompts you to enter a time; if you just type RET then leave exits without setting the reminder. This method is good for adding leave to scripts or to your `.bashrc', so that you may interactively give a time to leave, if desired, when the script runs.

NOTE: leave will output a reminder on the terminal screen five minutes before the given time, one minute before the time, at the time itself, and then every minute subsequently until the user logs off.

Running a Command on a Delay

The sleep tool does nothing but wait (or "sleep") for the number of seconds specified as an argument. This is useful for ringing the system bell, playing a sound file, or running some other command at your terminal after a short delay.

To do this, give the number of seconds to "sleep" for as an argument to sleep, followed by a semicolon character (`;') and the command(s) to run. This runs the given command(s) only after sleep waits for the given number of seconds.

Since the shell where you type this command will be unusable until the commands you give are executed (or until you interrupt the whole thing), type this command in an xterm or virtual console window other than the one you are working in.

  • To ring the bell in five seconds, type:

    $ sleep 5; echo -e '\a' RET
  • To announce the time in thirty seconds, type:

    $ sleep 30; saytime RET

You can also give the time in minutes, hours, or days. To do this, follow the argument with a unit, as listed in the following table.

UNIT - DESCRIPTION

s Seconds.

m Minutes.

h Hours.

d Days.

  • To announce the time in exactly five minutes, type:

    $ sleep 5m; saytime & RET

Mathematics

Tools and techniques for dealing with numbers are the subject of this chapter: listing them in sequence or randomly, calculating arithmetic, and converting between units. Larger applications, such as spreadsheets and plotting tools, are also mentioned.

Calculating Arithmetic

As you might expect, there are many tools for making arithmetic calculations in Linux. The following recipes describe how to use two of them for two common scenarios; a list of other calculator tools, including a visual calculator.

Making a Quick Arithmetic Calculation

To do a quick calculation that requires only addition, subtraction, multiplication, or division, use calc. It takes as an argument a simple mathematical expression, and it outputs the answer.

Use `*' for a multiplication sign and `/' for division; to output the remainder, use `%'. You can use parenthesis to group expressions--but when you do, be sure to quote them.

  • To output the result of 50 times 10, type:

    $ calc 50*10 RET
    500
    $
  • To output the result of 100 times the sum of 4 plus 420, type:

    $ calc '100*(4+420)' RET
    42400
    $
  • To output the remainder of 10 divided by 3, type:

    $ calc 10%3 RET
    1
    $

NOTE: This tool is useful for quickly computing a simple arithmetic equation, but it has several drawbacks: it only outputs whole integers, its operators are limited, and complex expressions must be quoted. For doing anything more than the simplest operations, see the next recipe, which describes bc.

Making Many Arithmetic Calculations

When you have a lot of calculations to make, or when you must compute numbers with decimals, use bc, a calculation language that supports arbitrary precision numbers. Type bc to perform arithmetic operations interactively, just like you would with a calculator.

Type each statement to evaluate on a line by itself, typing RET at the end the statement; the evaluation of what you type is output on the following line. Each line you type will be evaluated by bc as an arithmetic expression. To exit, type quit on a line by itself.

  • To multiply 42 and 17, type:

    $ bc RET
    bc 1.05
    Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software
    Foundation, Inc. 
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'. 
    42 * 17 RET
    714
    quit RET
    $

In this example, bc output its version number and warranty information when it started; then, the statement 42 * 17 was typed by the user, bc output the result (`714'), and then the user typed quit to exit bc.

By default, digits to the right of the decimal point are truncated from the output--so dividing 10 by 3 would output `3' as a result, and outputting the remainder from this operation by typing 10%3 would output a `1'. However, bc is an arbitrary precision calculator, and you can give the number of digits to use after the decimal point by specifying the value of the scale variable; its default value is 0.

  • To use bc to compute the result of 10 divided by 3, using 20 digits after the decimal point, type:




    $ bc RET
    bc 1.05
    Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software
    Foundation, Inc. 
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'. 
    scale=20 RET
    10 / 3 RET
    3.33333333333333333333
    quit RET
    $

The following table describes the symbols you can use to specify mathematical operations.

SYMBOL - OPERATION

expression + expression Add: output the sum of the two expressions.

expression - expression Subtract: output the difference of the two expressions.

expression * expression Multiply: output the product of the two expressions.

expression / expression Divide: output the quotient of the two expressions.

expression % expression Remainder: output the remainder resulting by dividing the two expressions.

expression ^ expression Power: raise the first expression to the power of the second expression.

(expressions) Group an expression or expressions together, altering the standard precedence of performing operations.

sqrt(expression) Output the square root of expression.

Outputting a Random Number

To output a random number, use random. Give as an argument an integer denoting the range of numbers to be output; random then outputs a random number from 0 to the number you give, minus one.

  • To output a random number from 0 to 9, type:

    $ random 10 RET

Listing a Sequence of Numbers

Use seq to print a sequence of numbers. This is very useful for getting a listing of numbers to use as arguments, or otherwise passing sequences of numbers to other commands.

To output the sequence from 1 to any number, give that number as an argument.

  • To output the sequence of numbers from one to seven, type:

    $ seq 7 RET
  • To output the sequence of numbers from one to negative seven, type:

    $ seq -7 RET

To output the sequence from any one number to another, give those numbers as arguments.

  • To output the sequence of numbers from nine to zero, type:

    $ seq 9 0 RET
  • To output the sequence of numbers from negative one to negative twenty, type:

    $ seq -1 -20 RET

To specify an increment other than one, give it as the second argument, between the starting and ending number.

  • To output the sequence of numbers from -1 to 14, incrementing by 3, type:

    $ seq -1 3 14 RET

Use the `-w' option to pad numbers with leading zeros so that they're all output with the same width.

Specify a separator string to be output between numbers as an argument to the `-s' option; the default is a newline character, which outputs each number in the sequence on its own line.

  • To output the sequence of numbers from 9 to 999, incrementing by 23, with numbers padded with zeros so that they're all of equal width, type:

    $ seq -w 9 23 999 RET
  • To output the sequence of numbers from 1 to 23, with a space character between each, type:

    $ seq -s ' ' 1 23 RET

To pass a sequence of numbers as arguments to a command, pipe the output of seq using a space character as a separator.

  • To concatenate all the files in the current directory, whose names are numbers from 25 through 75, into a new file called `selected-mail', type:

    $ cat `seq -s " " 25 75` > selected-mail RET

Finding Prime Factors

The factor tool calculates and outputs the prime factors of numbers passed as arguments.

  • To output the prime factors of 2000, type:

    $ factor 2000 RET
    2000: 2 2 2 2 5 5 5
    $

NOTE: If no number is given, factor reads numbers from standard input; numbers should be separated by space, tab, or newline characters.

Converting Numbers

The following recipes are for converting numbers in various ways.


Converting an Amount between Units of Measurement

Use the units tool to convert units of measurement between scales. Give two quoted arguments: the number and name of the units you have, and the name of the units to convert to. It outputs two values: the number of the second units you have, and how many of the second kind of unit can make up the quantity of the first that you've specified.

  • To output the number of ounces in 50 grams, type:

    $ units '50 grams' 'ounces' RET
            * 1.7636981
            / 0.56699046
    $

In this example, the output indicates that there are about 1.7636981 ounces in 50 grams, and that conversely, one ounce is about 0.56699046 times 50 grams.

The units tool understands a great many different kinds of units--from Celsius and Fahrenheit to pounds, hectares, the speed of light, and a "baker's dozen." All understood units are kept in a text file database; use the `-V' option to output the location of this database on your system, which you can then peruse or search through to see the units your version supports.


  • To determine the location of the units database, type:

    $ units -V RET
    units version 1.55 with readline, units database in
    /usr/share/misc/units.dat 
    $

In this example, the units database is located in the file `/usr/share/misc/units.dat', which is the file to peruse to list all of the units data.

Converting an Arabic Numeral to English

Use number to convert Arabic numerals to English text. Give a numeral as an argument; with no argument, number reads a numeral from the standard input.

  • To output the English text equivalent of 100,000, type:

    $ number 100000 RET

Other Math Tools

The following table lists some of the other mathematics tools available for Linux. It is by no means a complete list.

TOOL - DESCRIPTION

calc - is a scientific calculator tool for Emacs. {@sf{Debian}}: `calc'

dc - Like bc, the dc tool is an arbitrary-precision calculator language, but it is a reverse-polish calculator, where numbers are pushed on a stack. When you give an arithmetic operation symbol, dc pops numbers off the stack for their operands, and then it pushes the evaluation on the stack. {@sf{Debian}}: `dc'

dome - Richard J. Bono's dome is a geodesic math tool for calculating the properties of a geodesic dome symmetry triangle--it can calculate chord factors, vertex coordinates, and topological abundance of various dome types, including "Buckyball" formations and elliptical geodesics. {@sf{Debian}}: `dome' {@sf{WWW}}: http://www.cris.com/~rjbono/html/domes.html

gnucash - GnuCash is an intuitive personal finance application. Use it for managing finances, including bank accounts, stocks, income, and expenses; it's "based on professional accounting principles" to ensure accuracy in computation and reporting. {@sf{Debian}}: `gnucash' {@sf{WWW}}: http://www.gnucash.org/

gnumeric - Gnumeric is the GNOME spreadsheet application. It is powerful, and somewhat reminiscent of Excel. {@sf{Debian}}: `gnumeric' {@sf{WWW}}: http://www.gnu.org/software/gnumeric/gnumeric.html

gnuplot - The gnuplot tool can be used for data visualization, making 2-D and 3-D graphs, and plotting functions. {@sf{Debian}}: `gnuplot' {@sf{WWW}}: ftp://ftp.gnu.org/pub/gnu/gnuplot/

oleo - GNU Oleo is a spreadsheet application. It can run in both X and in the console, has Emacs-like key bindings, and can generate PostScript output. {@sf{Debian}}: `oleo' {@sf{WWW}}: http://www.gnu.org/software/oleo/oleo.html

sc - is a small spreadsheet tool that runs in the console; it provides formulas and other basic features you would expect from a minimal spreadsheet.

xcalc - is a visual scientific calculator for the X Window System--it draws a calculator on the screen, and you can use the mouse or keyboard to use it. It is capable of emulating the TI-30 and HP-10C calculators.

xspread - is the X client front-end to sc. {@sf{Debian}}: `xspread'

Email

The primary means of sending plain-text messages (or binaries in attachment files) between users across computer networks and systems on the Internet is called electronic mail, or email (and more often than not these days, just "mail").

The number of email applications (called mail user agents, or MUAs) available for Linux is large, and you could spend endless hours exploring the details of all of them. Instead of guiding you toward this route, this chapter attempts to do three things: give a brief intro to using the default mail agent; give an overview of other well-supported mail agents, with pointers on where to go for more info; and show how you can use other tools on the system to manipulate your email.

The mail tool is the default mail agent on Debian and most other Linux systems. It comes without many bells and whistles that are standard with most MUAs, and any user who sends and receives email more than occasionally will certainly want to learn a more advanced system.

However, mail is available on almost all Unix-based systems, and it works in a pinch--by learning to use it you can always send and receive email on any Linux- or Unix-based system you encounter.

NOTE: On some Unix-based systems, the name of the tool is mailx instead of mail.

Sending Mail

To send an email message with mail, give the email addresses to which you are sending as arguments, and then type the message proper in the lines that follow; type C-d on a line by itself to signify the end of the message body, and to send the message.

  • To send an email message to lisa@example.com, type:

    $ mail lisa@example.com RET
    Subject: Hello RET
    Hi there, long time no talk! I'm just learning how to use RET 
    Linux and thought I'd show you how easy it is to send email! RET
    C-d
    Cc: RET

The text you type on the `Subject:' line is displayed as the subject of your email message, and the lines of text you type after that is the body text of the message. Type C-d on a line alone to end the message. Then, mail prompts for `Cc:' addresses; a "carbon copy" of the email message is sent to any addresses you give here, if any (just type RET for none, and separate multiple addresses with commas).

When you type, mail just reads the standard input like any other command-line tool, so there's little direct editing capability in this basic email service--use C-u to erase the current line, and C-c C-c (that is, C-c pressed twice) to cancel your input and abort the message altogether.

That's it! No bells, no whistles--but no time-wasting excess, either.

Mailing a User on the Same System

To send an email message to another user on the same system, give their username on the system instead of an email address (technically, you are giving the email address, since email addresses take the form of username@hostname; when hostname is omitted, the localhost is assumed).

  • To send an email message to user mrs on your local system, type:

    $ mail mrs RET
    Subject: are you going to the party tonight? RET
    C-d
    Cc: RET
    Null message body; hope that's ok
    $

This command sends an email message to the user mrs on the local system. The email message itself is empty, but the subject is a short note asking whether user mrs will be attending a party.

NOTE: Besides being good for sending mail to users that you might share your system with, mail is useful for sending yourself mail, as a way to give yourself a reminder at your terminal.

Mailing a File or the Output of a Command

The mail tool is also useful for mailing the contents of a text file or the text output of a command. To do this, give the email addresses you want to send to as arguments to mail, and use the standard input redirection operators to redirect the text to use as the message body.

  • To mail the contents of the text file `trades' to the email address terrapin@example.com, type:

    $ mail terrapin@example.com < trades RET

Mailing the Contents of a URL

A variation on the previous recipe is to use mail and shell redirection to send the output of some command to some address via email. You can, for example, send the contents of a URL as an annotated text file by redirecting the output of the lynx Web browser.

  • To mail the text of the URL http://etext.org/ as annotated text to the email address droneon@example.com, type:

    $ mail droneon@example.com < lynx -dump -number_links
    http://etext.org/ RET 

Special Mail Composition Keystrokes

The following table lists the special keystrokes that work when composing a mail message, and describes their functions.

KEYSTROKE - DESCRIPTION

C-c C-c - Abort the current message and exit mail.

. RET or C-d - On a blank line, either of these commands sends the message and then exits mail.

C-u - Erase the current line and move the cursor to the beginning of the line.

There are also a few special commands that you may use while composing the body of the message. They're known as "tilde escapes" because you specify them by typing a tilde character (`~').

The following table lists some of these commands and describes their functions.

COMMAND - DESCRIPTION

~!command - Run command in a shell.

~baddress - Send a blind carbon copy to the usernames or email addresses given.

~d - Copy the file `dead.letter' from your home directory into the message.

~e - Edit the message in the default text editor program. (When you exit the text editor, you are returned to mail.)

~fnumber - Insert copies of the specified received messages into the message body. Messages are specified by number or a range (for example, `2-4' inserts messages two through four inclusive); if no number is given, the current received message is inserted.

~F - Same as `~f', but reads in the messages with full headers.

~rfile - Insert a copy of the file file into the message.

~wfile - Write a copy of the body text into the file file.

These commands should each be typed on a line by itself.

  • To insert a copy of the current mail message into the body of the message you are writing, and then open the message in the default text editor, type:

    ~f RET
    ~e RET

Receiving Mail

On Linux-based systems, the INBOX is a text file on the system where your incoming mail is written to. Its location is always given by $MAIL, a special shell variable.

  • To output the location of your INBOX, type:

    $ echo $MAIL RET

Usually, the INBOX location is in the `/var/spool/mail' directory, and has the same name as your username--so if your username is mrs, your INBOX is likely `/var/spool/mail/mrs'.

You shouldn't directly edit this file, because doing so can inadvertently cause you to lose incoming mail.

To see if you have any mail waiting in your INBOX, type mail. If you don't have any mail, mail will indicate this and exit; if you do have mail waiting, mail outputs a list of message headers, one line per message, each containing the status of the message (`N' for new messages, blank for previously read messages), the message number, the name of the sender, the date and time the message was received, and the number of lines and characters in the message.

  • To see if you have mail, type:
$ mail RET
Mail version 8.1 6/6/93.  Type ? for help.
"/var/spool/mail/m": 3 messages 3 new
>N  1 mrs           Mon Sep 6 17:29  13/345 "Re: A modest proposal"
 N  2 Ray           Tue Sep 7 04:20  15/694 "Latest news"
 N  3 lisa@example  Tue Sep 7 09:35  19/869 "Re: Hello"
& 

In this example, the user has three messages waiting--one from mrs, one from Ray, and one from lisa@example.com.

The mail prompt is an ampersand (`&') character; from there, you can read, delete, reply to, and save messages. When you type RET at the `&' prompt, mail outputs the next unread message to the screen. You can also type a number to output that message.

  • To read the next unread message in mail, type:

    & RET
  • To read message number three in mail, type:

    & 3 RET

There are two ways to exit mail: type q to exit mail and apply the deletion commands you have given, if any, to your INBOX; type x to exit mail and revert the state of your INBOX to how it was before you ran mail.

  • To exit mail and revert your INBOX to its state before you started mail, type:

    & x RET

Deleting Mail

To delete a message in mail, type d at the `&' prompt after reading the message in question. You can also specify a message or a range of messages to delete as an option to d.

  • To delete the message you just read, type:

    & d RET
  • To delete message 3, type:

    & d3 RET
  • To delete messages 10 through 14, type:

    & d10-14 RET

Options Available while Reading Mail

The following table summarizes the most common mail commands for reading mail; these commands work at the `&' prompt.

COMMAND - DESCRIPTION

? Output a help menu containing a list of mail options and their meanings.

d - Delete a message. Give the number or range of the message(s) to delete as an argument.

h - Output a list of headers of mail messages. You can specify a range or the number of the message to start with.

q - Exit mail and apply the changes you have made in this mail session to your INBOX.

r - Reply to the message you last read; you can also give a message number as an argument to reply to that message number.

u - Undelete a message you have deleted in the current mail session. Give the number or range of the message(s) to be undeleted as an argument.

x - Exit mail and revert the INBOX to its state before this mail session.

s file - Save the message you last read to the file in your home directory specified by file (if the file does not exist, mail will ask you whether or not it should create it).

NOTE: By default, only you (and, as always, the superuser) have access to read your INBOX. While there are tools available (such as mail, and the other MUAs) to read this file in special ways, you can also view this file like any other text file.

Managing Mail

A mail folder is simply a text file whose contents consist of saved mail messages; any tool that works on text can be used on a mail folder.

The following subsections describe some of the common ways to manage and otherwise modify your saved mail.


Viewing a Mail Folder

You can view your mail folders in less or edit them in a text editor, although the folder will appear as one long scroll containing all of the messages the folder contains.

You can also view them in elm or open them with mail, and they will appear in the normal way as your INBOX would appear with these tools.

To view a mail folder with elm, give the name of the folder as an argument to the `-f' option.

  • To view the mail folder `~/email/mrs' in elm, type:

    $ elm -f ~/email/mrs RET

If you save your mail messages in a lot of separate folders, you can view a sorted list of all messages from all files by using cat in conjunction with elm. Concatenate all the folders into one with cat and then view that file in elm as you would view any folder.

  • To view the contents of all of the email folders in your `~/email' directory, type:

    $ cat ~/email/* > allmessages RET
    $ elm -f allmessages RET

These commands write a new file, `allmessages', in the current directory, containing the contents of all email folders in `~/email'; then, that file is viewed in elm.

NOTE: To view a list showing who all the messages in a folder are from, use frm.

Setting Notification for New Mail

The biff tool notifies you when new mail arrives, by printing the header and first few lines of a mail message.

To turn biff on, use `y' as an option. To turn biff off, so that you stop being notified when new mail arrives, use `n' as an option. biff options don't take a hyphen.

  • To turn biff on, type:

    $ biff y RET

Some people put the above line in their `.bashrc' file so that biff is always set on in all of their shells.

Typing biff alone with no options will tell you whether biff is set to `y' or `n'.

  • To see what biff is set to, type:

    $ biff RET

A companion tool, xbiff, works only in the X Window System (you can use the regular biff in X, too). When you start it, xbiff draws a window containing a mailbox.

NOTE: The original version of biff was named after a dog. In the early 1980s at a UC Berkeley computer lab, a girl would bring her dog, Biff, with her when she went to use the computers. Biff was known for barking at the mailman when he came in to deliver the day's mail. He was also very popular with all of the BSD UNIX hackers at Berkeley, and when one of them wrote a mail notification tool, he thought of Biff--hence the name. (Biff, the dog, died in August 1993.)

Counting How Many Messages You Have

Use messages to count the number of mail messages in a folder or file. Give the name of a mail folder as an argument; with no arguments, it counts the mail you have waiting in your INBOX.

  • To see how many email messages you have waiting, type:

    $ messages RET
  • To count the number of email messages in the mail folder `~/email/saved', type:

    $ messages ~/email/saved RET

Seeing Who Your Mail Is From

Use frm to output a list of sender names and subjects for your mail. Give the name of a mail folder as an option; with no options, frm reads your INBOX.

  • To output a list showing sender names and subjects of your incoming mail, type:

    $ frm RET
  • To output a list showing sender names and subjects of the mail in the file `~/email/saved', type:

    $ frm ~/email/saved RET

NOTE: An alternate tool, from, works in similar fashion, but it does not output subject lines; instead, it outputs the names of senders and the time that messages were received.

Verifying an Email Address

Use vrfy to determine whether or not a given email address works. This is useful when you are unsure whether or not you have the right email address for someone. If the address works, vrfy outputs a message indicating that the recipient exists; if the address is not valid, vrfy outputs a message saying that the user is unknown.

  • To verify that the email address user@example.edu is valid, type:

    $ vrfy user@example.edu RET

Use the `-f' option to specify a text file containing email addresses; vrfy attempts to verify all email addresses contained in the file.

  • To verify all of the email addresses contained in the file `net-legends-faq', type:

    $ vrfy -f net-legends-faq RET

NOTE: vrfy relies on the remote system to get this information; in these days of the heavily corporatized Internet, an increasing number of sites no longer supply this kind of information to the general public. However, it's still useful enough to be worth mentioning.

Mail Attachments

MIME ("Multipurpose Internet Mail Extensions") is an Internet standard for encoding and attaching files to mail messages. It's used when sending image, audio, or other non-plain-text data via email.

Normally, you read and send MIME mail with your MUA. The following recipes, which show ways to send and receive MIME mail on the command line, are useful for when you just use the mail tool to read and send occasional mail with an attachment.

Reading a Mail Attachment

To read a mail attachment, write the message to a file and then run metamail with the file name as an argument. metamail lists each attachment and prompts you about whether it should display the attachment, write it to a file, or skip it.

In this example, the mail tool was used to open the INBOX and write the message to a file called `image.mail'; then, metamail was run with the file name as an argument.

Sending a Mail Attachment

To send a file as an email attachment, use metasend. It prompts for the values to use in the `To:', `Subject:', and `CC:' header fields, plus the following values for each MIME attachment: its `Content-type:' field, which describes the kind of data the attachment contains; the file name; and the type of encoding to use, if any (usually one is recommended).

  • To mail the JPEG file `dream.jpeg' in the current directory to the address dali@example.org, type:
$ metasend RET
To: dali@example.org RET
Subject: The image you requested RET
CC: RET
Content-type: image/jpeg RET
Name of file containing image/gif data: dream.jpeg RET
Do you want to encode this data for sending through the mail?
  1 -- No, it is already in 7 bit ASCII
  2 -- Yes, encode in base64 (most efficient)
  3 -- Yes, encode in quoted-printable (less efficient, more readable)
  4 -- Yes, encode it using uuencode (not standard, being phased out)
2 RET
Do you want to include another file too (y/n) [n] ? n RET
Delivering mail, please wait...  Mail delivery apparently succeeded.
$

The following table lists values to use in the MIME `Content-type:' field for various kinds of files.

VALUE - FILE TYPE

application/gzip File compressed with gzip.

application/zip File compressed with zip.

application/postscript PostScript file.

image/jpeg JPEG image file.

image/png PNG image file.

audio/basic Audio file.

audio/mpeg3 MP3 audio file.

audio/wav WAV audio file.


Making an Email Signature

A signature file (often called a "dot sig," and written as `.sig') is a text file containing text that you want to appear at the end of email messages and other online postings.

Sometimes, people put their name, email address, and a small quote, or a piece of ASCII art (such as text written in a figlet font; once the World Wide Web became popular, many people started including the URL of their home page in their `.sig'.

The use of signatures goes in and out of vogue with the years; you can decide whether or not you want to use one, but whatever you do, be sure to keep your `.sig' at most four lines in length--to use any more is considered very bad form. A first line consisting only of `-- ' is sometimes used; many applications recognize this text as the beginning of a `.sig' when processing messages.

You create your signature file in a text editor, just like any other text file. Name the file `.signature' or `.sig', and keep it in your home directory.

If you want to use more than one signature, use sigrot to "rotate" your various signatures--every time you run sigrot, it selects one of the signature files you keep in your `.sigrot' directory and writes it to `.signature'. To change your `.signature' every time you log in, you would run sigrot in your `.bash_login' file.

Picking the Right Mail Application

The following table lists some of the more popular MUAs that are available for Linux, describing their special features, and listing their Debian package name and URL (when available).

APPLICATION - DESCRIPTION

balsa - A graphical email client that works in X with GNOME installed; its interface is inspired somewhat by the proprietary Eudora. {@sf{Debian}}: `balsa' {@sf{WWW}}: http://www.balsa.net/

elm - A menu-driven MUA, elm was popular in the early 1990s among experienced users--it has some interesting features, including ways to send mails in batch mode to many addresses at once, and a tool to send telephone messages as email messages. Interest in elm has waned somewhat over the years, and most novices are advised to try mutt instead. {@sf{Debian}}: `elm me+' {@sf{WWW}}: http://www.instinct.org/elm/

gnus - The gnus newsreader for Emac can also be used to read and send mail. It has many features and should appeal to Emacs lovers--but a warning: it can be daunting to learn! {@sf{Debian}}: `gnus' {@sf{WWW}}: http://www.gnus.org/

mew - mew is an Emacs mail and news facility developed in Japan. It shows promise as a fairly new MUA and has many features for handling mail in complex ways. {@sf{Debian}}: `mew' {@sf{WWW}}: http://www.mew.org/

mh-e - MH-E is an Emacs front end to nmh, below. It's very powerful, yet it remains easy to use. {@sf{Debian}}: `emacsen-common' {@sf{WWW}}: http://www.emacs.org/

vm - VM ("View Mail") is a facility for reading and sending mail in Emacs. Older than gnus and mew, it is very configurable. {@sf{Debian}}: `vm' {@sf{WWW}}: http://www.wonderworks.com/vm/

The World Wide Web

Next to email, the most useful service on the Internet is the World Wide Web (often written "WWW" or "Web"). It is a giant network of hypertext documents and services, and it keeps growing by the instant--anyone with an Internet-connected computer can read anything on the Web, and anyone can publish to the Web. It could well be the world's largest public repository of information.

Viewing an Image from the Web

@sf{Debian}: `imagemagick'
@sf{WWW}: ftp://ftp.wizards.dupont.com/pub/ImageMagick/


If you just want to view an image file from the Web, you don't have to use a Web browser at all--instead, you can use display, giving the URL you want to view as an argument. This is especially nice for viewing your favorite webcam image, or for viewing images on ftp sites--you don't have to log in or type any other commands at all.

NOTE: When viewing the image, you can use all of the image manipulation commands that display supports, including resizing and changing the magnification of the image. For more information about display.

Reading Text from the Web

@sf{Debian}: `lynx'
@sf{WWW}: http://lynx.browser.org/


The venerable lynx is one of the first Web browsers available for general use. It can't display graphics at all, but it's a good interface for reading hypertext.

Type lynx to start it--if a "start page" is defined, it will load. The start page is defined in `/etc/lynx.cfg', and can be a URL pointing to a file on the local system or to an address on the Web; you need superuser privileges to edit this file. On Debian systems, the start page comes defined as the Debian home page, http://www.debian.org/ (but you can change this, of course; many experienced users write their own start page, containing links to frequently-visited URLs, and save it as a local file in their home directory tree).

To open a URL, give the URL as an argument.


When in lynx, the following keyboard commands work:

COMMAND - DESCRIPTION

@uparrow and @downarrow - Move forward and backward through links in the current document.

@rightarrow or RET - Follow the hyperlink currently selected by the cursor.

@leftarrow - Go back to the previously displayed URL.

DEL - View a history of all URLs visited during this session.

PgDn or SPC - Scroll down to the next page in the current document.

PgUp - Scroll up to the previous page in the current document.

= - Display information about the current document (like all pages in lynx, type @leftarrow to go back to the previous document).

g - Go to a URL; lynx will prompt you for the URL to go to. Type @uparrow to insert on this line the last URL that was visited; once inserted, you can edit it.

h - Display the lynx help files.

q - Quit browsing and exit the program; lynx will ask to verify this action.

The following are some recipes for using lynx.

Perusing Text from the Web

To peruse just the text of an article that's on the Web, output the text of the URL using lynx with the `-dump' option. This dumps the text of the given URL to the standard output, and you can pipe this to less for perusal, or use redirection to save it to a file.

$ lynx -dump 
http://www.sc.edu/fitzgerald/winterd/winter.html | less RET


It's an old net convention for italicized words to be displayed in an etext inside underscores like `_this_'; use the `-underscore' option to output any italicized text in this manner.

By default, lynx annotates all the hyperlinks and produces a list of footnoted links at the bottom of the screen. If you don't want them, add the `-nolist' option and just the "pure text" will be returned.

  • To output the pure text, with underscores, of the previous URL, and save it to the file `winter_dreams', type (all on one line):
$ lynx -dump -nolist -underscore 
http://www.sc.edu/fitzgerald/winterd/winter.html > winter_dreams RET

You can do other things with the pure text, like pipe it to enscript for setting it in a font for printing.

  • To print the pure text, with underscores, of the previous URL in a Times Roman font, type (all on one line):

    $ lynx -dump -nolist -underscore 
    http://www.sc.edu/fitzgerald/winterd/winter.html | enscript -B 
    -f "Times-Roman10" RET

Viewing a Site That Requires Authorization

To view a site or Web page that requires registration, use lynx with the `-auth' option, giving as arguments the username and password to use for authorization, separating them by a colon (`:') character.

  • To view the URL http://www.nytimes.com/archive/ with a username and password of `cypherpunks', type (all on one line):

    $ lynx -auth=cypherpunks:cypherpunks
    http://www.nytimes.com/archive/ RET 

It's often common to combine this with the options for saving to a file, so that you can retrieve an annotated text copy of a file from a site that normally requires registration.

  • To save the URL http://www.nytimes.com/archive/ as an annotated text file, `mynews', type (all on one line):

    $ lynx -dump -number_links -auth=cypherpunks:cypherpunks
    http://www.nytimes.com/archive/ > mynews RET

NOTE: The username and password argument you give on the command line will be recorded in your shell history log , and it will be visible to other users on the system should they look to see what processes you're running.

Options Available while Browsing Text

The following table describes some of the command-line options lynx takes.

OPTION - DESCRIPTION -anonymous - Use the "anonymous ftp" account when retrieving ftp URLs.

-auth=user:pass - Use a username of user and password of pass for protected documents.

-cache=integer - Keep integer documents in memory.

-case - Make searches case-sensitive.

-dump - Dump the text contents of the URL to the standard output, and then exit.

-emacskeys - Enable Emacs-style key bindings for movement.

-force_html - Forces rendering of HTML when the URL does not have a `.html' file name extension.

-help - Output a help message showing all available options, and then exit.

-localhost - Disable URLs that point to remote hosts--useful for using lynx to read HTML- or text-format documentation in `/usr/doc' and other local documents while not connected to the Internet.

-nolist - Disable the annotated link list in dumps.

-number_links - Number links both in dumps and normal browse mode.

-partial - Display partial pages while downloading.

-pauth=user:pass - Use a username of user and password of pass for protected proxy servers.

-underscore - Output italicized text like _this_ in dumps.

-use_mouse

Use mouse in an xterm.

-version - Output lynx version and exit.

-vikeys - Enable vi-style key bindings for movement.

-width=integer - Format dumps to a width of integer columns (default 80).


Getting Files from the Web

@sf{Debian}: `wget'
@sf{WWW}: http://www.wget.org/


Use wget, "Web get," to download files from the World Wide Web. It can retrieve files from URLs that begin with either `http' or `ftp'. It keeps the file's original timestamp, it's smaller and faster to use than a browser, and it shows a visual display of the download progress.

The following subsections contain recipes for using wget to retrieve information from the Web. See Info file `wget.info', node `Examples', for more examples of things you can do with wget.

Saving a URL to a File

To download a single file from the Web, give the URL of the file as an argument to wget.

This command reads a given URL, writing its contents to a file with the same name as the original, `septembr.mp3', in the current working directory.

If you interrupt a download before it's finished, the contents of the file you were retrieving will contain only the portion of the file wget retrieved until it was interrupted. Use wget with the `-c' option to resume the download from the point it left off.

  • To resume download of the URL from the previous example, type:

    $ wget -c ftp://ftp.neuron.net/pub/spiral/septembr.mp3 RET

NOTE: In order for the `-c' option to have the desired effect, you should run wget from the same directory as it was run previously, where that partially-retrieved file should still exist.

Archiving an Entire Web Site

To archive a single Web site, use the `-m' ("mirror") option, which saves files with the exact timestamp of the original, if possible, and sets the "recursive retrieval" option to download everything. To specify the number of retries to use when an error occurs in retrieval, use the `-t' option with a numeric argument---`-t3' is usually good for safely retrieving across the net; use `-t0' to specify an infinite number of retries, good for when a network connection is really bad but you really want to archive something, regardless of how long it takes. Finally, use the `-o' with a file name as an argument to write a progress log to the file--examining it can be useful in the event that something goes wrong during the archiving; once the archival process is complete and you've determined that it was successful, you can delete the log file.

  • To mirror the Web site at http://www.bloofga.org/, giving up to three retries for retrieving files and putting error messages in a log file called `mirror.log', type:

    $ wget -m -t3 http://www.bloofga.org/ -o mirror.log RET

This command makes an archive of the Web site at `www.bloofga.org' in a subdirectory called `www.bloofga.org' in the current directory. Log messages are written to a file in the current directory called `mirror.log'.

To continue an archive that you've left off, use the `-nc' ("no clobber") option; it doesn't retrieve files that have already been downloaded. For this option to work the way you want it to, be sure that you are in the same directory that you were in when you originally began archiving the site.

  • To continue an interrupted mirror of the Web site at http://www.bloofga.org/ and make sure that existing files are not downloaded, giving up to three retries for retrieval of files and putting error messages in a log file called `mirror.log', type:

    $ wget -nc -m -t3 http://www.bloofga.org/ -o mirror.log RET


Archiving Part of a Web Site

To archive only part of a Web site--such as, say, a user's home page--use the `-I' option followed by a list of the absolute path names of the directories to archive; all other directories on the site are ignored.

  • To archive the Web site at http://dougal.bris.ac.uk/~mbt/, only archiving the `/~mbt' directory, and writing log messages to a file called `uk.log', type:

    $ wget -m -t3 -I /~mbt http://dougal.bris.ac.uk/~mbt/
    -o uk.log RET 

This command archives all files on the http://dougal.bris.ac.uk/~mbt/ Web site whose directory names begin with `/~mbt'.

To only get files in a given directory, use the `-r' and `-l1' options (the `-l' option specifies the number of levels to descend from the given level). To only download files in a given directory, combine these options with the `--no-parent' option, which specifies not to ascend to the parent directory.

Use the `-A' option to specify the exact file name extensions to accept--for example, use `-A txt,text,tex' to only download files whose names end with `.txt', `.text', and `.tex' extensions. The `-R' option works similarly, but specifies the file extensions to reject and not download.

  • To download only the files ending in a `.gz' extension and only in the given directory `/~rjh/indiepop-l/download/' at `monash.edu.au', type:

    $ wget -m -r -l1 --no-parent -A.gz
    http://monash.edu.au/~rjh/indiepop-l/download/ RET

Reading the Headers of a Web Page

All Web servers output special headers at the beginning of page requests, but you normally don't see them when you retrieve a URL with a Web browser. These headers contain information such as the current system date of the Web server host and the name and version of the Web server and operating system software.

Use the `-S' option with wget to output these headers when retrieving files; headers are output to standard output, or to the log file, if used.

  • To retrieve the file at http://slashdot.org/ and output the headers, type:

    $ wget -S http://slashdot.org/ RET

This command writes the server response headers to standard output and saves the contents of http://slashdot.org/ to a file in the current directory whose name is the same as the original file.

Writing HTML

@sf{Debian}: `bluefish'
@sf{WWW}: http://bluefish.openoffice.nl/


Hypertext Markup Language (HTML) is the markup language of the Web; HTML files are just plain text files written in this markup language. You can write HTML files in any text editor; then, open the file in a Web browser to see the HTML markup rendered in its resulting hypertext appearance.

Many people swear by Bluefish, a full-featured, user-friendly HTML editor for X.

Emacs has a major mode to facilitate the editing of HTML files; to start this mode in a buffer, type:

M-x html-mode RET

The features of HTML mode include the insertion of "skeleton" constructs.

The help text for the HTML mode function includes a very short HTML authoring tutorial--view the documentation on this function to display the tutorial.

  • To read a short HTML tutorial in Emacs, type:

    C-h f html-mode RET

NOTE: When you're editing an HTML file in an Emacs buffer, you can open the same file in a Web browser in another window--Web browsers only read and don't write the HTML files they open, so you can view the rendered document in the browser as you create it in Emacs. When you make and save a change in the Emacs buffer, reload the file in the browser to see your changes take effect immediately.

Adding Parameters to Image Tags

@sf{Debian}: `imgsizer'
@sf{WWW}: http://www.tuxedo.org/~esr/software.html#imgsizer


For usability, HTML image source tags should have `HEIGHT' and `WIDTH' parameters, which specify the dimensions of the image the tag describes. By specifying these parameters in all the image tags on a page, the text in that page will display in the browser window before the images are loaded. Without them, the browser must load all images before any of the text on the page is displayed.

Use imgsizer to automatically determine the proper values and insert them into an HTML file. Give the name of the HTML file to fix as an argument.

  • To add `HEIGHT' and `WIDTH' parameters to the file `index.html', type:

    $ imgsizer index.html RET

Converting HTML to Another Format

@sf{Debian}: `unhtml'
@sf{Debian}: `html2ps'
@sf{WWW}: http://dragon.acadiau.ca/~013639s/
@sf{WWW}: http://www.tdb.uu.se/~jan/html2ps.html


There are several ways to convert HTML files to other formats. You can convert the HTML to plain text for reading, processing, or conversion to still other formats; you can also convert the HTML to PostScript, which you can view, print, or also convert to other formats, such as PDF.

To simply remove the HTML formatting from text, use unhtml. It reads from the standard input (or a specified file name), and it writes its output to standard output.

  • To peruse the file `index.html' with its HTML tags removed, type:

    $ unhtml index.html | less RET
  • To remove the HTML tags from the file `index.html' and write the output to a file called `index.txt', type:

    $ unhtml index.html > index.txt RET

When you remove the HTML tags from a file with unhtml, no further formatting is done to the text. Furthermore, it only works on files, and not on URLs themselves.

Use lynx to save an HTML file or a URL as a formatted text file, so that the resultant text looks like the original HTML when viewed in lynx. It can also preserve italics and hyperlink information in the original HTML.

One thing you can do with this lynx output is pipe it to tools for spacing text, and then send that to enscript for setting in a font. This is useful for printing a Web page in typescript "manuscript" form, with images and graphics removed and text set double-spaced in a Courier font.

  • To print a copy of the URL http://example.com/essay/ in typescript manuscript form, type:

    $ lynx -dump -underscore -nolist http://example.com/essay/ | pr -d
    | enscript -B RET

NOTE: In some cases, you might want to edit the file before you print it, such as when a Web page contains text navigation bars or other text that you'd want to remove before you turn it into a manuscript. In such a case, you'd pipe the lynx output to a file, edit the file, and then use pr on the file and pipe that output to enscript for printing.

Finally, you can use html2ps to convert an HTML file to PostScript; this is useful when you want to print a Web page with all its graphics and images, or when you want to convert all or part of a Web site into PDF. Give the URLs or file names of the HTML files to convert as options. Use the `-u' option to underline the anchor text of hypertext links, and specify a file name to write to as an argument to the `-o' option. The defaults are to not underline links, and to write to the standard output.

  • To print a PostScript copy of the document at the URL http://example.com/essay/ to the default printer, type:

    $ html2ps http://example.com/essay/ | lpr RET
  • To write a copy of the document at the URL http://example.com/essay/ to a PostScript file `submission.ps' with all hypertext links underlined, type:

    $ html2ps -u -o submission.ps http://example.com/essay/ RET

Validating an HTML File

@sf{Debian}: `weblint'
@sf{WWW}: http://www.weblint.org/


Use weblint to validate the basic structure and syntax of an HTML file. Give the name of the file to be checked as an argument, and weblint outputs any complaints it has with the file to standard output, such as whether or not IMG elements are missing ALT descriptions, or whether nested elements overlap.


  • To validate the HTML in the file `index.html', type:

    $ weblint index.html RET

More Web Browsers and Tools

Surprisingly, there are not nearly as many Web browsers for Linux as there are text editors--or even text viewers. This remains true for any operating system, and I have often pondered why this is; perhaps "browsing the Web," a fairly recent activity in itself, may soon be obsoleted by Web readers and other tools. In any event, the following lists other browsers that are currently available for Linux systems.

WEB BROWSER - DESCRIPTION

amaya Developed by the World Wide Web Consortium; both a graphical Web browser and a WYSIWYG editor for writing HTML. {@sf{Debian}}: `amaya' {@sf{WWW}}: http://www.w3.org/amaya/

arena Developed by the World Wide Web Consortium; a very compact, HTML 3.0-compliant Web browser for X. {@sf{Debian}}: `arena' {@sf{WWW}}: http://www.w3.org/arena/

dillo A very fast, small graphical Web browser. {@sf{Debian}}: `dillo' {@sf{WWW}}: http://dillo.sourceforge.net/

express small browser that works in X with GNOME installed. {@sf{Debian}}: `express' {@sf{WWW}}: http://www.ca.us.vergenet.net/~conrad/express/

links A relatively new text-only browser. {@sf{WWW}}: http://artax.karlin.mff.cuni.cz/~mikulas/links/

gzilla A graphical browser for X, currently in an early stage of development. {@sf{Debian}}: `gzilla' {@sf{WWW}}: http://www.levien.com/gzilla/

w3m Another new text-only browser whose features include table support and an interesting free-form cursor control; some people swear by this one. {@sf{Debian}}: `w3m' {@sf{WWW}}: http://ei5nazha.yz.yamagata-u.ac.jp/

Other Internet Services

There are many Internet services other than email and the World Wide Web; this chapter describes how to use many of the other popular services, including telnet, ftp, and finger.

Connecting to Another System

Use telnet to connect to a remote system. Give the name of the system to connect to as an argument, specifying either its name or numeric IP address. If that system is reachable, you will be connected to it and presented with a login: or other connection prompt (the network is not exclusive to Linux systems) just as if you were seated at a terminal connected to that system. If you have an account on that system, you can then log in to it.

  • To connect to the system kanga.ins.cwru.edu, type:

    $ telnet kanga.ins.cwru.edu RET
    Trying 129.22.8.32...
    Connected to kanga.INS.CWRU.Edu.
    Escape character is '^]'.
    
    
    BSDI BSD/OS 2.1 (kanga) (ttypf)
    
    
                             /\
     WELCOME TO THE...     _!  !_
                         _!__  __!_
          __            !          !
        _!  !_          !   !  !   !
       !      !   /\    !   !  !   !
       !      !  !  !   !   !  !   !___
       !      ! !   !   !   !  !   !   !
       !      !_!_  !   !   !  !   !   !
       !      !   ! !   !   !  !   !   !
      _!      !   !_!_  !          !   !_
     !        !       !_!          !     !
    !                                    !
    !         CLEVELAND FREE-NET         !
    !      COMMUNITY COMPUTER SYSTEM     !
    !____________________________________!
    
              brought to you by
    
        Case Western Reserve University
        Office of Information Services
    
    
    Are you: 
            1. A registered user
            2. A visitor
    
    Please enter 1 or 2: 1 RET
    
    Enter your user ID (in lower case) at the Login: prompt.
    Then enter your password when asked.  Note that the 
    password will not print on the screen as you type it.
    
    Login: 

In this example, the user connected to the system at kanga.ins.cwru.edu; the bottom Login: prompt was the prompt of the remote system (if you are ever unsure what system you are on, use hostname as a shell prompt.

To disconnect from the system, follow the normal procedures for logging out from the system you are connected to (for how to do that on a Linux system.

  • To disconnect from a remote Linux system, type:

    $ C-d
    Connection closed.
    
    $

In the preceding example, the first shell prompt was on the remote system, and the second prompt was on the local system.

Suspending a Connection with Another System

You can also temporarily escape back to the local shell by typing the escape character, which is a key sequence that is interpreted by telnet before it reaches the remote system. You will then be brought to the telnet command prompt, where you can suspend with the `z' command; to return to the remote system, bring the job back into the foreground.

  • To temporarily return to a local shell prompt, type:

    faraway-system$ C-[
    telnet> z RET
    [2]+ Stopped                    telnet
    $
  • To return to the remote system, type:

    $ fg RET
    faraway-system$

In the first of the two preceding examples, the escape character C-[ was typed on the remote system, whose shell prompt in this example is `faraway-system$' (you don't have to type the escape character at a shell prompt, though; you can type it regardless of what program you are running or where you are on the remote system). Then, the `z' command was given to telnet to suspend the telnet connection. In the second example, the suspended telnet connection to the remote system was brought back into the foreground.

NOTE: You should be aware that it's possible (though not often desirable) to "nest" multiple layers of telnet sessions on top of each other by connecting from one system to the next, to the next, and so on, without disconnecting from the previous system. To avoid this, make sure you know which host you're leaving when you're about to telnet off to another; the hostname tool is useful for this.

Connecting to Another System with Encryption

@sf{Debian}: `kerberos4kth-user'
@sf{WWW}: http://web.mit.edu/kerberos/www/
@sf{WWW}: http://www.openssh.com/


On some systems, your system administrator may ask you to install and use kerberos, openssh, or some other network security tool so that you may connect to a remote system in a more secure manner than with telnet. These tools encrypt the data that is passed between the local and remote systems during your connect session; they're becoming very popular today among security-conscious administrators. Should you be asked to use one, follow your administrator's instructions in installing and configuring it for your system.

NOTE: In order to be of any use, the services and tools discussed in this chapter require that your system is online or otherwise connected to a network.

Transferring Files with Another System

FTP ("File Transfer Protocol") is a way to exchange files across systems. Use the ftp tool to connect to another system using this protocol, giving the name or numeric IP address of the system you want to connect to as an argument. Once connected, you will be prompted to log in with a username and password (if you have one on that system).

Many systems are set up to accept "anonymous ftp" connections, where a public repository of files are available for downloading by the general public; to use this, log in with a username of anonymous, and give your email address for a password.

  • To make an anonymous ftp connection to ftp.leo.org, type:


$ ftp ftp.leo.org RET
Connected to ftp.leo.org.
220-Welcome to LEO.ORG.
220-See file README for more information about this archive.
220-
220-Your connection class is named: The world outside Germany
220-
220-If you don't connect from inside Munich and login anonymously,
220-your data transfers are limited to a certain bandwidth.
220-
220-If you notice unusual behaviour, drop a note to ftp-admin@leo.org.
220 FTP server leo.org-0.9alpha ready.
Name (ftp.leo.org:m): anonymous RET
331 Guest login ok, send your email address as password.
Password: at118@po.cwru.edu RET
230-      _    ___  ___
230-     | |  | __|/   \            LEO - Link Everything Online
230-     | |__| _| | - |        Munich University of Technology (TUM)
230-     |___/|___|\___/           Department of Computer Science
230-
230-       This Anonymous FTP site is in Munich, Germany, Europe.
230-                  It's Tue Sep 28 18:31:43 MET DST 1999.
230-   Please transfer files during non-business hours (1800-0900 CET).
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Once connected and logged in, use the cd and ls commands to change directory and to list files on the remote system.

It is standard practice for public systems to have a `/pub' directory on their FTP host that contains all the files and goodies available to the general public.

  • To change to the `/pub' directory on the remote system and look at the files that are there, type:

    ftp> cd /pub RET
    250 Directory changed to /pub.
    ftp> ls RET
    ftp> ls
    200 PORT command successful.
    150 Opening ASCII connection for file (918 bytes)
    total 30258
    -rw-rw-r--   1 ftpadmin ftpadmin 10942767 Sep 28 06:18 INDEX.gz
    drwxr-xr-x   5 ftpadmin ftpadmin     512 Sep 17 18:22 comp
    -rw-rw-r--   1 ftpadmin ftpadmin 9512498 Sep 28 06:40 ls-lR.gz
    drwxr-xr-x   2 ftpadmin ftpadmin     512 Sep 17 18:22 rec
    drwxr-xr-x   3 ftpadmin ftpadmin     512 Sep 17 18:22 science
    226 Transfer completed with 918 Bytes/s.
    ftp> 

In this example, the `/pub' directory contained three subdirectories (`comp', `rec', and `science') and two files, `INDEX.gz' and `ls-lR.gz'; many public systems have files similar to these in their `/pub' directories---`INDEX.gz' is a listing of all files on their ftp site, with descriptions, and `ls-lR.gz' is the output of the command ls -lR run on the directory tree of their ftp server.

The following subsections describe how to upload and download files. Use the quit command to exit ftp and end the connection to the remote system.

Uploading a File

Use the put command to upload a file; give the name of the file as an argument. put takes that file in the current directory of the local system, and puts a copy of it in the current directory of the remote system.

  • To put a copy of the file `thyme.rcp' from the current directory on the local system to the current directory of the remote system, type:

    ftp> put thyme.rcp RET

The current directory of the local system is, by default, the directory where you ran the ftp command. To change directories on your local system, use lcd; it works just like the cd command, but it changes the local directory.

  • To change to the parent directory of the current directory on the local system, type:

    ftp> lcd .. RET
    Local directory now /home/james/demos
    ftp> 

In this example, the local current directory is now `/home/james/demos'.

There are other important commands for downloading files--use `i' to specify that files be transferred as binary; normally, the transfer is set up for text files. When you want to transfer programs, archives, compressed files, or any other non-text file, set the transfer type to `i' first.

In recent years, most public systems have added a security measure forbidding the upload by anonymous users to anywhere but the `/incoming' or `/pub/incoming' directories.

The mput command works like put but allows you to specify wildcards. By default, mput asks you, for each file, whether to upload the file or not; to turn off this file prompting, type prompt before giving the mput command. This command is a toggle--type prompt again to turn file prompting back on for your session.

Downloading a File

The get command works like put, but in reverse--specify a file on the remote system, and get saves a copy to the current directory on the local system. Again, use i first when downloading non-text files. (You can also download text files with i, so it is good practice to always set it before you transfer files; most Linux systems are configured to set the type to `i' immediately upon connection).

  • To download the file `INDEX.gz' in the current directory on the remote system, saving it to your `~/tmp' directory, type:

    ftp> lcd ~/tmp RET
    Local directory now /home/james/tmp
    ftp get INDEX.gz RET
    local: INDEX.gz remote: INDEX.gz
    Transferred 10942767 bytes
    ftp>

NOTE: The mget command works like get but allows wildcards; as with mput, you will be prompted to verify each file unless you use the prompt command first to turn this off.

33.3 Reading Usenet

@sf{WWW}: http://www.faqs.org/usenet/index.html
@sf{WWW}: http://www.geocities.com/ResearchTriangle/Lab/6882/


Usenet is a famous, vast collection of world-around discussion boards called newsgroups, where messages (called articles) can be read and publicly responded to. Newsgroups are named and organized by hierarchy, with each branch delineated by a period (`.'); for example, the `comp.os.linux' newsgroup is part of the `comp.os' branch of the `comp' hierarchy.

The following table lists the "Big Eight" Usenet hierarchies and give examples of some newsgroups in each one.

USENET HIERARCHY - DESCRIPTION

comp - Computing. news:comp.os.linux.advocacy,
news:comp.text.tex

humanities - Humanities. news:humanities.music.composers.wagner

misc - Miscellaneous. news:misc.consumers.frugal-living

news - Newsgroups relating to Usenet itself.
news.newusers.questions

rec - Recreation. news:rec.music.marketplace.vinyl,
news:rec.food.cooking

sci - Science. news:sci.math, news:sci.cognitive

soc - Social groups and cultures. news:soc.culture.usa,
news:soc.college

talk - Talk and chit-chat. news:talk.environment,
news:talk.politics.guns

While there are many other hierarchies, these eight are technically the only newsgroups considered to be part of Usenet proper. While netnews is the term for the collection of all newsgroups including those in Usenet, these terms are often used interchangeably.

The "alternative" hierarchy, `alt', is perhaps the most popular hierarchy of all--just about every subject you might want to discuss has an appropriate newsgroup here, including non sequiturs. There are also hierarchies for topics concerning certain geographical areas; for example, the `cols.' hierarchy is for topics pertaining to Columbus, Ohio, and `seattle' is for Seattle, Washington. So, while `cols.forsale' pertains to items for sale in the greater Columbus area, `seattle.forsale' is for items for sale in and around Seattle. Hierarchies can exist also for certain organizations; for example, the `gnu' hierarchy is for newsgroups concerning the GNU Project, and `bit' is for newsgroup redistributions of the popular Bitnet LISTSERV mailing lists.

The following recipes describe tools for reading and posting articles to netnews.

Choosing a Newsreader

An application that lets you read and post articles to newsgroups is called a newsreader. Here are some of the best newsreaders available for Linux-based systems.

NEWSREADER - DESCRIPTION

gnus - Gnus is a very powerful and feature-full newsreader for use in Emacs. You can use it to read mail, too. {@sf{Debian}}: `gnus' {@sf{WWW}}: http://www.gnus.org/

knews - A graphical newsreader for use in X. Its features include the display of article threads in a graphical tree, and options for those reading news over slow connections. {@sf{Debian}}: `knews' {@sf{WWW}}: http://www.matematik.su.se/~kjj/

mozilla - Historically, commercial Web browsers also had mail and newsreaders built into them, and that capability remains in the Mozilla browser. {@sf{Debian}}: `mozilla' {@sf{WWW}}: http://www.mozilla.org/

nn - The motto of nn is "No News is good news, but nn is better"; it's an older (and very popular) newsreader that was designed for reading the most news in the minimal amount of time. {@sf{Debian}}: `nn' {@sf{WWW}}: http://www.math.fu-berlin.de/~guckes/nn/

pan - The "Pimp A** Newsreader" is a new-generation graphical newsreader that is designed for speed. It is meant to be easy for beginners to use, and it works in X with GNOME installed. {@sf{Debian}}: `pan' {@sf{WWW}}: http://www.superpimp.org/

peruser - News Peruser is a suite of small tools for use in X that facilitate the reading and composing of news articles when you're offline--it downloads batches of news when your system is online. {@sf{Debian}}: `peruser' {@sf{WWW}}: http://www.ibiblio.org/pub/Linux/system/news/readers/

slrn - Based on rn, one of the oldest newsreaders, slrn is optimized for use over slow connections (like home modem dial-ups). {@sf{Debian}}: `slrn' {@sf{WWW}}: http://www.slrn.org/

Finding Newsgroups for a Topic

@sf{Debian}: `nn'
@sf{WWW}: ftp://ftp.uwa.edu.au/pub/nn/beta/


Use nngrep to find newsgroup names that match a pattern. This is useful for finding groups on a particular topic.

  • To output a list of all newsgroups that match the pattern `society', type:

    $ nngrep society RET

Use the `-u' option to only search through unsubscribed groups. This is useful if you are subscribed to a number of groups, and you are looking only for groups you aren't subscribed to yet.

  • To output a list of all unsubscribed-to newsgroups that match the pattern `society', type:

    $ nngrep society RET

In the previous example, if you were already subscribed to the group alt.society.neutopia, that group will not be displayed; but other groups matching the pattern `society' that you are not subscribed to would be listed.

Listing Online System and User Activity

The following tools are used to list the activity of other users and systems on the Internet--showing whether or not they are currently online and perhaps displaying a little more information about them.

Checking Whether a System Is Online

Use ping to determine whether a particular system is currently connected to the Internet.

Type ping followed by the name or numeric IP address of the system you want to check; if your system is online and the system to be checked is also online, ping should continually output lines telling how long the latency, in milliseconds, is between the two systems. Type C-c to interrupt it and stop pinging.

  • To ping the host bfi.org, type:

    $ ping bfi.org RET
    PING bfi.org (209.196.135.250): 56 data bytes
    64 bytes from 209.196.135.250: icmp_seq=0 ttl=63 time=190.0 ms
    64 bytes from 209.196.135.250: icmp_seq=1 ttl=63 time=159.9 ms
    64 bytes from 209.196.135.250: icmp_seq=2 ttl=63 time=160.5 ms
    C-c
    --- bfi.org ping statistics ---
    3 packets transmitted, 3 packets received, 0% packet loss
    round-trip min/avg/max = 159.9/170.1/190.0 ms
    $

In this example, the host bfi.org was pinged and a total of three pings were sent and received before the user typed C-c to interrupt it. As long as these ping lines are output, you know that the other machine is connected to the Internet (or at least to the same network that your localhost is connected to).

You really don't need to analyze the information on each line of a ping message--the only useful information is the number at the end of the line, which tells you how many milliseconds it took to go out to the Internet, touch or "ping" that host, and come back. The quicker the better---pings that are four or five digits long (or greater) mean a slow connection between the two machines. When you interrupt the ping, some statistics are output, including the minimum, average, and maximum number of milliseconds it took to ping the given host. In the example above, the high was 190 and the low was 159.9 milliseconds, with an average of 170.1.

NOTE: If your own system is not online, ping will report that either the network is unreachable or that the host isn't found.

Checking Whether a User Is Online

Use finger to check whether or not a given user is online. Give as an argument the username of the user (if on the local system) or their email address (if on a remote system). This is called "fingering" a user.

If the system they are using has finger enabled (most Unix-based systems should), the command will tell you the following: the date and time when they last logged in; whether or not they are currently logged in; their full name; their office room and telephone number; their home directory; what shell they use; whether or not they have mail waiting; the last time they read mail; and, finally, their "plan," as described below.

  • To finger the user bradley@ap.spl.org, type:
$ finger bradley@ap.spl.org RET
[ap.spl.org]
Login: bradley                         Name: Bradley J Milton
Directory: /sp1/bradley                Shell: /bin/tcsh
Last login Wed Jan 20 16:38 1999 (PST) on ttypb from zais.pair.com
No mail.
Plan:
To learn to how use Linux and GNU software.
$

In this example, the user bradley on the system at ap.spl.org is not currently logged in, logged in last on 20 January, and uses the tsch shell.

NOTE: On Unix-based systems, you can put information in a hidden file in your home directory called `.plan', and that text will be output when someone fingers you. Some people put elaborate information in their `.plan' files; in the early 1990s, it was very much in vogue to have long, rambling .plans. Sometimes, people put information in their `.plan' file for special events--for example, someone who is having a party next weekend might put directions to their house in their `.plan' file.

Listing Who Is Logged In to a System

To get a listing of all users who are currently logged in to a given system, use finger and specify the name (or numeric IP address) of the system preceded with an at sign (`@').

This gives a listing of all the users who are currently logged in on that system. It doesn't give each individual's `.plan's, but the output includes how long each user has been idle, where they are connected from, and (sometimes) what command they are running. (The particular information that is output depends on the operating system and configuration of the remote system.)

  • To output the users who are currently logged in to the system ap.spl.org, type:
$ finger @ap.spl.org RET
[spl.org]
Login      Name              Tty  Idle  Login Time   Office
allison    Allison Chaynes  *q2 16:23  Sep 27 17:22 (gate1.grayline)
gopherd    Gopher Client    *r4  1:01  Sep 28 08:29 (gopherd)
johnnyzine Johnny McKenna   *q9 15:07  Sep 27 16:02 (johnnyzine)
jezebel    Jezebel Cate     *r1    14  Sep 28 08:42 (dialup-WY.uu.net)
bradley    Bradley J Milton  t2     2  Sep 28 09:35 (spl.org)
$

Finding the IP Address of a Host Name

When you know the name of a particular host, and you want to find the IP address that corresponds to it, ping the host in question; this will output the IP address of the host in parenthesis.

You can also use dig, the "domain information groper" tool. Give a hostname as an argument to output information about that host, including its IP address in a section labelled `ANSWER SECTION'.

  • To find the IP address of the host linart.net, type:

    $ dig linart.net RET
    ...output messages...
    ;; ANSWER SECTION:
    linart.net.            1D IN A         64.240.156.195
    ...output messages...
    $

In this example, dig output the IP address of 64.240.156.195 as the IP address for the host linart.net.

Finding the Host Name of an IP Address

To find the host name for a given IP address, use dig with the `-x' option. Give an IP address as an argument to output information about that address, including its host name in a section labelled `ANSWER SECTION'.

  • To find the host name that corresponds to the IP address 216.92.9.215, type:

    $ dig -x 216.92.9.215 RET
    ...output messages...
    ;; ANSWER SECTION:
    215.9.92.216.in-addr.arpa.  2H IN PTR  rumored.com.
    ...output messages...
    $

In this example, dig output that the host name corresponding to the given IP address was rumored.com.

Listing the Owner of a Domain Name

An Internet domain name's domain record contains contact information for the organization or individual that has registered that domain. Use the whois command to view the domain records for the common .com, .org, .net, and .edu top-level domains.

With only a domain name as an argument, whois outputs the name of the "Whois Server" that has that particular domain record. To output the domain record, specify the Whois Server to use as an argument to the `-h' option.

  • To output the name of the Whois Server for linart.net, type:

    $ whois linart.net RET
  • To view the domain record for linart.net, using the whois.networksolutions.com Whois Server, type:

    $ whois -h whois.networksolutions.com linart.net RET

NOTE: This command also outputs the names of the nameservers that handle the given domain--this is useful to get an idea of where a particular Web site is hosted.

Sending a Message to Another User's Terminal

Use write to write a message to the terminal of another user. Give the username you want to write to as an argument. This command writes the message you give, preceded with a header line indicating that the following is a message from you, and giving the current system time. It also rings the bell on the user's terminal.

  • To send the message `Wake up!' to the terminal where user `sleepy' is logged in, type:

    $ write sleepy RET
    Wake up!
    C-d
    $

The other user can reply to you by running write and giving your username as an argument. Traditionally, users ended a write message with `-o', which indicated that what they were saying was "over" and that it was now the other person's turn to talk. When a user believed that a conversation was completed, the user would end a line with `oo', meaning that they were "over and out."

A similar command, wall, writes a text message to all other users on the local system. It takes a text file as an argument and outputs the contents of that file; with no argument, it outputs what you type until you type C-d on a line by itself. It precedes the message with the text `Broadcast message from username' (where username is your username) followed by the current system time, and it rings the bell on all terminals it broadcasts to.

  • To output the contents of `/etc/motd' to all logged-in terminals, type:

    $ wall /etc/motd RET
  • ToNEWSREADER - DESCRIPTION output the text `Who wants to go out for Chinese food?' to all logged-in terminals, type:

    $ wall RET
    Who wants to go out for Chinese food? RET
    C-d

You can control write access to your terminal with mesg. It works like biff: with no arguments, it outputs whether or not it is set; with `y' as an argument, it allows messages to be sent to your terminal; and with `n' as an argument, is disallows them.

The default for all users is to allow messages to be written to their terminals; antisocial people usually put the line mesg n in their `.bashrc' file.

  • To disallow messages to be written to your terminal, type:

    $ mesg n RET
  • To output the current access state of your terminal, type:

    $ mesg RET
    is n
    $

In the preceding example above, mesg indicated that messages are currently disallowed to be written to your terminal.

Chatting with Other Users

There are several ways to interactively chat with other users on the Internet, regardless of their platform or operating system. The following recipes describe the most popular tools and methods for doing this.

Chatting Directly with a User

@sf{Debian}: `ytalk'
@sf{WWW}: http://www.iagora.com/~espel/ytalk/


Use talk to interactively chat in realtime with another user. Give the username (or email address) of the user you want to chat with as an argument; a message will be sent to that user's terminal, indicating that a connection is requested. If that person then runs talk, giving your username as an argument, you will both be connected in a talk session--the screen will clear and then what you type will appear on the top of the screen; what the other user types will appear at the bottom of the screen.

  • To request a chat with the user kat@kent.edu, type:

    $ talk kat@kent.edu RET

This command sends a connection request to the user kat@kent.edu. If the user is not logged on or is refusing messages, talk will output a message indicating such; but if that user is available, talk will send a message to that user asking to complete the connection, and it will tell you that it is ringing your party.

If that user then types talk stutz@dsl.org (if, in this example, your email address is stutz@dsl.org).

You can then type, and what you type will appear on both your screen and that user's screen; that user, in turn, can also type--even while you are typing--and what that user types appears on the other half of both screens.

It is standard practice to indicate that you are done saying something by typing RET RET, thus making a blank line on your half of the screen. Some users, when they have typed to the bottom of their half of the screen, sometimes type RET repeatedly to "clear" their half of the screen and bring the cursor back to the top.

Type C-c to end a talk session.

When you type, both users see the characters appear in realtime; my first demonstration of the interactive nature of the Internet, back in 1991, was when I had a live, real-time chat with a user in Australia, on the other side of the globe--the magic felt that day has never quite left whenever I run this command!

NOTE: A similar command, ytalk, allows you to connect to multiple users, and it contains other features as well; it is generally considered to be the superior successor of talk, but it is not yet available or standard on all Unix-based systems.

Chatting with Users on IRC

Internet Relay Chat (IRC) is a global chat system, probably the oldest and largest on the Internet. IRC is a great way to meet and talk to all kinds of people, live on the Internet; it has historically been very popular with Linux users.

There are several IRC networks, each with its own servers and tens of thousands of users; to "go on" IRC, you use an IRC client program to connect with an IRC server. Like CB radio, IRC networks have channels, usually based on a particular topic, which you join to chat with other users in that channel (you can also send private messages to other users).

The following table lists some of the IRC clients available for Linux.

CLIENT - DESCRIPTION

bitchx - BitchX is an IRC client whose features include ANSI color, so it can display all of the character escape codes that are popularly used on IRC for special effects. Despite what you might gather from its name, it doesn't require X in order to run. {@sf{Debian}}: `bitchx' {@sf{WWW}}: http://www.bitchx.org/

epic EPIC is a large, feature-filled IRC client. {@sf{Debian}}: `epic' {@sf{WWW}}: http://www.epicsol.org/

irssi A modular IRC client; note that some versions can only be run in X with GNOME. {@sf{Debian}}: `irssi' {@sf{WWW}}: http://irssi.org/

xchat Xchat is a graphical IRC chat client for use in X. {@sf{Debian}}: `xchat' {@sf{WWW}}: http://www.xchat.org/

zenirc ZenIRC is a minimalist, no-frills (yet fully extensible) IRC mode for Emacs. {@sf{Debian}}: `zenirc' {@sf{WWW}}: http://www.splode.com/~friedman/software/emacs-lisp/zenirc/


Chatting with Users on ICQ

@sf{WWW}: http://www.portup.com/~gyandl/icq/


In the late 1990s, a company called Mirabilis released a proprietary program for PCs called ICQ ("I Seek You"), which was used to send text messages to other users in realtime. Since then, many free software chat tools have been written that use the ICQ protocol.

One nice feature of ICQ is is that you can maintain a "buddy list" of email addresses, and when you have an ICQ client running, it will tell you whether or not any of your buddies are online. But unlike talk, you can't watch the other user type in realtime--messages are displayed in the other user's ICQ client only when you send them.

The following table lists some of the free software ICQ clients currently available.

CLIENT - DESCRIPTION

licq - Licq is an ICQ client for use in X. {@sf{Debian}}: `licq' {@sf{WWW}}: http://www.licq.org/

micq - Micq ("Matt's ICQ clone") is an easy-to-use ICQ client that can be used in a shell. {@sf{Debian}}: `micq' {@sf{WWW}}: http://phantom.iquest.net/micq/

zicq - Zicq is a version of Micq with a modified user interface. {@sf{Debian}}: `zicq'