• Keine Ergebnisse gefunden

MAINTAINING FREE DISK SPACE

Im Dokument Micronix Operating System (Seite 122-133)

Keeping your hard disk from filling up is possibly the hardest task in maintaining your Micronix system. Creating files, copies of files, backup files, revisions of files, temporary files, archives, etc., is so easy to do, you will be surprised at how easy it is to fill up 10 or 20 megabytes of storage. You can use the df (disk free) command to monitor the amount of free space remaining in a file system.

The place to start in keeping some free space is with each user doing their part. Users need to remove temporary files or directories, and move long-term backups to floppy disks. It may be convenient to have every revision of a program or text around;

but it sure will fill up a hard disk in a hurry. A Micronix system with a single user might go for a couple of months before running out of space. A system with several users' might last only three weeks.

When users prove unable to control their use of disk space, it is up to the system administrator to provide some assistance.

You can do this by using the du command to monitor each user's disk usage. You can send mail to the users that are hogging disk space, asking them to clean up their act. If this fails, you can \ try stronger methods, such as public humiliation (list the space hoggers in the message of the day).

You may actually need more disk space' than your present hard disk p~ovides. The way you can determine this is to calculate the amount of space used by the resident programs and their support files, for example, the data 'liles in a database. The du command (explained -in the next section) will calculate this for you. If the programs alia files share'd' by all users take up most of the hard disk, there will be no space for user files. The solution is to move shared data files to a new hard disk, keeping the users on the original disk. Making an additional hard disk a part of the file system is explained in the section on the Routine Commands file, mounting commands.

3.1. Checking Disk Usage: du The disk usage command (du) by files in' a directory, subdirectories. Remember that disk space. So, if a directory one megabyte of disk space.

counts the number of blocks used including all the files in a block is 512 bytes, or 1/2 k of uses 2000 blocks, it is taking up

The Micronix file system is organized so that the user directories are all subdirecties of fa. This makes it simple to locate each user's home directory and summarize the portion of the file system that they are using. We should point out that any file can grow until, it has used all the free space in the system. There aren't any limitations put on programs or users that prevents them from overindulging in disk space use. Let's look at a file system that is shared by programmers and text writers and see how the du command works:

_II du - 8 la/ • . 1 lalalliene 403 lalcpm

