Chapter 9. Linux Overview

This chapter describes some GNU/Linux fundamentals and tries to teach by example some basic things you need to know in order to use a GNU/Linux system, eg how to edit a configuration file, or print something. It also teaches you about some useful commands and concepts. It is written assuming that you are running an ARMLinux desktop system, but largely applies eqully to any desktop system. If you have not used GNU/Linux much or at all before then this chapter will be very useful. Although written from a desktop perspective, some of the info here is relevant to small ARMlinux systems too.

Logging in

Afte installing GNU/Linux, either on the desktop, or on a target device and booting up, you should be met by the following:

armlinux login:

If this is the first time that you have logged in, then you will have to initially log in as the root user which is accomplished by typing root before pressing Return.

You will then see that the prompt is represented by a hash sign (#) which means that you are looking at the root prompt. In contrast, the prompt for non-root users is usually represented by a dollar sign.

[root@armlinux /root]#

or for the non-root user:

[paulw@armlinux paulw]$

Although it is possible to work with your new Linux system at this stage, we would advise you to immediately refer to the section called Accounts for the specifics of creating a user account.

The Shell

As a new ARMLinux user, you will have to get to grips with the UNIX command prompt although memory-efficient GUIs like fvwm are available. Regular users of Linux call this prompt a shell and it is the means by which you can communicate with the kernel. In fact, the shell is a program which you can use to do all your Linux work if this is what you desire. Because Linux has been developed by a range of people with different interests and needs, it is not surprising that there are a range of shells that you can choose from. Examples include the Bourne Again Shell (Bash) and the Korn Shell (ksh). To find out the name of your current shell type the following command at the prompt:

echo $SHELL

If the response is: /bin/bash then your default shell is bash. Bash is a good shell to learn both because it is installed by default on many Linux distributions and because it has a range of features which you will learn to use as your Linux experience increases. It can also be a good idea to learn how to work with a second shell in case you ever have to use a machine that is not running Bash.

Simple Commands

There are also a number of simple commands that you can employ to do useful work on your Linux system like those which are shown in Table 9-1.

Although we list a range of options which you can use with these commands, you should learn how to refer to the UNIX manual pages for a definitive explanation (see the section called Help!).

Change Directory

The cd command allows you to change directory. To change to the /home directory, you would therefore type cd and /home at the command line.

cd /home

Print the Working Directory

You can also find out the location of the current directory as an absolute path from root by using the pwd command to display the result on screen. Our example consequently shows that we are currently in the /home directory.

pwd
/home

Move Files

The mv command is used to move a file or directory from one place to another. The file sample.txt can therefore be moved into your /home directory by issuing the following command where the tilde (~) represents /home.

mv sample.txt ~

mv can also be used to rename a file. To change sample.txt's name to final.txt and move the renamed file to the /home directory, enter the following command:

mv sample.txt ~/final.txt

Copy a File

cp is very similar to mv in terms of the way in which you use it. One notable difference is that cp leaves the source file in situ whilst copying the file to your intended destination.

cp sample.txt ~/home

Tip: cp is also used to copy directories including their contents. If you need to do this, issue the cp command in conjunction with the -R option before typing the names of your source and destination directories.

Delete a File

The rm command is very easy to use although it is extremely easy to delete files unintentionally! We therefore advise you to use the -i option so that Linux confirms your intentions before taking any action.

rm -i sample.txt

Make a directory

You can use the mkdir command to create directories and sub-directories. Creation of a directory therefore involves typing the command and the name of your proposed directory whereas the creation of a sub-directory depends upon the -p option.

mkdir work

mkdir -p /work/paul

Delete a Directory

It's easy to delete an empty directory with the rmdir command. If we assume that the pleasure directory is empty, the next command removes it from our system.

rmdir pleasure

Tip: You should use the rm with the -R option to delete a directory which contains files.

The Filesystem

In order to provide you with a working knowledge of the Linux filesystem, the following topics will be introduced in this section.

  1. The Linux Root Filesystem

  2. Permissions

  3. Alternative Filesystems

Overview

The filesystem is made up of files and folders or directories. The top level folder is called the root folder and contains all of the files that are pertinent to your system. Each file within this system is allotted a name and a path on the basis of where it lies in relation to the root folder. Thus a sample file -alephlinux.txt- may be found at /home/letters/alephlinux.txt where the forward slash "/" before home denotes root.

Important: The new user must also appreciate that the filesystem is case-sensitive and therefore distinguishes between ALEPHLINUX.txt and alephlinux.txt.

Linux also provides support for long filenames although you should avoid the use of symbols like "@" within filenames, as they are used for other purposes.

The Linux Root Filesystem

The following schematic provides a simple representation of the most important directories and files which make up the root filesystem whilst the subsequent sub-section provides a brief description of the filesystem's structure. For more information about the root filesystem, enter man hier at the prompt for a full description.

Directories

/usr

Contains files and sub-directories which may be shared between machines. Important sub-directories include:

  • /usr/lib which contains programming and language libraries

  • /usr/local which provides the location for user-specific programs and files

  • /usr/include for C #include files

/etc

all configuration files should be in here (often in subdirectories)

/home

contains home directories for all users on the system. /home/paul would therefore be the home directory for user paul.

/bin

contains fundamental executable files (commands or programs) used by users. Only the basic ones are here, most are in /usr/local/bin, but usually a user doesn't care where the executable is actually stored. which <commandname> will tell you where an executable actually resides.

/sbin

includes executable files which are for system administration, as opposed to programs used by users. An example of this would be the shutdown command which closes the system down properly.

/mnt

location for mounting filesystems. For supplementary information, consult the section called Alternative Filesystems

/tmp

a directory which provides the temporary location for different programs. /tmp files tend to be deleted when the system is re-booted.

/dev

contains special pseudo files which give access to devices like the keyboard - /dev/kbd - and the virtual terminals - /dev/console, /dev/tty0 and /dev/tty1.

/var

a directory which contains files which can grow through usage. Typical examples include email message files and system accounting files.

  • /var/adm for per-process accounting records

  • /var/tmp for temporary files which are not deleted at re-boot time.

  • /var/spool for running system processes. /var/spool/mail would be a typical file in this sub-directory

Permissions

Although you should now have some appreciation of the Linux filesystem it is important to realise that Linux can be used in a multi-user or networked environment. It is therefore sensible to learn about the various types of role and permission which can be associated with a file so that the file owner can decide exactly who has access to files.

Any user may consequently fit into any one of three roles which include:

  1. the ownership role

  2. the group role

  3. the other role

The owner of a file can change file permissions at will. Moreover, a file may be associated with a group which is useful in a collaborative project context in which file access can be restricted to group members. Finally, the other role applies to a user who is neither the owner of the file nor the member of the group which is associated with the file.

In a similar vein, for every Linux file, three types of permission can be applied to each of the three roles. These permission switches are as follows

  1. R (Read): enables the user to read files, or (for a directory) to list files on the system

  2. W (Write): allows for the alteration or deletion of files, or (for a directory) deleting, adding and renameing of files

  3. Execute (Execute): allows for the execution of a file where it is an executable or for changing directories.

In order to clarify matters, this information can be most effectively presented in tabular form. Note that a dash in the line of text denotes the absence of a permission whilst r, w or e indicates that one of the three types of switch is activated.

Table 9-3. Permissions by Role

OwnerGroupOther
r w xr w xr - x

To illustrate all of the above, consider a situation where we want to know the permissions which apply to a particular file. After invoking the ls -l <filename> command, our hypothetical output might look some thing like the following:

—rw—r——r—— 1 paul paul 388 June 10 09:30 notes.txt

Reading across the listing from left to right, the first character position show the file's filetype which in this example is a normal file. Other possibilities include:

  1. d for a directory

  2. c for a device

  3. b for a socket

  4. s for a pipe

The remaining nine bits apply to the user, group and other roles respectively with three bits being alotted to each of the roles. Thus our hypothetical output shows that the user has read and write permissions whilst the group and other roles have read permission only. Note also that a dash denotes the absence of a permission.

If however, it becomes necessary to change file permissions, this can be accomplished by:

  1. setting file permissions with octal numbers

  2. setting file permissions with a combination of symbols

  3. setting the setuid, setgid and sticky bits

To alter a file's permissions with numbers, Linux uses four numbers which determine permission types including:

  1. 4: read permissions

  2. 2: write permissions

  3. 1: execute permissions

  4. 0: no permissions

Therefore, to alter the permissions status of our hypothetical file so that the group has read and write permissions, we would add 4 (read permission) and 2 (write permission) together before issuing the following command:

chmod 664 notes.txt

The following table summarises the situation thus far:

Table 9-4. Permissions by Numbers

RolePermissionCalculation
Owner64+2+0 (r+w+e)
Group64+2+0 (r+w)
Other44+0+0 (r)

In a situation where it is necessary to set permissions one role and one permission at a time, the symbolic permission notation can be used. In order to make use of this facility, the user need only remember that permissions may be granted or denied by using the following three symbols in conjunction with the read, write and execute switches that we have already encountered:

  1. u signifies the user/owner role

  2. g represents the group role

  3. o signifies the other role

Therefore, in order to allocate a group read and write permissions for the file notes.txt using symbolic notation, the user could enter the following command:

chmod g+rw notes.txt

Because many permutations are possible when using this method, the table below gives some indication of how permissions may be alterred. Note that "+" means that permission is granted whilst "-" shows that permission is denied.

Table 9-5. Permissions by Symbols

Granted/DeniedPermissionsString
user, group, otherread, write, executeugo+rwx
user, group, otherread, write, executeugo-rwx
user, groupread, writeug+rw
user, groupread, writeug-rw
userreadu+r
userreadu-r

Of course, there is much more that could be said about permissions but for further details on the specifics of topics like sticky bits, shadow passwords and filesystem maintenance, consult the relevant man page. Refer to the section called Help! for advice on using man.

The important thing to remember is that if you are having a problem with missing files or some other mysterious error, it is very often due to incorrect permissions somewhere in the system. Always remember to check.

Alternative Filesystems

ARMLinux can similarly make use of a range of filesystems in addition to its own Second Extended filesystem (ext2fs).

Under Linux the user will however have to mount a device before it can be accessed and used. This is done with the mount command but you will initially have to edit the /etc/fstab file as the root user in order to avail of this facility. This file is also used to specify which filesystems should be mounted automatically at boot time. To edit this file - which is just a text file - use Vim to open the file with the following command:

vim /etc/fstab

If your file doesn't include a line like the following:

/dev/hda1     /adfs     adfs       noauto,user   0   0

then you should add one in order to be able to read your RISC OS drive from ARMLinux. Note that if your RISC OS drive is RISC OS 4 with long filenames then this is not supported at the time of writing so you can skip this section. The format of this file is explained in man fstab.Save and quit by depressing the ESC key, waiting for a beep and then typing :wq /etc/fstab. Where this line is missing, type it in from scratch noting that there should be no spaces between noauto any punctuation and user. if you want this drive to be automatically mounted on boot then change the final 0 to a 1. You will then need to make a mount directory.

mkdir /adfs

Congratulations, you are now in a position to mount your RISC OS filesystem with the following command:

mount /adfs

You can now access your files from the /adfs directory.

Debian Package Management

In order to take full advantage of Debian, you need to learn a little about the package management system which underpins it. Debian packages everything in .DEB files. These packages are controlled by a program called dpkg, or from a friendlier front-end such as dselect or apt. The system is extremely powerful; every file on your system is known about by the system and it takes care of a great deal of complexity when installing, removing or upgrading software. It knows about the interdependencies between pieces of software and if you ask to install something it will also get the other things it needs. It knows which files are configuration files and will not overwrite them when upgrading a package. It can also upgrade a running system without breaking things and lets you find out what is on your system. To a large extent the package management system is what makes Debian special and once you understand it you will find it a marvellous facility.

dselect is the interface that you will first use. It was designed when Debian had 500 rather than 5000 packages and suffers a bit because of this, but it is quite straightforward to use and a good introduction to the package system. Later you will just use apt to install new software. Once apt has been taught where to get software (usually off the CD and off the net) you can say things like apt-get install <software> and it will go away and get it for you, then install it, install anything else necessary and configure them all, often without asking you any further questions apart from telling you which CD to insert or if the download size is OK.

It is important to understand however that if you want to install software that is not in the Debian archive then everything is not taken care of for you and you will have to understand what is going on and do some work yourself. For example, if obtaining a package from a distribution which is meant for x86-based PCs, you will have to compile it from source as the binary versions supplied will not work on an ARM-based machine. Such a procedure is outside this manual's scope but - assuming that you want to use a package which is on the ARMLinux CD or in the huge Debian archive - read on!

dpkg can for example be used to install a package by using the i (or --install) switch.

dpkg -i /cdrom/debian/dists/potato/main/binary-arm/utils/mc<TAB>

Note that the <TAB> above means press the TAB key, not type in those letters. This uses the shell's filename expansion facility to fill in the end of the filename. It's a marvellous facility. If it beeps then there is more than one possible answer - press <TAB> again to see the list. It even works on commands.

However, it is standard practice to use apt instead to save typing long pathnames, like this:

apt-get install mc

Here apt knows where to look for packages, finds mc and then uses dpkg to actually do the installation, but saves you worrying about the actual location of the package.

What you have just done is to use dpkg to install Midnight Commander (mc) - a visual shell which does not need X Windows - on your system. Conversely, you may choose to delete or uninstall a package which can be accomplished by using the -r (or --remove) switch. The following command consequently removes mc.

dpkg -r mc

Don't be too hasty however. MC is an excellent way of navigating the filesystem when used in conjunction with the shell. So why not learn a bit about it before using dpkg's -r switch?

Congratulations, you've managed to mount your filesystem and have a look at some files. Before removing your CD-ROM, you will need to use the umount command which can either be used to unmount the current filesystem or a specific directory. But please be careful with your typing and key in umount rather than unmount. If it tells you that the filesystem is busy then your current directory is probably in the mounted filesystem. You need to change directory elsewhere before you can umount.

umount /dev/cdrom

or

umount /cdrom

In order to find out about other filesystem types and the specifics of the mount and umount commands, you can take advantage of the range of commands and applications which are briefly described in the section called Help!.

Help!

If you are an experienced Linux user, enter the following commands before proceeding to the next section. If you are a beginner, move swiftly on to the next paragraph!

updatedb

/usr/sbin/makewhatis

If you are a newbie, you will be a little perplexed by all the unfamiliar terminology. If this is the case, don't despair. Linux is very well documented and you can access all this information by taking a few preliminary steps. At the prompt enter the following command:

updatedb

This command updates a database of filenames which you can then search by typing in the locate command with your filename as the command's argument. The experienced user can of course enter special characters - called metacharacters - as opposed to a text string in order to generate a more sophisticated search but a discussion of this technique is outside the scope of this manual. For further details take a look at the updatedb man page as well as the man pages for locatedb, locate, find and xargs. Remember however to update the filename database regularly if you are continually producing new documents. If your machine is left on overnight it will automatically do this itself.

You can of course make use of a further command which you can again enter at the shell prompt (and as root):

/usr/sbin/makewhatis

What you have just done is to build the whatis database which contains information that you can now access to improve your skills. This process may take a few minutes but when it is completed, you can read the UNIX manual pages on any subject that you want. To make use of man, type the man command with the topic area as man's argument at the shell prompt. You can then scroll through the manual by pressing the space bar as a prelude to leaving man by typing q for quit. The following command consequently takes you to that part of the UNIX manual which is concerned with Groff - a document formatting system which many people use as an alternative to a word processor:

man groff

But how can you use man if you don't know the name of the command which would meet your requirements? Well, help is available with the apropos command. To use apropos, simply type the name of a keyword that is applicable to your interests after the apropos command (it is this indexing ability that the whatis database is used for). In order to find out about the editors which are available on your system type:

apropos editor

You may also see man -k mentioned - which is exactly equivalent to apropos (use whichever command you prefer) - as well as the whatis command. Whatis is particularly useful if you have heard about an application and require a simple one line description. If necessary, you may also take advantage of the built-in help facility which comes with many commands by typing the name of a command, a help switch, the pipe character and less to signify the less pager which allows you to view information one screen at a time.

man --help | less

Alternatives to both man and the apropos command include the info pages, the manuals of the Linux Documentation Project which can be downloaded from (http://www.linuxdoc.org/) and a selection of HOWTO documents which are available on the Aleph ARMLinux CD and can be read through a web browser like Lynx.

Accounts

You may also need to create a user account if you have not done this already. It is important to do this because the root account gives you access to all files on your system. What this means is that a few careless strokes on the keyboard whilst you are logged in as root could result in an unusable system (rm is a potentially disastrous command to use although its effect can be lessened with the -i switch). In your early adventures with ARMLinux it would therefore be better if you learnt about your system from the relative safety of a user account. To create a user account, follow the instructions below:

Login as root,
or 
su root
if logged in as an ordinary user,
type 
adduser fred
at the prompt where fred is our hypothetical user, 
You will be asked to set a password, (which can be done for an existing user with the 
passwd command)
and follow the instructions.

Assuming that you are logged in as root do the following:

adduser majcon

Linux will set up the new user with a password, user id, a group membership (id) and a login name, home directory and mailbox. You can then enter the password twice as instructed.

A detailed discussion of Linux systems administration is outside the scope of this manual but consult The Linux Systems Administrators' Manual which is available from http://www.tcm.hut.fi/~viu/linux/sag/ for more information. What you must remember is that your password must be as ingenious as you can make it if you wish to avoid the possibility of your files being read by a stranger. Your password should make use of a mixture of upper and lower-case letters as well as numbers and symbols. But again, be sure to remember what you have actually typed!

You might think that this discussion of user accounts is not really relevant to you but it becomes an important consideration when your ARMLinux machine is being used concurrently by other users in a business or educational setting.

Editing

Because of the many uses to which ARMLinux can be put, it would not be practical in a short manual to provide a description of the rudiments of every program. We have therefore limited ourselves to an introductory treatment of text editing because this is a task which any user will need in their ARMLinux career.

There are literally hundreds of editors available including Vim, Jed, Joe and Emacs. Jed is a nice full-screen editor which is somewhere between MS DOS's Edit and Emacs whilst Joe will be appreciated by those who are used to the old Borland/WordPerfect control-key settings. Emacs, in contrast, has many of the characteristics of a complete working environment because it allows the user to do everything from writing letters to surfing the net. You can even play games within Emacs or indulge in a bit of psychotherapy by using the doctor package! We have not however, provided an Emacs tutorial in this guide so interested readers should refer to the section called Reading List in Chapter 12 or to http://www.gnu.org/manual/emacs-20.3/emacs.html/ where you can find a comprehensive Emacs guide.

Tip: If you decide to learn Emacs, you may see references to the META key in the Emacs literature which is equivalent to the ALT key on most keyboards. If you can't use ALT (it often doesn't work in terminals, for example) then you can use ESC to do the same job, but it should be released before the next keypress, not held down at the same time as it.

This section introduces you to:

  1. ae - the standard, tiny editor.

  2. Jed - a modeless editor which users of StrongED and Zap will find very accessible.

  3. Vim - an extremely powerful editor which can be found on all UNIX-like operating systems.

Editing with ae

ae can be activated by typing:

  1. ae at the shell prompt

  2. ae <filename> where you wish to work on a pre-existing file.

Two screens will then appear: an editing screen into which you can type and a help screen which provides a selection of useful commands. If you have used ae before, you can toggle the help screen on and off by typing C-x+C-h.

ae operates, like many Linux editors, via a series of control characters. C-x therefore instructs the user to depress the C (Ctrl) and x keys at the same time.

Typing a non-control character consequently has the the effect of placing the character which you have typed at the cursor. When you have finished your work, type C-x+C-s to save the current file to disc or C-x+C-c to save and exit.

ae is therefore very easy to use although its simplicity conceals a number of sophisticated features which include:

  • The ability to work with multiple buffers by using a root buffer and a series of virtual folds which correspond to the files to be edited.

  • User configurable key bindings.

For further information on ae, visit the editor's home page at http://www.interalpha.net/customer/nyangau/ae/platform.htm/.

Editing with Jed

Jed can be driven from a series of menus or with a combination of shortcuts. Jed is a modeless editor which means that you do not have to be in different modes to edit or insert text. Jed is also very easy to use and offers a range of facilities which include:

  • Colour syntax highlighting which can be useful for debugging your documents.

  • Special features which are activated on the basis of filetype.

  • Extensibility via the C-like S language.

Jed can be invoked by typing:

  1. jed at the shell prompt.

  2. jed <filename> at the shell prompt where you wish to edit a specific file.

  3. C-x+C-f in the mini-buffer. If you choose this command, you will see Enter Filename in the mini-buffer.

In addition to commands which begin with the Ctrl character, Jed also uses the ESC key for a number of commands. ESCn therefore means that you should press ESC before releasing it and pressing key n.

Assuming that you are working on the file readme.txt, type jed <readme.txt> at the shell prompt. You can then insert and edit text and move around the document by using the arrow keys. When you have finished the session, type C-x+C-s to save your document to disc. You can then exit from Jed by typing C-x+C-c.

The Jed screen contains a number of features which may be unfamiliar to you. These are:

  1. A Menu Bar across the top of the screen.

  2. A Mode Line containing useful information.

  3. A Mini-Buffer which is below the Mode Line.

The Menu Bar contains the menu options which you can use as an alternative to the keyboard shortcuts. To activate the Menu Bar, press the F10 key and select the menu which you require by using the arrow keys. The menu options should be self-explanatory with the possible exception of the Buffers option. A buffer is essentially a temporary workspace inside which you perform your work until you save any changes which are then written to the file.

In contrast, the Mode Line provides information about the document which you are currently working on. If you can see two asterisks (**) on the extreme left of the mode line, this is an indication that you have made changes to a document which has not been saved to disc. The mode line also tells you where you are in the document in terms of a line number as well as giving an indication of the current editing mode. Editing modes essentially help you to efficiently edit your documents by activating features like syntax colouring and specific formatting styles.

Finally, the Mini-Buffer is located below the Mode Line and echoes commands back to the user. Try keying in C-x+C-v to find an alternative file and you should get the idea but remember to hit the Return button after you have finished typing.

You should now know enough about Jed to perform simple editing. Jed also comes with its own form of on-line Help which can be activated by pressing C-h+C-h. A number of useful WWW resources are also available so point your browser to http://space.mit.edu/%7Edavis/doc/jed.html/ and http://www.geocities.com/mmarko.geo/jed/ Finally, take a look at Appendix A which lists some useful Jed commands. Please be aware however that the table uses commands which assume that Jed is using Emacs keybindings.

Editing with Vim

Vim is another editor which you can learn how to use. Vim also comes with an excellent tutorial which you can avail of by typing the following command at the prompt:

vimtutor

You can also save a bit of typing by using the filename completion facilities of the Bash shell. Simply type vim/usr/doc/vim and then press <TAB> so the shell fills in the remainder of the directory name, then you can enter the tutor and press <TAB> again to get the rest.

The tutorial will open from within Vim and you will then be able to learn enough to perform most of your editing activities. But just in case you want to familiarise yourself with Vim without recourse to the tutorial, what follows is an introduction to the editor's capabilities.

Vim is a modal editor which means that there are different modes for performing different tasks. Vim consequently operates in command mode when commands are being issued or in insert mode when text is entered on the screen. Although the method of issuing commands with a key press may seem counter-intuitive and positively archaic in comparison with more conventional point-and-click methods, it is actually a very efficient method of working and should be perservered with if at all possible.

In order to become conversant with Vim, we therefore suggest that you learn a few new commands per day and practice! Appendix B lists some of the common commands that you are likely to need.

Note: The user enters command mode by pressing the ESC key whilst insert mode can be activated by pressing i.

For more information on Vim, consult its home page http://www.vim.org/ or check out one of the many books which are available on Vi - Vim's predecessor.

Linux and Printing

Overview

After having learnt something about text editing, it seems sensible to provide a brief introduction to the subject of printing under Linux. Although word processors are available for Linux, you will still need to learn something about traditional UNIX tools like the lpr printer daemon and the power of PostScript - a language which is used to describe page layouts.

Although using the command line to print documents is not the easiest way to produce a hard copy of your documents, this approach has considerable advantages over the use of a conventional word processor like OpenOffice or Abiword because the user creates plain text files which are portable across platforms. Moreover, although BSD-derived packages like lpr are more difficult to learn about than GUI based printer management tools, the Berkeley UNIX (BSD) approach gives the user a fine-grained control over the printer.

Planning Ahead

Because of the complexity of the printer configuration process, we shall not discuss the topic in any detail. We would however, advise any user to do the following:

  • Obtain your printer's technical specifications which will usually be available from the manufacturer's web site.

  • Read through all relevant document - both HOWTOs and man pages - before doing anything.

  • Check that your printer is working from within RISC OS before attempting to configure it for Linux.

  • Do a test print using the lptest utility.

  • Edit the /etc/printcap file where necessary.

  • Ensure that Ghostscript works both with the X Windows System and through the shell.

  • Use an application like magicfilter which helps you to configure your printer.

Tip: If you have a Linux system up and running and you want to print man pages, an environmentally friendly method is to take advantage of the psnup command which forms part of the pstools package. This command allows you to decide how many man pages will be printed per page although it is dependent on the user being able to convert the requisite page to PostScript format.

A Simple Example

Assuming that you have successfully configured your printer, printing through the shell generally involves two stages:

  1. the user creates a document with an editor like Vim or Emacs which may be interlaced with formatting instructions. Such formatting instructions are typically specific to either TeX or Groff.

    A number of filters may also be applied to the file if the user intends to do things like formatting line lengths. Other examples of typical filters include Enscript and a range of magic filters which convert to PostScript on the basis of a file's initial filetype.

  2. The file is then sent to the printer by using lpr, Enscript or Ghostscript.

With regard to point two, lpr could be used to print a plain text file formatted according to personal preference. If a more complex document has been generated with either TeX or Groff which includes floating objects like tables and graphs, then one possible alternative would be to convert the file to PostScript as a prelude to printing to a PostScript printer. Groff and TeX files can for example both be converted to PostScript using Dvips - a DVI to PostScript driver. Alternatively, users without a PostScript printer can also take advantage of Ghostscript- a program which can be used as a PostScript viewer, file converter and printer driver.

So in order to make the process more meaningful, let's use a fictitious document to illustrate the process in action. Suppose we have written a letter to a friend using LaTeX - the TeX macro set. For those who are unfamiliar with LaTeX, a sample file together with formatting instructions, is listed below:

\documentclass[a4 paper,12pt]{letter}
\name{Mr A. L. User}
\address{ARMLinux Users' Group\\
Torvald's Road\\
Linuxland}
\signature{ARMLinux User}
\date{June 12, 2000}
\begin{document}
\begin{letter}{Aleph One\\
The Old Courthouse\\
Bottisham\\
Cambridge}
\opening{Dear Aleph One}
I am writing to say how pleased I am with Aleph ARMLinux. Yes it
is very different from RISC OS but it's worth perservering with.
\closing{Yours sincerely}
\end{letter}
\end{document}

You would of course create this document with your favourite editor before saving it as letter.tex. Don't forget the suffix which indicates that the file is a LaTeX source file. letter.tex would then be processed by using the latex command to create a Device-Independent or DVI file - letter.dvi - with the dvi suffix.

latex letter

You are now ready to convert letter.dvi to PostScript by using Dvips. If you are successful, you will be left with letter.ps.

dvips -o letter.ps letter.dvi

And finally, print using either lpr Enscript or Ghostscript.

lpr letter

You can also print the raw LaTeX file with the pr command although this would not be particularly appropriate in a situation where one wished to process the formatting instructions as opposed to seeing them on the page.

pr letter

Resources

There is a wealth of information on printing and related utilities under Linux.

But your first port of call should be the:

Aleph ARMLinux CD

The printing HOWTOs are available on the CD in the Docs.Html-Howto. The relevant man pages are, as always, ever useful.

PostScript

General PostScript and Ghostscript resources are available from http://www.geocities.com/SiliconValley/5682/postscript.html/. PostScript-specific information can also be found on Adobe's web site at http://www.adobe.com/print/postscript/.

Ghostscript

Ghostscript's Home Page can be found at http://www.cs.wisc.edu/~ghost/ whilst the Ghostscript Manual is available from http://www.pdflib.com/gsmanual/index.html/.

TeX

Point your browser to http://www.tug.org/in order to learn about printing TeX-related files. Similarly, http://www.sunsite.ubc.ca/Resources/Graphics/dvips/ is the link to a comprehensive manual on the DVI to PostScript driver.

The X Windows System

The Client-Server Model

Although it is possible to work entirely through the shell, modern Linux distributions allow the user to work through a GUI and ARMLinux is no exception! Indeed, if your preferred method of working is to point-and-click, then you will feel very much at home with this distribution.

However, a brief explanation of the X Windows System is in order so that you can take advantage of the power which is at your fingertips.

The X Windows System or "X" as it is more commonly known is based on a client-server way of doing things in which the server program determines access to your graphics hardware. The client, in contrast, is simply an applications program like xpdf or one of the many types of window manager. Although X clients usually run locally, remote connection to a client is possible and can be very useful in situations where you need to access an important file on another computer. RISC OS users will no doubt be interested to know that it is even possible to start up an X-Server under RISC OS itself if you take advantage of an application like !X (http://gnome.co.uk/) or !X-Server (http://kyllikki.fluff.org/software/x/).

Window Managers and X Applications

There are many window mangers available for GNU/Linux so for reasons of brevity, we will confine ourselves to a description of Window Maker's basic features because this is the default desktop for Debian.

X Windows can be activated with the startx command. . To start Window Maker simply press the right mouse button and click on WindowManagers and then on the wmaker sub-menu.

When you fire up Window Maker, you will notice a number of distinctive features which include:

  • The Window Maker Workspace from which you can launch applications by clicking with the right mouse button before choosing the application which you require.

  • An Applications Dock on the right hand side of your screen which is used to activate applications which you use regularly.

  • A series of Miniwindows at the bottom of your screen. The Miniwindow is made up of an icon and a title and appears when you temporarily close an application window.

To end your Window Maker session, click on the workspace with your right mouse button and select WindowManagers and Exit or Exit Session. If you choose Exit Session, all applications will be closed.

For further information, take a look at the official Window Maker web site (http://www.windowmaker.org/) which has links to mailing lists, user guides and sample configuration files where you wish to customise your setup.

Congratulations, you can now use all of the X applications which are on the CD but you will need to make a few changes to the default configuration before X Windows is fully usable.

  • Add the line *input: true to the .X defaults file which will be in your home directory. This should solve the problem of being unable to type into dialogue boxes under X.

  • You will need to install pcnfsd if you wish to use the Network Filing System (NFS) for sharing files over a network to a RISC OS machine or a PC. It is not needed for UNIX-UNIX sharing. Supplementary information on this topic can be found on the CD in Docs/html-howto. The Networking HOWTO is also required reading.

So we've taken a look at Window Maker itself and in order to help you to use this window manager, what follows is a description of some of the core X applications which you may find useful. If you decide to install an application, follow the instructions in the section called Alternative Filesystems which tell you how to install a package by using dpkg.

X Applications

xterm

A window containing the shell. xterm allows the user to cut-and-paste and to scroll. To close the xterm window, type exit at the prompt, press Ctrl+D or select Close with your mouse by clicking on the button on the extreme left of the fvwm titlebar.

xpdf

A viewer for Portable Document Format (PDF) files. xpdf has been ported to RISC OS by Leo Smiers.

xfig

A program which is ideal for the production of complex drawings which can be saved in a variety of formats including PostScript and LaTeX.

xv

Allows the user to view and convert images in a variety of formats including GIF, JPEG and TIFF. Facilities are also available for image cropping, rotation, gamma correction and for the capturing of screenshots.

games

You can even have some fun with Linux by playing games like xmahjonng, xgalaga or xgammon. If you want to have fun without using X, then why not check out bsd-games - a collection of classic non-X games including battleshar, gomoku and phantasia?

ARMLinux and the Internet

One of the attractions of ARMLinux is that there are so many tools which allow you to read and send news and email and to view web pages. This section will therefore show you how to establish a dial-up connection as well as introducing you to some useful net-related utilities.

Connecting to the Net with PPP

In order to get on-line you will need to set up your dial-up connection so we'll help you to do this by taking a look at the Point-to-Point Protocol (PPP).

This section has consequently been written for those who wish to gain a general sense of what is involved before consulting alternative resources. Newbies should therefore read this section before referring to the PPP-HOWTO which is on the CD in Docs.Html-Howto. Useful information can also be gained from the README.linux file in /usr/doc/ppp-2.2.0f-2, the pppd man pages and from the PPP FAQ (http://cs.uni-bonn.de/ppp/faq.html/). Users who wish to establish their own PPP server or to set up a Wide Area Network (WAN) will also find these resources helpful. Moreover, those who wish to use the Debian distribution of ARMLinux should refer to install.en.txt on the CD in Debian.docs for an explanation of pppconfig. Debian users will also find the wvdial dialler to be invaluable.

Note: We have avoided any reference to SLIP connections or to DIP scripts because of the sheer complexity of the latter.PPP configuration will also become easier as ARMLinux is developed. The RHS Linux Network Manager is already available which allows users to configure interfaces, domains and name servers from the fvwm control panel and the eventual appearance of KDE will mean that PPP can be set up by using the kppp tool.

At present, you may set up your internet connection by:

  1. Writing your own scripts.

  2. Using the pppsetup program.

Writing Scripts

In order to configure PPP, you will need to find out the following information which is usually available from your Internet Service Provider (ISP):

  1. Dialup number.

  2. PABX number if you require an outside dialling tone.

  3. Login details which will usually be a combination of letters and numbers.

  4. Password-again a combination of letters and numbers.

  5. Gateway-four numbers punctuated by dots.

  6. Domain Name Server (DNS) Internet Protocol (IP) address - as with gateway.

Note: It is advisable to ask for two DNS IP addresses in case one of the servers is temporarily disconnected from the net.

You will also need to ask your ISP about:

  1. Its support for PAP or CHAP authentication.

  2. The allocation of IP addresses. Nowadays, ISPs tend to dynamically assign IPs on a session-by-session basis. If this applies to you, this may have implications for how you offer server apps like ftpd on your machine.

  3. The IP and netmask numbers that can be used in a situation where provision has been made for a subnet of IP numbers.

You will also have to think about configuring your modem which will involve:

  1. Finding the name of the COM port.

  2. Creating a link between the COM port name and /dev/modem.

  3. Taking other factors into account like flow-control, line-termination and the connection speed that you will require.

Tip: if you don't know the name of your COM port pipe the output of dmesg through fgrep:

dmesg | fgrep tty

If you require further information on configuring your modem, take a look at the Serial-HOWTO which is on the CD in Docs.html-Howto.

Note: You may also need to recompile your kernel to enable PPP support.You can check that PPP support is enabled by availing of the dmesg command:

dmesg | fgrep PPP:

If you think for example of a situation where you want to establish a connection with Freeserve - a popular account with RISC OS users - PPP configuration can be achieved by taking the following steps:

  • Edit the /etc/ppp/options file so that it contains information on the device that you will be using as well as the script - CHAP or PAP - that you will be using for dialling:

    connect '/usr/sbin/chat -v -f /etc/ppp/chat-script'
    asyncmap 0
    crtscts
    defaultroute
    modem
    lock
    mtu 542
    mru 542
    115200
    /dev/modem

  • Set up configuration and dialer files which may be found in /usr/doc/ppp-2.2.0f or in /etc/ppp. Assuming a chat script, enter the following in /etc/ppp/chat-script:

    ABORT 'NO CARRIER'
    ABORT BUSY
    ''ATF1
    OK ATD084550796699
    CONNECT''
    login:USER.freeserve.co.uk
    word:PASSWORD

  • Create or adapt the secrets file if you are using PAP or CHAP authentication where both files - /etc/ppp/chap-secrets and /etc/ppp/pap-secrets - take the form of:

    USER.freeserve.co.uk*PASSWORD

  • Run pppd as root.

  • Configure /etc/resolv.conf so that domain names are associated with IP addresses:

    # /etc/resolv.conf

    search. 
    domain freeserve.co.uk
    nameserver 194.152.64.35
    nameserver 195.92.193.8

  • Automate the connection process by copying the ppp-on and ppp-off scripts to /usr/bin as root. This will then allow you to toggle your connection on and off with the equivalent command.

Fine-Tuning

You should then

  • Secure all passwords on your system by setting them to 660 with chmod.

  • Log all PPP operations where you are having problems by entering the following command:

    tail -f /var/log/messages

  • If you want to use PPP as a normal user, SUID pppd by entering this command at the prompt:

    chmod +s 'which pppd'

PPPsetup

The pppsetup program is an effective alternative for those who feel intimidated by the process of hand-crafting an internet connection. PPPsetup is available from http://members.nbci.com/chrissawer/ and was orginally derived from PPP version 2.3.5. Newbies should consequently note that the chat and chat.8 files should be placed in /usr/sbin and /usr/man/man8 respectively. The program also needs a current version of chat which can be downloaded from ftp://cs.anu.edu/pub/software/ppp/.

Shutting Down

Shutting down an ARMLinux machine is substantially different from what you are used to. Simply resetting the machine can for example lead to the corruption of data, or at least a very slow boot due to the disc-checking process. You can shut the system down properly with the halt command although you will have to be logged in as root:

halt

If you want to reboot then you use reboot instead. Even easier is to use Ctrl-Alt-Del which also does 'reboot', even if you are not root. These are actually synonyms for various options to the shutdown command - ie shutdown -h now is the same as the halt command. There are of course many other options or switches that you can use in relation to this command, but you don't need to know those now. Use man 8 shutdown to read the details if you are interested.

A Word of Encouragement

This subsection has only scratched the surface of what can be accomplished with ARMLinux. We have however given you enough information to enable you to take those first tentative steps on your journey towards GNU/Linux enlightenment.

Good Luck and welcome to the open-source revolution!