• Keine Ergebnisse gefunden

CUSTOMIZING THE ENVIRONMENT

Im Dokument Micronix Operating System (Seite 136-152)

The Micronix operating system makes it easy for you to alter the outward workings of Micronix in ways that make day-to-day operations more convenient for the system manager and other users. We call such changes "customizing the environment"

because there are no definite prescriptions for specific changes.

We will provide suggestions and examples, but your situation and experience will determine Which features you customize. These are changes that anyone can make, with no knowledge of Micronix programming.

Now then. What features are open for adaptation to your needs?

o your command prompt,

o shorthand abbreviations of your most-used commands (aliases), o the order in which to search directories ·for command files, o routine commands to be automatically executed at login time, o routine commands to be executed when the system "goes

multi-user",

o the message of the day, o the initial sign-on message, o the login banner, and

o the directories and LST: device to use with the CP/M emulator, upm.

Changes are accomplished by using a text editor to modify certain Micronix files. The editor can be either the Micronix editor (edit) or a program such as WordStar.

The easiest customizing changes to explain, and understand, are the various message files. These files are read by Micronix at the appropriate times and displayed on the console or user's terminal. We'll talk about these first.

The other aspects that you can customize involve creating a new file with the text editor that contains nothing but a list of normal Micronix commands. The new file must have a certain name and be in a certain place so that Micronix can find it at the appropriate times. A typical example of this feature is to put an fack command in a file called /ete/re, so the file system automatically gets inspected every day when you go from single to mu'iti-user mode. You could put mount commands into the same file to get any additional hard disks mounted without having to enter the commands manually.

The files involved in this customizing process are called:

o /etc/rc - the routine commands to be executed while going multi-user,

o .sh - commands for customizing the user's interface, the shell, and

o .upm - drive and LST: device designations for the CP/M emulator, upm.

We'll discuss each of these files in one of the sections that follows.

6.1. Message Files

The message fi,,~es are ordinary ascii character files that are transmitted to a terminal in exactly the form that they appear in the file. Thus, by using an editor, you ~an create the very image that r~ want to appear on the screen.

NOTE

If you use a CP/M-based editor ,like WordStar or NewWord, you will need to run the clean program on the file after you finish editing it. Repeat this cleaning process each "time you edit the file,. Example: after editing the message of the day with NewWord, at the Micronix prompt enter clean letc/motd.

In the examples we will be using, we use the Micronix edit program. The edit program is a line-oriented editor, meaning that it works on a single line at a time. This makes it nice for the purposes of this manual, but you may prefer to use a screen oriented editor. Screen-oriented editors allow you to edit a whole screen at a time by moving the cursor to different positions. WordStar and NewWord are screen-oriented editors.

6.1.1. Message of the Day

The contents of the message of the. day file appear when users log in. The same message is used for all users, making it an ideal way to convey information of general interest. Messages are entered by editing the flmotd" file, for message of the day, in the "/etc" directory.

For example, to change the message to read "The hard disk is

Tracking and Invoicing System

• :w

This editing session changes the banner to something more appropriate for the business described above than "Micronix" in 3D letters. Of ,course, we don't mind if you leave our banne'r up. If you don't want a banner at all, just rm or mv the file.

6.1.3. Sign-on Message

The sign-on message is displayed on the console whenever Micronix is reset. Thus, only the first user to log-on will see this message. The delivered sign-on message assumes that, this user has logged in ~s "root", and issues reminders about the responsibilities and hazards of being the superuser.

You can change this message, which is in the ,file /etc/signon, to suit your particular environment. For example, you might include in the message instructions for running fsck, correcting the date and going mult~-user. This way, instructions are always available to the person bringing up the system, and can be edited as necessary to reflect your individual practices.

6.2. Command Files

"Command files", in the parlance of UNIX, are known as scripts. Just think of a script used by actors and you get the idea. A script is a list of commands to be followed that can be interpreted by a program, usually the shell. As mentioned pre-viously, a script is just a list of the same sort of commands you use day in and day out; using the script, however, saves you the time and effort of remembering to' enter' routine commands.

The scripts that we are inte·rested in here are the ones that Micronix will "automatically" look for at certain points. The is executed when the first person to log in at the console types

"exit"t causing the system to "go multi-user". The .upm script is used by the upm program to designate disk drives for the CP/M emulator. The next three sections give examples of what you can do with these scripts.

6.2.1. Log-in Commands: The .sb Script

The .sh script is the user's principal tool for customizing his or her working environment. After a user has typed in their log-in name (and their password), a shell program (command inter-preter is started for them. You may recall from our earlier discussion of "accounts" that a user has a home directory and a login shell. The home directory is usually la/username, and the shell is normally a program called Ibin/sh, which processes Micronix commands.

When the /bin/sh program starts up, it always looks in the user's home directory for a file named .sh If the shell program finds the .sh file, it reads it and executes the commands that it finds there. Applications of the .sh file are given below. If .sh isn't there, the shell program just proceeds to display the Micronix prompt.