1589- la/david 1003 lalfrank 4_/a/howard 1 (a/john .1216 la/len

12 la/marc 35 laiinike

3 I a/network 82 la/n.orm 1136 la/rik II [1

A glance at this list uncovers the major disk users: David, Frank, Len and Rik. If disk sp_ace, has become (or will soon become) an issue, a pleas_ant note can be mailed to these users requesting that they be more considerate, and use floppy disks for backups. You might guess that for this command to work, shared data space, i.e., databases, would have to be kept in a place other than a subdirectory of a user.

The du command compiles disk usage reports for the fi~es or director,ies listed after the command and options. Du recognizes two options,

-s Summarize disk usage for names specified, or -a All files and subdirectories are reported.

If neither option is used, a summary of disk usage by directory is produced.

Individual users can benefit by using the du command. For example, Len could discover where he is using all that disk space by typing "du -a la/len", which would list out every file and directory connected through his home directory with the blocks used.

3.2._ Disk Free Command

The disk free command (df) is simple, quick and easy to use.

Compared to the trouble you will be in if you don't have any free blocks left to use in a file system, you should use df every day, if not more often.

The disk free command counts the number of free blocks remaining in a file system. This makes df the exact opposite of du, which counts the blocks in use. To use df, you simply specify the names of the file systems that you want to check.

For example)

II df I dev I root

8117 /dev/root II []

informs you that there are 8117 free blocks remaining in tbe root file system. Keeping in mind that a block is 512 bytes long, 8117 blocks corresponds to 4.0585 megabytes remaining on root, a heaithy amount.

How much free space is necessary? Well, that depends a lot on your daily use, and how many people are using the system. A nice rule ~f thumb would be to maintain 1 megabyte, that is 2000 blocks, of free space available on each hard disk file system.

If you ever get down to only 100 blocks of free space remaining, you are in imminent danger of running out of free space. The solution is to clean up the file system by convincing users to remove unused files or copy old files to backups. The find command can be used to find old or unused (not recently accessed) files.

3.3. Finding Types of Files: find

The find command:~s the system administrator's, and user's, most useful tool for uncovering unused files. The find command uses information that is part of the description of fil~s (the inode) to select files. For example, find can be used to print a list of the files that haven't been modified (written to) in 90 days, as in

# find la/jan -mtime +90 -print /a/jan/Pilot/stat.c

/a/jan/Pilot/global.c /a/jan/Foreign/term.h /a/jan/Foreign/bio.c /a/jan/Foreign/cio.c II []

which discloses that Jan has some files that haven't been modified in more than 90 days. Files such as this (unmodified for 90 days) are prime candidates for removal to a backup diskette.

Another use of the find command is to seek out and remove files in ypur own user directories. For example, some wordprocessors create files with the extension ".bak" every time they are used to edit a file. Eventually, this means that you will have two copies of every file you have ever edited. The

find command can locate and remove these files, as in

% find. -name " •• bak" -exec "m {}j"

% []

which starts in your current directory, and searches it and all its subdirectories removing files with the .bak extension. As a system administrator, you could use this command to free enormous amounts of disk space in the entire file system. However, many

people Please without

will not take kindly to your removal of their files.

save despotic measures (removing other people's files their- permission) for situations when reason has not prevailed.

Here's one more idea for using find. Whenever a program bombs, an image of the memory it is using, and a copy of the process status, is saved in in the· current directory in a file named "core". Since not everyone appreciates just what a core file is, (it is used for debugging purposes), they may remain in the file system, unused, forever. You may want to search out

"core" files that are over a week long by typing

n

find

la

-name .core -a~ime +7 -print /a/len/Edit/YY/core

II []

This time, we found only one "core" file over a week old. The next thing to do is send Len some mail asking him (politely) about the file.

We have only touched upon the power of the find command. If you want to learn more about find, check out the entry for find in the reference manual, under Programs.

4. USERS

Users aren't the people Who use Micronix; users are the names that people log-in with. This may seem somewhat confusing, but "user names" are all that a poor computer knows about. A person logging in as the "root", for example, becomes the root for the computer, regardless of the person's true identity. The computer's only communications with you are the keys that you type on the keyboard, so typing "root" as your user name makes you the root.

Files and directories are owned by·users. Thus, logging in as a particular user makes you the owner of that user's files.

The "user" system is the basis for "security" on the Micronix system. And, even if you don't desire any security, having each person log-in as a unique user· helps to organize the file system and provides more information about the files in it.

The information about user names is kept in the file called /etc/passwd. Each line in this file is called an account. An

account describes between five and seven characteristics of a user name:

1 the user name

2 an encrypteq password

3,4 user and group identification numbers 5 space for a descriptive comment

6 the home directory

7 the program to execute after log-in

Here is a typical account from the /etc/passwd file. Notice that colons (:) are,used to separate characteristics.

sandy:5ui7i9W5pHdj:21:3:Sandy E. 555-1212:/a/sandy:/bin/sh The user name is the same as the name entered during log-in.

The encrypted password is a disguised form of the password the person must know to log-in as that user. All users should have passwords if you' desire system security, but they are not mandatory. It is po~ible for some users to have passwords while

others do not.

The user and group identification numbers are used in file descriptors (inodes) as a shortened form of the user or group name. Programs that include user names in their output, like owner and Is, use the /etc/passwd file to convert the user identification number to a user name.

After the identification numbers, a space is provided for a comment on the user name. This is often the real name of the user, and their Phone number. Comments are optional.

When you skip an optional field, there should be two of colons side-by-side with nothing in between them.

/etc/passwd entry with no comment entry would look like sandy:5ui7i9W5pHdJ:21:3::/a/sandy:/bin/sh

pairs

A

Users are placed in their home directory a'fter logging in.

The home directory is also established as part of the information about a user. For example", using the cd (change directory) command without an argument moves the user to their home directory.

The last characteristic of a user is the name of a program to execute after log-in is complete" Usually, this is "the shell", a program that interprets commands typed by the user. It is also possible to use other programs instead of the shell, for example, a word processing program. Having a log-in program other than the shell restricts that user to that program. The user restricted in this manner logs out automatically by quitting the program. More on this in the section on changing the accounts.

Micronix initially has only one user: the root, or superuser. Although it is possible to use Micronix with only the root user name, this is not recommended. The root user is only intended for use by the system administrator for backups and maintenance. An inexperienced root user can swiftly destroy the entire file system with a simple command (which we'll tell you about later). To prevent the accidental destruction of your carefully configured Micronix system, you and your associates should always use their own user names. The root user name should be reserved for system administration tasks.

How do you create, change, or remove users? Well, it's almost easier done than said. The account command does all the tricky work; all you need to supply is the user name,. One thing we need to mention: only the root user can use the account program.

4.1.' Adding New Users': account

Before using the account command, you should select a user name. ' User names can be up to eight letters long. Since this is the name used' for receiving mail, it is best to pick a name that will be recognized by other people. Also, the name should be entirely in lower 'case letters. Let's start up the account program and add the user jayne.

II account

A) add an account B) delete an account C) change an account D) short display E) long display F) finish

