0% found this document useful (0 votes)
21 views10 pages

Notes of Module 1

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
21 views10 pages

Notes of Module 1

Uploaded by

Himani Verma
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 10

UNIX

The Unix operating system is a set of programs that act as a link between the computer and
the user.

The computer programs that allocate the system resources and coordinate all the details of
the computer's internals is called the operating system or the kernel.

Users communicate with the kernel through a program known as the shell. The shell is a
command line interpreter; it translates commands entered by the user and converts them into
a language that is understood by the kernel.

 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.

 Several people can use a Unix computer at the same time; hence Unix is called a
multiuser system.

 A user can also run multiple programs at the same time; hence Unix is a multitasking
environment.

Unix Architecture

Here is a basic block diagram of a Unix system −

The main concept that unites all the versions of Unix is the following four basics −

 Kernel − The kernel is the heart of the operating system. It interacts with the
hardware and most of the tasks like memory management, task scheduling and file
management.
 Shell − The shell is the utility that processes your requests. When you type in a
command at your terminal, the shell interprets the command and calls the program
that you want. The shell uses standard syntax for all commands. C Shell, Bourne
Shell and Korn Shell are the most famous shells which are available with most of the
Unix variants.

 Commands and Utilities − There are various commands and utilities which you can
make use of in your day to day activities. cp, mv, cat and grep, etc. are few
examples of commands and utilities. There are over 250 standard commands plus
numerous others provided through 3rd party software. All the commands come along
with various options.

 Files and Directories − 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 filesystem.

Actions :

 Provides mechanism for creating and deleting processes.

 Provides processor scheduling, memory & I/0 management

 Provides inter – process communication

The Shell

 A utility program that comes with the UNIX system

Features of shell are :

 Interactive processing

 Back ground processing

 I/ O Redirection

 Pipes

 Shell Scripts

 Shell Variables

 Programming constructs

Process Management
 A process is a program in execution

 Several processes can be executed simultaneously a UNIX system.

 A process is generally created using the “fork ()”.system call

 The process that invokes the “fork ()” system call is the parent process, and the newly
created process is called the child process

CPU Scheduling

 UNIX uses round – ration scheduling to support its multi-user and time – sharing feature.

 Round – robin fashion of scheduling is considered to be the oldest, simplest and widely
used algorithm.

 Every process is given a time slice.

Memory Management

 Virtual memory

 Swap area

 Demand paging

File Management

 UNIX uses a hierarchical file system with ‘1’ as its root

 Every non – leaf node of the tree is called as directory file

 Every leaf node can either be a file, or an empty directory.

Types of UNIX users

 Broad classification of users

- root

- non-root

 Group

- Unix allows user ID’s to be grouped

- A single user ID can be member of multiple groups

 Differentiating users with respect to file access

-OWNER

-Group

-others
Working with UNIX

 User logs in with a valid user ID.

 User logs out to terminate the login session.


 Layer-1: Hardware –
It consists of all hardware related information.
 Layer-2: Kernel –
It interacts with hardware and most of the tasks like memory management, task
scheduling, and management are done by the kernel.
 Layer-3: Shell commands –
Shell is the utility that processes your requests. When you type in a command at the
terminal, the shell interprets the command and calls the program that you want.
There are various commands like cp, mv, cat, grep, id, wc, nroff, a.out and more.

 Layer-4: Application Layer –


It is the outermost layer that executes the given external applications.

Figure – kernel and its block diagram


This diagram shows three levels: user, kernel, and hardware.

 The system call and library interface represent the border between user programs and
the kernel. System calls look like ordinary function calls in C programs. Assembly
language programs may invoke system calls directly without a system call library. The
libraries are linked with the programs at compile time.
 The set of system calls into those that interact with the file subsystem and some system
calls interact with the process control subsystem. The file subsystem manages files,
allocating file space, administering free space, controlling access to files, and retrieving
data for users.
 Processes interact with the file subsystem via a specific set of system calls, such as open
(to open a file for reading or writing), close, read, write, stat (query the attributes of a
file), chown (change the record of who owns the file), and chmod (change the access
permissions of a file).
 The file subsystem accesses file data using a buffering mechanism that regulates data
flow between the kernel and secondary storage devices. The buffering mechanism
interacts with block I/O device drivers to initiate data transfer to and from the kernel.
 Device drivers are the kernel modules that control the operator of peripheral devices.
