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.
The Unix O/S can be divided into three parts:
Kernel
Memory resident part of the operating
system.
It communicates directly with the
hardware.
The user never interacts directly with the
kernel directly.
Utilities
About 200 standard programs that perform
functions universally required by users.
Most operating system services are
performed by the utilities in Unix.
Shell and Time-sharing Utilities
The highest level of the system software.
An interactive program that interprets and
executes commands.
It communicates directly with the user and
makes calls to the utilities or kernel.
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.)
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
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.
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
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
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.
If it is, the command is executed directly by the shell (examples are
cd, pwd).
If not, a list of directories defined by the shell's PATH variable
is searched for the command.
When a match is found, the command from that directory
is executed.
If no match is found, you get a warning message from 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