Turnkey Users

The .sh file may seem to be theidea.l method for creating a

"turnkey" user, that is, one that automatically executes a file.

(If you want to create turnkey user~, look up the account command description, earlier in this chapter, for instructions on Changing the Shell.) The difference between using .sh and account for turnkey users is that' account creates restricted u'sers" that is, they are logged, out when they finish with the turnkey program. The .sh turnkey programs exit to the Micronix prompt without logging the user 'out.

-If you only use .sh to start up turnkey programs, you are really misusing .sh, and overlooking most of its potential.

Aliases

With the .sh file, you can change the name of, or abbreviate, your favorite commands. This is called creating aliases. An alias has exactly the same meaning as'an alias in real life: an ass'umed name. The aliases' that you will use are there to replace long or often-used command lines with an alias named by you that is easy for you to remember.,' For example,

typing

%.a1ias ws "cd -/ws; upm b:/backupws"

% []

causes your shell to substitute the letters "ws" for the line "cd -/ws; upm b:/backup ws", saving you 22 keystrokes. If you often work with CP/M formatted'floppy disks, here are several aliases that you can use:

alias fard "far mfa"

alias farr "far mfa -r"

alias farx "far mfa -xu

, (displays floppy directory) (copies to the floppy) (copies from the floppy)

The "far" command reads or writes floppy diskettes in CP/M format. (More information about far is contained in the section on COPYING FLOPPY DISKETTES, and in the Program entry for far.) If you have trouble keeping the r and x flags straight, you could create these aliases:

alias copy to "far mfa -r"

alias copyfrom "far mfa -x"

As an example ~ the following command,s show the listing of the filenames on a diskette~ and copying (extracting) a file from the diskette:

% fard maint.bak first.doc install. txt

%' copyfrom first.doc

% []

There are other aliases that are useful for dealing with floppy disks that have Micronix file systems on them. To use

a

Micronix disk~ you must first mount ,it (see the section on COPYING MICRONIX DISKETTES~ or the program pages for moUnt.) You can create aliases for mounting and unmounting diskettes~ as in

alias mof "mount mfa If;dir If"

alias umof "cd; umount mfa"

to save time when using these commands. These examples demonstrate stri~ging sequential commands together with the semi-colon. "mof" connects the floppy file system to the If directory and then displays the current directory there; "umof" takes you out of that directory (a precondition for unmounting) back to your home directory, and then unmounts the floppy.

By keeping all these aliases in your .sh fi1e~ they are ready to use as soon as you log-in. You can check which aiiases you have in effect at any time by typing the command "alias" by itself.

Path

Another aspect change is called the to be searched for default path is:

directory Ibin; and

of your environment that you might need to path., The path is the list of directories the program that you have requested. The first, your current directory; next, the finally the directory lusr/bin.

You would want to change your path if, for examp1e~ you have programs installed into a directory that is not part of the default path. Suppose you have added a directory with database programs in it, called /db. You would add this to your path by typing

path • /db Ibin lusr/bin

making Idb the second directory to be searched for commands.

(The dot stands for your current directory.) If you want this path to be in effect every time you log in, put the path ca.mand in your .sh file. Otherwise it stays in effect only until you log out.

Another interesting, and fun~ aspect of the environment to change is 'the prompt. The prompt tha t comes with your system is a percent sign (%), or a pound sign (H) for the superuser.You can change the prompt to make it more descriptive by substituting the user name for the percent sign, for example,

prompt JIrik: "

changes the prompt to "rik: f l . Leaving a space after the prompt makes your command line easier to read. If having your own name on the command lines isn't interesting enough, you can try s,omething like

prompt "-What is your command. master? ..

for a real feeling of power, or

prompt "Like, how's your karma?"

if - you want to be mellow. Adding the prompt line to y~ur .sh file will make it automatic arid permanent, until you remove the line :from' • sh.

Miscellaneous .sh Tricks

You can also add other commands to your .sh file. Yo~ can include the mail command, for example, and automatically check your "mailbox" while logging in. Another neat one is to include the command

echo There are 'who

I

lines' users on the system.

which will report how many other users are logged in.

The thing to remember with most .sh commands is that they will take some time to execute EVERY time you log in. If you are sometimes impatient, you can interrupt these commands by typing rubout or delete. If you are always impatient, refrain from adding commands to your .sh file. The alias, path and prompt commands are built into the shell so they will be done quickly;

thus, they can still be used by impatient people.

The .sh file belongs in your home directory. Use an editor program to create your own .sh file. (Remember to "clean" the file if you create it with a CP/M editor like NewWord). For starters, here is the .sh that we have been talking about ("rik"

on the first line is the customized prompt):

rik: type .sh

alias fard "far mfa"

alias copy to "far mfa -r"

alias copyfrom "far mfa -x"

alias mof "mount mfa /f;cd /f"

alias umof "cd;umount mfa"

prompt "rik: "

path. /db /bin /usr/bin

