Part 6: Some Essential Linux Applications




LINUX NEWBIE ADMINISTRATOR GUIDE
ver. 0.194 2003-06-04 by Stan, Peter and Marie Klimas
The latest version of this guide is available at http://linux-newbie.sunsite.dk.
Copyright (c) <1999-2003> by Peter and Stan Klimas. Your feedback, comments, corrections, and improvements are appreciated. Send them to linux_nag@canada.com This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0, 8 or later http://opencontent.org/openpub/ with the modification noted in lnag_licence.html.

Contents of this section:
6.1. Word processing
   6.1.1 StarOffice / OpenOffice Suite
   6.1.2 abiword
   6.1.3 kword
   6.1.4 klyx, lyx and latex
   6.1.5 WordNet (dictionary / thesaurus /synonym / antonym finder)
6.2 Spreadsheet
6.3 Databases
6.4 CAD
6.5 Web browsers: Mozilla, Konqueror, and Lynx
6.6 Writing CD-Rs: cdrecord and cdparanoia
6.7 Automating graphs with gnuplot


Intro. This part covers only application we frequently use or like. There are thousands of Linux programs. If you are unsatisfied with our lean choice, try: http://www.linuxapps.com/ or http://stommel.tamu.edu/~baum/linuxlist/linuxlist/linuxlist.html or http://www.boutell.com/lsm/ or http://www.linuxlinks.com/Software/

6.1 Word processing

6.1.1 OpenOffice.org /StarOffice Suite

OpenOffice is a complete office suite: word processor, spreadsheet, presentation program, drawing program, graphing module, and editor for mathematical equations.  It sports the best, and the most feature-packed word processor and spreadsheet for Linux.  Highly recommended.  OpenOffice is included on the more recent Linux distribution CDs (Nov.2002). The latest version can be downloaded (free) from http://www.openoffice.org/ (large, ~70 MB download, probably not practical with a modem). The current (non-developer) version of OpenOffice is 1.0.1  (Oct. 2002).  OpenOffice is cross-platform: it runs on Linux, MS Windows, Solaris, and Mac OS X, with full file-level compatibility.

Brief history. StarOffice used to be a commercial program ("Star Division", Germany). It was purchased by Sun Microsystems and the source code donated to the open source community under General Public Licence (Aug.2000).  It is being rapidly developed by programmers many of whom are still associated with / paid by Sun. The open-source version is called "OpenOffice.org".  Sun occassionally releases its own product based on a recent stable built of OpenOffice and calls it "StarOffice". Thus "OpenOffice.org" and "StarOffice"  are basically the same products, with some (minor) feature additions in StarOffice. OpenOffice is officially called OpenOffice.org because of some trademark issues.

Description. OpenOffice looks and acts very much like MS Office for Windows. This includes richness of features, large size (requires considerable amount of disk space, memory, and processor speed), and well-burried features (may require some careful mouse-clicking to access some items).  OpenOffice may not be worth your trouble without at least 64 MB of physical memory; the more memory the better. Open Office is very stable, although it sometimes displays weird artefacts ("ghosts") on my screen.  It has a good file-level compatibility with MS Office: read and write MS Word, MS Excel and MS PowerPoint file formats. Natively, it uses a ground-breaking xml open file format:  the text and pictures are zipped together into one file. When I unzip the file (unzip my_file.sxv), I can extract the original pictures--something MS Office cannot possibly do (with sometimes serious consequences for document management).

OpenOffice does not look as "sexy" as some other Linux office alternatives. Yet, it is a real productivity workhorse and its polish is rapidly improving. In brief, we highly recommend StarOffice/OpenOffice to cover even demanding office needs. Feature-for-feature, it matches almost anything found in MS Word or MS Excel, and adds some extras (long missing in MS Office).

Best of all, OpenOffice sports an open and beautifully designed file format which is rapidly becoming a standard (only unimaginative or corrupt decisions makers would insist on storing their data in a file format that can be read exclusively by a product of one company). This file format is suitable for serious uses because it can be parsed with third-party tools.

Installation. The installation of OpenOffice/StarOffice can be confusing. It goes like this:
- Make sure you have enough hard drive space. To check the space use the df (="disk free") command:

df -h

This displays a report on the used and available hard drive space in a human-legible form (option -h). At minimum, you need some 350 MB of free disk space (of which, ~100 MB you can release after installation).
- Decompress the downloaded file. I did it as root in the /usr/local directory for "local server" installation, but you may also choose /home/your_login for "personal" installation:

cd /usr/local
tar -xvf StarOffice5.2.tgz

Substitute the filename "StarOffice5.2.tgz" with the name of the file you downloaded.

- As root, run the setup program for a "local server" with the DOS-style /net switch:

