Thursday, 11 January 2018

UNIX Fundamentals

What is Unix

Multitasking
Multiuser
Computer operating system
Modular design
Unified file system
C programming language as a systems programming

History and Evolution of Unix


UNIX has evolved over the past many years, from its conceptual state into a powerful and effective OS
UNIX evolved from a early time-sharing OS called MULTICS ( PDP-11 ) .
Ken Thompson of AT&T of Bell Laboratories originally designed UNIX OS in 1969
Originally written in assembly language, the core of the UNIX system was recoded in ‘C’ in 1973,after Dennis Ritchie came up with ‘C’ language
In 1977, Berkeley campus of the University of California made the first BSD release
Ideas and code from Berkeley Unix (including the vi editor) were fed back to Bell Labs
In 1980’s , Many academic ( like BSD) and Commercial  ( like Xenics )
1983 GNU ( Richard Stallmen started Free software distribution)

Unix Philosophy

Do one thing and do it well
Everything is file
Small is beautiful
Store data and configuration in flat text files - Text file is a universal interface
Use shell scripts to increase leverage and portability
Chain programs together to complete complex task - Use shell pipes and filters to chain small utilities that perform one task at time
Keep it Simple, Stupid (KISS)


Unix OS’s 

Currently more than 50 Unix and Unix like OS are being used
AIX from IBM.
Solaris from SUN Microsystems.
HP-UX and Tru64 from Hewlett Packard.
UnixWare from Caldera.
FreeBSD, which is an open source product.

UNIX Architecture

The architecture of UNIX can be divided into three levels of functionality

The lowest level is the kernel, which schedules tasks, manages resources, and controls security.

The next level is the shell, which acts as the UI, interpreting user commands and starting applications.

The tools are at the highest level. These provide utility functions such as ls, vi, and cat.




UNIX File System - 

The abstraction used by kernel to represent and organize the storage resources.
Inverted tree structure


In UNIX there are three basic types of files

Ordinary Files
text, executable programs, images,  etc.

Directories
Unix directories do not "contain" files.
Used to organize groups of files

Special Files
Eg. to represent a real physical device such as a printer, tape drive or terminal, used for Input/output (I/O) operations
Usually only found under directories named /dev

An index node

A data structure used to represent a filesystem object
Stores the attributes and disk block location(s) of the filesystem object's data
Commonly used INODE information can be found by using ls -l command
We can check the inode of a file using ls –i


UNIX Process 

OS performs following actions while creating a process -

Assign Process ID , Priority and Scheduling
Allocating Memory and Resources
Setup the process environment
Return Process ID
...

Process Creation

Parent Process creates child processes in a chain leading to formation of a process tree. Parent child processes share resources. Parent process wait for child process to complete. For every command, Unix creates or starts a new process. A process, in simple terms, is an instance of a running program. The operating system tracks processes through a five-digit ID number known as the PID or the process ID.