UNIX:
UNIX is an operating system which was first developed in
the 1960s, and has been under constant development ever since. By operating
system, we mean the suite of programs which make the computer work. It is a
stable, multi-user, multi-tasking system for servers, desktops and laptops.
UNIX systems also have a graphical user interface (GUI)
similar to Microsoft Windows which provides an easy to use environment.
However, knowledge of UNIX is required for operations which aren't covered by a
graphical program, or for when there is no windows interface available, for
example, in a telnet session.
Types of UNIX:
There are many different versions of UNIX, although they
share common similarities. The most popular varieties of UNIX are Sun Solaris,
GNU/Linux, and MacOS X.
Parts of UNIX:
The UNIX operating system is made up of
three parts; the kernel, the shell and the programs.
Kernel:
The kernel of UNIX is the hub of the
operating system: it allocates time and memory to programs and handles the file
store and communications in response to system calls.
Shell:
The shell acts as an interface between the user and the
kernel. When a user logs in, the login program checks the username and
password, and then starts another program called the shell. The shell is a
command line interpreter (CLI). It interprets the commands the user types in
and arranges for them to be carried out. The commands are themselves programs:
when they terminate, the shell gives the user another prompt (% on our
systems).
The adept user can customize his/her own shell, and users
can use different shells on the same machine. Staff and students in the school
have the tcsh shell by default
History - The shell keeps a list
of the commands you have typed in. If you need to repeat a command, use the
cursor keys to scroll up and down the list or type history for a list of
previous commands.
Program:
Set of instruction to perform particular
function is called program.
Fundamentals
of UNIX
Unix
Users - In order to
make use of a UNIX system, you must first log in. This requires a user account,
which consists of:
Username:
This is your login name and is how you
are identified to the system itself and to other users of the system.
Password:
Along with your username, your password
grants you access to the system. Don't forget or lose your password. If you
write your password down, keep it in a safe place.
Default group:
The default group that your username
belongs to.
Contact info:
So that system administrators and other
users can contact you if necessary.
Home directory:
A directory or "folder"
assigned to your username. This grants you access to disk storage. This is
where you will keep your files and data.
Default shell:
The program which manages your login and
command line sessions .
Unix
Groups
A UNIX group is a collection of users -
i.e. a list of usernames. Groups provide a mechanism to assign permissions to a list of users all at once. Each user can
belong to more than one group.
UNIX
Processes
When a program is started on UNIX, it
creates what is known as a "process" on the system. Every process is
assigned a unique serial number called its process id or PID for short.
Processes can be created by any user, but can only be destroyed by someone with
the permissions to do so - usually the user that created the process or the
system administrator. This ensures that the compute jobs you start on the
system will not be disturbed by any other user of the system until they complete
or you decide to stop them yourself.
Processes and process management becomes
important on UNIX systems that are shared between a number of users. The
concept of users and PIDs is the main tool by which the available system
resources are shared fairly among everybody who needs access to them. Processes
can be suspended or given lower priority in cases where one or more users
should step out of the way for someone else, but wish to do so without losing
their work up to that point.
Signals:
Signals are a complex flow-of-control
operation. A signal is an interruption of the program of some sort. To fully
and properly understand signals, one must ALWAYS remember signals are classic
examples of asynchronous events. For example, when you hit CNTL-C, that sends the SIGINT signal to your program. When you hit CNTL-\, that sends the SIGQUIT signal to your program.
n Signals are software interrupts
n Used to handle asynchronous events
n Each signal is a positive integer, defined
by standardized names
n All the signals start with SIG
n SIGKILL = 9
n SIGTERM = 15 (Software termination signal (sent by
kill by default).)
n SIGCHLD = 17
n SIGINT = 2 (Issued if the user sends an interrupt signal)
Under unreliable signal,
system calls are not restarted automatically when interrupted by a signal.
Therefore, in order for a program to account for all cases, the program would
need to check the value of errno after every system call, and reissue
the system call if its value is EINTR.
Along similar lines,
unreliable signal semantics don't provide an easy way to get an atomic pause
operation (put the process to sleep until a signal arrives). Because of the
unreliable nature of reinstalling signal handlers, there are cases in which a
signal can arrive without the program realizing this.
n In older versions of UNIX, signals could be lost and the
process would never know
n Processes had little control over signals. It could catch
or ignore the signal
n Sometimes we want to temporarily block signals and process
them later to protect a critical section of code
Under reliable signal
semantics, on the other hand, the signal handler remains installed when called,
and the race condition for reinstallation is avoided. Also, certain system
calls can be restarted, and an atomic pause operation is available via the
POSIX sigsuspend function.
n A signal is said to be generated or raised for
a process when an event happens that causes the signal to occur
n A signal is delivered
to a process when it takes action based on that signal
n During the time between generation and delivery, a signal
is said to be pending
n A process may block
some signals using a signal mask that
defines which signals are currently blocked for the process.