cd /usr/local/OpenOffice641
./setup /net

[Without the "/net" or "-net" switch, OpenOffice will perform a personal installation (into your home directory!), and then only one user will be able to run it, plus your home directory will be clogged.]

- After this "network" installation, each user has to perform her own installation to put some personal files into their "home" directories. This is done by running (as a user, without the /net switch):

cd /usr/local/OpenOffice641
./setup

To run any of the OpenOffice component from the command line (in X terminal), I could use:

ooffice&     (word processor)
oowriter&    (same as above)
oocalc&      (spreadsheet)
oodraw&      (vector drawing program)
ooimpress&   (presentation program similar to MS PowerPoint)
oosetup&     (installation program)
oopadmin&    (printer administration utility)
oomath&      (equation editor, it is not typical to run it stand-alone)

Hints.  ooofice comes with a extensive, contex-sensitve help (press <F1>). Here, we are going to collect some quick reference on using oowriter (just started Nov.2002).

The most important are the paragraph styles. I use them to format chapter headings, captions, table headings, etc. To apply a style to a paragraph, I place the cursor in the paragraph to be modified, and then double-click on the name of the style in the "Stylelist". To modify a style (or create a new one), I use the menu "Format"-"Style-"Catalog".

Some useful keyboard shortcuts (most apply across the entire OpenOffice, not only the wordprocessor):
<Ctrl>x  Cut
<F1> Help
<Ctrl><Space> Non-breaking space
<Ctrl>c  Copy
<F2> Formula bar
<Ctrl><Shift>-  Non-breaking hyphen
<Ctrl>v  Paste
<F3> Autotext completion
<Ctrl><Enter> Manual (hard) page-break
<Ctrl>a  Select All
<F4> Data source view on/off
<Shift><Enter> Line-break without paragraph change
<Ctrl>f  Find (and replace)
<Shift><F4>  Toggle asolute-relative references in a spreadsheet formula.
<Ctrl><Shift><Enter> Manual column break (in multi-columnar document)
<Ctrl>z  Undo
<F5> Navigator on/off
<Insert> Insert/overwrite mode on/off
<Ctrl><Shift>p Superscript
<F7> Spellcheck
<Home> Go to beginning of the line
<Ctrl><Shift>b Subscript
<F9> Update fields (or recalculate spreadsheet)
<End> Go to end of the line

<F11> Stylist on/off
<Ctrl><Home> Go to beginning of the document

<F12> Numbering on/off
<Ctrl><End> Go to end of the document

Selection with mouse:
<LeftMouseButton>  Select text, cells, etc.
<Shift><LeftMouseButton>  Extend the current selection.

Dragging with Mouse:
<LeftMouseButton>  Drag the selection to move it.
<Ctrl><LeftMouseButton>  Copy the selection to the dragged location.  

Some codes used inside equations:
Element type
Example
Fractions
1 over {2+3}
{a + b} over {d + e}
Superscripts
a^2 + b^c = c^2
a^n a^m = a^{n+m}
Subscripts
a_1, a_2, ... a_n
K_r=K_0 e^{-E_a over {kT}}
Roots
sqrt  {a+b}
nroot 3 {a+b}
Greek letters
%alpha %beta %gamma %delta %epsilon %varepsilon %zeta %eta %theta %vartheta %iota %kappa %lambda %mu %nu %xi %omicron %pi %varpi%rho %varrho %sigma %varsigma %tau %upsilon %phi %varphi %chi %psi %omega newline
%ALPHA %BETA %GAMMA %DELTA %EPSILON %ZETA %ETA %THETA %IOTA %KAPPA %LAMBDA %MU %NU %XI %OMICRON %PI %RHO  %SIGMA  %TAU %UPSILON %PHI %CHI %PSI %OMEGA
Common relationships
=  approx equiv  def  sim  simeq  prop  <>  <  <=  <<  >  >=  >>  <>  dlarrow  drarrow  dlrarrow towards  parallel  ortho  leslant  geslant  transl  transr
Common operators
+   -  +-   -+  cdot  times  and  or  in  notin
Arrows
lefarrow  rightarrow  uparrow  downarrow
Other common symbols
infinity  emptyset
Sum and product
sum X_n
sum from 1 to n X_n
prod X_n
Integrals and derivatives
int f(x) dx
int from 1 to 2 f(x) dx
{partial x} over {partial t}

6.1.2 abiword