The file subsystem also interacts directly with “raw” I/O device drivers without the
intervention of the buffering mechanism. Finally, the hardware control is responsible
for handling interrupts and for communicating with the machine. Devices such as disks
or terminals may interrupt the CPU while a process is executing. If so, the kernel may
resume execution of the interrupted process after servicing the interrupt.
 Interrupts are not serviced by special processes but by special functions in the kernel,
called in the context of the currently running process.
Difference between Unix and Linux –
Linux is essentially a clone of Unix. But, basic differences are shown below:

LINUX UNIX

The source code of Linux is freely available to its The source code of Unix is not
users freely available general public

It has graphical user interface along with command


line interface It only has command line interface

Linux OS is portable, flexible, and can be executed


in different hard drives Unix OS is not portable

Different version of Linux are Ubuntu, Linux Mint, Different version of Unix are AIS,
RedHot, Solaries, etc. HP-UX, BSD, Iris, etc.

The file systems supported by Linux are as follows: The file systems supported by
xfs, ramfs, vfat, cramfsm, ext3, ext4, ext2, ext1, ufs, Unix are as follows: zfs, js, hfx,
autofs, devpts, ntfs gps, xfs, vxfs

Unix File System

A file system is a logical collection of files on a partition or disk. A partition is a container


for information and can span an entire hard drive if desired.
Your hard drive can have various partitions which usually contain only one file system, such
as one file system housing the /file system or another containing the /home file system.

One file system per partition allows for the logical maintenance and management of
differing file systems.

Everything in Unix is considered to be a file, including physical devices such as DVD-


ROMs, USB devices, and floppy drives.

Directory Structure

Unix uses a hierarchical file system structure, much like an upside-down tree, with root (/) at
the base of the file system and all other directories spreading from there.

A Unix filesystem is a collection of files and directories that has the following properties −

 It has a root directory (/) that contains other files and directories.
 Each file or directory is uniquely identified by its name, the directory in which it
resides, and a unique identifier, typically called an inode.
 By convention, the root directory has an inode number of 2 and
the lost+found directory has an inode number of 3. Inode numbers 0 and 1 are not
used. File inode numbers can be seen by specifying the -i option to ls command.
 It is self-contained. There are no dependencies between one filesystem and another.

Unix file system is a logical method of organizing and storing large amounts of information
in a way that makes it easy to manage. A file is a smallest unit in which the information is
stored. Unix file system has several important features. All data in Unix is organized into
files. All files are organized into directories. These directories are organized into a tree-like
structure called the file system.
Files in Unix System are organized into multi-level hierarchy structure known as a directory
tree. At the very top of the file system is a directory called “root” which is represented by a
“/”. All other files are “descendants” of root.
Directories or Files and their description –
 / : The slash / character alone denotes the root of the filesystem tree.
 /bin : Stands for “binaries” and contains certain fundamental utilities, such as ls or cp,
which are generally needed by all users.
 /boot : Contains all the files that are required for successful booting process.
 /dev : Stands for “devices”. Contains file representations of peripheral devices and
pseudo-devices.
 /etc : Contains system-wide configuration files and system databases. Originally also
contained “dangerous maintenance utilities” such as init,but these have typically been
moved to /sbin or elsewhere.
 /home : Contains the home directories for the users.
 /lib : Contains system libraries, and some critical files such as kernel modules or device
drivers.
 /media : Default mount point for removable devices, such as USB sticks, media
players, etc.
 /mnt : Stands for “mount”. Contains filesystem mount points. These are used, for
example, if the system uses multiple hard disks or hard disk partitions. It is also often
used for remote (network) filesystems, CD-ROM/DVD drives, and so on.
 /proc : procfs virtual filesystem showing information about processes as files.
 /root : The home directory for the superuser “root” – that is, the system administrator.
This account’s home directory is usually on the initial filesystem, and hence not in
/home (which may be a mount point for another filesystem) in case specific
maintenance needs to be performed, during which other filesystems are not available.
Such a case could occur, for example, if a hard disk drive suffers physical failures and
cannot be properly mounted.
 /tmp : A place for temporary files. Many systems clear this directory upon startup; it
might have tmpfs mounted atop it, in which case its contents do not survive a reboot, or
it might be explicitly cleared by a startup script at boot time.
 /usr : Originally the directory holding user home directories,its use has changed. It now