echo There are ' who

I

lines ' users on the system.

rik: []

6.2.2. ·Routine Commands File: /etc/rc

The commands in the /etc/rc file are automatically executed as part of the proces& of going multi-user. After the root user has accomplished the' tasks of checking the root file system and setting the date, the command "exit" is typed to make the system go multi-user. 'Since you can count" on this point being reached reliably, it is a good place to perform routine tasks.

Typical tasks that belong in this file are removing tempor-ary files from the previous day's activities, testing additional file systems, mounting those file systems, and waking up daemons.

Let's look at the /etc/rc file that may have come with your Micronix system.

/I type /etc/rc

echo Starting update daemon echo Starting network daemons netdaemon

update II []

The echo commands are pretty straightforward: they display the message that follows them on the console. netdaemon is the command that wakes up the network daemon which manages network-ing. update awakens the update daemon. The update daemon is responsible for periodically executing the sync command, which synchronizes disk buffers in memory with the appopriate blocks on the disk. No multi-user system should be without an update daemon to watch out for it.

with it.

So, you see that you already have a routine command file some commands in it. Now we'll tell you how to improve on

One of the things that you do when you use a computer is generate temporary files. Some programs, such as edit, create temporary files when they are used. Humans are also known to be

the creators of temporary files • Micronix has prepared for this by having a spec~al directory appropriately named /tmp.

Making the /tmp directory truly temporary should mean that files are erased from /tmp on a regular basis. This is obviously a job for the rc file. Including the commands

echo Removing temporary files ~roa /tmp.

era /tmp/*

sends a message-to the console and removes any files in the /tmp directory. NOw,- files left in the /"imp -directory are truly temporary, because they will be removed by the rc.- file.

Another routine task that you ,may be faced with is mounting additional file systems. Your Mlcronix system has the root file system "built-into" it, so it isn't-mountable. But, if you buy another ha_rd disk to use with your system, it will need to be mounted every time after you reset the system.

To mount the disk drive, you have to enter a mount command, along with the name of the drive and the place in the file system to mount it, and wait for the process to complete. For example, to mount a second 16 megabyte hard disk, the command is

mount m16b /b

You should put this command in the rc file have to think about doing it every day. And, remember that file systems should be checked mounted. So, we'll bundle these two commands

them to the rc file, as in

'echo Checking the second file system.

fsck /dev/m16b

echo Mounting the second file system.

mount m16b /b

so that -you won't we hope that you before they are together, and add

When you type "exit" from single-user mode, the commands in the rc -file will be executed. After the echo command reports

"Checking ••• ", the fsck command performs-its thorough checks of the unmounted file system on the second hard disk. This will take about 5 or 10 minutes, but is well worth the time. Then, the second echo command notifies you that it is "Mounting ••• ", and the mount command adds the new file system to the directory lb.

From this time until the system is reset, the second hard disk will comprise the /b directory.

OK. Let's add the commands we discussed to the rc file and see what we've got:

II type I etc/rr;.

echo Checking the second file system.

fsck /dev/m16b

echo Mounting the second file system.

mount m16b /b

echo Removing temporary files from /tmp.

era Itmp/*

echo Starting upWate daemon echo Starting network daemons netdaemon

update

6.2.3. Configuring upm With .upm

"upm" is Micronix's way of imitating CP/M~ which is an operating system quite distinct from Micronix. It is there to enable you to take advantage of all the well-tested and inexpen-sive software atfailable for CP/M systems. ".upm" is a file that you create to tell upm Where to find and put things.

CP/M has a very different file system from Micronix. The location of a file under CP/M is determined by which dis,k drive it is on. Therefore a CP/M filename might be "A:frogeyes''-, meaning the file "frogeyes" is on drive A:.

Get this straight right now: There is no inherent connec-tion between CP/M drive names (like A:) and Micronix directories (like la). You make these connections with explicit commands.

The details of using upm are discussed under "upm" in the Programs section of the Reference Manual.

The .upm file sets up drive designations for the CP/M

emulator~ upm. A .upm file is no't a shell script. Rather~ it is a set of instructions that are passed to upm. When upm begins to execute, it looks for a .upm file in either the home directory (like a .sh file), or in the current directory. A typical .upm file looks like

% type .upm

a:/cpm b:./ Ist:/dev/ttyC

% []

which sets the A: drive to the /cpm directory and the B: drive to the current directory. Any printer output to the LST: device is routed to the port ttyC~ where presumably a serial printer is connected. The upm entry in the Reference manual provides a clearly written and detailed description of how upm works~ and what you can do with your .upm file.

7. SECURITY

Whether you like it or not, your Micronix file system requires that you do something about security. You might only need to secure your files from being erased by the nine year old computer wizard on your home system. Or, the files you wish to

Whether you like it or not, your Micronix file system requires that you do something about security. You might only need to secure your files from being erased by the nine year old computer wizard on your home system. Or, the files you wish to

Im Dokument Micronix Operating System (Seite 136-152)