Operating System Cit333
Operating System Cit333
Operating System Cit333
&
Linux/Unix Administration
1
Abstract
I write or compile a Operating system book for students of 3rd year of RPI.
I try my best to give my effort for this Book. Error or mistake may be occurs during
study.
In next page the course content of PBTE of OS is given. But when u read the book
according to chapter may be you look at some different content so don’t worry
about this. It is same as board but I write in my own style and own method.
2
Course Content of OS according to PBTE LAHORE
DAE IN CIT
CIT 333 – OS
Learning Objects
3) Unix/Linux Implementation
3.1 Describe the development of UNIX/LINUX Development
3.2 Explain the Design principle of UNIX/LINUX
3.3 Log in and Log out in system
3.4 Configure user own environment
3.5 Change and manage own password
3
3.6 Use Unix/Linux Help System(manual system)
3.7 Characterize Unix/Linux File System and its organization
3.8 Name correctly File and Directory
7 System Administrations
7.1. SYSTEM ADMINSTRATION TASKS.
7.2. UNIX/LINUX INSTALLATION BASICS.
7.3. RESOURCE AND USER ADMINSTRATION.
4
7.4. KERNEL BASICS AND CONFIGURATION.
7.5. SYSTEM ACCOUNTING AND PERFOMINANCE MONITORING.
7.6. DEVICE AND MAIL ADMINSTRATION. 7.7. UUCP AND
FTP SERVICES ADMINSTRATION.
7.8. BACKING UP AND RESTORING THE SYSTEM.
7.9. FILE SYSTEM AND DISK ADMINSTRATION.
Index
5
3. Unix/Linux Implementation……………………………………………………………………………………………………….70-86
3.1 Describe UNIX/LINUX
Development………………………………………………………………………………………………...70
3.2 Design principle of
UNIX/LINUX………………………………………………………………………………………………….......72
3.3 Log in and Log out in
system……………………………………………………………………………………………………………73
3.4 Configure user own environment…………………………………………………………………..
………………………………..74
3.5 Change and manage
password…………………………………………………………………………………………………….....74
3.6 Unix/Linux Help
System……………………………………………………………………………………………………………………75
3.7 Unix/Linux File
System……………………………………………………………………………………………………………………..75
3.8 Directory structure, Name and File
sys……………………………………………………………………………………….......76
3.9 Creating and deleting File and
Directory…………………………………………………………………………………….......79
3.10 Set permission on File and Directory………………………………………………………………………………………………82
4. Unix/Linux Command…………………………………………………………………………………………………………………87-96
5. Text Processing…………………………………………………………………………………………………………………...97-102
6. Unix/Linux Shells……………………………………………………………………………………………………………….103-107
7. System Administration……………………………………………………………………………………………………………….108
Past paper………………………………………………………………………………………………………………………………………110
6
Part#A
Basic Concept of Operating system
This chapter is not including in your course content but this is very important for learning
Operating system.
So don’t ignore this. Here only some terminology and some definition
1) Software
2) Hierarchy and types of software
3) Windows ,DOS and Linux
1) Software
A set of instruction given to the computer to perform a specific task or solve a problem called
software or program. OR
Software is the combination of instructions to perform the specific task. Soft ware is also called
program.
2) Hierarchy and types of software
Fig 0.1
7
2.1) Software
A set of instruction given to the computer to perform a specific task or solve a problem called
software or program. OR
• System software
• Application software
System software is computer software designed to operate and control the computer hardware
and to provide a plate form for running application software.
Operating systems, utility programs, and device drivers are the examples of system software.
Operating system is the main and most popular type of system software. according to Fig 0.1
• Operating system
An operating system is a program that acts as an interface between the user and the computer
hardware and controls the execution of all kinds of programs. It enables the computer
hardware to communicate and operate. DOS and Windows example of OS.
• Utility programs
A program that performs a specific task related to the management of computer function,
resources, or file, password protection and virus protection.
Example: File manager, image viewer, Diagnostic utility, PC maintenance utility, Antivirus, Disk
cleanup and Firewall etc…
Device Driver
A device Driver is a computer program that operates or controls a particular type of device that
is attached to a computer like printers
2.2.1 Language Translators whatever language or type of language we use to write our
programs, they need to be in machine code in order to be executed by the computer. There are
3 main categories of translator used, according to Fig 0.1
• Compiler The language translator program that translates the complete source
program into machine code as a whole is called compiler. The C and C++ compilers are
best examples are compilers.
8
• Interpreter The language translator program that translates the source code into machine
code statement by statement is called interpreter.
• Assembler The language translator program that translates the program written in
assembly language into machine code is called Assembler.
2.3Library Programs
Library programs are compiled libraries of commonly-used routines. On a Windows system they
usually carry the file extension dll and are often referred to as run-time libraries. The libraries
are run-time because they are called upon by running programs when they are needed. When
you program using a run-time library, you typically add a reference to it either in your code or
through the IDE in which you are programming.
Using library programs saves time when programming. It also allows the programmer to
interact with proprietary software without having access to its source code.
Application software
An Application software or group of program that is designed for end user. It is used to perform
various applications on computer, also known as application package.
Ms Word, Access Photoshop is the example of Application software.
• General-Purpose Software
Software is general-purpose if it can be used for lots of different tasks. You can use a word
processor to write letters, memos, essays, instructions, notes, faxes, invoices and lots more.
These days we tend to use integrate suites of office software where a range of general-purpose
software is provided, usually with the facility to combine elements from each application in a
single file.
• Special-Purpose Software
This software performs a single specific task. This task might be complex like payroll calculation,
stock control etc. but will be based on a single task.
• Bespoke Software
Bespoke software is written for a single client. Large organizations have a need for welldeveloped
applications suited to their specific needs. Such software is often expensive to develop since the
development costs are not shared among a large number of people purchasing the software. It
is also known as custom software.
PackagedSoftware
The software that is developed for sale to the general public is called packaged software.
Packaged software is used to solve some common problem of many people or users
9
3) Windows, DOS and Linux
DOS Windows
Windows provide the graphic
DOS (Disk Operating System) interface to the user for
Definition are simple text command interacting with hardware and
based operating systems. executing their application
programs.
Windows uses graphics,
DOS provide the command images and text to provide the
GUI
based interface to the user. interface to the user to
interact with the machine.
Commands are used as only Uses various input devices for
Input System way for the user to give input this purpose such as mouse,
to the machine. touch screen.
Not available, DOS can
Windows allow multiple task
Multitasking execute a single task at a time.
to be operated at same time.
10
Chapter#1
An operating system is a program that acts as an interface between the user and the computer
hardware and controls the execution of all kinds of programs. It enables the computer
hardware to communicate and operate. OR
Operating system is a computer software and interface between hardware and user, it enables
the computer hardware to communicate and operate
DOS, Windows, UNIX, Linux and Mac are today’s core operating systems; they all run from big
systems to Smart phone &handheld devices to ease human work.
11
Fig 1.1
Computer system can be divided into four components: show in fig 1.2
Fig 1.2
OS is a resource allocator
Decides between conflicting requests for efficient and fair resource use
OS is a control program
12
Controls execution of programs to prevent errors and improper use of the
computer
In short, computer organization mainly deals with how a particular hardware works in a
computer where as computer architecture deals with how to design a circuit for such
hardware.
Let me give you an Example. Assume that I bought a car. I know how to drive it. It is enough to
learn how to start it, how to shift gears and how to apply brakes etc. to drive a car, you do not
need to learn how to repair if anything fails. Knowing how to drive a car is nothing but computer
organization.
If I have to repair my car then I should drive it to a mechanic because he would knows how it
was manufactured and how to repair it. This is computer architecture.
If you know both driving and repairing then you know both organization and architecture.
13
Example: instruction sets, instruction formats, data types, addressing modes
1.1.4) OS Environment
OS nature can be Stand-alone, Multiple Users, Multitasking or Real Time Operating System.
The users of batch operating system do not interact with the computer directly. Each user
prepares his job on an off-line device like punch cards and submits it to the computer operator.
To speed up processing, jobs with similar needs are batched together and run as a group. Thus,
the programmers left their programs with the operator. The operator then sorts programs into
batches with similar requirements. Show in Fig 1.3 and 1.4
• CPU is often idle, because the speeds of the mechanical I/O devices are slower than CPU.
14
Fig 1.5 Memory layout
In a multiprogramming system there are one or more programs loaded in main memory which
are ready to execute. . Only one program at a time is able to get the CPU for executing its
instructions (i.e., there is at most one process running on the system) while all the others are
waiting their turn.
The main idea of multiprogramming is to maximize the use of CPU time. Show in Fig 1.6
Fig 1.6
Detail
To overcome the problem of underutilization of CPU and main memory, the multiprogramming
was introduced. The multiprogramming is interleaved execution of multiple jobs by the same
computer. In multiprogramming system, when one program is waiting for I/O transfer; there is
another program ready to utilize the CPU. So it is possible for several jobs to share the time of
the CPU. But it is important to note that multiprogramming is not defined to be the execution
of jobs at the same instance of time. Rather it does mean that there are a number of jobs
available to the CPU (placed in main memory) and a portion of one is executed then a segment
of another and so on. A simple process of multiprogramming is shown in figure 1.7
15
Fig 1.7
As shown in Fig 1.7, at the particular situation, job' A' is not utilizing the CPU time because it is
busy in I/0 operations. Hence the CPU becomes busy to execute the job 'B'. Another job C is
waiting for the CPU for getting its execution time. So in this state the CPU will never be idle and
utilizes maximum of its time.
A program in execution is called a "Process", "Job" or a "Task". The concurrent execution of
programs improves the utilization of system resources and enhances the system throughput as
compared to batch and serial processing. In this system, when a process requests some I/O to
allocate; meanwhile the CPU time is assigned to another ready process. So, here when a process
is switched to an I/O operation, the CPU is not set idle.
Multiprogramming is a common approach to resource management. The essential components
of a single-user operating include a command processor, an input/ output control system, a file
system, and a transient area. A multiprogramming operating system builds on this base,
subdividing the transient area to hold several independent programs and adding resource
management routines to the operating system's basic functions.
1.2.3) Multiprocessing
Systems that have more than one CPU are called “Multiprocessing”, and task is divided into
more than one processor (CPU). OR
In multiprocessing operating system a task is divided between more than one processor(CPU)
so that parallelism can be achieved.
Detail
In Multiprocessing system, CPU shares the computer bus and some time memory and I/O
device etc. Multiprocessing system is more reliable and faster than Multiprogramming.
16
If the underlying hardware provides more than one processor then that is multiprocessing.
Several variations on the basic scheme exist, e.g., multiple cores on one die or multiple dies in
one package or multiple packages in one system. Anyway, a system can be both multi
programmed by having multiple programs running at the same time and multiprocessing by
having more than one physical processor. There are Two types of multiprocessing.
Asymmetric Multiprocessing Symmetric Multiprocessing
17
Fig 1.8 Fig 1.9 Fig 1.10
A multitasking Operating system is any type of system that is capable of running more than one
program at a time using switching or scheduling technique. Modern Computer uses this type of
OS.
Time sharing is also called multitasking it is a logical extension of multiprogramming.
Multiple jobs are executed by the CPU by switching between them, but the switches occur so
frequently that the user may interact with each program while it is running,
This type of OS is used in modern OS when multiple tasks share common resources (e.g. CPU
and memory).
The main motive of multitasking is to utili ze the CPU efficiently and reduce the response time.
Operating system uses CPU scheduling and multiprogramming to provide each user with a small
portion of a time. Show in Fig 1.11 and 1.12
18
1.2.5) Multithreading
This capability of Operating systems allows different parts or stages of any software or program
to run concurrently. Show in Fig 1.13
It supports multiple executions simultaneously and ensures that each application executes
within its standard format. UNIX, Linux and Windows
Fig 1.13
Network Operating System runs on a server and provides server the capability to manage data,
users, groups, security, applications, and other networking functions. The primary purpose of the
network operating system is to allow shared file and printer access among multiple computers in
a network, typically a local area network (LAN), a private network or to other networks. Examples
of network operating systems are Microsoft Windows Server 2003, Microsoft Windows Server
2008, UNIX, Linux, Mac OS X, Novell NetWare, and BSD.
• Upgrades to new technologies and hardware can be easily integrated into the system.
• Remote access to servers is possible from different locations and types of systems.
19
• Dependency on a central location for most operations.
Distributed system is similar to network OS. However in such OS there is no need to exchange
info explicitly. It is handling by the OS itself. OR
Distributed systems use multiple central processors to serve multiple real time application and
multiple users. Data processing jobs are distributed among the processors accordingly to which
one can perform each job most efficiently.
The processors communicate with one another through various communication lines (such as
high-speed buses or telephone lines). Two schemes are mostly used for building distributed
system. Show in table with fig. Fig 1.14 and 1.15
20
Real time Operating Systems (RTOS) responds quickly or instantly.
This types OS work with real environments, such whether forecast, storms and cyclones water
telemetry systems, Civil and Military aviation systems, air traffic control, GPS and GIS
applications. DOS and UNIX are not real-time OS.
21
1.4) Interrupts
The meaning of interrupts is to break the sequence of operation. It is a signal receives from I/O.
While the CPU is executing a program on “interrupt” breaks the normal sequence of execution of
instruction, diverts its execution to some other program called (ISR). Interrupt service routine,
after executing ISR the control is transferred back again to the main program.
There are two common ways in which buses implement interrupts vectored and polling
1.4.1.1) Vectored
Devices that use vectored interrupts are assigned an interrupt vector. This is a number that
identifies a particular interrupt handler. This vector may be fixed, configurable (using jumpers or
switches), or programmable. In the case of programmable devices, an interrupt device cookie is
used to program the device interrupt vector. When the interrupt handler is registered, the kernel
saves the vector in a table. When the device interrupts, the system enters the interrupt
acknowledge cycle, asking the interrupting device to identify itself. The device responds with its
interrupt vector. The kernel then uses this vector to find the responsible interrupt handler.
1.4.1.2) Polling
Polling is the process where the computer or controlling device waits for an external device to
check for its readiness or state, often which low level hardware. for example when a printer is
connected via parallel port the computer waits until the printer has receive the next character.
These processes can be as mints as only reading one bit.
1.4.2) DMA
Direct memory access (DMA) is a method of transferring data from the computer RAM to
another part of the computer without processing it using CPU or without using CPU.
Direct Memory Access (DMA) is a capability provided by some computer bus architectures that
allows data to be sent directly from an attached device (such as a disk drive) to the memory on
22
the computer's motherboard. The microprocessor is freed from involvement with the data
transfer, thus speeding up overall computer operation.
While most data that is input or output from your computer is processed by the CPU, some data
does not require processing, or can be processed by another device. In these situations, DMA can
save processing time and is a more efficient way to move data from the computer's memory to
other devices.
For example, a sound card may need to access data stored in the computer's RAM, but since it
can process the data itself, it may use DMA to bypass the CPU. Video cards that support DMA can
also access the system memory and process graphics without needing the CPU. Ultra DMA hard
drives use DMA to transfer data faster than previous hard drives that required the data to first
be run through the CPU.
In order for devices to use direct memory access, they must be assigned to a DMA channel.
Each type of port on a computer has a set of DMA channels that can be assigned to each
connected device. For example, a PCI controller and a hard drive controller each have their own
set of DMA channels. Usually a specified portion of memory is designated as an area to be used
for direct memory access. In the ISA bus standard, up to 16 megabytes of memory can be
addressed for DMA.
In older computers, four DMA channels were numbered 0, 1, 2 and 3. When the 16-bit industry
standard architecture (ISA) expansion bus was introduced, channels 5, 6 and 7 were added. ISA
was a computer bus standard for IBM compatible computers, allowing a device to initiate each
channel requires two lines in order to function. One line is for is for the DMA controller, which
asks for clearance from the CPU. The other line is for the CPU to recognize that the DMA
controller is able to send data over the lines without disruption from the CPU.
DMA channels are used to communicate data between the peripheral device and the system
memory.
DMA channels are slower than later data transfer methods, and therefore are not as common.
One later interface is the Ultra DMA, which has a data transfer rate up to 33 MB per second.
Each DMA transfers approximately 2 MB data per second.
DMA is a feature of modern computers that allows certain hardware subsystem within the
computer to access system memory independently of the CPU. Without DMA
when the CPU working, it is typically fully occupied for entire duration of the read write operation,
and it unavailable to perform other work. With DMA the CPU intiates the transfer, does other
operation while the transfer is in progress, and receive an interrupt from DMA controller when
the operation is done.
23
Diagram
of how modern computer work. Fig 1.17
All sort of information is to be feed into computer for ultimate results, for this purpose Input /
Output devices will be used.
Input devices
Keyboard
Mouse Microphone (speech input)
Scanner
Digital camera
Trackball Stylus
Output devices
Computer screen
Laser printer
Loudspeakers
♦ After I/O starts, control returns to user program only upon I/O completion.
24
– wait loop (contention for memory access).
♦ After I/O starts, control returns to user program without waiting for I/O completion.
– System call – request to the operating system to allow user to wait for I/O completion.
– Device-status table contains entry for each I/O device indicating its type, address, and state.
– Operating system indexes into I/O device table to determine device status and to modify table entry to
include interrupt.
A storage device is any computing hardware that is used for storing, porting and extracting data
files and objects. It can hold and store information both temporarily and permanently, and can
be internal or external to a computer, server or any similar computing device.
A storage device may also be known as a storage medium.
Storage devices are one of the core components of any computing device. They store virtually
all the data and applications on a computer, except hardware firmware. They are available in
different form factors depending on the type of underlying device. For example, a standard
computer has multiple storage devices including RAM, cache, a hard disk, an optical disk drive
and externally connected USB drives.
Volatile memory
Volatile memory, also known as volatile storage, is a sort of computer memory that requires
power to maintain the stored information and popularly known as temporary memory. Like
RAM
Non volatile Memory
This type of memory retains the stored information even if power is off. BIOS are the practical
example of NVM. It is designed for permanent or fixed programmable memory.
Now we discuss primary and secondary
• Primary Storage Devices: Generally smaller in size, are designed to hold data
temporarily and are internal to the computer. They have the fastest data access speed,
and include RAM and cache memory.
25
• Secondary Storage Devices: These usually have large storage capacity, and they store
data permanently. They can be both internal and external to the computer, and they
include the hard disk, compact disk drive and USB storage device.
26
Several types of disks may be used for Secondary
Main memory – only large storage media that the CPU can access directly.
Secondary storage – extension of main memory that provides large nonvolatile storage
Magnetic disks – rigid metal or glass platters covered with magnetic recording material.
Disk surface is logically divided into tracks, which are subdivided into sectors.
The disk controller determines the logical interaction between the device and the
Registe
Cache
Main Memory
Flash/USB
Hard Drive
Tape Backup
Price Speed Size
27
storage.
• Floppy disks
• Hard disks
•
•
•
• capacity.
• ••
computer.
1.8.1) Register
In a computer, a register is one of a small set of data holding places that are part of a computer
processor. A register may hold a computer instruction.
1.8.2) Cache
Cache memory is extremely fast memory that is built into a processor. Cache memory to store
instructions that are repeatedly required to run programs, improving overall processor speed.
1.8.3) RAM
Random Access Memory is working memory of a computer where data is temporarily stored for
various processes. Computer memories that dynamically stores program and data values during
operation and in which each byte of memory may be randomly accessed.
1.8.4) Flash/USB memory universal serial bus is often used for the same purpose for which floppy
disk or CD was used, i.e. for storage. This is used for backup of data and transfer from one to
other computer,
1.8.5) Hard Disk Hard Disk drives are also called Mass storage, used to store large amount of
programs or data It read and write masses (bulk) of data on magnetic and optical media in
28
nonvolatile nature and measured in Megabytes, Gigabytes and Terabytes. Hard disk drives, floppy
disks and Optical disks are forms of mass storage.
About Protection?
Resources require protection from illegitimate access.
That is, ensure that each object is accessed correctly and only by those processes that are allowed
to do so. Principle of protection
Programs, user and system should be given just enough privileges to perform their tasks.
1.9.2) I/O protection: All the input/output operations are privileged instructions and hence are
done in kernel mode. OS must ensure that application prog which is part of user mode does not
get control of computer in Kernel mode.
1.9.3) Memory protection: User mode should be given access to only those memory locations
for which they are allowed. It is achieved by having at least two registers viz. Base register: It
stores the starting physical address of the allowed memory location Limit register: It stores the
size of the range. So whenever CPU asks for the memory location access by giving its access, it is
checked if it falls between Base address and Base+ Limit address. In kernel mode OS has access
29
to all the memory locations including kernel and user memory. Loading of base and limit
registers is again a privileged instruction and hence done in Kernel mode.
1.9.4) CPU protection: It is achieved through a timer which is decremented with every clock
tick. When timer reaches 0, interrupt occurs and current process execution is suspended by
CPU. It is used to implement time sharing, also used for computing current time. Loading of this
timer is privileged instruction and hence done in kernel mode.
1.10.1) Buffering
A buffer is an area of main memory for holding data during input and output data transfers. A
buffer contains data that is stored for a short amount of time typically in RAM.
Detail
A buffer contains data that is stored for a short amount of time, typically in the computer's
memory (RAM). The purpose of a buffer is to hold data right before it is used. For example, when
you download an audio or video file from the Internet, it may load the first 20% of it into a buffer
and then begin to play. While the clip plays back, the computer continually downloads the rest
of the clip and stores it in the buffer. Because the clip is being played from the buffer, not directly
from the Internet, there is less of a chance that the audio or video will stall or skip when there is
network congestion.
Buffering is used to improve several other areas of computer performance as well. Most hard
disks use a buffer to enable more efficient access to the data on the disk. Video cards send images
to a buffer before they are displayed on the screen (known as a screen buffer). Computer
programs use buffers to store data while they are running. If it were not for buffers, computers
would run a lot less efficiently and we would be waiting around a lot more. In figure 1.20 shows
buffering while we use internet and figure 1.21 show working of internal computer buffer
30
Figure 1.20 figure 1.21
1.10.2) Spooling
A spool is a buffer that holds output for a device, such as a printer, that cannot accept
interleaved data streams.
Spooling overlaps input of one job with the computation of other jobs.
31
Chapter#2
Operating system will manage all the resources those are attached to the system means all the
resources, like memory, processor, I/O etc, those are attached to the system are known as
resources of computer system and OS will manage all the resources of the system.
When multiple users or multiple jobs running are concurrently on the operating system,
resources must be allocated to each of them. Some (such as CPU cycles, main memory, and file
storage) may have special allocation code and rules.
32
In general, a computer system has some resources which may be utilized to solve a problem.
They are
Operating system also controls all the storage operation means how the data or file will be
stored into the computer and how files will be accessed by the user’s etc.
All the operation those are responsible for storing and accessing the files & also creation of file.
Directory etc… handle OS.
All operating systems need to provide an interface to communicate with the user. This could be
a Command Line Interface or a Graphical User Interface. There are two types of interface.
CLI GUI
2.2.4) Booting
The process of starting or restarting the computer is known as booting. A cold boot is when you
turn on a computer that has been turned off completely. A warm boot is the process of using
the operating system to restart the computer.
Note: Process, memory and File Management cover in next topic 2.3.
33
2.3) Component of Operating System OR Explain How OS manage resources:
Def: Process management is an integral part of any modern day Operating system. The OS must
allocate resources to processes, enable processes to share and exchange information, protect
the resources of each process from other processes and enable synchronization among
processes.
The operating system is responsible for the following activities in connection with process
management:
i) System Process
System process required to starting an OS, and stored in memory.Explore.exe is biggest process.
When user opens any task in computer, user process generated, including resource (CPU,
memory, file etc.)
A process is a program in execution. A process needs some certain resources, including CPU time,
memory, files and I/O devices to accomplish its task. OR A process is defined as an entity which
represents the basic unit of work to be implemented in the system.
Program is a passive entity and process is an active entity.
A program by itself is not a process. It is a static entity made up of program statement while
process is a dynamic entity. Program contains the instructions to be executed by processor. A
program does not perform any action by itself.
34
A process includes:
As a process executes, it changes state. The state of a process is defined as the current activity
of the process. Process can have one of the following five states at a time. Show in fig 2.1
New
1 The process is being created.
2 Ready
The process is waiting to be assigned to a processor. Ready processes are waiting to have
the processor allocated to them by the operating system so that they can run.
Running
3 Process instructions are being executed (i.e. The process that is currently being executed).
4 Waiting
The process is waiting for some event to occur (such as the completion of an I/O
operation).
35
Terminated
5 The process has finished execution.
36
Each process is represented in the operating system by a process control block (PCB) also called
a task control block. PCB is the data structure used by the operating system. Operating system
groups all information that needs about particular process.
PCB contains many pieces of information associated with a specific process which are described
below. And memory layout of PCB show in Fig 2.2
Process control block includes CPU scheduling, I/O resource management, file management
information etc.. The PCB serves as the repository for any information which can vary from
process to process. Loader/linker sets flags and registers when a process is created. If that process
get suspended, the contents of the registers are saved on a stack and the pointer to the particular
stack frame is stored in the PCB. By this technique, the hardware state can be restored so that
the process can be scheduled to run again.
Parent process creates children processes, which, in turn create other processes, forming a tree
of processes. Generally, process identified and managed via a process identifier (PID).
Processes are the primitive units for allocation of system resources. Each process has its own
Address space and (usually) one thread of control. .
37
Each process has a parent process, which explicitly arranged to create it. The processes created
by a given parent are called its child processes. A child inherits many of its attributes from the
parent process. A process ID number names each process. A unique process ID is allocated to
each process when it is created
Processes are created with the fork() system call (so the operation of creating a new process is
sometimes called forking a process). The child process created by fork is a copy of the original
parent process, except that it has its own process ID.
After forking a child process, both the parent and child processes continue to execute normally.
If you want your program to wait for a child process to finish executing before continuing, you
Must do this explicitly after the fork operation, by calling wait() or waitpid().
Some term/definition
Fork (): system call that is used to create a new child process identical to the parent(in Unix)
Example: Google chrome uses a fork to handle each page within a separate process.
Zombie process: A process that is waiting for its parent to accept its return code is called a
zombie process
38
2.3.1.5) Process scheduling
Def: In multiprogramming environment, OS decides which process gets the processor when and
how much time. This function is called process scheduling. OR The
process scheduling is the activity of the process manager that handles the removal of the
running process from the CPU and the selection of another process on the basis of a particular
strategy.
Scheduling Queues
Scheduling queues refers to queues of processes or devices. When the process enters into the
system, then this process is put into a job queue. This queue consists of all processes in the
system. This figure 2.3 shows the queuing diagram of process scheduling.
figure 2.3
39
• Device queue: device queue is a queue for which multiple processes are waiting for a
particular I/O device each device has its own device queue.
Two state process models refer to running and non-running states which are described below.
2.3.1.6) Schedulers
Schedulers are special system software’s which handles process scheduling in various ways. Their
main task is to select the jobs to be submitted into the system and to decide which process to
run. Schedulers are of three types
Select which processes should be brought into the ready queue. It is also called job scheduler.
Long term scheduler determines which programs are admitted to the system for processing.
Job scheduler selects processes from the queue and loads them into memory for execution.
Process loads into the memory for CPU scheduling. The primary objective of the job scheduler is
to provide a balanced mix of jobs, such as I/O bound and processor bound. It also controls the
degree of multiprogramming. Processes can be described as either:
I/O-bound process: spends more time doing I/O than computations; many short CPU burst
CPU-bound process: spends more time doing computation than I/O; few very long CPU burst
Select which process should be executed next and allocates CPU. It is also called CPU scheduler.
40
Main objective is increasing system performance in accordance with the chosen set of criteria. It
is the change of ready state to running state of the process. CPU scheduler selects process among
the processes that are ready to execute and allocates CPU to one of them.
Short term scheduler also known as dispatcher, execute most frequently and makes the fine
grained decision of which process to execute next. Short term scheduler is faster than long term
scheduler.
Medium term scheduling is part of the swapping. It removes the processes from the
memory. It reduces the degree of multiprogramming. The medium term scheduler is
incharge of handling the swapped out-processes. Fig 2.4 show Medium Term Scheduler
Fig 2.4
Running process may become suspended if it makes an I/O request. Suspended processes cannot
make any progress towards completion. In this condition, to remove the process from memory
and make space for other process, the suspended process is moved to the secondary storage.
This process is called swapping.
41
5 It selects processes from pool It can re-introduce the
It selects those processes
and loads them into memory process into memory and
which are ready to execute
for execution execution can be continued.
A context switch is the mechanism to store and restore the state or context of a CPU in Process
Control block so that a process execution can be resumed from the same point at a later time.
Using this technique a context switcher enables multiple processes to share a single CPU.
Context switching is an essential part of a multitasking operating system features. When the
scheduler switches the CPU from executing one process to execute another, the context switcher
saves the content of all processor registers for the process being removed from the CPU, in its
process descriptor. The context of a process is represented in the process control
block of a process. Show in fig 2.5
Context switch time is pure overhead. Time dependent on hardware support like some
hardware provide multiple set of registers per CPU.
Note: Context switch time is overhead mean , the system does not useful work while switching.
fig
2.5
Some hardware systems employ two or more sets of processor registers to reduce the amount
of context switching time. When the process is switched, the following information is stored.
42
• Program Counter
• Scheduling Information
• Changed State
• I/O State
• Accounting
Memory management is the functionality of an operating system that tell how a process
managed in memory it also handles or manages primary memory
• Keeps tracks of primary or main memory i.e. what part of it use by whom, what part is are not
in use.
• In multiprogramming, OS decide which process will get memory when and how much Keep
track of what parts of memory are in use.
• Allocate memory to processes when needed. De allocate when processes are done.
Memory management provides protection by using two registers, a base register and a limit
register. The base register holds the smallest legal physical memory address and the limit register
specifies the size of the range. For example, if the base register holds 300000 and the limit register
is 1209000, then the program can legally access all addresses from 300000 through 411999. Show
in below Figure 2.6
43
Fig 2.6
• Compile time -- When it is known at compile time where the process will reside, compile time
binding is used to generate the absolute code.
• Load time -- When it is not known at compile time where the process will reside in memory,
then the compiler generates re-locatable code.
• Execution time -- If the process can be moved during its execution from one memory segment
to another, then binding must be delayed to be done at run time Logical versus Physical
Address Space
An address generated by the CPU is a logical address whereas address actually available on
memory unit is a physical address. Logical address is also known a Virtual address.
Virtual and physical addresses are the same in compile-time and load-time address-binding
schemes. Virtual and physical addresses differ in execution-time address-binding scheme.
The set of all logical addresses generated by a program is referred to as a logical address space.
The set of all physical addresses corresponding to these logical addresses is referred to as a
physical address space.
The run-time mapping from virtual to physical address is done by the memory management unit
(MMU) which is a hardware device. MMU uses following mechanism to convert virtual address
to physical address.
• The value in the base register is added to every address generated by a user process which is
treated as offset at the time it is sent to memory. For example, if the base register value is
10000, then an attempt by the user to use address location 100 will be dynamically reallocated
to location 10100.
• The user program deals with virtual addresses; it never sees the real physical addresses.
44
2.3.2.1) Virtual Memory
Virtual memory is a technique in which you transfer a data in hard disk from RAM, Means
specific part in hard disk use as a RAM. OR
Virtual memory is a feature of an Operating system that allows a computer to compensate for
shortages of physical memory by temporarily transferring pages or data from RAM to Hard disk
2.3.2.2) Swapping
Swapping is a mechanism in which a process can be swapped temporarily out of main memory
to a backing store, and then brought back into memory for continued execution. So, the process
of swap in and swap out of data is called swapping.show in Figure 2.9
To replace pages or segments of data in memory, Swapping is a useful technique that enables a
computer to execute programs and manipulate data files larger than main memory. The OS
copies as much data possible into main memory, and leaves the rest on the disk, when the OS
needs data from the disk; it exchanges a portion of data (called pages or segment) in a main
memory with a portion of data on disk
DOS does not perform swapping, but most other OS like OS/2, WINDOWS and Linux do.
Remember that swapping is only necessary when that data is not already in the RAM.
45
Fig2.9
2.3.2.3) Fragmentation
As processes are loaded and removed from memory, the free memory space is broken into little
pieces. It happens after sometimes that processes can not be allocated to memory blocks
considering their small size and memory blocks remains unused. This problem is known as
Fragmentation
As you use your computer daily files get written and deleted constantly from the disk, either by
yourself or by the operating system creating and removing temporary files. This process leave
the disk in no sort of order and when new file are written to the disk they start to get written in
the gaps on the disk, this is called Fragmentation.
The Defragmentation process gather data and remove gaps, making data into order is defrag
which makes disk performance faster.
2.3.2.4) Paging
• Page number (p) -- page number is used as an index into a page table which contains base
address of each page in physical memory.
• Page offset (d) -- page offset is combined with base address to define the physical memory
address.
46
Fig 2.10
Fig 2.11
2.3.2.5) Segmentation
Segmentation is a technique to break memory into logical pieces where each piece represents a
group of related information. For example ,data segments or code segment for each process,
data segment for operating system and so on. Segmentation can be implemented using or
without using paging.Show in Fig 2.11
Unlike paging, segment are having varying sizes and thus eliminates internal fragmentation.
External fragmentation still exists but to lesser extent.
47
Fig 2.12
• Segment number (s) -- segment number is used as an index into a segment table which
contains base address of each segment in physical memory and a limit of segment.
• Segment offset (o) -- segment offset is first checked against limit and then is combined with
base address to define the physical memory address.
Fig 2.12
48
2.3.3) Device management
OS manages device communication via their respective drivers. Operating System does the
following activities for device management.
• Keeps tracks of all devices. Program responsible for this task is known as the I/O controller.
• Decides which process gets the device when and for how much time.
• De-allocates devices.
Device management controls the peripheral device by sending them command to their own
properties language.
The software routine known how to deal each device is called “driver” (Device driver allow user
application to communicate with a system device).
The OS required driver for attached peripheral device in the computer. When a new device is
added drivers of this device is necessary to install in computer for communication.
To perform useful functions, processes need access to the peripherals connected to the
computer, which are controlled by the kernel through device drivers. For example, to show the
user something on the screen, an application would make a request to the kernel, which would
forward the request to its display driver, which is then responsible for actually plotting the
character/pixel.
OS
Since main memory (primary storage) is volatile and too small to accommodate all data and
programs permanently, the computer system must provide secondary storage to back up main
memory.
Generally speaking, system has several levels of storage, including primary storage, secondary
storage and cache storage. Instructions and data must be placed in primary storage or cache to
be referenced by a running program. Because main memory is too small to accommodate all
data and programs, and its data are lost when power is lost, the computer system must provide
secondary storage to back up main memory.
49
Secondary storage consists of tapes, disk, and other media designed to held information that
will eventually be accessed in primary storage (primary, secondary, cache) is ordinarily divided
into byte or words consisting of a fixed number of byte.
Responsibility
All operating systems include support for a variety of file systems. Modern file systems
comprise a hierarchy of directories. While the idea is conceptually similar across all
generalpurpose file systems, some differences in implementation exist. The file system is of
particular interest. Obviously, programs need to read and write files and directories, create and
delete them, search them, list file Information, permission management. File systems may
provide journaling, which provides safe recovery in the event of a system crash. A journeyed file
system writes information twice: first to the journal, which is a log of file system operations,
then to its proper place in the ordinary file system. In the event of a crash, the system can
recover to a consistent state by replaying a portion of the journal. In contrast, non-journeyed
file systems typically need to be examined in their entirety by a utility such as fsck or chkdsk.
A file is a collection of related information defined by its creator. Commonly, files represent
programs (both source and object forms) and data. OR
The operating system is responsible for the following activities in connections with file
management:
Keeps track of information, location, uses, status etc. The collective facilities are often known as
file system.Decides who gets the resources.
2.3.4.1) File
50
A file is a named collection of related information that is recorded on secondary storage such as
magnetic disks, magnetic tapes and optical disks.In general, a file is a sequence of bits, bytes,
lines or records whose meaning is defined by the files creator and user.
Attributes of a File
▪ Name – only information kept in human-readable form
• Time, date, and user identification – data for protection, security, and usage monitoring
• Information about files is kept in the directory structure, which is maintained on the
disk.
File structure is a structure, which is according to a required format that operating system can
understand.
• An object file is a sequence of bytes organized into blocks that are understandable by the
machine.
• When operating system defines different file structures, it also contains the code to support
these file structure. UNIX, MS-DOS support minimum number of file structure.
File type refers to the ability of the operating system to distinguish different types of file such as
text files source files and binary files etc. Many operating systems support many types of files.
Operating systems like MS-DOS and UNIX have the following types of files:
I. ORDINARY FILES
51
• These may have text, databases or executable program.
• The user can apply various operations on such files like add, modify, delete or even remove the
entire file.
• These files represent physical device like disks, terminals, printers, networks, tape drive etc.
File access mechanism refers to the manner in which the records of a file may be accessed.
There are several ways to access files
I. Sequential access
I) SEQUENTIAL ACCESS
A sequential access is that in which the records are accessed in some sequence i.e the information
in the file is processed in order, one record after the other. This access method is the most
primitive one. Example: Compilers usually access files in this fashion.
• Each record has its own address on the file with by the help of which it can be directly accessed
for reading or writing.
• The records need not be in any sequence within the file and they need not be in adjacent
locations on the storage medium.
• An index is created for each file which contains pointers to various blocks.
52
• Index is searched sequentially and its pointer is used to access the file directly.
Files are allocated disk spaces by operating system. Operating systems deploy following three
main ways to allocate disk space to files.
I. Contiguous Allocation
I) CONTIGUOUS ALLOCATION
• Easy to implement.
• No external fragmentation
• Each file has its own index block which stores the addresses of disk space occupied by the file.
53
It is system software that takes commands from the operating system to read and write the disk
cluster( group of sectors). The file system manages a folder/directory structure, which provides
an Index to the files. OR
File system is used to control how data is stored and retrieved.
• Create a file
• Write to a file
• Delete a file
• Truncate a file
File system types can be classified into disk/tape file system, network file system and
specialpurpose file system.
A disk file system is a file system designed for the storage of files on a data storage device, most
commonly a disk driver, which might be directly or indirectly connected to the computer
Examples include FAT (FAT12, FAT16, FAT32), exFAT, NTFS,HFS and HFS+, HPFS, UFS, ext2, ext3,
ext4, XFS, btrfs, ISO 9660, Files-11, Veritas File System, VMFS, ZFS, ReiserFS and UDF.
A Flash File System is a File System designed for storing files on flash memory device.
A tape file system is a file system and tape format designed to store files on tape in a
selfdescribing form. Magnetic tapes are sequential storage media with significantly longer
random data access times than disks, posing challenges to the creation and efficient
management of a general-purpose file system.
54
A new concept for file management is the idea of a database-based file system. Instead of, or in
addition to, hierarchical structured management, files are identified by their characteristics, like
type of file, topic, author, or similar rich metadata.
A network file system is a file system that acts as a client for a remote file access protocol,
providing access to files on a server.. Examples of network file systems include clients for the
NFS, AFS, SMB protocols, and file-system-like clients for FTP and WebDAV.
A device file system represents I/O devices and pseudo-devices as files, called device files.
Examples in Unix-like systems include devfs and, in Linux 2.6 systems,udev.
A shared disk file system is one in which a number of machines (usually servers) all have access
to the same external disk subsystem (usually a SAN). Examples include GFS2 from Red Hat,
GPFS from IBM, SFS from DataPlow, CXFS from SGIand StorNext from Quantum Corporation.
A Special File System is basically any File System that is not a disk file system or not a network
File System. This includes system where the files are arranged dynamically by software,
intended for such purpose as communication between computer process or temporary file
space.
The Operating system provides some services to program and to the user of these programmers
in order to make programming task easier. Show Fig 2.13
1) Program Execution:
The operating system should be able to load a program into memory and execute it.
Normally, a user program cannot execute I/O operations directly. So when a running program
needs an i/o the operating system should be able to fulfill the need of that program.
55
3) File System Manipulation:
Programs need to read and write files. Similarly, new files can be created and unwanted existing
files are deleted. Operating system should be able to manage the activities related to files. OR
simply; Program capability to read, write, create and delete file.
4) Communication
Sometimes, programs need to exchange information with each other. Exchange of information
can be implemented using a shared memory (same machine) or message passing in the form of
packets (on a network). OS should be able to communicate between programs.
5) Error detection
The OS should always be aware of possible errors. Error due to hardware i.e. CPU, memory or
I/O devices etc or Due to Software i.e. user program etc. the OS should take necessary steps to
ensure correct and constant computing.
6) Resource Allocation
OS is the manager of resources and when resources are requested by different users at the
same time, then OS allocates and de allocates these resources to many user/programs in an
efficient manner.
7) Accounting
i) To keep track of resources, i.e. which resources are used by which users so that they can be
billed?
ii) Usage statistics of resources may be a valuable tool for researchers in order to
reconfigure the system for improving computer services.
Protection: Any mechanism for controlling access of processes or users to resources defined by
OS.
Security: Defines the system against internal and external attacks.
Detail
Security refers to providing a protection system to computer system resources such as CPU,
memory, disk, software programs and most importantly data/information stored in the computer
system. If a computer program is run by unauthorized user then he/she may cause severe
56
damage to computer or data stored in it. So a computer system must be protected against
unauthorized access, malicious access to system memory, viruses, worms etc. We're going to
discuss following topics in this article.
• Authentication
• Program Threats
• System Threats
Protection Considering a computer systems having multiple users the concurrent execution of
multiple processes, then the various processes must be protected from each another's activities.
Protection refers to mechanism or a way to control the access of programs, processes, or users
to the resources defined by computer systems. Following are the major activities of an operating
system with respect to protection.
• OS ensures that external I/O devices are protected from invalid access attempts.
Fig 2.13
In computing, a system call is how a program requests a service from an operating system kernel.
This may include hardware related services (for example accessing a hard disk drive).
57
User space Application
System Calls
Kernel
Fig 2.14 Sys call
2.5.1) Types of System Calls
1) Process control
3) Device management
58
receive messages transfer status information
attach and detach remote devices
• System programs provide OS functionality through separate applications, which are not
part of the kernel or command interpreters. They are also known as system utilities or
system applications.
• Most systems also ship with useful applications such as calculators and simple editors, (
e.g. Notepad ). Some debate arises as to the border between system and non-system
applications.
• System programs may be divided into these categories:
o File management - programs to create, delete, copy, rename, print, list, and
generally manipulate files and directories. o Status information - Utilities to
check on the date, time, number of users, processes running, data logging, etc.
System registries are used to store and recall configuration information for
particular applications.
o File modification - e.g. text editors and other tools which can change file
contents. o Programming-language support - E.g. Compilers, linkers,
59
debuggers, profilers, assemblers, library archive management, interpreters for
common languages, and support for make.
Many operating systems do not have well-de.ned structures. MS-DOS is an example of such a
system. When DOS was originally written its developers had no idea how big and important it
would eventually become. It was written by a few programmers in a relatively short amount of
time, without the benefit of modern software engineering techniques, and then gradually grew
over time to exceed its original expectations. It does not break the system into subsystems,
and has no distinction between user and kernel modes, allowing all programs direct access to
the underlying hardware.
60
Fig 2.15 - MS-DOS layer structure
The original UNIX OS used a simple layered approach, but almost all the OS was in one big layer,
not really breaking the OS down into layered subsystems:
61
Fig 2.17 - A layered operating system
2.7.3 Microkernels
• The basic idea behind micro kernels is to remove all non-essential services from
the kernel, and implement them as system applications instead, thereby making
the kernel as small and efficient as possible.
• Most microkernels provide basic process and memory management, and
message passing between other services, and not much more.
• Security and protection can be enhanced, as most services are performed in user
mode, not kernel mode.
• System expansion can also be easier, because it only involves adding more
system applications, not rebuilding a new kernel.
• Mach was the first and most widely known microkernel, and now forms a major
component of Mac OSX.
• Windows NT was originally microkernel, but suffered from performance
problems relative to Windows 95. NT 4.0 improved performance by moving
more services into the kernel, and now XP is back to being more monolithic.
• Another microkernel example is QNX, a real-time OS for embedded systems.
62
Figure 2.18 - Architecture of a typical microkernel
2.7.4 Modules
63
2.7.5 Hybrid Systems
• Most OSes today do not strictly adhere to one architecture, but are hybrids of
several.
2.7.5.1 Mac OS X
• The Max OSX architecture relies on the Mach microkernel for basic system
management services, and the BSD kernel for additional services. Application
services and dynamically loadable modules ( kernel extensions ) provide the rest
of the OS functionality:
2.7.5.2 iOS
• The iOS operating system was developed by Apple for iPhones and iPads. It runs
with less memory and computing power needs than Max OS X, and supports
touchscreen interface and graphics for small screens:
64
Figure 2.21 - Architecture of Apple's iOS.
2.7.5.3 Android
• The Android OS was developed for Android smartphones and tablets by the
Open Handset Alliance, primarily Google.
• Android is an open-source OS, as opposed to iOS, which has lead to its
popularity.
• Android includes versions of Linux and a Java virtual machine both optimized for
small platforms.
• Android apps are developed using a special Java-for-Android development
environment.
65
2.8 Operating-System Design and Implementation
• Requirements define properties which the finished system must have, and are a
necessary first step in designing any large complex system. o User
requirements are features that users care about and understand, and are
written in commonly understood vernacular. They generally do not include any
implementation details, and are written similar to the product description one
might find on a sales brochure or the outside of a shrink-wrapped box. o
System requirements are written for the developers, and include more details
about implementation specifics, performance requirements, compatibility
constraints, standards compliance, etc. These requirements serve as a "contract"
between the customer and the developers, ( and between developers and
subcontractors ), and can get quite detailed.
• Requirements for operating systems can vary greatly depending on the planned
scope and usage of the system. ( Single user / multi-user, specialized system /
general purpose, high/low security, performance needs, operating environment,
etc. )
2.8.3 Implementation
66
Part#B. DOS, Commands and Directory
This chapter is not included in your course content but this is very important for learning
Operating system.
So don’t ignore this. Here only some terminology, definition, file system, and commands are
given
DOS stands for DISK OPERATING SYSTEM and Like MS Windows, MS-DOS is operating system. DOS is the
software program, which controls the input and output of your computer. Unlike Microsoft Windows
DOS requires the user to type commands instead of using a mouse. DOS is a single-user, single-task
operating system
MS-DOS is a non-graphical command line operating system created for IBM compatible computers. DOS
was first introduced by Microsoft in August 1981 and last updated in 1994 when MS-DOS 6.22 was
released.DOS operating system is not commonly used today.
Command Prompt
Command Prompt is a native Windows program that lets you execute commands without using a GUI. To
open the Command Prompt. You can do this by going to Start> All Programs>Accessories> Command
Prompt. C:\Documents and Settings\username. This shows that what directory you are currently in.
Every disk you use under DOS has one main directory, called the root directory
C:\ Root Directory
C:\DOS Root with sub directory C:\DOS\RPI
Root with sub directory & another sub directory .
DOS providing solution by adding sub directories to manage data or files
DOS Commands
If you want know the version of DOS just write c:\>ver
in command line prompt then the following message appears on your screen:
67
MS-DOS version 6.22
the ver. command displays the version number of MS-DOS
View the contents of a directory by using the dir command. The dir command stands for "directory."
C:\>dir
A directory list appears. This is a list of all the files and subdirectories that a directory contains. All the
files and directories on your drive are stored in the root directory.
c:\dir
c:\dir/p
the p actually stands for "page"
To view the contents on next screen of information, press any key on your keyboard. Repeat this step
until the command prompt appears at the bottom of your screen.
Another helpful switch you can use with the dir command is the /w, this could view the contents of a
directory in wide format
c:\dir/w
c:\dir/p/w
The root directory is the directory you were in before you changed to the DOS directory and now you
want to go back on root directory
c:\DOS>
write cd\
No matter which directory you are in, this command always returns you to the root directory. Now it
simply look like this
c:\>
c:\DOS\EDIT.COM
If you want to come back on DOS sub directory then it will write cd..
then prompt can back it to c:\DOS
Creating a Directory
To create a directory, you will use the md command. The md command stands for "make directory."
C:\>md fruit
You have now created a directory named FRUIT and if you want to create another directory within the
FRUIT directory named GRAPES then again write md grapes then it will look like this
68
C:\FRUIT\GRAPES> To switch back to
the FRUIT directory, type cd .. The command prompt should now look like the
following: C:\FRUIT>
Deleting a Directory
Changing Drives
If user writes a: then prompt will to Switch drive A (Floppy Drive) and look like this
A:\> and type c:
Your command prompt should return to the following:
C:\ You change to that drive, when you type a drive letter followed by a colon. If you want to view files
on drive A then type
dir a: A list of the files on the floppy disk will appears.
Now write D: or E: or F:
Copying Files
Here you will copy the Edit.hlp and Edit.com files from the RPI directory to the FRUIT directory, You will
specify
copy c:\rpi\edit.com c:\fruit
The following message appears: 1 file(s) copied
similarly copy
c:\rpi\edit.hlp c:\fruit The
following message appears:
1 file(s) copied
Wildcards is used to copy a group of files from the DOS directory to the FRUIT directory.
C:\DOS>dir*.txt
To list all files ending with the extension TXT type
C:\DOS>dir *.txt
MS-DOS lists all the files that end with a TXT extension. The wildcard ignores different beginnings of the
files and focus only on the extensions now
copy C:\DOS>dir*.txt c:\fruit
69
Renaming Files
Rename a file, you will use ren command. The first is the file you want to rename, and the second is the
new name for the file. You separate the two names with a space. ren oldname newname ren
readme.txt peach.txt write c:\dir to see renamed file
The name PEACH.TXT should appear instead of the name README.TXT.
To rename the files that begin with EDIT to the new name PEAR, type the following command: ren
edit.* pear.*
dir pear.* When the files were renamed, their extensions remained the same. For example,
EDIT.COM became PEAR.COM, and EDIT.HLP became PEAR.HLP.
If you want to rename extensions of several files then use wildcards to rename the files. ren *.txt *.old
To confirm that you renamed the files successfully, type the following at the command prompt: C:\dir
Deleting Files
To delete a file, you will use the del command. If you want to delete the PEAR.COM & PEAR.HLP files
then type
del pear.com del
pear.hlp
Deleting a Group of Files
To delete files in the current directory that end with the extension TXT by using wildcard.
dir *.TXT
del *.TXT When directory is empty, you can delete it by using the rd (remove directory) command
rd directory name.
DOS Commands
cd Change directory
dir See a content & detail of files in directory
copy copy a file from one location to another, don’t forget file extension.
md Make or create a new directory
rd Remove a directory & its’ contents
ren Rename a file
help To see a detailed list of many commands.
70
help /? Shows DOS help commands
chkdsk Cchecks a disk
scandisk Check a disk (only if running dos 6 or 6.2 or up versions)
mem Shows your memory usage consumption &know about remaining free space cls Clears the
screen
date Show and allows the date to be changed
time Show and allows the time to be changed
vol Show the volume label of a disk
comp compares two files diskcomp a: b: compares two disks by several means.
*.* It means any file name and any extension regardless of length.
*. Any file name ending with the extension dir*.bat
copy *.* copies all files copy a:*.* c:\games
dir/w
directory wide across the screen dir/p directory
pause a page at a time dir/w/p wide and pause
directory
dir/o directory in order of alphabetic
dir/w/o/p All the above commands together (directory, wide, order, paused)
dir *.exe directory of files ending .exe
dir *.bat directory of files ending .bat
dir *.COM directory of files ending .com
dir t*.* directory of files beginning with the letter t
dir ta*.* directory of files starting ta
dir /s directory show file size
dir /s *.txt Files with txt extension will be display in full size.
8 Format Commands
9 Delete commands
del Delete a file (don’t forget to include the file extension) del *.* Removes all files but not
directory or sub directories.
RD Removes an empty sub directory
Deltree Removes a directory sub directories and all files within them.
UNDELETE: Accidentally erased file can be retrieved
71
10 most useable Commands
cd Chang directory
dir Contents of directory
copy Copy files/contents
del remove file(s)
edit change file(s)
move cut file(s)
72
Chapter#3
Unix/Linux Implementation
Topic to Learn
3.1 Describe UNIX/LINUX Development 3.6 Unix/Linux Help System
3.2 Design principle of UNIX/LINUX 3.7 Unix/Linux File System
3.3 Log in and Log out in system 3.8 Directory structure, Name and File sys
3.4 configure user own environment 3.9 Creating and deleting File and Directory
3.5 Change and manage password 3.10 Set permission on File and Directory
UNIX has been a popular OS for more than two decades because of its multi-user, multi-tasking
environment, stability, portability and powerful networking capabilities.
In the late 1960s, researchers from General Electric, MIT and Bell Labs launched a joint project
to develop an ambitious multi-user, multi-tasking OS for mainframe computers known as
MULTICS (Multiplexed Information and Computing System). MULTICS failed (for some MULTICS
73
enthusiasts "failed" is perhaps too strong a word to use here), but Ken Thompson writing a
simpler operating system himself, known as UNICS (Uniplexed Information and Computing
System). Those days CPU power and memory is short, so command of this OS is suitable for
those computer, this OS use short command, less space, time etc. hence the tradition of short
UNIX commands we use today, e.g. ls, cp, rm, mv etc.
Ken Thompson the author of the first C compiler in 1973. They rewrote the UNIX kernel in C -
and released the Fifth Edition of UNIX to universities in 1974. UNIX development into two main
branches: SYSV (System 5) and BSD (Berkeley Software Distribution).
1) Kernel
A 'kernel' is the central or Core component of most computer operating systems; it act as a
bridge between application and the data processing performed at the hardware level. The
kernel's responsibilities include managing the system's resources (the communication
between hardware and software components).
A computer kernel interfaces between the three major computer hardware components,
providing services between the application/user interface and the CPU, memory and other
hardware I/O devices. The kernel is responsible for:
When an OS is loaded into memory, the kernel loads first and remains in memory until the OS is
shut down again.
A shell is software that provides an interface for an operating system's users to provide access
to the kernel's services. OR
A shell is a user interface for access to an operating system services.
On Unix-based or Linux-based operating systems, a shell can be invoked through the shell
command in the command line interface (CLI), allowing users to direct operations through
computer commands, text or script.
UNIX shells are divided into four categories:
• Bourne-like shells
• C shell-like shells
74
• Nontraditional shells
• Historical shells
NOTE: diagram and more detail in chapter 6
3) System Utilities
A program that performs a very specific task, usually related to managing system resources.
Operating system contains a number of utilities for managing disk drivers, printers, and other
devices.
4) Application programs
An Application software or group of program that is designed for end user. It is used to perform
various applications on computer, also known as application package.
Ms Word, Access Photoshop is the example of Application software.
Linux is a Multiuser Multitasking system with a full set of UNIX-compatible tools. Network
compatible
75
Fig 3.3 Desgin principle of unix/linux
To log in
• Have your user id (user identification) and password ready. Contact your system
administrator if you don't have these yet.
• Type your user id at the login prompt, and then press ENTER. Your user id is
casesensitive, so be sure you type it exactly as your system administrator instructed.
• Type your password at the password prompt, then press ENTER. Your password is also
case-sensitive.
• If you provided correct user id and password then you would be allowed to enter into
the system. Read the information and messages that come up on the screen something
as below.
login : amrood amrood's
password:
Last login: Sun Jun 14 09:32:32 2009 from 62.61.164.73
$
You would be provided with a command prompt ( sometime called $ prompt ) where you would
type your all the commands. For example to check calendar you need to type calcommand as
follows −
76
$ cal
June 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20 21
22 23 24 25 26 27
28 29 30
$
3.3.2) Logging Out
When you finish your session, you need to log out of the system to ensure that nobody else
accesses your files while masquerading as you.
To log out
Just type logout command at command prompt, and the system will clean up everything
and break the connection
• Type in your new password. Always keep your password complex enough so that no
body can guess it. But make sure, you remember it.
77
$ passwd
Changing password for amrood
(current) Unix password:******
New UNIX password:*******
Retype new UNIX password:*******
passwd: all authentication tokens updated successfully $
Note − I have put stars (*) just to show you the location where you would need to enter the
current and new passwords otherwise at your system, it would not show you any character when
you would type.
In LINUX/UNIX whenever you need help with a command type “man” followed by the command
name.
• The Syntax is man [options] command
• Common options are
-
matches.
• We can use help command also. Command - -help
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.
When you work with UNIX, one way or another you spend most of your time working with files.
This tutorial would teach you how to create and remove files, copy and rename them, create links
to them etc.
• Ordinary Files − an ordinary file is a file on the system that contains data, text, or
program instructions. In this tutorial, you look at working with ordinary files.
• Directories − Directories store both special and ordinary files. For users familiar with
Windows or Mac OS, UNIX directories are equivalent to folders.
78
• Special Files − some special files provide access to hardware such as hard drives,
CDROM drives, modems, and Ethernet adapters. Other special files are similar to aliases
or shortcuts and enable you to access a single file using different names.
bin home lib etc dev usr proc root ver tmp
bin
Important Directories
1) /: The root directory, the top-level directory in the FHS (File system Hierarchy) or Directory
structure. All other directories are sub directories of root. Every single file and directory start
from the root directory. Only root user has privilege under this directory. 2) /bin: user
binaries
This contains files that are essential for correct operation of the system.
These are available for use by all users.
Sbin mean’s system binaries which are only expected to be used by the super user.
79
• Also Contains executables
• Linux commands located under this directory are used typically by system administrator.
• For example: iptable, reboot, fdisk, ipconfig etc..
Provides a location for mounting devices such as remote file system and removable media.
• Home directories for almost all user to store their personal files
• For example: /home/ABC
This directory is used to store files which change frequently, and must be available to be written
to:
Directory that contains temporary files created by system and users, files under this directory
are deleted when system is rebooted.
• This also contain startup and shutdown shell scripts used to start/stop individual
programs.
• For example: /ete/resotv.conf
/etc/logrotate.conf
This contains various devices as file, e.g. hard disk, CD ROM drive etc.
80
• For example: /dev/tty
/dev/usbmon0.
This is a pseudo file system contains information about running process. (E.g. proc/pid) it
contains information about system process.
Contains libraries files that supports the binaries located under /bin and /sbin. Library file name
are either id* or lib*.so*
Opt stands for optional, contains add-on applications from individual vendors. Add-on
applications should be installed under either /opt or /opt/sub-directory.
81
3.9) Creating and deleting File and Directory
Press two keys Shift + ZZ together to come out of the file completely.
Now you would have a file created with filemame in the current directory.
$ vi filename
$
3.9.2) Deleting File
Caution: It may be dangerous to delete a file because it may contain useful information. So be
careful while using this command. It is recommended to use -i option along with rm command.
Following is the example which would completely remove existing file filename:
$ rm filename
$
You can remove multiple files at a tile as follows −
82
3.9.3) Creating Directories
Directories are created by the following command −
$mkdir dirname
Here, directory is the absolute or relative pathname of the directory you want to create. For
example, the command −
$mkdir mydir
$
Creates the directory mydir in the current directory. Here is another example −
$mkdir /tmp/test-dir
$
This command creates the directory test-dir in the /tmp directory. The mkdir command
produces no output if it successfully creates the requested directory.
If you give more than one directory on the command line, mkdir creates each of the directories.
For example −
$mkdir docs pub
$
Creates the directories docs and pub under the current directory.
83
−
$cd dirname
$
Here, dirname is the name of the directory that you want to change to. For example, the
command −
$cd /usr/local/bin
$
Changes to the directory /usr/local/bin. From this directory you can cd to the directory
/usr/home/amrood using the following relative path −
$cd ../../home/amrood
$
3.9.6) Renaming Directories
The mv (move) command can also be used to rename a directory. The syntax is as follows −
$mv olddir newdir
$
File ownership is an important component of UNIX that provides a secure method for storing
files. Every file in UNIX has the following attributes −
• Owner permissions − the owner's permissions determine what actions the owner of the
file can perform on the file.
• Group permissions − the group's permissions determine what actions a user, who is a
member of the group that a file belongs to, can perform on the file.
• Other (world) permissions − the permissions for others indicate what action all other
users can perform on the file.
84
$ls -l /home/amrood
-rwxr-xr-- 1 amrood users 1024 Nov 2 00:10 myfile
drwxr-xr--- 1 amrood users 1024 Nov 2 00:10 mydir
Here first column represents different access mode ie. permission associated with a file or
directory.
The permissions are broken into groups of threes, and each position in the group denotes a
specific permission, in this order: read (r), write (w), execute (x) −
• The first three characters (2-4) represent the permissions for the file's owner. For example
-rwxr-xr-- represents that onwer has read (r), write (w) and execute (x) permission.
• The second group of three characters (5-7) consists of the permissions for the group to
which the file belongs. For example -rwxr-xr-- represents that group has read (r) and
execute (x) permission but no write permission.
• The last group of three characters (8-10) represents the permissions for everyone else.
For example -rwxr-xr-- represents that other world has read (r) only permission.
3.10.2) File Access Modes
The permissions of a file are the first line of defense in the security of a Unix system. The basic
building blocks of Unix permissions are the read, write, and execute permissions, which are
described below −
1. Read
Grants the capability to read ie. view the contents of the file.
2. Write
Grants the capability to modify, or remove the content of the file.
3. Execute
User with execute permissions can run a file as a program.
1. Read
Access to a directory means that the user can read the contents. The user can look at the
filenames inside the directory.
85
2. Write
Access means that the user can add or delete files to the contents of the directory.
3. Execute
Executing a directory doesn't really make a lot of sense so think of this as a traverse permission.
A user must have execute access to the bin directory in order to execute ls or cd command.
86
Here's how you could combine these commands on a single line:
$chmod o+wx,u-x,g=rx testfile
$ls -l testfile
-rw-r-xrwx 1 amrood users 1024 Nov 2 00:10 testfile
Using chmod with Absolute Permissions
The second way to modify permissions with the chmod command is to use a number to specify
each set of permissions for the file.
Number Octal Permission Representation Ref
0 No permission ---
1 Execute permission --x
2 Write permission -w-
3 Execute and write permission: 1 (execute) + 2 (write) = 3 -wx
4 Read permission r--
5 Read and execute permission: 4 (read) + 1 (execute) = 5 r-x
6 Read and write permission: 4 (read) + 2 (write) = 6 rw-
7 All permissions: 4 (read) + 2 (write) + 1 (execute) = 7 rwx
Each permission is assigned a value, as the following table shows, and the total of each set of
permissions provides a number for that set.
Here's an example using testfile. Running ls -1 on testfile shows that the file's permissions are as
follows −
$ls -l testfile
-rwxrwxr-- 1 amrood users 1024 Nov 2 00:10 testfile
Then each example chmod command from the preceding table is run on testfile, followed by ls -
l so you can see the permission changes −
87
$ chmod 755 testfile
$ls -l testfile
-rwxr-xr-x 1 amrood users 1024 Nov 2 00:10 testfile
$chmod 743 testfile
$ls -l testfile
-rwxr---wx 1 amrood users 1024 Nov 2 00:10 testfile
$chmod 043 testfile
$ls -l testfile
----r---wx 1 amrood users 1024 Nov 2 00:10 testfile
3.10.5) Changing Owners and Groups
While creating an account on Unix, it assigns a owner ID and a group ID to each user. All the
permissions mentioned above are also assigned based on Owner and Groups.
Two commands are available to change the owner and the group of files −
• chown − The chown command stands for "change owner" and is used to change the
owner of a file.
• chgrp − The chgrp command stands for "change group" and is used to change the group
of a file.
The value of user can be either the name of a user on the system or the user id (uid) of a user
on the system.
Following example −
$ chown amrood testfile
$
Changes the owner of the given file to the user amrood.
NOTE: The super user, root, has the unrestricted capability to change the ownership of a any
file but normal users can change only the owner of files they own.
88
3.10.7) Changing Group Ownership
The chrgp command changes the group ownership of a file. The basic syntax is as follows −
$ chgrp group filelist
The value of group can be the name of a group on the system or the group ID (GID) of a group
on the system.
Following example −
$ chgrp special testfile
$
89
Chapter#4
Unix/Linux Command
Topic to Learn
4.1 Command related to user and file search 4.5 Print File using Linux/Unix commands
4.2 Process job related Command 4.6 Linux/Unix Scheduling Commands
4.3 Manipulates file and directories 4.7 Text Processing Commands
Commands 4.8 Storage and Status Commands
4.4 Search and view Content of File
Commands
NOTE: here maximum commands are given; this is responsibility of your teachers that they have
to prepare the students according to course content.
Command Description
access The system function which checks a user's permissions to access a file.
agrep Version of the grep utility which also matches approximate patterns.
apt-cache Search for information about software packages available through APT.
aptitude Text-based front end for the APT package management system.
as An assembler.
87
bg Continues a program running in the background.
biff This command is used for enable or Display incoming main notification.
bye This command most often used alias for exit command
chroot Run a command or shell from another directory, and treat that directory as root.
crontab View and edit a list of jobs for the system to run at regular intervals.
88
delgroup Remove a group from the system.
depmod Generate a list of kernel module dependences and associated map files.
dirname Strip the filename from a pathname, leaving only the directory component.
dpkg Query, install, remove, and maintain Debian software packages and their dependencies.
findsmb List information about machines networked with the Samba protocol.
foreach Execute a set of commands once for each of a given set of input items.
89
fsck Check and repair a Linux file system.
iostat Report CPU and I/O statistics for devices and partitions.
ip Display and manipulate information about routing, devices, policy routing and tunnels.
join Join the lines of two files which share a common field of data.
90
ksh The Korn shell command interpreter.
mailcompat Provide SunOS 4.x compatibility for the Solaris mailbox format.
make Automatically build executable programs and libraries from source code.
91
mt Control magnetic tapes.
mv Move files and directories from one location to another, and optionally rename them.
nc
nohup Run a command even if the session is disconnected or the user logs out.
partprobe Inform the operating system about changes to the partition table.
pax Read and write file archives, and copy directory hierarchies.
pgrep Examine the active processes on the system and reports the process IDs of the processes.
92
pine Command line program for internet news and email.
pkill Send a signal to any process whose attributes match a regular expression.
pvs Display the internal version information of dynamic objects within an ELF file.
rm Delete files.
rn A newsgroup reader.
93
sed A utility for filtering and transforming text.
strftime Format strings that represent the system date and time.
strip Discard symbols from object files.
94
test Check file types and compare values.
timex Report process data and system activity for a specified command.
trap A function which "traps" signals and interrupts, and reacts to them.
tty Print the file name of the terminal connected to standard input.
uptime Display information about how long the system has been running.
95
wc Display a count of lines, words, and characters in a file.
wget Download files via HTTP or FTP.
whatis Display short manual page descriptions.
whereis Locate the binary, source, and manual page files for a command.
which Locate the binary executable of a command.
while Execute a set of actions while a certain condition is true.
who Report which users are logged in to the system.
whoami Print your effective userid.
whois An internet user name directory service.
write Send a message to another user.
X Executable of the X Window System.
Xorg The executable of the X Window System server.
xargs Build and execute complex commands, and execute them on
multiple files.
xfd Display all the characters in an X font.
xhost Server access control program for X.
xinit The initializer of the X Window System.
xlsfonts Display X font lists.
xrdb An X server resource database utility.
xset A user preference utility for X.
xterm A terminal emulator for X.
xz Compress files to .xz files.
xzcat View compressed .xz files.
yacc "Yet another compiler-compiler."
yes Repeatedly output a given string, or the letter "y".
yppasswd Change a network password in an NIS database.
yum An interactive rpm-based package manager.
zcat Print the uncompressed contents of compressed files.
zip A compression and archiving utility.
zipcloak Encrypt files within an existing zip archive.
zipinfo Display technical information about a zip file.
zipnote View, add, or modify a zip file's comments.
zipsplit Split a single zip archive into a set of smaller zip files.
108
Chapter#5
Text Processing
Topic to Learn
5.1 Invoke Vi editor
5.2 Compose Text using vi
5.3 Modes of vi editor
VI is a screen display-oriented text editor. It works with current display screen, line,
character, graph etc… Detail
vi (pronounced "vee-eye", short for visual, or perhaps vile) is a display-oriented text editor based
on an underlying line editor called ex. Although beginners usually find vi somewhat awkward to
use, it is useful to learn because it is universally available (being supplied with all UNIX systems).
It also uses standard alphanumeric keys for commands, so it can be used on almost any terminal
or workstation without having to worry about unusual keyboard mappings.
System administrators like users to use vi because it uses very few system resources.
$ vi filename
Where filename is the name of the file you want to edit. If the file doesn't exist, vi will create it for
you.
The main feature that makes VI unique as an editor is its mode-based operation. VI has two
modes: command mode and input mode. In command mode, characters you type perform
actions (e.g. moving the cursor, cutting or copying text, etc.) In input mode, characters you type
are inserted or overwrite existing text.
When you begin vi, it is in command mode. To put vi into input mode, press i (insert). You can then
type text which is inserted at the current cursor location; you can correct mistakes with the
109
backspace key as you type. To get back into command mode, press ESC (the escape key). Another
way of inserting text, especially useful when you are at the end of a line is to press a (append).
In command mode, you are able to move the cursor around your document. h, j, k and l move
the cursor left, down, up and right respectively (if you are lucky the arrow keys may also
work). Other useful keys are ^ and $ which move you to the beginning and end of a line
respectively. w skips to the beginning of the next word and b skips back to the beginning of the
previous word. To go right to the top of the document, press 1 and then G. To go the bottom of
the document, pressG. To skip forward a page, press ^F, and to go back a page, press ^B. To go
to a particular line number, type the line number and press G, e.g. 55G takes you to line 55.
To delete text, move the cursor over the first character of the group you want to delete and
make sure you are in command mode. Press x to delete the current character, dw to delete the
next word, d4w to delete the next 4 words, dd to delete the next line, 4dd to delete the next 4
lines, d$ to delete to the end of the line or even dG to delete to the end of the document. If you
accidentally delete too much, pressing u will undo the last change.
Occasionally you will want to join two lines together. Press J to do this (trying to press backspace
on the beginning of the second line does not have the intuitive effect!)
vi uses buffers to store text that is deleted. There are nine numbered buffers (1-9) as well as
the undo buffer. Usually buffer 1 contains the most recent deletion, buffer 2 the next recent,
etc.
To cut and paste in vi, delete the text (using e.g. 5dd to delete 5 lines). Then move to the line
where you want the text to appear and press p. If you delete something else before you paste,
you can still retrieve the delete text by pasting the contents of the delete buffers. You can do
this by typing "1p, "2p, etc.
To copy and paste, "yank" the text (using e.g. 5yy to copy 5 lines). Then move to the line where you
want the text to appear and press p.
In command mode, you can search for text by specifying regular expressions. To search
forward, type / and then a regular expression and press . To search backwards, begin with a
? instead of a /. To find the next text that matches your regular expression press n.
To search and replace all occurences of pattern1 with pattern2, type :%s/pattern1/pattern2/g
. To be asked to confirm each replacement, add a c to this substitution command. Instead
of the % you can also give a range of lines (e.g. 1,17) over which you want the substitution to
apply.
110
5.2.4) Other useful vi commands
Programmers might like the :set number command which displays line numbers (:set
nonumber turns them off).
To save a file, type :w . To save and quit, type :wq or press ZZ. To force a quit without saving
type :q! .
To execute shell commands from within vi, and then return to vi afterwards, type :!shell command
. You can use the letter % as a substitute for the name of the file that you are editing (so :!echo
% prints the name of the current file).
Cursor movement:
h left j
down k
up
l right
^ beginning of line
$ end of line
1G top of document
G end of document
<n> G go to line <n>
^F page forward ^B
page backward w
word forwards b
word backwards
111
<n> dd delete n lines
Miscellaneous:
u undo :w
save file
:wq save file and quit
ZZ save file and quit
:q! Quit without saving
1) “Ed” editor
Ed – A line-oriented text editor. It operates in the line mode. You can give commands to the
editor to perform various operations on a line. Including:
Mean’s ed editor only working with lines. It is most basic UNIX editor, and is found in every
UNIX system.
Using “ED”
The ed text editor works by using a buffer an in memory storage area where the actual text resides
until you explicitly store the text in a file.
Modes
Command mode: is what you get by default. In this mode, ed interprets anything that type as a
command.
Text-input mode: enables you to enter text into the buffer. You can enter input mode by using the
commands a (append), c (change), i (insert).
112
2) GNU emacs
Emacs is design to manipulating pieces of text, although it is capable of formatting and printing
document like a word processor.
3) Text editor
• Text editor is simple, open source word processing and text editor.
• It also has capability to check spell.
• It is work with line, paragraph, file, etc... As you wish. It is GUI.
4) JOT
5) Vueped
• It is GUI
• Provide point and cursor facility
• Developed by HP
6) Nuepad
7) pico
• It is GUI
113
• Point and cursor facility.
5.3) vi Modes
• Command mode is the mode you are in when you start (default mode)
• Command mode is the mode in which commands are given to move around in the
file, to make changes, and to leave the file
• Commands are case sensitive: j not the same as J
• Most commands do not appear on the screen as you type them. Some commands
will appear on the last line: : / ?
• The mode in which text is created. (You must press <Return> at the end of each line
unless you've set wrap margin.)
• There is more than one way to get into insert mode but only one way to leave:
return to command mode by pressing <Esc>
When in doubt about which mode you are in, press <Esc>
114
Chapter#6
Unix/Linux Shells
Topic to Learn
6.1 Define Unix Linux shell 6.3 Describe bourn shell
6.2 Explain the Function of Shell 6.4 Use bourn shell in Unix/Linux
A shell is software that provides an interface for an operating system's users to provide access to
the kernel's services. OR
A shell is a user interface for access to an operating system services.
Detail
A shell is a program that provides the traditional, text-only user interface for Linux and other
Unix-like operating systems. Its primary function is to readcommands that are typed into a
console (i.e., an all-text display mode) or terminal window (an all-text window) in a GUI
(graphical user interface) and then execute (i.e., run) them.
A user is in a shell (i.e., interacting with the shell) as soon as that user has logged into the system.
A shell is the most fundamental way that a user can interact with the system, and the shell hides
the details of the underlying operating system from the user.
The term shell derives its name from the fact that it is an outer layer of an operating system. A
shell is an interface between the user and the internal parts of the operating system (at the
very core of which is the kernel).
115
6.2) Explain the Function of Shell
Computers understand the language of zeros and ones known as binary language. In the early
days of computing, instructions were provided using binary language, which is difficult for all of
us to read and write. Therefore, in an operating system there is a special program called the
shell. The shell accepts human readable commands and translates them into something the
kernel can read and process. The most generic sense of the term shell means any program that
users employ to type commands. A shell hides the details of the underlying operating system
and manages the technical details of the operating system kernel interface, which is the
lowestlevel, or "inner-most" component of most operating systems.
user
Shell Kernal OS
Converstion
binary
fig 6.3
116
6.3) Describe bourne shell
A number of different shells have been developed for Unix-like operating systems. They share
many similarities, but there are also some differences with regard to commands, syntax and
functions that are important mainly for advanced users. Every Unix-like operating system has
at least one built-in shell, and most have several. Sh (Bourne shell)
sh (the Bourne Shell) is the original UNIX shell, and it is still in widespread use today. Written by
Stephen Bourne at Bell Labs in 1974, it is a simple shell with a small size and few features,
perhaps the fewest of any shell for a Unix-like operating system. Bell Labs was the research and
development arm of AT&T (The American Telephone and Telegraph Company), the former U.S.
telecommunications monopoly. The first version of UNIX was developed at Bell Labs in 1969.
Among the functions that most users have come to expect in a shell but which are missing in sh
are file name completion, command editing, command history and ease of executing multiple
background processes (also referred to as jobs). A process is an instance of an executing
program; a background process operates generally unnoticed while users are working with
foreground processes. File name completion is the completion by the system of the names of
files that have only partially typed in by a user. Command history allows users to conveniently
find and reissue previously issued commands. Every Unix-like system contains sh or another
shell which incorporates its commands.
Feature
• Command History Feature: NO( the ability to store commands in a buffer, than modify
and reuse)
• Line Editing Feature: NO(Ability to current or previous command line with a text editor
Restricted shell: No( security limitation)
117
4. It has limited functionality
5. It cannot re-edit previous command commands or to control background jobs
6. It’s function is sufficient and cannot convinces the user
7. It is also used for programming script, bourne shell script also under BASH
8. Bourne shell is located at /bin/sh
9. Default prompts is $
10. Limited security
1) bash (Bourne-again shell) is the default shell on Linux. It also runs on nearly every other
Unix-like operating system as well, and versions are also available for other operating systems
including the Microsoft Windows systems. Bash is a superset of sh (i.e., commands that work in
sh also work in bash, but the reverse is not always true), and it has many more commands than
sh, making it a powerful tool for advanced users. But it is also intuitive and flexible, and thus it is
probably the most suitable shell for beginners. bash was written for the GNU project (whose goal
is to develop a complete, Unix-compatible, high performance and entirely free operating
system), primarily by Brian Fox and Chet Ramey. Its name is a pun on the name of Steve Bourne.
2) csh (the C shell) has a syntax that resembles that of the highly popular C programming
language (also developed at Bell Labs), and thus it is sometimes preferred by programmers. It
was created in 1978 by Bill Joy. It is more compatible for c programming languages. It has ability
to re-edit the command. The default prompt for c shell is the % sign.
3) ksh (the Korn shell) is a superset of sh developed by David Korn at Bell Labs in 1983. It
contains many features of the C shell as well. It is based on bourne shell most command and
login style, prompt style are same. One enhancement that is particularly useful is it’s
commandline editing facility. It is possible using either vi or emacs keys to recall and edit
previous commands. There are also more powerful programming constructs than the bourne
shell. Default Location os (/bin/ksh).
118
4) tcsh (the TENEX C shell) is based on csh but also has programmable file name completion,
command line editing, a command history mechanism and other features lacking in csh. It is
named after the TENEX operating system, which inspired the author of tcsh. tcsh replaced the
csh as the default shell on some BSD operating systems (i.e., FreeBSD and Darwin).
When logged into the shell you will normal see one of the following prompts: $, % or #.
This is an indication that the shell is waiting for an input from the user. The prompts
can be customised but generally the last character should be left as the default
prompt character as it helps to indicate which shell you are running and whether or
not you are logged in as root.
The Bourne, Korn, and Bash shells all accept a similar syntax. Unless you are using one of
the advanced features you do not necessarily need to know which one of them you are
in. If however you are in the C or tcsh shells this uses a completely different syntax and
can require commands to be entered differently. To make it a little easier these have
two different prompts depending upon the shell.
When logged into the computer as root, the user should take great care over the
commands that are entered (further information about the root user is included in
the System Administrator book). If you enter something incorrectly you could end up
damaging the Linux installation files or even delete all the data from a disk. For this
reason the prompt is different when logged in as a root user as a constant reminder
of the risks.
The default prompt for root is the hash sign # this is regardless of the shell being used.
Using the shell to run command you can use it’s built-in programming languages to write your own
commands or program. You put command into file known as shell script OR
1. Write a script
2. Give the shell permission to execute it
119
3. Put it somewhere the shell can find it
It is lab …. Practical
Chapter#7
System Administration
Red Hat 6 RHEL Installation
1. Select Install or upgrade an existing system option on Grub Menu
2. Choose a language
3. Choose a keyboard type
4. Choose a installation media
5. Skip DVD media test (or select media test, if you want to test installation media before
installation)
6. Red Hat 6 graphical installer starts, select next
7. Accepct Pre-Release Installation
8. Select storage devices
9. Insert computer name
10. Select time zone
11. Enter a password for root user
12. Select type of installation
Read every options info carefully. And select encrypting if needed and option to review and
modify partition layout.
13. Review partition layout
Modify if needed. Default setup with ext4 and LVM looks good for desktop machine.
14. Accept write changes to disc
15. Writing changes (creating partitions) to disc
16. Configure boot loader options
Select device to install bootloader and check/create boot loader operating system list.
17. Select softwares to install and enable repositoriesThis case we select Software Development
Workstation and enable Red Hat Enterprise Linux 6.0 Beta Repository and select Customize
now.
18. Customize package selection Select PHP and Web Server to installation.
120
Select MySQL and PostgreSQL Databases.
Select set of Development tools like
Eclipse IDE.
19. Checking dependencies for installation
20. Starting installation process
21. Installing packages
22. Installation is complete
Click reboot computer and remove installation media.
Red Hat 6 RHEL Finishing Installation
23. Selecting RHEL 6 from grub
24. Booting Red Hat 6
25. Red Hat 6 Welcome screen
26. Create normal user
27. Setup date and time and keep up-to-date with NTP
28. Login Red Hat 6 Gnome Desktop
29. Red Hat (RHEL) 6 Gnome Desktop, empty and default look
Note : chapter 7 is almost practical, you can understand chapter 7 better with practical. So don’t
ignore this.
121
Please visit for more notes
https://dae-note.blogspot.com/
122
Past paper
123
124