holds executables, libraries, and shared resources that are not system critical, like the X
Window System, KDE, Perl, etc. However, on some Unix systems, some user accounts
may still have a home directory that is a direct subdirectory of /usr, such as the default
as in Minix. (on modern systems, these user accounts are often related to server or
system use, and not directly used by a person).
 /usr/bin : This directory stores all binary programs distributed with the operating
system not residing in /bin, /sbin or (rarely) /etc.
 /usr/include : Stores the development headers used throughout the system. Header files
are mostly used by the #include directive in C/C++ programming language.
 /usr/lib : Stores the required libraries and data files for programs stored within /usr or
elsewhere.
 /var : A short for “variable.” A place for files that may change often – especially in
size, for example e-mail sent to users on the system, or process-ID lock files.
 /var/log : Contains system log files.
 /var/mail : The place where all the incoming mails are stored. Users (other than root)
can access their own mail only. Often, this directory is a symbolic link to
/var/spool/mail.
 /var/spool : Spool directory. Contains print jobs, mail spools and other queued tasks.
 /var/tmp : A place for temporary files which should be preserved between system
reboots.
Types of Unix files – The UNIX files system contains several different types of files :

1. Ordinary files – An ordinary file is a file on the system that contains data, text, or
program instructions.
 Used to store your information, such as some text you have written or an image you
have drawn. This is the type of file that you usually work with.
 Always located within/under a directory file.
 Do not contain other files.
 In long-format output of ls -l, this type of file is specified by the “-” symbol.
2. Directories – Directories store both special and ordinary files. For users familiar with
Windows or Mac OS, UNIX directories are equivalent to folders. A directory file contains an
entry for every file and subdirectory that it houses. If you have 10 files in a directory, there
will be 10 entries in the directory. Each entry has two components.

(1) The Filename


(2) A unique identification number for the file or directory (called the inode number)

 Branching points in the hierarchical tree.


 Used to organize groups of files.
 May contain ordinary files, special files or other directories.
 Never contain “real” information which you would work with (such as text).
Basically, just used for organizing files.
 All files are descendants of the root directory, ( named / ) located at the top of the tree.
In long-format output of ls –l , this type of file is specified by the “d” symbol.

3. Special Files – Used to represent a real physical device such as a printer, tape drive or
terminal, used for Input/Ouput (I/O) operations. Device or special files are used for device
Input/Output(I/O) on UNIX and Linux systems. They appear in a file system just like an
ordinary file or a directory.
On UNIX systems there are two flavors of special files for each device, character special files
and block special files :
 When a character special file is used for device Input/Output(I/O), data is transferred
one character at a time. This type of access is called raw device access.
 When a block special file is used for device Input/Output(I/O), data is transferred in
large fixed-size blocks. This type of access is called block device access.
For terminal devices, it’s one character at a time. For disk devices though, raw access means
reading or writing in whole chunks of data – blocks, which are native to your disk.

 In long-format output of ls -l, character special files are marked by the “c” symbol.
 In long-format output of ls -l, block special files are marked by the “b” symbol.
4. Pipes – UNIX allows you to link commands together using a pipe. The pipe acts a
temporary file which only exists to hold data from one command until it is read by another.A
Unix pipe provides a one-way flow of data.The output or result of the first command
sequence is used as the input to the second command sequence. To make a pipe, put a vertical
bar (|) on the command line between two commands.For example: who | wc -l
In long-format output of ls –l , named pipes are marked by the “p” symbol.

5. Sockets – A Unix socket (or Inter-process communication socket) is a special file which
allows for advanced inter-process communication. A Unix Socket is used in a client-server
application framework. In essence, it is a stream of data, very similar to network stream (and
network sockets), but all the transactions are local to the filesystem.
In long-format output of ls -l, Unix sockets are marked by “s” symbol.

6. Symbolic Link – Symbolic link is used for referencing some other file of the file
system.Symbolic link is also known as Soft link. It contains a text form of the path to the file
it references. To an end user, symbolic link will appear to have its own name, but when you
try reading or writing data to this file, it will instead reference these operations to the file it
points to. If we delete the soft link itself , the data file would still be there.If we delete the
source file or move it to a different location, symbolic file will not function properly.
In long-format output of ls –l , Symbolic link are marked by the “l” symbol (that’s a
lower case L).

You might also like