Introduction

This lecture gives a general view of some of the utilities that are common in Operating Systems, and gives more details on the ones available in Unix.

File System

Files are stored on devices such as hard and floppy disks. The details of how this may be done is considered in a later lecture. The O/S defines a file system on the devices. Many O/S use a hierarchical file system:

A directory is a file that keeps a list of other files. This list is the set of children of that directory node in the file system. A directory cannot hold any other kind of data.

On MSDOS a file system resides on each floppy or partition of the hard disk. The device name forms part of the file name.

On Unix there is a single file system. Devices are mounted into this file system. (Use the command mount to see this.)

Comments

Navigation

To locate your position as a user of the file system, there is the concept of your current working directory. Unix only has one working directory per user. MSDOS has one per device.

MSDOS maintains a current file system (drive).

Unix has a per user home directory.

You can change the current working directory by using the command

cd new-directory

Comments

File and directory naming

An individual node of the file system has its own name. Naming conventions differ between O/S's. In MSDOS, a name is constructed of upto 8+3 characters. Windows95 uses tricks on top of the MSDOS file system to give ``long file names'' of upto 255 characters. In ``standard Unix'' (POSIX) a name may consist of upto 256 characters.

The full file names are constructed by concatenating the directory names from the root down to the file, with some special separator between names. This is known as absolute path naming. In MSDOS, the full path name also includes the drive name.

Example: MSDOS

C:\expsys\lectures\search.txt

Example: Unix

/usr/usrs/os /usr/usrs/os/myfile Relative naming means that files are named from some special directory:
. current directory (Unix and MSDOS)
.. parent directory (Unix and MSDOS)
~ home directory (some Unix shells)
~user home directory of user (some shells)

Example: Unix

~fred/../bill/dir1/./../file1
If just the name itself is given without any special prefixes (such as /, ., .., ~) then it refers to the file in the current working directory.

Comments

Basic utilities

An O/S - to the user - consists of the O/S itself plus a command interpreter and a set of programs that perform common operations. This set of operations include

Comments

Unix utilities

File copying:

cp [options] original new cp [options] files... dir The options include
-i interactive confirmation of overwrites
-f force a copy
-R recursively copy to a directory
For more information, man cp

Comments

File renaming:

mv [options] original new The options include
-i interactive confirmation of overwrites
-f force a move
For more information, man mv

Comments

File removal

rm [options] files...
For more information, man rm

Comments

Printing a file:

lpr [options] files...
For more information, man lpr

Comments

Displaying contents of a file:

cat files... more files... cat concatenates all the files together and sends the result to standard output ie it displays the contents to the screen. Like


For more information, man cat

more displays a page at a time. Move to the next page by pressing the space bar.



For more information, man more

Comments

Listing contents of a directory:

ls [options] files... ls shows information about the files, or the contents of directories.

There are a large number of options for ls:
-l show in long format



-a show ``hidden'' files (starting with .)


-F show type information too


For more information, man ls

Comments

Changing directories:

cd [directory] If no directory is given, change back to the home directory. If the argument is a single '-' (cd -), changes back to the last directory you moved from. Note: the concept of current working directory for a user in Unix is actually maintained by the shell, so the shell actually performs this function itself, rather than by separate programs.
For more information, man cd

Comments

Showing current working directory:

pwd

Some shells perform this function directly (since they already have this information), some leave it to a program.
For more information, man pwd

Comments

Making a new directory:

mkdir directory...
For more information, man mkdir

Comments

Removing a directory:

rmdir directory...
For more information, man rmdir

Comments

man pages

All the Unix command information is kept on line. Select the manual pages from the system menu. A typical man page looks like:

An alternative to man that is available under the X Window System is xman

The format is
Name
what the command is called
Synopsis
how it is used
Description
what it does
Options
what the options are
See Also
related commands
Files
files used
Bugs
known bugs

For more information, man man

Comments

File name globbing

When you type a line of input to any of the Unix shells, it goes through a number of steps. The line is first globbed. This expands out patterns. After this, a check is made to see if the first word is a command special to the shell. Words in the command that contain the characters ? or * are treated as patterns for filenames. The word is expanded into a list of file names, according to the type of pattern. The following expansions are made by most shells, including bash:
* matches any string (including null)
? matches any single character As a special case, any . beginning a word must be matched explicitly. Example: The directory contains the files tmp tmp1 tmp2 tmp10 The pattern *1* matches the files tmp1 and tmp10.
The pattern t??? matches tmp1 and tmp2

Comments

Command history

bash has a command history for convenience. The list of previous commands may be obtained by history Entering the command !n (n is an integer) will re-execute the nth command. You can also use the arrow keys to move through the command list, and to edit a command.

Comments

Communications

There is an electronic mail system called `pine'. It is fairly simple to use. If you send mail to `os', it will be sent to all those enrolled in O/S. (Outside the Faculty, you will need to mail to `os@ise' or `os@ise.canberra.edu.au'.)

There is a network news reader called nn. This allows you to read messages posted in newsgroups, on about 800 topics. One newsgroup is set up for O/S, called uc.ise.os. You can post to this group, and use it for discussion of O/S and CSG2 related topics. It has an odd command structure. Pressing moves through groups without reading anything. Select an article to read to pressing its corresponding (lower case) letter. Then press to read it as you leave the group. Commands to nn are either upper case letters or prefixed with `:'.

More friendly news readers include `tknews'.

Comments


Summary

This lecture has looked at common utilities available under Unix. They include

Comments


This page is http://pandonia.canberra.edu.au/OS/l1_2.html, copyright Jan Newmarch.
It is maintained by Jan Newmarch.
email: jan@ise.canberra.edu.au
Web: http://pandonia.canberra.edu.au/
Last modified: 14 August, 1995