(type abiword or AbiWord in an X-terminal) AbiWord (http://www.abisource.com). It is a good light-weight wordprocessor. Really worth trying for simple word processing needs. Although still fairly light on features, it is quite useful to me, e.g. it supports spelling-as-you-type without the overhead of StarOffice. It is under heavy development and both versions for Linux an MS Windows are available.

6.1.3 kword

kword is still in developement and we would not recommend using it for anything important--it may crash.  However, it looks like the coolest office application of the three main (GPL) office suites. It is frame-based, like "framemaker" (hearsay, never used framemaker) which makes it easy to use and powerful for desktop publishing. Pretty feature-rich (certainly more features than in abiword).

To run kword in another language, I can do something like this (in X terminal, runs kword in the Dutch language):

exec sh -c "KDE_LANG=nl kword" &

Here is a list of some useful "standard" keyboard shortcuts. These shortcuts are used inside any kde-based applications (where applicable):
<Alt>  Access the top menu.
<Alt><a character>   Quick access to the items in the top menu. The character is the underlined letter in the menu name. For example (for the English-language menus):  <Alt>f -- "File" menu; <Alt>e -- "Edit" menu; <Alt>v -- "View" menu; <Alt>i -- "Insert" menu.  <Alt>o -- "Format" menu.
<Ctrl>x  Cut
<Ctrl>c  Copy
<Ctrl>v  Paste
<Ctrl>a  Select All

6.1.4 lyx and latex

(Type lyx in an X-windows terminal). lyx is a front end (WYSIWYG, running under X-Windows) for Latex. [There is also Klyx, which is a "K-desktop" variant of Lyx, but it is not updated any more.] Latex has for years been the heavy-duty document preparation and typesetting program, particularly popular in academia because it is good with equations, can handle very large documents, etc.

The good news is that even if you do not know what Latex is, you may still be able to use lyx. Think of lyx as a word processor, although its philosophy is different from that of other popular word processors, and therefore it may require an adjustment of your mindset. Latex (and lyx) philosophy is to type in the text, define the "styles" and leave the formatting to the typesetting program. This means you never adjust the spacing (between words, sentences, paragraphs, chapter, etc.) manually. When done with typing of your document, you "compile" your text to create a device independent file ("*.dvi").  The *.dvi file can be viewed using a dvi viewer and printed. The quality of the output is usually outstanding, but its creation process is typically somewhat more frustrating than using a regular word processor.

The strength of Latex is the excellent quality of the printouts, its capability to cope with long, complex documents (technical books, math, etc.), availability of all foreign characters and even rarely used symbols, its portability across many different platforms, and the popularity of the file format. Its weakness is the relative usage complexity.

lyx
is free and it is included on your Mandrake or RedHat CD for you to try. As almost any piece of Linux software, you can also download it from Linuxberg: http://idirect.linuxberg.com/kdehtml/off_word.html or any other fine Linux software depository on the Internet.

If instead of easier lyx, you wanted to try straight, hard-core Latex, here is some intro to get you started:
latex my_latex_file.tex
dvips my_file.dvi
dvips -o output_file.ps my_file.dvi

The option -o introduces the output file.
dvipdf my_file.dvi output_file.pdf
or
ps2pdf my_file.ps my_file.pdf
kdvi my_file.dvi&
or
kghostview my_file.pdf&

Here is my sample Latex file:
 
% Any line starting with "%" is a comment.
% "\" (backslash) is a special Latex character which introduces a Latex
% command.
\documentclass[10pt]{article}
\begin{document}
% Three commands are present in every Latex document. Two of them are
% above and one at the very end of this sample document.
This is a simple document to try \LaTeX. Use your favorite plain text
editor to type in your text. See how the command \LaTeX produces the
\LaTeX logo. Here is the end of the first paragraph.
Here starts the second paragraph (use one or more empty lines in your
input file to introduce a new paragraph).
The document class of this sample is ``article'' and it is defined at the
very beginning of the document. Other popular classes are ``report'',
``book'' and ``letter''.
Please note that the double quote is hardly ever used, utilize
two ` to begin a quote and two ' to close it. This nicely formats the
opening and closing quotes.
Here are different typefaces:
{\rm This is also roman typeface. It is the default typeface.}
{\bf This is bold typeface. }
{\em This is emphasize (italic) typeface.}
{\sl This is slanted typeface, which is different from the italic.}
{\tt This is typewriter typeface.}
{\sf This is sans serif typeface.}
{\sc This is small caps style.}
You can itemize things:
\begin{itemize}
\item one
\item two
\item three
\end{itemize}
You can also enumerate things:
\begin{enumerate}
\item one
\item two
\item three
\end{enumerate}
Try some foreign letters and symbols:
\aa \AA \o \O \l \L \ss \ae \AE \oe \OE \pounds \copyright \dag \ddag \S
\P. There are also three dashes of different length: - -- ---.
Try some accents over the letter ``a'': \'{a} \`{a} \"{a} \^{a} \~{a}
\={a} \.{a} \b{a} \c{a} \d{a} \H{a} \t{a} \u{a} \v{a}. Other letters can
be accented in a similar way.
The pair of ``\$'' marks a math context. Many special characters are
available only in the ``math'' context. For example, try the Greek
alphabet:
Small: $ \alpha \beta \gamma \delta \epsilon \varepsilon \zeta \eta
\theta \vartheta \iota \kappa \lambda \mu \nu \xi o \pi \varpi
\rho \varrho \sigma \varsigma \tau \upsilon \phi \varphi
\chi \psi \omega $
Capital: $ A B \Gamma \Delta E Z H \Theta I K \Lambda M \Xi \Pi P
\Sigma T \Upsilon \Phi X \Psi \Omega $
Try some equations: $ x^{y+1} + \sqrt{p \times q}=z_{try_subscripts} $
\begin{center}
$ \frac{x \times y}{x/2+1}=\frac{1}{3} $
\end{center}
\LaTeX math commands are very similar to those in the old ``Word Perfect''
equation editor.
Use the verbatim mode to print the 10 special symbols which normally have
special meaning in \LaTeX: \verb|%${}_#&^~\|. The special symbols must be
contained between any two identical characters which in the example above
is |. Most of these special symbols can also be printed by preceding the
character with a backslash: \% \$ \{ \} \_ \# \& \^.
% This command ends the document (this is the third one that *must* be
% present in every document).
\end{document}

6.1.5 WordNet (dictionary / thesaurus /synonym / antonym finder)

As a dictionary / thesaurus, I use WordNet (type wn in text terminal).  It did not come on RH 7.0 CDs, so I had to download (10 MB) and install it myself. Really worth it. Try: http://www.cogsci.princeton.edu/~wn/.  RedHat 8.0 came with wn pre-installed, and a GUI frontend to it:
ktheasurus&

6.2 Spreadsheet

oocalc&

I currently use the good spreadsheet called calc, which is part of OpenOffice.org. It can be run by clicking an appropriate menu item from your favourite desktop ("K"--"Office"--"OpenOffice.org Calc") or typing in an X terminal:
oocalc&

I am a very heavy spreadsheet user, so here are some other promising programs I keep my eyes on. In my opinion, Linux does not have an excellent spreadsheet program yet, but oocalc can do a lot.
Users can even define their own function in oocalc. For example, i can write in the editor ("Tools"-"Macros"-"Edit") such a function:

REM  *****  BASIC  *****
REM This function calculates an area of a donut with radii r1 and r2
Function my_function(r1,r2)

REM return the value using the variable called like the function
my_function=abs(pi()*r1^2 - pi()*r2^2)

End function

and then use it from my spreadsheet using something like:   =my_function(2;3)

Currently (Nov.2002, ver.1.01) oocalc supports 256 columns (A .. IV), 32000 rows (1 .. 32000), and up to 256 sheets ("sheet1", "sheet2", etc, named dynamically and be re-named). Work is in progress to increase the number of rows and columns. It has hundreds of build-in functions (covering compatiblity with anything found in MS Excel).

The user interface is sometimes awkward. For example, adding a new data series to a chart requires highlighting a spreadsheet range, and then dragging and dropping it onto the chart with a mouse.  Still, the chart component supports (for XY graphs) two Y axes, two X axes,  good selection of line types, bitmaps for data points, error bars, regression fits, etc.  Really powerful if you learn how to use it--to my taste too much of careful mouse clicking is required. I would really enjoy a giant dialog box with all the options for the chart typed into it for me to modify when required.

6.2.1 gnumeric

(in X terminal) Nice spreadsheet, part of GNOME, included with standard RH distributions (RH6.0 or higher). Although still fairly incomplete, it is quite usable.  Gnumeric is under heavy development and definitely has the potential to become really great in the near future--it already has a lot of built-in functions, but its printing is unreliable--major pain.

6.2.2 kspread

Kspread is another highly promising spreadsheet. It is part of the KDE ("koffice") since KDE2. Still not ready for a serious use.
Both gnumeric's and kspread's file format is xml (the already standard, next-generation, "enhanced html"). This file format is definitely good news if you ever experienced problems with the incompatibility of the MS-Windows-based spreadsheet file formats. Like html,  xml is legible to humans.  The spreadsheet files are compressed, so to view the contents on the console, I can do something like:  zless my_gnumeric_file.gnumeric

A comparison of the file sizes for a simple spreadsheet book (containing just one formula, copied 10 000 times) demonstrates that the human-legible file format is not necessary a liablity, and that MS Excel is bloated:
Gunmeric 1.09                    27,136
OOCalc 1.01                      57,756
kspread 1.2RC1                   90,560
MS Excel 2000                   549,888
QuattroPro 9 for MS Windows     155,648   

6.3 Databases

If you are a database person, you will be pleased to see that Linux is very well covered in this area.
postgreSQL is a high-powered database available on Mandrake and RH CD (free, unrestrictive BSD license).

mySQL http://www.MySQL.com/  GPL database, simpler and easier than postrgreSQL, yet very very capable. Favourite among many database developers. Like postgreSQL, mySQL is not meant to be just a personal database, and it may be hard to use it as such.

There are also commercial databases which are free for personal use, e.g. Sybase for Linux ( http://www.sybase.com:80/sqlserver/linux/aselinux_install.html ) and Interbase ( http://www.interbase.com/downloads/products.html).  There is also Oracle for Linux: http://platforms.oracle.com/linux/index_lin.htm. For an Oracle-Linux howto, see: http://jordan.fortwayne.com/oracle/index.html

6.4 CAD

QCAD (GPL): http://www.qcad.org (simple but useful for small drawing or learning)
OCTREE (free for non-commercial applications): http://www.octree.de/html/frames/eng/f_octree.htm
VariCAD (proprietary commercial, a free 15-day trial version available for download, geared towards mechanica design): http://www.varicad.com/
VARKON (LGPL): http://www.varkon.com/
Microstation (proprietary): http://www.microstation.com/academic/products/linux.htm--the academic edition of Microstation includes the Linux version of their excellent CAD system (better than AutoCad).

There is also something called "LinuxCAD" but it appears to be a rip-off (not recommended).

6.5  Web browsers: Mozilla, Konqueror, Galeon, and Lynx

All newer linux distributions (Nov. 2002) include as the main web browser "mozilla". Type in an X-terminal:

mozilla&

This is a state-of-art browser and one cannot wish for much more (except maybe some speed). It is a decendant of the famous Netscape.

Other choices for an Internet browser are: KDE-based konqueror and galeon.  I use galeon.

If your ISP connection is really slow, you may prefer a text-based browser:

lynx

Don't expect it to look as fancy a GUI-based browser-it is text-mode based. The good think about it is that it is always works and is fast. Great for a quick look at an html file.

On an older Linux,  you probably have installed a 4.xx version of Netscape ("a tried and true browser"). To run it, try (in X-terminal):

netscape&

To compose html pages (including this guide), I use mozilla (WYSiWYG view or code view), or netscape (WYSiWYG view or code view), or WebMaker (code view).

6.6 Writing CD-Rs: cdrecord and cdparanoia

Disclaimer: Copying copyrighted material is illegal. Do NOT use the  instructions below for anything illegal.

INTRO

Writing CDs used to be tricky, but these days I simply use (as root, in X terminal):

xcdroast &

If it works for you as it works for me, you don't need to read any further.
 
Perhaps still useful if xcdroast does not work on your system, here are the steps I once followed to write CDs using command-line tools. Please note that xcdroast is just a graphical front-end to the command line tools described below, so it will not work if the commands do not work. My only complaint s were that my low-cost, no-name "12x 8x 32x" CD-RW writes at top speed of 12x (for CD-R) but reads only at the speed of 2x (instead of 8x forCD-RW), and rips audio at 1x, no matter what I do.

SETUP

o
All setup has to be done as root. Newer distributions (e.g. RedHat 8.0) may require no setup at all.

o
Check your boot files if they pass a parameter to the kernel with the information that you have the ide-scsi drive: "hdb=ide-scsi". If required, add  to the file

/etc/lilo.conf  or /boot/grub/grub.conf (depending which boot loader your system uses):

the option "hdb-ide-scsi" so that the line looks like this:

append="hdb=ide-scsi"   #(for /etc/lilo.conf, at the end of the Linux "image" section)
kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda6 hdb=ide-scsi     #(for /boot/grub/grub.conf)

Adjust the line above if your CD writer is not "hdb" (second drive on the first IDE interface). It makes your IDE-ATAPI CD-W(R) to be seen on your Linux system as a SCSI device. (It is not really a SCSI device, it is an IDE device, it just pretends to be SCSI.) Run lilo after making any changes to /etc/lilo.conf . Grub does not need re-running.

o
Add the loop devices to the /dev/ directory if it is not present. This is not a obligatory, but a nice feature if you plan creating your own data CDs. The loop device will let you mount a CD image file (as if it was a already a filesystem) to inspect its content.  The loop devices don't exist on my hard drive after Linux RedHat installation, so I create them using:

cd /dev/
./MAKEDEV loop

o
Make sure that appropriate modules are loaded to the kernel using:

lsmod

If required, add these two lines at the end of the file /etc/rc.d/rc.local so that the needed kernel modules are automatically loaded on system startup:

/sbin/insmod ide-scsi
/sbin/insmod loop

These two kernel modules are needed for SCSI emulation of IDE drives and to support the loop devices, respectively.

o
Check, create or modify the device /dev/cdrom so it now points to the correct device , most likely:

ls -l /dev/cdrom
ln -s /dev/scd0 /dev/cdrom  #(if required)

You may need to do this because "/dev/cdrom" pointed to an IDE device (probably /dev/hdb) but now this changes since your CD-R is going to be in SCSI emulation mode.

There is also /dev/cdwriter that you may want to point to /dev/cdrom although it is not necessary on a single CD drive system:

ln -s /dev/cdwriter /dev/cdrom

o
Reboot so that the changes to /etc/lilo.conf take effect. Check if  your CD-R(W) still works properly for normal reading.

o
Check if the program cdrecord is installed, e.g.,:

cdrecord -scanbus

If it is not installed, download the program "cdrecord" from your favorite Linux software repository (e.g., http://idirect.linuxberg.com/ ). Then install the source code, compile it, install the program, and make symbolic links so that the executable are easy to run (the installation would be much easier if you found a binary *.rpm file):

cd /usr/local
tar -xvzf /the_path_to_which_you_downloaded/cdrecord-1.6.1.tar.gz
ls
cd cdrecord-1.6.1
make
make install
ls /opt/schily/bin/
ln -s /opt/schily/bin/* /usr/local/

The program cdrecord is a spartan, command line utility for writing CD. There are several GUI front ends to it, but they will be useless if the underlying cdrecord does not work properly. My advice: use command line for some time--you get to understand how things work, get flexibility, and reliable results. Then you can install GUI front ends to make CD covers, and make things easier for Windows-educated users on your system.

o See if your cdwriter is recognized. If it is, it should now show in the output from this command:

cdrecord -scanbus

CREATING DATA CDs

o
Create a CD image containing your data:

mkisofs -r -o cd_image input_data_directory

This makes an International Standard Organization (ISO) standard 9660-type filesystem containing the files from input_data_directory, but writes the filesystem to an ordinary file on the hard drive.  This output file is an "image" of the new CD which I am creating.  The option "-o" indicates that the parameter that follows is the  output filename of this image.  The option "-r" enables "Rock Ridge" extensions to the ISO protocol so that file attributes are saved, and it sets the file permissions so all the files on the CD are publicly readable (can be read by all user, not only the file owner).  The filenames are  abbreviated to the "8.3" DOS-type length but, since Linux supports so called "Rock Ridge" extensions to ISO9660, it also writes the full names and all the file permissions as well--this way the new filesystem is portable across all popular operating systems (DOS, MS Windows, Linux, UNIX, etc)--really convenient to the user.

The input data directory can be assembled from differenet directories and files from all-over your filesystem using symbolic links (saves harddrive space because the data is not copied), but if you do it you probably want to tell mksiofs to follow symbolic links using the option -f:

mkisofs -r -f -o cd_image input_data_directory_containing_symlinks

o
You may want to inspect the CD image file by mounting it through the loop device:

mount -t iso9660 /dev/loop0 cd_image /mnt/cdrom
[now the content of the file should appear in /mnt/cdrom]
cd /mnt/cdrom
[inspect the file mounted through the loop device]

When done with inspection, change your working directory away from the mountpoint and unmount the file:

cd
umount /mnt/cdrom

o
If everything worked, you may burn your data CD:

cdrecord -v speed=8 dev=0,0,0 -data cd_image

The first number in "dev=" stand for the scsi bus number (the first one is 0, second bus is 1, ...), device id on the scsi bus (between 0 and 7), and the scsi lun number (always 0) respectively. You must customize them: the first two numbers can be read in the output from cdrecord -scanbus, the third number is always 0. Make sure to use the correct numbers or you may write to a wrong drive and corrupt your data.

The timing of writing to CD-Rs is very important, or an error may occur (the laser cannot be switched on and off at will). Therefore avoid doing intensive tasks during creating a CD, e.g. don't create or erase large files on the hard drive.  My old system (RH6.2) will not permit me to start new tasks when using cdrecord .

In a similar way, I can burn a CD from an ISO CD image downloaded from the Internet. One source (a Debian FAQ) recommends the following command (as root) to burn the image "binary-i386-1.iso" to a CD:

nice --18 cdrecord -eject -v speed=2 dev=0,6,0 -data -pad binary-i386-1.iso

This assigns a very high priority ("niceness" of  minus 18) to the CD burning task (thus minimizing the possiblity of an error).

CREATING AUDIO CDs

o Audio tracks have to be in files of *.cdr (I guess it is the same as *.cdda.raw),  *.wav (wave), or *.au format before you can write them to a CD.

o
The utility sox converts between the various audio file formats (sox understands quite a few of them). For example, I can convert a .wav file to a .cdr file:

sox my_file.wav my_file.cdr

You don't need to do the conversions manually - cdrecord supports *.wav and *.au directly (it does a conversion from *.wav or *.au to *.cdr "on the fly").  This is very convenient because audio files tend to be large.

o Audio CDs don't contain a filesystem, they store "raw data". This means that you cannot mount an audio CD. Also, each track is written separately, i.e., as if it was a different "partition" on the CD.

o To read audio tracks from an audio CD and write them to suitable files on your hard drive (typical format is *.raw or *.wav) , you need a "cd ripper".  A popular CD ripper is "cdparanoia".
If cdparanoia is not installed, download it. The installation from source goes as follows (I use the autocompletion <Tab> shortcut when typing the long filenames):
cd /usr/local
tar -xvzf /the_path_to_which_you_downloaded/cdparanoia-III-alpha9.6.src.tgz
ls
cd cdparanoia-III-alpha9.6
./configure
make
make install
To rip the first track from an audio CD, I can use:

cdparanoia 1

which will put the first track from the CD into the wave file "cdda.wav" in the current directory.

To rip tracks 1 to 2 from an audio CD to a "raw" file format, I can use:

cdparanoia -B -p "1-2"

The option -B specifies to use a "batch" mode, so that each track is put into a separate file (this is probably what you want, otherwise all tracks would be placed in one output file).  The "-p" option specifies output in raw format. The files are named track1.cdda.raw and track2.cdda.raw .
To rip all tracks from an audio CD, each track to a separate *.wav file, while forcing reading speed 4x, I can use:

cdparanoia -S 4 -B "1-"

Make sure you have sufficient free space on your hard drive. You can use use the space on your DOS partition (if you have dual boot).

o
To write suitable audio files to a CD-R(W), I can use:

cdrecord -v speed=8 dev=0,0,0 -pad -dao -audio track*

o
Some audio CDs do not have gaps between individual audio tracks. The easiest way to make a copy of such an audio cd, is to use the utility "cdrdao".

To copy a disk to the file "data.bin" (on my harddrive), and the table of contents to the file "toc-file.toc", I can use this command:

cdrdao read-cd --device 0,0,0 --buffers 64 --driver generic-mmc-raw --read-raw toc-file.toc


To burn the CD from the files I just created, I can use:

cdrdao write --device 0,0,0 --buffers 64 --driver generic-mmc --speed 12 toc-file.toc

o
Note on re-writeable CDs. Some stereos will not play re-writeable CDs because of the size of the pits on the CDs. For example, my home stereo (JVC) cannot read re-writable CDs (CD-RW) at all, although it will read write-once disks (CD-Rs). Therefore, re-writable CDs may be good to store data but not audio (unless I plan to play them exclusively on my computer).

CREATING MIXED-MODE CDs

Mixed-mode CDs (meaning CDs which contain both data and audio, often game CDs) are not a problems, e.g.:

mount -t iso9660 /dev/cdrom /mnt/cdrom (mount the data part of the mixed-mode CD)
mkisofs -r -o cd_image /mnt/cdrom (make an ISO filesystem from the data on the CD).
umount /mnt/cdrom  (unmount the CD)
cdparanoia -B "2-" (rip the content of all audio tracks on the CD, except the first track since it is data)
cdrecord -v speed=2 dev=0,0,0 -data cd_image -audio track* (write the data and audio files, piece by piece)

MAKING A COPY OF THE ENTIRE CD

Most CDs can be copied by first copying all data (for data CDs) or all tracks (for audio CDs) onto the hard drive as described before, but some CDs cannot.

For example, these kinds of data (not audio) CDs need to be treated differently: bootable CDs (like Linux installation CD), CDs that require the label, disk with errors, etc.  For data CDs,  I use these commands to make an exact copy:

dd if=/dev/cdrom of=cd_image
cdrecord -v speed=2 dev=1,0,0 -data cd_image

The dd command copies the input file (if), which in this case is the device /dev/cdrom to the output file (of) which in this example is a file called cd_image (on the hard drive in the current working directory).  The second command copies the file cd_image that was created by the dd command onto an empty CD.
For data disk with error, you might want to try:

dd conv=noerror,notrunc if=/dev/cdrom of=cd_image
cdrecord -v speed=2 dev=1,0,0 -data cd_image

The option "conv=noerror,notrunc" specifies that the potential read errors are to be ignored, and files not truncated on error.
For audio CDs, I use these command to make a copy:

cdparanoia -B "1-" (rip the content of all audio tracks on the CD, from track 1 on. The tracks are saved into files in the current directory and named: track01.cdda.wav, track02.cdda.wav, etc.)

cdrecord -v speed=2 dev=1,0,0 -audio track* (write all the audio files to the CD, one by one. The tracks are separated by a 2 s gap).

To copy an audio CDS in the most acurate way, man cdrecord recommends doing this:

cdda2wav -v255 -D2,0 -B -Owav
cdrecord -v dev=2,0 -dao -useinfo  *.wav

To make an exact copy of mixed mode CDs:

dd if=/dev/cdrom of=cd_image (The dd command will output an error message when the the data has ended and audio started. This is expected and ok).
cdparanoia -B "2-" (rip the content of all audio tracks on the CD, except the first track since it is data)
cdrecord -v speed=2 dev=1,0,0 -data cd_image -audio track* (Write the data and subsequent audio files, piece by piece.)

RE-WRITABLE CDs

Re-writable CDs (CD-RW) are used the same way as regular write-once CDs (CD-R), but you have to blank re-writable disks before you will be able to re-use them, e.g.:

cdrecord -v speed=2 dev=1,0,0 blank=fast

To see other (more thorough and slower) options for blanking, use:

cdrecord blank=help

For example this thorough blanking can take 0.5 hour on my system, but is not really necessary unless the old data is confidential:

cdrecord dev=0,0,0 blank=disk

Again, older stereos often will not play CD-Rs.

SIMPLIFYING LONG COMMANDS WITH AN ALIASES

To simplify writing long commands required by cdrecord (or cdrdao),  I may want to define a global alias by placing the following line in the file /etc/bashrc:
alias cdrecord="cdrecord -v speed=2 dev=1,0,0"
Re-login for the changes in /etc/bashrc to take effect. After creating this alias, I can record a CD using the following shortened command (no need to specify the CD writer speed and device name all the time):
cdrecord -audio track*

6.7 Automating creation of graphs with gnuplot

gnuplot is good for automating generation of graphs for numerical data and/or mathematical functions. For "interactive" generation of graphs, I prefer any spreadsheet. As old-fashioned as gnuplot may look, it can be quite handy if you want to periodically re-generate a graph or visualize (for inspection) massive amounts of data from a graph "template". gnuplot is flexible (many options available, including 3d plots) but one needs to take your time to learn it. Setting up a complex graph can take me 2 hours (but it's ok, if the graph is to be re-used many times over). The best help is to start gnuplot, and on the "gnuplot>" prompt, type "help".  gnuplot is available for Linux and MS Windows.

My data sets are stored in text (ASCII, *.dat) files. My "graph templates" are stored in gnuplot "command" files (*.gnu).  The output goes to a graphics file (*.png) which can be printed or imported to any word processor.
 
To generate a graph from an example gnuplot command file "make_graphs.gnu", I can do:
gnuplot make_graphs.gnu

To display the graph, I would do (in X terminal):

display my_graph.png

My example  "make_graphs.gnu" that generates an x-y graph follows.


# Comment are introduced with the hash (#)
# Stamp the graph with the current date and time
set timestamp "%Y-%m-%dT%T%z"
# This sets the graph resolution (the default is 100)
set samples 600
# Save the plot to a *.png file (make it colour)
set output "my_plot.png"
set terminal png color
#interesting terminals: png, x11, postscript, postscript eps, hpgl
set title "My Graph"   # Graph title
set xlabel "Distance [m]"      # title of x1 axis (bottom)
set x2label "Distance [feet]"  # title of x2 axis (top)
set ylabel "sin meters"        # title of y1 axis (left)
set y2label "log feet"         # title y2 axis (right)
set xtics  # control major tic marks on the axis
set x2tics; set ytics; set y2tics #commands can be separated with semicolons
set mytics # control minor tics on the axis, here I add them to the y axis
set xrange [0:15]          # Range for display on the x1 axis
set x2range [0:15.0/0.305] #Expressions are ok. This one converts meters to feet.
set yrange [*:*]           # The "*" sets the range to auto
set y2range [*:*]          # Range for the y2 axis
set nologscale  # or "set logscale x1x2y1y2" #Control logscale, linear scale is the default
set nogrid      # or "set grid" #Control gridlines, no grid is the default
set key outside # or "set nokey" #Control legend and its positions: "top", "bottom", "left"
# The following line creates the plot with 4 graph series
plot sin(x) axes x1y1, log(x) axes x2y2, "data.dat" using 1:2, \
   "data.dat" using 1:3
# Long lines can be split with \
# The third series uses columns 1 and 2 from the file
# The fourth plots the 3 column agains the 1st column from the data file.

Goto part 7: Learning with Linux