UNIX
UNIX is an operating system. An operating system is a software that acts as an interface between
the user and the computer hardware. An operating system acts as a resources manager. Here
resources mean hardware resources like the processor, the main memory, the hard disk, I/O
devices and other peripherals. In addition to being a multi-user operating system, UNIX gives its
users, the feeling of working on an independent computer system. UNIX also provides
communication facility with other users who are connected to the system either directly or
indirectly, using networking. It is highly portable and has a large number of utilities and can work
both on desktops as well as network environments with equal ease.
Features of UNIX
OS Several features of UNIX have made it popular. Some of them are:
Portable
UNIX can be installed on many hardware platforms. Its widespread use can be traced to the
decision to develop it using the C language.
Multiuser
The UNIX design allows multiple users to concurrently share hardware and software
Multitasking
UNIX allows a user to run more than one program at a time. In fact more than one program can
be running in the background while a user is working foreground.
Networking
While UNIX was developed to be an interactive, multiuser, multitasking system, networking is
also incorporated into the heart of the operating system. Access to another system uses a standard
communications protocol known as Transmission Control Protocol/Internet Protocol (TCP/IP).
Organized File System
UNIX has a very organized file and directory system that allows users to organize and maintain
files.
Device Independence
UNIX treats input/output devices like ordinary files. The source or destination for file input and
output is easily controlled through a UNIX design feature called redirection.
Utilities
UNIX provides a rich library of utilities that can be use to increase user productivity.
Differences between UNIX and Windows
UNIX WINDOWS
UNIX is an open source(free download) Windows is not an open source(paid ONE)
UNIX has very high security system Windows has low security system
UNIX is a command based operating system Windows is not a command based operating
system
The file system is arranged in hierarchical The file system is arranged in parallel
manner manner
Free office(such as excel, PowerPoint and Pay for MS Office
others)
UNIX is not a user friendly Windows is a user friendly
Low Hardware cost High Hardware cost
Customizable add features Not customizable
ASSIGNMENT:
Difference between UNIX AND DOS, UNIX AND LINUX.
Architecture of UNIX System/ UNIX System Structure
Introduction
• UNIX is an operating system.
• An operating system is a set of programs that act as a link between the computer and the user.
• The operating system (OS) manages the resources of a computer.
• Examples of computer resources are: CPU, RAM, disk memory, printers, displays, keyboard,
etc.
• UNIX OS allows complex tasks to be performed with a few keystrokes.
• UNIX OS doesn’t tell or warn the user about the consequences of the command.
• Unix was originally developed in 1969 by a group of AT&T employees Ken Thompson, Dennis
Ritchie,Douglas McIlroy, and Joe Ossanna at Bell Labs.
• There are various Unix variants available in the market.
• Solaris Unix, AIX, HP Unix and BSD are a few examples.
Linux is also a flavor of Unix which is freely available.
The Architecture of the UNIX system is divided into 4 major components.
They are:
1) The Kernel
2) The Shell
3) Files and Processes
4) System Calls
1. The Kernel
The Kernel is the heart of the Operating System.
It interface between Shell and Hardware.
It performs Low Level Task.
E.g.: Device Management, Memory Management etc.
2. The Shell
The Shell is a collection of UNIX Commands.
The Shell acts as an interface between the user and the kernel.
The Shell is a Command Line Interpreter (CLI)–Translates the commands
provided by the user and converts it into a language that is understood by the
Kernel.
Only one Kernel running on the system, but several shells in action-one for
each user who is logged in.
Eg: C Shell, Bourne Shell, Korn Shell etc.
System Call
A system call is a request for the operating system to do something
on behalf of the user's program.
The system calls are functions used in the kernel itself.
To the programmer, the system call appears as a normal C function call.
UNIX system calls are used to manage the file system and control
processes.
Example: read(), open(), close(), fork(), exec(), exit()
There can be only one kernel running on the system.
Application
• This layer includes the commands, word processors, graphic programs and
database management programs.
File
• A file is an array of bytes that stores information.
• All the data of Unix is organized into files.
• All files are then organized into directories.
• These directories are further organized into a tree-like structure called the file
system.
Booting in UNIX
The Unix operating system boots in a series of steps, typically referred to as the
boot process. The specific steps of the boot process may vary slightly depending
on the Unix distribution, but the overall process is similar.
Here are the general steps of the Unix boot process:
1. BIOS or UEFI: The system firmware (BIOS or UEFI) initializes the
hardware, performs a power-on self-test (POST), and searches for
bootable devices.
2. Bootloader: The bootloader is responsible for loading the operating
system into memory. The bootloader is typically installed in the
Master Boot Record (MBR) of the disk and loads the operating
system kernel from the disk into memory.
3. Kernel: The kernel is the core of the Unix operating system. It is
responsible for managing system resources, including memory, CPU,
and input/output (I/O) devices. The kernel initializes the system and
starts the init process.
4. Init: The init process is responsible for starting system services and
daemons. It reads the configuration files and starts the required
services based on the runlevel.
5. Runlevel: The runlevel is a mode of operation in Unix that
determines which services are started when the system boots. The
runlevel is usually set to 3 or 5, depending on the distribution.
6. Services and Daemons: Once the system is in the correct runlevel, the
init process starts the necessary system services and daemons. These
services include networking, file systems, and other system services.
7. Login prompt: Finally, the system displays a login prompt, indicating
that the system is ready for user interaction.
Overall, the boot process of Unix is designed to be modular and flexible.
Different Unix distributions may have different startup scripts, but the basic
steps of the boot process remain the same.
Shutdown Process
In Unix-like operating systems such as Linux, the shutdown process involves
bringing the system to a state where it can be safely powered off or rebooted.
Here's a basic overview of how the shutdown process typically works:
1. Decide on Shutdown Type:
o Halt: Stops all processes and shuts down the system, leaving it
powered on but in a halted state where the CPU is not executing
any code.
o power off: Powers off the system completely after halting.
o Reboot: Shuts down the system and then restarts it.
2. Initiate Shutdown:
o Normally, shutting down a system requires superuser (root)
privileges. The shutdown command is typically used to initiate the
process.
bash
sudo shutdown -h now # Halt the system immediately
sudo shutdown -P now # Power off the system immediately
sudo shutdown -r now # Reboot the system immediately
o The -h, -P, and -r options specify the type of shutdown (halt, power
off, reboot) and now indicates immediately.
Types of Unix Commands
Basically there are two types of Unix commands.
They are—external commands and internal commands.
External Commands
A command with an independent existence in the form of a separate file is called
an external command. For example, programs for the commands such as cat and
ls, exist independently in a directory called the /bin directory. When such
commands are given, the shell reaches these command files with the help of a
system variable called the PATH variable and executes them. Most of the Unix
commands are external commands.
Internal Commands
A command that does not have an independent existence is called an internal
command. Actually the routines for internal commands will be a part of another
program or routine. For example, the echo command is an internal command as
its routine will be a part of the shell’s routine, sh. In other words the echo
command is built into the shell. As such, internal commands are also called the
built-in commands. cd and mkdir, are two examples of internal commands.
Processes and its creation phases
A process is simply a running program. A process is said to be born when the
program starts execution and remains alive till the process is active. After the
execution the process is said to be died.
A process in a Unix system is created by fork system call. Every process except
process 0 is created. The process that invokes the fork system call is parent
process and the newly created process is the child process.
Every process has one parent process but a parent can have many child process.
The kernel identifies it process by its process identification number (PID).
Process 0 is a special process created "by hand" when the system boots.
There are 3 distinct phase in mechanism of process creation and uses 3 system
calls: fork(), exec() and wait().
fork(): Creates a child process. A new process is created because an existing
process creates an exact copy of itself. This child process has the same
environment as its parent but only the PID is different. This procedure is known
as forking.
exec(): After forking the process, the address space of the child process is
overwritten by the new process data. This is done through exec call to the
system. No new process is created over here. The PID & PPID remains
unchanged.
wait(): The parent then executes wait system call to wait for the child process
to complete its execution.
exit():
When the process dies it immediately moves to the zombie state and remains in
that state until the parent picks it up to exit status. A zombie is the harmless dead
child.