<RUB) abort Selection: a User name: jayne Account added.

As you can see, adding a new user required that you make two entries: you selected "a" (add an account), and ypu typed the name .. jayne". That's all there is to ,it. What the account.

program does for you is make an entry in the /etc/passwd file for the new user, create a home directory attached to /a, change the ownership of the new directory (/a/jayne) from root to jayne and set the log-in shell to be the standard Micronix shell.

If you want to have some security on your system, you will want to assign a password to the new user. You can either use the passwd command, or select "c", change an account.

Immediately, after the line "Account added" appeared, the main menu (choices A to F) was redisplayed. You can choose to make more accounts, or change existing ones. When you are finished, select "f" to finish. The changes tha't you are making won't take effect until you type "f". If you interrupt the account program by typing DELETE or RUBOUT, none of the changes will be made.

4.2. Removing a User

Removing a user from the system is a two step process. The first step is to backup and remove all the user's files. The second step is to use the account program to remove the user.

You want to remove all the user's files from the system just to prevent wasted space. Whether you want to back the files up or not is your decision to make. The following commands will help you backup a user's home direc,tory, along with any subdirec-tories. Let's assume that the user Jayne has moved on to greener pastures, and you want to backup her files in case she ever comes back. What you do is type

II find I al jayne -name II • • bak" -exec "na {} j II

H

td la/jayne Idev/mfa

Insert new media and press RETURN to continue

or type the name of a new device containing a file system.

->

Function complete.

II []

which removes all the ".bak" files, and then copie~ all Jayne's files to a 5 1/4" floppy diskette with a file aystem on it. (If there isn't a file system on the floppy disk, td will tell you and offer to make one for you.) Now, you are safely backed .up.

You can remove Jayne's files by typing II rm -r la/jayne

Last chance before obliterating jayne. OK? (Y/N)y II ["]

The rm command with the -r option is very potent. This is the simple command that can destroy an entire file system if used carelessly (or maliciously). To prevent accidental damage to your file systems, don't log-in as root unless you need to, and only share the root password with people you trust.

Now, for the second step. Use the account program and select "b", for "delete an account". A list of the current users will be displayed, and you will be prompted for a "User name:".

Simply type "jayne", select "ftl to finish, and you're done.

4.3. Changing Accounts

There are four characteristics of accounts that you can change with the account command:

the user name, the password,

the home directory, and

the shell, or log-in program.

You will use the previously unprotected directories and login accounts.

change function to add passwords to users, or to change the default home shells that are created when you add

Changing the user name is the simplest change operation.

The account program will request the current user name, then the new user name t and _ you're done. From now on, the new user name must be entered at log-int and will appear in- output as the name of the owner of files. The home directory is not changed.

Changing the password is almost as simple. Once again, you will need to supply the name of the account you wish to change.

Thent you will be asked to provide a password. While you enter the password, the screen display (echo) will be turned off.

Since you won't be able to see what you are typing, you-will be asked to enter the password a second time to double-check what you think you typed. The password is then encrypted for entry in the letc/passwd file. (The passwd command can also be used to enter or change passwords. Non-root users can use passwd to change their own passwords.)

The next characteristic that you can change is the home directory. Say, for examplet you add a new hard disk mounted in the root directo~y as

lb.

You;want to move the home directory of user "becca" from.f a/becca to Ib/becca. The first thing you'll need to do is create the directory on the b drive. (account automatically. creates home directories on the a drive, so normally this particular step isn't needed.)

Assuming that the new hard disk has been formatted (formatmw), a file system put on it (mkfs), and it is mounted, use the "make directory" conimand (mkdir) to create becca's new home directory:

H mkdir Ib/becca H []

You're not done yet, though. You still need to use the account program to tell Micronix to always log becca into that newly-created directory. You also should "give" the ownership of the directory to the user by the owner co~and:

H

owner -becca Ib/becca II []

If the directory originally created by the account program (/a/becca) isn't going to be used, copy the old files to the new directory and remove the old one in order to keep the file system neat.

# cptree la/becca Ib/becca

# rm -r /a/becca

4.3.1. Logging Directly Into a Program

Perhaps the most interesting account characteristic that you can change is the log-in program, or "shell". Normally, when a user logs in, a program called Ibin/sh is executed. This is the Micronix shell, which puts the command prompt on the screen and

sees that the jobs you want done get done. Micronix users almost always access programs by way of the shell program.

The thing to understand is that the shell .program i$ just

The thing to understand is that the shell .program i$ just

Im Dokument Micronix Operating System (Seite 122-133)