Unit 1 To 4 - Linux
Unit 1 To 4 - Linux
Computers can store information on various storage media, such as magnetic disks, magneti
tapes, and optical disks. So that the computer system will be convenient to use, the operating
system provides a uniform logical view of information storage. The operating system abstracts
from the physical of its storage devices to define a logical storage unit, the file. Vites are
mapped by the operating system onto physical devices. These storage devices are nonvolatile,
so the contents are persistent through power failures and system reboots usually
A file is a named collection of related information that is recorded on secondary storagu: From
a bew's perspective, a file is the smallest allotment of logical secondary storage, that is, data
cannot bewrinen to secondary storage unless they are within a file. Commonly, files represent
programs thoth source and object forms) and data Data files may be numeric, alphabetic,
alphanumeric of Binary Files may be free form, such as text files, or may be formatted rigidly.
In general, a file is a sequence of bits, bytes, lines, or records, the meaning of which is defined
by the file's creator and user. The concept of a file is thus extremely general The information
in a file is defined by its creator. Many different types of information may be stored in a file-
source programs, object programs, executable programs, numeric data, text payroll records,
graphic images, sound recordings, and so on. A file has a certain defined which depends on its
type. A text file is a sequence of characters organized into lines (and possibly pages). A source
file is a sequence of subroutines and functions, each of which is further organized as
declarations followed by executable statements. An object file is a sequence of hytes organized
in to blocks understandable by the system's linker. An executable file is a series of code sections
that the loader can bring into memory and execute
File Attributes
t file is named, for the convenience of its human users, and is referred to by its name. A name
is usually a string of characters, such as example.e. Some systems differentiate between
uppercase and lowercase characters in names, whereas other systems do not. When a file is
named, it comes independent of the process, the user, and even the system that created it. For
instance, one user might create the file example.c, and another user might edit that file by
specifying its name. The file's owner might write the file to a floppy disk, send it in an e-mail,
or copy it across a network, and it could still be called example.c on the destination system. A
file's attributes vary from one operating system to another but typically consist of these:
Name
The symbolic file name is the only information kept in human readable form.
Identifier
This unique tag, usually a number, identifies the file within the file system the non-human-
readable name for the file.
Type
Location
This information is a pointer to a device and to the location of the file on that device.
Size
The current size of the file (in bytes, words, or blocks) and possibly the maximum allowed size
are included in this attribute. Protection. Access-control information determines who can do
reading, writing execiting, and so on.
This information may be kept for creation, last modification, and last use These data can be
useful for protection, security, and usage monitoring.
File Operations
A file is an abstract data type. To define a file properly, we need to consider the operatams that
can be performed on files. The operating system can provide system calls to create, write read
reposition, delete, and truncate files. Let's examine what the operating system must do to
perfons each of these six basic file operations. It should then be easy to see how other similar
operations such as renaming a file, can be implemented.
Creating a file
Two steps are necessary to create a file. First, space in the file system must be found for the
file. Second, an entry for the new file must be made in the directory.
Writing a file
To write a file, we make a system call specifying both the name of the file and the information
to be written to the file. Given the name of the file, the system searches the directory to find
the file's location.
The system must keep a write pointer to the location in the file where the next write is to take
place. The write pointer must be updated whenever a write occurs.
Reading a file
To read from a file, we use a system call that specifies the name of the file and where in
memory) the next block of the file should be put. Again, the directory is searched for the
associated entry, and the system needs to keep a read pointer to the location in the file where
the next read is to take place Once the read has taken place, the read pointer is updated. Because
a process is usually either reading from or writing to a file, the current operation location can
be kept as a per-process. Both the read and write operations use this same pointer, saving space
and reducing system complexity.
The directory is searched for the appropriate entry, and the current-file-position pomeris
repositioned to a given value. Repositioning within a file need not involve any actual 10 This
file operation is also known as a file seek.
Deleting a file
directTe delete file, we search the directory for the same file. Having found the cisted direction
entry we release all the space, as that it can be rensed by other files, and ethe directory enцу.
Truncating a file
The user may want to erase the contents of a file but keep its attributes. Rather than forcing the
user to delete the file and then recreate it, this function allows all attributes to remain unchanged
except for file length-but lets the file be reset to length zero and its file space released.
These six basic operations comprise the minimal set of required file operations. Other common
operations include appending new information to the end of an existing file and renaming an
existing file. These primitive operations can then be combined to perform other file operations.
For instance, we can create a copy of a file, or copy the file to another I/O device, such as a
printer or a display, by creating a new file and then reading from the old and writing to the new.
We also want to have operations that allow a user to get and set the various attributes of a file.
For example, we may want to have operations that allow a user to determine the status of a file,
such as the file's length, and to set file attributes, such as the file's owner.
1. Sequential Access
The simplest access method is sequential method. Information in the file is processed in order.
one record after the other. This mode of access is by far the most common; for example, editors
and compilers usually access files in this fashion.
Reads and writes make up the bulk of the operations on a file. A read operation-read next-reads
the next portion of the file and automatically advances a file pointer, which tracks the I/O
location. Similarly, the write operation-write next-appends to the end of the file and advances
to the end of the newly written material (the new end of file). Such a file can be reset to the
beginning, and on some systems, a program may be able to skip forward or backward n records
for some integer n-perhaps only for n= 1. Sequential access, which is depicted in Figure, is
based on a tape model of a file and works as well on sequential-access devices as it does on
random-access ones.
A file is a made up of fixed length logical address that allow programs to read and write records
rapidly in no particular order. The direct-access method is based on a disk model of a file, since
disks allow random access to any file block. For direct access, the file is viewed as a numbered
sequence of blocks or records. Thus, we may read block 14, then read block 53, and then write
block 7. There are no restrictions on the order of reading or writing for a direct-access file.
2. Direct Access
Direct-access files are of great use for immediate access to large amounts of information.
Databases are often of this type. When a query concerning a particular subject arrives, we
compute which block contains the answer and then read that block directly to provide the
desired information. As a simple example, on an airline-reservation system, we might store all
the information about a particular flight (for example, flight 713) in the block identified by the
flight number. Thus, the number of available seats for flight 713 is stored in block 713 of the
reservation file. To store ill formation about a larger set such as people, we might compute a
hash function on the people's names or search a small in-ncemory index to determine a block
to read and search For the direct-access method, the file operations must be modified to include
the block number as a parameter. Thus, we have read n, where n is the block number, rather
than read next, and write n rather than write next. An alternative approach is to retain read next
and write next, as with sequential access, and to add an operation position file to n. where n is
the block number. Then, to effect a read n, we would position to n and then read next. The
block number by the user to the operating system is normally aA relative block number is an
index relative to the begirm.ing of the file. Thus, the first relative block of the file is 0, the next
is 1, and so on, even though the absolute disk address may be 14703 for the first block and
3192 for the second. The use of relative block numbers allows the operating system to decide
where the file should be placed (called the allocation problem, as discussed in Chapter 11) and
helps to prevent the user from accessing portions of the file system that may not be part of her
file. Some systems start their relative block numbers at 0; others start at 1. How, then, does the
system satisfy a request for record Nina file? Assuming we have a logical record length L., the
request for record N is turned into an 1/0 request for L bytes starting at location L (N) within
the file (assuming the first record is N = 0). Since logical records are of a fixed size, it is also
easy to read, write, or delete a record. Not all operating systems support both sequential and
direct access for files. Some systems allow only sequential file access, others allow only direct.
access. Some systems require that a file be defined as sequential or direct when it is created;
such a file can be accessed only in a manner consistent with its declaration. We can easily
simulate sequential access on a direct-access file by simply keeping a variable cp that defines
our current position, as shown in Figure. Simulating a direct-access file on a sequential-access
file, however, is extremely inefficient and clumsy.
Index Sequential access methods can be built on top of a direct-access method. These methods
generally involve the construction of an index for the file. The like an index in the back of a
contains pointers to the various blocks. To find a record in the file, we first search the index
and then use the to access the file directly and to find the desired record.
For example, a retail-price file might list the universal codes (UPCs) items, with the associated
prices. Each record consists a 10-digit UPC and a 6-digit price, a 16-byte record. If our disk
has 1.024 bytes per we can store 64 records per block. A file of 120,000 records would occupy
about 2.000 blocks (2 million bytes). By keeping the file sorted by UPC, we can define an
index consisting of the first UPC in each block. This index would have entries of 10 digits each,
or 20,000 bytes, and thus could be kept in memory. To find the price of a particular item, we
can make a binary search of the index. From this search, we learn exactly which block contains
the desired record and access that block. This structure allows us to search a large file doing
little 1/0. With large files, the index file itself may become too large to be kept in memory. One
solution is to create an index for the index file. The primary index file would contain pointers
to secondary index files, which would point to the actual data items. For example, IBM's
indexed sequential-access method (ISA) uses a small master index that points to disk blocks of
a secondary index. The secondary index blocks point to the actual file blocks. The file is kept
sorted on a defined key. To find a particular item, we first make a binary search of the master
index, which provides the block number of the secondary index. This block is read in, and
again a binary search is used to find the block containing the desired record. Finally, this block
is searched sequentially. In this way, any record can be located from its key by at most two
direct-access reads. Figure 10.5 shows a similar situation as implemented by VMS index and
relative files.
Adams
Arthur
Asher
.
.
.
smith
Directory Overview
The directory can be viewed as a symbol table that translates file names into their directory
entries. If we take such a view, we see that the directory itself can be organized in many ways.
We want to be able to insert entries, to delete entries, to search for a named entry, and to list
all the entries in the directory. In this
section, we examine several schemes for defining the logical structure of the directory system.
Create a file New files need to be created and added to the directory.
Delete a fileWhen a file is no longer needed, we want to be able to remove it from the directory.
List a directoryWe need to be able to list the files in a directory and the contents of the
directory en for each file in the list.
Rename a fileBecause the name of a file represents its contents to its users, we must be able
to change the name when the contents or use of the file changes. Renaming a file may also
allow its position within the directory structure to be changed.
Traverse the file systemWe may wish to access every directory and every file within a
directory structure. For reliability, it is a good idea to save the contents and structure of the
entire file system at regular intervals. Often, we do this by copying all files to magnetic tape.
This technique provides a backup copy in case of system failure. In addition, if a file is no
longer in use, the file can be copied to tape and the disk space of that file released for reuse by
another file.
Directory Structure
A directory is a container that is used to contain folders and file. It organized files and folders
into hierarchical manner. There are several logical structures of directory, these are given as
below.
Single level directory is simplest directory structure. In it all files are contained in same
directory which make it easy to support and understand.
A single level directory has a significant limitation, however, when the number of files
increases or when the system has more than one user. Since all the files are in the same
directory, they must have the unique name. if two users call their dataset test, then the unique
name rule violated.
Advantages:
Since it is a single directory, so its implementation is very easy. • If files are smaller in size,
searching will faster.
Disadvantages:
There may chance of name collision because two files cannot have the same name.
As we have seen, a single level directory often leads to confusion of files names among
different users. the solution to this problem is to create a separate directory for each user.
In the two-level directory structure, each user has their own user files directory (UFD). The
UFDs has similar structures, but each lists only the files of a single user. system's master file
directory (MFD) is searches whenever a new user id=s logged in. The MFD is indexed by
username or account number, and each entry points to the UFD for that user.
Advantages:
We can give full path like /User-name/directory-name/.1040
Different users can have same directory as well as file name.
Searching of files become more easy due to path name and user-grouping.
Disadvantages:
A user is not allowed to share files with other users.
Still it not very scalable, two files of the same type cannot be grouped together in the same
user.
3.Tree Structured Directory Structure
Once we have seen a two-level directory as a tree of height 2, the natural generalization isto
extend the directory structure to a tree of arbitrary height. This generalization allows the user
to create their own subdirectories and to organized on their files accordingly.
Advantages:
Searching becomes very easy, we can use both absolute path as well as relative.
Disadvantages:
Every file does not fit into the hierarchical modelfiles may be saved into multipledirectories.
Directory Implementation
The selection of directory-allocation and directory-management algorithms significantly
affects the efficiency, performance, and reliability of the file system. In this section, we
discuss the trade-offs involved in choosing one of these algorithms.
1. Linear List
The simplest method of implementing a directory is to use a linear list of file names with
pointers to the data blocks. This method is simple to program but time-consuming to execute.
To create a new file, we must first search the directory to be sure that no existing file has the
same name. Then, we add a new entry at the end of the directory. To delete a file, we search
the directory for the named file and then release the space allocated to it. To reuse the
directory entry, we can do one of several things. We can mark the entry as unused (by
assigning it a special name, such as an all-blank name, or with a used unused hit in each
entry), or we can attach it to a list of free directory entries. A third alternative is to copy the
last entry in the directory into the freed location and to decrease the length of the directory. A
linked list can also be used to decrease the time required to delete a file
The real disadvantage of a linear list of directory entries is that finding a file requires a linear
search. Directory information is used frequently, and users will notice if access to it is slow.
In fact, many operating systems implement a software cache to store the most recently used
directory information. A cache hit avoids the need to constantly reread the information from
CC-403-ADVANCE OPERATING SYSTEM AND LINUX Page 8
SHREE MARUTI VIDHYAMANDIR COLLEGE OF BUSSINESS
MANGEMNET AND COMPUTER SCIENCE – B.C.A BHAVNAGAR
disk. A sorted list allows a binary search and decreases the average search time. However, the
requirement that the list be kept sorted may complicate creating and deleting files, since we
may have to move substantial amounts of directory information to maintain a sorted
directory. A more sophisticated tree data structure, such as a B-Tree, might help here. An
advantage of the sorted list is that a sorted director listing can be produced without a separate
sort step.
2. Hash Table
Another data structure used for a file directory is Hash Table with this method, a linear list
stores the directory entries, but a hash data structure is also used. The hash table takes a value
computed from the file name and returnsa pointer to the file name in the linear list. Therefore,
it can greatly decrease the directory search time. Insertion and deletion are also fairly
straightforward, although some provision must be made for collisions-situations in which two
file names hash to the same location.
The major difficulties with a hash table are its generally fixed size and the dependence of the
hash function onthat size. For example, assume that we make a linear-probing hash table that
holds 64 entries. The hash functionconverts file names into integers from 0 to 63, for instance,
by using the remainder of a division by 64. If welater try to create a 65th file, we must enlarge
the directory hash table-say, to 128 entries. As a result, we need anew hash function that must
map file names to the range 0 to 127, and we must reorganize the existing directoryentries to
reflect their new hash-function values.
alternatively, a chained-overflow hash table can be used. Each hash entry can be a linked list
instead of an individual value, and we can resolveble and Each has entry can be linked
Lookups may be somewhat slowed, because searching for a name might require steppinary to
the linked list of colliding table entries. Still, this method is likely to be much faster than a
linear search through the entire directory.
The allocation methods define how the files are stored in the disk blocks. There are three
main file allocation methods.
• Contiguous Allocation
• Linked Allocation
• Indexed Allocation
All the three methods have their own advantages and disadvantages as discussed below:
1. Contiguous Allocation
In this scheme, each file occupies a contiguous set of blocks on the disk. For example, if a
file requires n blocks and is given a block b as the starting location, then the blocks assigned
The file 'mail' in the following figure starts from the block 19 with length = 6
blocks.Therefore, it occupies 19, 20, 21, 22, 23, 24 blocks.
Advantages:
Both the Sequential and Direct Accesses are supported by this. For direct access, the
address of the kth block of the file which starts at block b can easily be obtained as (b-k).
This is extremely fast since the number of seeks are minimal because of contiguous allocation
of file blocks.
Disadvantages:
This method suffers from both internal and external fragmentation. This makes it
inefficient in terms of memory utilization, Increasing file size is difficult because it depends
on the availability of contiguous memory at a particular instance.
In this scheme, each file is a linked list of disk blocks which need not be contiguous.
The disk blocks can be scattered anywhere on the disk. The directory entry contains a pointer
to the starting and the ending file block. Each block contains a pointer to the next block
occupied by the file.
The file 'jeep' in following image shows how the blocks are randomly distributed. The
last block (25) contains -1 indicating a null pointer and does not point to any other block
Advantages:
This is very flexible in terms of file size. File size can be increased easily since the system
does not have to look for a contiguous chunk of memory. This method does not suffer from
external fragmentation. This makes it relatively better in in terms of memory utilization.
Disadvantages:
Because the file blocks are distributed randomly on the disk, a large number of seeks are
needed to access every block individually. This makes linked allocation slower.
It does not support random or direct access. We cannot directly access the blocks of a file. A
block k of a file can be accessed by traversing k blocks sequentially (sequential access) from
the starting block of the file via block pointers.
3. Indexed Allocation
In this scheme, a special block known as the Index block contains the pointers to all the
blocks occupied by a file. Each file has its own index block. The ith entry in the index block
contains the disk address of the ith file block. The directory entry contains the address of the
index block as shown in the image:
Advantages:
This supports direct access to the blocks occupied by the file and therefore provides fast
access to the file blocks.
Disadvantages:
The pointer overhead for indexed allocation is greater than linked allocation.
For very small files, say files that expand only 2-3 blocks, the indexed allocation would keep
one entire block (index block) for the pointers which is inefficient in terms of memory
utilization. However, in linked allocation we lose the space of only I pointer per block.
a free space list which keeps track of the disk blocks that are not allocated to some file or
directory. The free space list can be implemented mainly as:
A Bitmap or Bit Vector is series or collection of bits where each bit corresponds to a disk
block. The bit can take two values: 0 and 1: 0 indicates that the block is allocated and I
indicates a free block. The given instance of disk blocks on the disk in Figure 1 (where green
blocks are allocated) can be represented by a bitmap of 16 bits as: 0000111000000110.
Advantages –
Simple to understand.
Finding the first free block is efficient. It requires scanning the words (a group of 8 bits) in a
bitmap for a non-zero word. (A 0-valued word has all bits 0).
The first free block is then found by scanning for the first 1 bit in the non-zero word.
The block number can be calculated as: (number of bits per word) *(number of 0-values
words) + offset of bit first bit I in the non-zero word.
2.linked list-
In this approach,the free disk blocks are linked together i.e, a free black contains a pointer to
the next free block.the block number of the very first disk block is stored at a seprate location
on disk and is also cached in memory.
3.grouping-
This approach stores the address of the free blocks in the first free block. The first free block
stores the address of some,say n free blocks.out of these n blocks, the first n-1 blocks are
actually free and the last block contains the address of next free n block.
An advantage of this approach is that the addresses of a group of free disk blocks can be
found easily.
4.Counting-
This approach stores the address of the first free disk block and a number n of free contiguous
disk blocks that follow the first block.
2. a number n
For example in figure the first entry of the free space list would be([address of block
5],2),because 2 contiguous free blocks follow block 5.
Devices communicate with the computer via signals sent over wires or through the air.
Buses include rigid protocols for the types of messages that can be sent across the bus and the
procedures for resoving contention issues.
Figure below illustrates three of the four bus types commonly found in a morden pc.
1.thepci bus connects high-speed high-bandwidth devices to the memory subsystem(and the
cpu).
2.the expansion bus connects a lower low-bandwidth devices,which typically deliver data one
character at a time(with buffering).
3.thescsi bus connects a number of scsi (small compuer system interface)devices to a common
SCSI controller.
4.A daisy-chain bus,(not shown) is when a string of devices is connected to each other like
beads on a chain, and only one of the devices is directly connected to the host.
One way of communicating with devices is through registers associated with each port.
Registers may be one to four bytes in size. And may typically include (a subset of) the following
four:
The data in register is read by the host to get input from the device.
The status register has bits read by the host to determine the status of the device,such as idele,
ready for input ,busy,error,transaction complete etc.
In this case a certain portion of the processor’s address space is mapped to the device,and
communicates occur by reading and writing directly to from those memory areas.
Memory-mapped i/o can be used either instead of or more often in combination with traditional
register .for example graphics cards still use register for control information such as setting the
video mode.
A potential problem exiss with memory-mapped i/o ,if a processs is allowed to write directly
to the address space used by a memory –mapped i/o device.
Polling:
the complete protocol for interaction between the host and a controller can be complex, but the
basic handshaking notion is simple.
Assume that 2 bits are used to coordinate the producer-consumer relationship between the
controller and the host.the controller indicates its state through the busy bit in the status register.
The controller sets the busy bit when it is busy working and clears the busy bit when it is ready
to accept the next command.
The host signals its wishes via the command-ready bit in the command register.the host sets
the command-ready bit when a command is available for the controller to execute.
1.the host repeatedly checks the busy bit on the device until it becomes clear.
2. the host writes a byte of data into the data-out register,and sets the write bit in the command
register.
3. the host sets the command ready bit in the command ready bit set,it first sets the busy bit.
4.when the device controller sees the command ready bit set,it first sets the busy bit.
5. then the device controller reads the command register ,sees the write bit set,reads the bytes
of data from the data-out register and outputs the byte of data.
6.the device controller then clears the error bit in the status register ,the command-ready bit,and
finally clears the busy bit,signaling the completion of the operation
Polling can be very fast and efficient ,if both the device and the controller are fast and if there
is significant data to trtansfer.it becomes inefficient,however.if the host must wait a long time
in the busy loop waiting for the device,or if frequent cheeks need to be made for data that is
infrequently there.
Interrupts:
The cpu has an interrupt-request line that is sensed after every instruction.
A device’s controller raises an interrupt by asserting a signal on the interrupt request line.
The cpu then performs c state save and transfers control to the interrupt,performs the nessary
processing ,performs a state restore, and executes a return from intrupts introduction.
Direct Memory Access uses hardware for accessing the memory, that hardware is called a
DMA Controller. It has the work of transferring the data between Input Output devices and
main memory with very less interaction with the processor. The direct Memory Access
Controller is a control unit, which has the work of transferring data.
DMA Controller is a type of control unit that works as an interface for the data bus and the I/O
Devices. As mentioned, DMA Controller has the work of transferring the data without the
intervention of the processors, processors can control the data transfer. DMA Controller also
contains an address unit, which generates the address and selects an I/O device for the transfer
of data. Here we are showing the block diagram of the DMA Controller.
Dual-Ended DMA: Dual-Ended DMA controllers can read and write from two memory
addresses. Dual-ended DMA is more advanced than single-ended DMA.
Interleaved DMA: Interleaved DMA are those DMA that read from one memory
address and write from another memory address.
Address register – It contains the address to specify the desired location in memory.
Note: All registers in the DMA appear to the CPU as I/O interface registers. Therefore,
the CPU can both read and write into the DMA registers under program control via the data
bus.
The figure below shows the block diagram of the DMA controller. The unit
communicates with the CPU through the data bus and control lines. Through the use of the
address bus and allowing the DMA and RS register to select inputs, the register within the
DMA is chosen by the CPU. RD and WR are two-way inputs. When BG (bus grant) input is 0,
the CPU can communicate with DMA registers. When BG (bus grant) input is 1, the CPU has
relinquished the buses and DMA can communicate directly with the memory.
Explanation: The CPU initializes the DMA by sending the given information through
the data bus.
• The starting address of the memory block where the data is available (to read) or where
data are to be stored (to write).
• It also sends word count which is the number of words in the memory block to be read or
written.
• Control to define the mode of transfer such as read or write.
• A control to begin the DMA transfer
Modes of Data Transfer in DMA
There are 3 modes of data transfer in DMA that are described below.
• Burst Mode: In Burst Mode, buses are handed over to the CPU by the DMA if the
whole data is completely transferred, not before that.
The kernel provides many services related to I/O. Several services such as scheduling,
caching, spooling, device reservation, and error handling – are provided by the kernel’s I/O
subsystem built on the hardware and device-driver infrastructure. The I/O subsystem is also
responsible for protecting itself from errant processes and malicious users.
1. I/O Scheduling –
To schedule a set of I/O requests means to determine a good order in which to execute
them. The order in which the application issues the system call is the best choice.
Scheduling can improve the overall performance of the system, can share device access
permission fairly to all the processes, and reduce the average waiting time, response
time, and turnaround time for I/O to complete.
OS developers implement schedules by maintaining a wait queue of the request for each
device. When an application issues a blocking I/O system call, The request is placed in
the queue for that device. The I/O scheduler rearranges the order to improve the efficiency
of the system.
2. Buffering –
A buffer is a memory area that stores data being transferred between two devices or
between a device and an application. Buffering is done for three reasons.
1. The first is to cope with a speed mismatch between the producer and consumer of a
data stream.
2. The second use of buffering is to provide adaptation for data that have different data-
transfer sizes.
3. Caching –
A cache is a region of fast memory that holds a copy of data. Access to the cached copy
is much easier than the original file. For instance, the instruction of the currently running
process is stored on the disk, cached in physical memory, and copied again in the CPU’s
secondary and primary cache.
The main difference between a buffer and a cache is that a buffer may hold only the
existing copy of a data item, while a cache, by definition, holds a copy on faster storage
of an item that resides elsewhere.
4. SpoolingandDeviceReservation –
A spool is a buffer that holds the output of a device, such as a printer that cannot accept
interleaved data streams. Although a printer can serve only one job at a time, several
applications may wish to print their output concurrently, without having their output mixes
together.
The OS solves this problem by preventing all output from continuing to the printer. The
output of all applications is spooled in a separate disk file. When an application finishes
printing then the spooling system queues the corresponding spool file for output to the
printer.
5. ErrorHandling –
An Os that uses protected memory can guard against many kinds of hardware and
application errors so that a complete system failure is not the usual result of each minor
mechanical glitch, Devices, and I/O transfers can fail in many ways, either for transient
reasons, as when a network becomes overloaded or for permanent reasons, as when a disk
controller becomes defective.
6. I/O Protection –
Errors and the issue of protection are closely related. A user process may attempt to issue
illegal I/O instructions to disrupt the normal function of a system. We can use the various
mechanisms to ensure that such disruption cannot take place in the system.
To prevent illegal I/O access, we define all I/O instructions to be privileged instructions.
The user cannot issue I/O instruction directly.
The Kernel I/O Subsystem in Operating System
An Operating System (OS) is a complex software program that manages the hardware and
software resources of a computer system. One of the critical components of an OS is the
Kernel I/O Subsystem, which provides an interface between the operating system and
input/output (I/O) devices. The Kernel I/O Subsystem manages the I/O requests made by the
user applications and translates them into hardware commands that the devices can
understand. In this article, we will discuss the importance of the Kernel I/O Subsystem and
its advantages and disadvantages.
Importance of Kernel I/O Subsystem
The Kernel I/O Subsystem is an essential part of any modern Operating System. It provides
a unified and consistent interface to the I/O devices, which enables the user applications to
access them without knowing the details of the underlying hardware. The Kernel I/O
Subsystem also manages the concurrency and synchronization issues that arise when
multiple applications try to access the same device simultaneously.
Advantages of Kernel I/O Subsystem
• Device Independence: The Kernel I/O Subsystem provides device independence to the
user applications. It abstracts the hardware details and provides a unified interface to the
CC-403-ADVANCE OPERATING SYSTEM AND LINUX Page 19
SHREE MARUTI VIDHYAMANDIR COLLEGE OF BUSSINESS
MANGEMNET AND COMPUTER SCIENCE – B.C.A BHAVNAGAR
devices. This means that the application developers can write code that is independent of
the hardware platform, and the Kernel I/O Subsystem takes care of the hardware-specific
details.
• Efficient Resource Management: The Kernel I/O Subsystem provides efficient
resource management for the I/O devices. It manages the I/O requests and schedules them
in a way that optimizes the usage of the available resources. This ensures that the I/O
devices are not overutilized, and the system remains responsive.
• Concurrency Management: The Kernel I/O Subsystem manages the concurrency
issues that arise when multiple applications try to access the same device simultaneously.
It ensures that the applications get exclusive access to the device when needed and allows
multiple applications to share the device when appropriate.
Disadvantages of Kernel I/O Subsystem
• Complex Implementation: The Kernel I/O Subsystem is a complex software
component that requires a lot of resources to implement and maintain. Any issues with the
Kernel I/O Subsystem can affect the performance and stability of the entire system.
• Security Risks: The Kernel I/O Subsystem can pose security risks to the system if not
implemented correctly. Attackers can exploit vulnerabilities in the Kernel I/O Subsystem
to gain unauthorized access to the system or cause a denial-of-service attack.
Typical functions and services offered by the Kernel:
As we know, a process needs two type of time, CPU time and IO time. For I/O, it requests the
Operating system to access the disk.
However, the operating system must be fare enough to satisfy each request and at the same
time, operating system must maintain the efficiency and speed of process execution.
The technique that operating system uses to determine the request which is to be satisfied next
is called disk scheduling.
Seek Time
Seek time is the time taken in locating the disk arm to a specified track where the read/write
request will be satisfied.
Rotational Latency
It is the time taken by the desired sector to rotate itself to the position from where it can access
the R/W heads.
It is the average of time spent by each request waiting for the IO operation.
The main purpose of disk scheduling algorithm is to select a disk request from the queue of IO
requests and decide the schedule when this request will be processed.
The list of various disks scheduling algorithm is given below. Each algorithm is carrying some
advantages and disadvantages. The limitation of each algorithm leads to the evolution of a new
algorithm.
FCFS stands for First-Come-First-Serve. It is a very easy algorithm among the all-disk
scheduling algorithms. It is an OS disk scheduling algorithm that runs the queued requests and
processes in the way that they arrive in the disk queue. It is a very easy and simple CPU
scheduling algorithm. In this scheduling algorithm, the process which requests the processor
first receives the processor allocation first. It is managed with a FIFO queue.
Example:
Let's take a disk with 180 tracks (0-179) and the disk queue having input/output requests in the
following order: 81, 110, 38, 156, 68, 172, 92, 10. The initial head position of the Read/Write
head is 45. Find the total number of track movements of the Read/Write head using the FCFS
algorithm.
= 36 + 29 + 72 + 46 + 88 + 16 + 80 + 82
= 449
Advantages
Disadvantages
SSTF stands for Shortest Seek Time First, and it serves the request that is closest to the
current position of the head. The direction of the head pointer is quite important in this
algorithm. When a tie happens between requests, the head will serve the request in its current
direction. In comparison to the FCFS, the SSTF algorithm is very efficient in terms of the total
seek time.
Example:
Solution:
= 5 + 11 + 14 + 52 + 20 + 23 + 46 + 16
= 187
There are various advantages and disadvantages of SSTF Disk Scheduling Algorithm. These
advantages and disadvantages are as follows:
Advantages
1. It improves and increase the throughput.
2. SSTF's total seek time is lower than the FCFS.
3. It has less response time and average waiting time.
Disadvantages
1. Starvation can happen for requests far from the head.
2. In the SSTF disk scheduling algorithm, the high variance is available in waiting time
and response time.
3. The algorithm is slowed by frequent changes in the head's direction.
FCFS stands for First Come First Serve. SSTF stands for Shortest Seek Time First.
It increases the total seek time than the SSTF. It reduces the total seek time than the FCFS.
It gives more response time and average waiting It gives less response time and average
time. waiting time.
Its head direction doesn't matter, and the head Its head direction plays an important role in
moves in both forward or reversed directions. breaking a tie between requests.
It is also known as the Elevator algorithm. In this algorithm, the head may move in both
directions, i.e., the disk arm begins to move from one end of the disk to the other end and
servicing all requests until it reaches the other end of the disk. After reaching the other end, the
head position direction is changed and further continues servicing the requests till the end of
the disk.
Example:
Let's take a disk with 180 tracks (0-179) and the disk queue having input/output requests in the
following order: 75, 90, 40, 135, 50, 170, 65, 10. The initial head position of the Read/Write
head is 45 and will move on the left-hand side. Find the total number of track movements of
the Read/Write head using the SCAN algorithm.
Solution:
= 215
There are various advantages and disadvantages of SCAN disk scheduling algorithm. These
advantages and disadvantages are as follows:
Advantages
1. In the SCAN disk scheduling algorithm, low variance happens in the waiting time and
response time.
Disadvantages
1. If no requests remain to be serviced, the head moves till the end of the disk.
It is also known as the Circular Elevator algorithm. It is an improved version of the SCAN
disk scheduling algorithm. In this algorithm, the head works for requests in a single direction,
i.e., it scans all the way to the end of a direction and then jumps to another end and services the
requests in the same direction.
Example:
Let's take a disk with 180 tracks (0-179) and the disk queue having input/output requests in the
following order: 75, 90, 40, 135, 50, 170, 65, 10. The initial head position of the Read/Write
head is 45 and will move on the right-hand side. Find the total number of track movements of
the Read/Write head using the C-SCAN algorithm.
Solution:
= 5 + 15 + 10 +15 + 45 + 35 + 9 +179 + 10 + 30
= 353
There are various advantages and disadvantages of the C-SCAN disk scheduling algorithm.
These advantages and disadvantages are as follows:
Advantages
Disadvantages
1. If no requests remain to be serviced, the head will travel to the end of the disk.
2. It generates more search movements than the SCAN algorithm.
It is the more advanced version of the SCAN disk scheduling algorithm. In this algorithm, the
head begins at one end of the disk and works its way to the other end, and serving all requests
along the way. When the head reaches the end of one end's last request, it changes direction
and returns to the first request, servicing all requests in between. Unlike SCAN, instead of
going to the last track, this head goes to the last request and then changes direction.
Example:
Let's take an example to understand the LOOK Disk Scheduling Algorithm. Let's take a disk
with 180 tracks (0-179) and the disk queue having input/output requests in the following
order: 75, 90, 40, 135, 50, 170, 65, 10. The initial head position of the Read/Write head is 45
and would move on the right-hand side. Find the total number of track movements of the
Read/Write head using the LOOK disk scheduling algorithm.
Solution:
= 5 + 15 + 10 + 15 + 45 + 35 + 130 + 30
= 285
There are various advantages and disadvantages of the LOOK Disk Scheduling Algorithm.
These advantages and disadvantages are as follows:
Disadvantages
It is a combination of the LOOK and SCAN disk scheduling algorithms. In this disk scheduling
algorithm, the head begins from the initial request to the last request in the other direction and
serves all requests in between. The head jumps in the other direction after finishing the last
request at one end and proceeds towards the remaining requests, completing them in the same
direction as previously. Unlike LOOK, it only responds to requests in one direction.
Example:
Let's take an example to understand the C-LOOK Disk Scheduling Algorithm. Let's take a
disk with 180 tracks (0-179) and the disk queue having input/output requests in the following
order: 75, 90, 40, 135, 50, 170, 65, 10. The initial head position of the Read/Write head is 45
and would move on the right-hand side. Find the total number of track movements of the
Read/Write head using the C-LOOK disk scheduling algorithm.
Solution:
= 5 + 15 + 10 + 15 + 45 + 35 + 160 + 30
= 315
There are various advantages and disadvantages of the C-LOOK Disk Scheduling Algorithm.
These advantages and disadvantages are as follows:
Advantages
Disadvantages
• The system call and library interface represent the border between user programs and the
kernel. System calls look like ordinary function calls in C programs. Assembly language
The source code of Linux is freely The source code of Unix is not freely
available to its users available general public
Advantages of UNIX:
1. Stability: UNIX is known for its stability and reliability. It can run for long periods of
time without requiring a reboot, which makes it ideal for critical systems that need to run
continuously.
2. Security: UNIX has a robust security model that includes file permissions, user
accounts, and network security features. This makes it a popular choice for systems that
require high levels of security.
3. Scalability: UNIX can be scaled up to handle large workloads and can be used on a
variety of hardware platforms.
4. Flexibility: UNIX is highly customizable and can be configured to suit a wide range of
needs. It can be used for everything from simple desktop systems to complex server
environments.
5. Command-line interface: UNIX’s command-line interface allows for powerful and
efficient interaction with the system.
Disadvantages of UNIX:
1. Complexity: UNIX can be complex and difficult to learn for users who are used to
graphical user interfaces (GUIs).
2. Cost: Some UNIX systems can be expensive, especially when compared to open-source
alternatives like Linux.
3. Lack of standardization: There are many different versions of UNIX, which can make it
difficult to ensure compatibility between different systems.
4. Limited software availability: Some specialized software may not be available for UNIX
systems.
Process Control :
This system calls perform the task of process creation, process termination, etc.
The Linux System calls under this are fork() , exit() , exec().
• fork()
• A new process is created by the fork() system call.
• A new process may be created with fork() without a new program being run-
the new sub-process simply continues to execute exactly the same program that
the first (parent) process was running.
• It is one of the most widely used system calls under process management.
• exit()
• The exit() system call is used by a program to terminate its execution.
• The operating system reclaims resources that were used by the process after the
exit() system call.
• exec()
• A new program will start executing after a call to exec()
• Running a new program does not require that a new process be created first:
any process may call exec() at any time. The currently running program is
immediately terminated, and the new program starts executing in the context of
the existing process.
File Management :
File management system calls handle file manipulation jobs like creating a file, reading, and
writing, etc. The Linux System calls under this are open(), read(), write(), close().
• open():
• It is the system call to open a file.
UNIX is no longer a small system, it is a rather very powerful one. Unlike Windows & DOS,
UNIX can be used concurrently by several users. You can interact with a UNIX system through
a command-line interpreter called the shell. UNIX is a computer operating system that was
first developed on 3 November 1971 and has been constantly updated since then.
Features of UNIX
Unix is an operating system, so it has all the features that the OS must-have. UNIX also looks
at a few things in a different way than other OS. Features of UNIX are listed below :
1. Multiuser System :
Unix provides multiple programs to run and compete for the attention of the CPU. This happens
in 2 ways :
• Multiple users running multiple jobs
• Single user running multiple jobs
In UNIX, resources are actually shared between all the users, so-called a multi-user system.
For doing so, computer give a time slice (breaking unit of time into several segments ) to each
user. So, at any instant of time, only one user is served but the switching is so fast that it gives
an illusion that all the users are served simultaneously.
2. Multitask System :
A single user may run multiple tasks concurrently. Example : Editing a file, printing another
on the printer & sending email to a person, and browsing the net too at the same time. The
Kernel is designed to handle user’s multiple needs.
The important thing here is that only one job can be seen running in the foreground, the rest all
seems to run in the background. Users can switch between them, terminate/suspend any of the
jobs.
We come to one of the most obvious and common uses for Linux.If you have a PC that's seen
better days, Windows is far from the ideal OS.
Install a lightweight Linux distribution on it and it'll feel like a newmachine again.
Some Linux distributions, like BackTrack or Kali, are security-focuseddistros for testing
security systems.
XBMC works great on Linux, whether you're running on a RaspberryPi or just a low-powered
PC, and you can turn just about any PC intoan all-in-one retro video game console.
If you don't want to leave your computer on 24/7 just to share files ordownload torrents, a tiny
dedicated Linux box might be a bettersolution. With an old computer or a cheap new one, you
can puttogether a home server that stores your backups, streams movies andmusics, seeds
torrents, or performs any number of other tasks quietly inthe corner.
With a little Linux knowledge and a cheap computer—like theRaspberry Pi— you can create
all sorts of tiny home automationgadgets. You can control your home with Siri, mount a
GoogleCalendar tablet on your wall, set up a home surveillance system,control your blinds and
air conditioner, stream music in your livingroom, build a digital photo frame, build a sunrise
alarm clock,and...pretty much anything else you can think of.
If you dual- or triple-boot your system and ever want to movepartitions around, you'll have a
much easier time with a Linux live CDand GParted.
You'd be surprised how many web sites you visit every day actuallyrun on Linux—and if you
want to build a web site, you probably willtoo.
You don't even need to install Linux on a box to make it useful—all you need is asolid live
CD. Just boot from the CD and you can grab any files from the hard drive,even if the computer
won't boot or you've forgotten your password.
Describe different flavors of Linux OS. OR Explain about popular Linux flavors.Linux is not
just a single operating system. It exists in several dozenversions called distributions.
Unlike Windows, no one company has guided the developmentof Linux. Some Linux
distributions are developed on userfriendlystandards.
Two main shell architectures are used by most of all distribution, known asGNOME and KDE.
• Debian is regarded as the largest Linux distribution to date interms of users. It is famous for
its stability and quality.
• It has a very large numbers of users and over 28,000 packages youcan add to it. It is very
stable and newbie friendly.
Ubuntu:
• The most popular distorts out in the world right now, since its releasefive years ago.
• Some suggest it has as much as 40% of Linux desktops. It is anothergood quality, stable
release that is very newbie friendly.
• This eases the pain a little by helping you in your first steps.
Fedora:
• This is a distribution with a long history. Once part of Red Hat, Fedorawas launched for the
‘Linux Hobbyist’.
• It is very secure and has a large number of packages available for it.
• This one seemed to be less newbie friendly than others, with not somany options for desktop
users.
• If you want to run a web server or something then this would be ideal.
OpenSUSE:
• The following is helpful and informative and there are lots of packagesavailable for it.
• There is however some controversy over a deal it has with Microsoft,something about use of
patents.
11.1.Mandriva:
• Mandriva used to be Mandrake, and even as a Windows user back thenI knew what that was.
• It is one of the distributions that offer both free and commercialversions of the software.
Slackware:
• It is supposed to be the cleanest and most bug free edition available, butseems quite hard core.
• It lags a little behind other distributions and doesn’t have all the coolbits to make your desktop
smart.
Mint:
• The programmers have forums and feedback loops which theysubscribe to.
• They listen and try to implement the best suggestions into thedistribution.
• It has many specific tools, and to my mind is the most useable out ofthe box.
Desktop Environment: (a) X Window Basic (b) KDE Basic (c) GNOME Basic
What is X window:
The X window system is a computer software and network protocol thatprovides a basis for
graphical user interfaces (GUIs) and input devicecapability for networked computers.
The X.Org Foundation leads the X project, with the current referenceimplementation,
Xorg Server, available as free and open source software under the MITLicense and similar
permissive licenses.
Functions of X Window:
It is provides the basic framework for building such GUIenvironments.X window was
specifically designed to be used over network connections.It is often used in conjunction with
an X session manager toimplement sessions.
The X Protocol:
The X protocol was developed in the mid-1980s to provide anetwork transparent graphical user
interface (GUI).
The client is known as an X client and the server as an X serverX client can send requests to
have an X server on a local machineperform certain display operations.
The configuration file used for your Xorg server is called xorg.conf,located in the /etc/X11
directory.xorg.conf contains all the specifications for your graphics card,monitor, keyboard,
and mouse.
To configure the xorg.conf file, you need specific information on handabout your
hardware.You can use anXorg configuration utility built into the Xorg server.You can use the
Xorg command with the -configure option.
Limitations of X window:
o Systems built upon the X windowing system may haveaccessibility by disabled users
✓ Network
o An X client cannot generally be detached from one serverand reattached to another unless its
code specificallyprovides for it.
✓ Client–server separation
✓ Competitors
What is GNOME:
GNOME itself is licensed under the GNU General Public License (GPL) for itsapplications.
The GNU Network Object Model Environment is full form of GNOME,You can download the
source code of GNOME software directly fromgnome.org.Several companies have joined
together to form the GNOME Foundation,These include such companies as Sun, IBM, and
Hewlett- Packard as well asLinux distributors such as Fedora, SUSE, and TurboLinux.
Features of GNOME:
It is requires less time to load and use less memory.Gedit has been word editor program for
Multiple Document.F-Spot image is a camera managers and the Beagle is a search tool.The
new menu editor-Alacarte, lets you customize your menus easily.The disk usage analyzer,
Baobab, lets you quickly see how much diskspace is used.
The GNOME video player-Totem, supports web access, featuringWindows Media Player
support.
Buttons and windows are easier to use and appear more pleasing to the eye.
The Cairo images theme is compliant with the TANGO style guidelines.
GNOME provides the Seahorse Encryption Key Manager forencryption, signing, and
decryption of files and text.
The GNOME Control Center provides an organization and access for yourdesktop
configuration.
GNOME Interface:
The GNOME interface consists of the panel and a desktop, as shownin following figure.The
panel appears as a long bar across the bottom of the screen.It holds menus, programs, and
applets.The menu operates like the Start menu and lists entries for applicationsyou can run on
your desktop.
You can display panels horizontally or vertically and have themautomatically hide to show you
a full screen.The Applications menu is reserved for applications. Other tasks, such asopening
a home directory window or logging out, are located in the Placesmenu.
The System menu holds the Preferences menu for configuring yourGNOME interface, as well
as the Administration menu for accessing thedistribution administrative tools.
GNOME Components:
thedesktop,the panels,
You have two panels displayed, one used for menus, application icons, andrunning applets at
the top of the screen, and one at the bottom of the screen usedprimarily for managing your
windows and desktop spaces.
To the right are the time and date icons. An update button will appear if updatesare available.
The packages are separated into “Platform” and “Desktop” sections in thesame manner as the
sources are distributed on the GNOME.
Packages:
Platform Packages:
GIO Files:
GIO provides APIs for asynchronously reading and writing filesand other streams.
GIO Networking:
The asynchronous API designs means your application doesn'tblock waiting for a response.
GStreamer:
You can use GStreamer to provide sound and video playback,record input from multiple
sources, and edit multimedia content.`
GStreamer supports encoding and decoding numerous formats bydefault, and support for
additional formats can be added with plug-ins.
WebKit:
WebKitGTK+ makes it easy to add web functionality to yourapplication, or to use HTML5 and
associated technologies tocreate dynamic user interfaces quickly.
Desktop Packages:
Brasero:
Brasero is a simple application to burn, copy and erase CDand DVD media: audio, video or
data.
This package contains the main binary, the burning plugins and thenautilus extension.
Cheese:
Cheese is a cheesy program to take pictures and videos fromyour web cam. It also provides
some graphical effects in order toplease the user's play instinct.
Deskbar-applet:
Management:
Installing software in GNOMEIn the Search Box with the magnifying glass icon, type the name
of the
application you wish to install.Next, click the Find button – The message Querying appears in
the lowerleft corner briefly and then zero or more listings will appear that matchyour search
query.Tick the box next to the description of the application you wish to install.
Select any additional packages to install or remove at this time bychanging tick boxes next to
the package name.Finally, click the Apply button. This starts the installation process.
Unless an error is displayed, the application is now installed (or removed)on your computer.
To remove software you should follow the standard installation procedure,but untick boxes
beside the programs you wish to uninstall.
In the Search Box with the magnifying glass icon, type the name of theapplication you wish to
remove.
Next, click the Find button. The message Querying appears in the lowerleft corner briefly then
zero or more listings will appear that match yoursearch query.
Unless an error is displayed, the application is now removed from your computer.
Introduction to KDE:
KDE software is based on the Qt framework. KDE was founded in 1996 byMatthias Ettrich.
He proposed the creation of not merely a set of applications but a desktopenvironment in which
users could expect things to look, feel, and workconsistently.
He also wanted to make this desktop easy to use, the KDE project was born.
KDE Menus:
When you start KDE, the KDE panel is displayed at the bottom of the screen.The button for
the main menu shows a k, the KDE icon.
This is the button for the KDE main menu.Click this button to display the menu of applications
you run. (you canalso open the main menu by pressing ALT-F1).
KDE Windows
A KDE window has the same functionality you find in other windowmanagers and desktops.
You can resize the window by clicking and dragging any of its corners orsides.
You can perform click-and drag operation in the windowThe top of the window has a title bar
showing the name of the window,The active window has the title bar highlighted.
To move the window, click this title bar and drag it where you want.
Opened windows are also shown as buttons on the KDE taskbar located on thepanel.
The KDE panel (Kicker), located at the bottom of the screen, providesaccess to most KDE
functions.
The panel includes icons for menus, directory windows, specificprograms, and virtual
desktops.
At the left end of the panel is a button for the main menu (also known asthe K menu), a KDE
K icon.
KDE File Manager and Internet Client: KonquerorThe KDE file manager, known as
Konqueror, is a multifunctional utility with
which you can manage files, start programs, browse the web, and download filesfrom remote
sites.
Traditionally, the term “file manager” was used to refer to managing files onlocal hard disk.The
KDE file manager extends its functionality well beyond this traditionalfunction because it is
Internet capable, seamlessly displaying remote file systemsas if they were your own, as well
as viewing web pages with browsercapabilities.
The most common (and most commonly misunderstood) issue surrounding theKDE project is
the licensing issue.The combination of licenses between KDE and Qt make the issue lessthan
obvious, especially if you are using KDE/Qt to develop a closedsourceor commercial
application.These issues, for all their complexity, are manageable.
In some cases the KDE project uses a different license than the one thatTrolltech has chosen
for Qt.These licenses have different goals and purposes and apply to softwareprojects in
different ways.
The free version of Qt fell under the FreeQt license. This version wasavailable only if the
recipient's product was distributed under a freesoftware license. It permitted the redistribution
of Qt and access to thesource code.Explain the KDE Control Center. OR How to configure
KDE,With the KDE Control Center, you can configure your desktop andsystem. The Control
Center can be directly started by selecting ControlCenter from the main menu.The KDE
Control Center is the place to go to change any settings thataffect the whole of your KDE
environment.
The Control Center window is divided into two panes.The left pane shows a tree view of all
the components you can configure,and the right pane displays the dialog windows for the
selected component.The settings are divided into several major categories, which each
containseveral pages of settings.
Here you will find settings that change the way your KDEdesktop and applications look. For
example background, color,fonts, icon etc..
✓ Desktop
This is where you will find settings to configure the appearanceand behavior of your KDE
desktop. For example behavior,multiple desktop, panels, taskbar etc..
CC-403-ADVANCE OPERATING SYSTEM AND LINUX Page 44
SHREE MARUTI VIDHYAMANDIR COLLEGE OF BUSSINESS
MANGEMNET AND COMPUTER SCIENCE – B.C.A BHAVNAGAR
✓ Internet & Network
This section is where you would configure settings to do withinternet and networking under
KDE. For example connectionpreferences, desktop sharing, file sharing, local
networkbrowsing etc..
✓ KDE Components
This section is where you can modify advanced KDE optionssuch as file associations and
default applications. For examplecomponent chooser, file manager, kde performance etc.
✓ Peripherals
This section is where you would change settings related toperipheral devices such as keyboards
and joysticks.
✓ Power Control
This section has a single module, Laptop Battery. Here you canconfigure the appearance and
behavior of the Klaptop daemonbattery monitor. You can select battery icons to
representdifferent power states, and set up notification of certain events.
This section is where you can configure options to do with regionand locale, and also
accessibility related options for disabledpersons.
✓ KDE Wallet
o KDE Wallet aims to provide secure storage for passwords andweb form data.
o The default wallet is named "kdewallet", and you can eithercreate a new wallet for your local
passwords or accept thedefault wallet for all data in the "Automatic Wallet Selection"section.
o You can change here your personal information which will beused in mail programs and
word processors.
✓ Privacy
o This module allows you to erase traces which KDE leaves onyour system such as command
histories or browser caches.
✓ System Administration
o This module allows you to configure aspects of your system suchas the bootloader, the kernel
and helps you perform essentialsystem tasks. Most of these sections will require the root
orAdministrator password to effect changes.
✓ Font Installer
o Here is where you would configure both personal and systemwidefonts. This dialog allows
you to install new fonts, delete oldones and preview the fonts you have installed.
✓ Linux Kernel
o If you run KDE on Linux there is a KControl module to create ormodify configuration files
for a Linux kernel. This configuratoris compatible with kernels previous to 2.5.
✓ Login Manager
o This module allows you to configure the KDE login manager,kdm. kdm is a powerful login
manager with a large range ofoptions.
Advantages:
Cost – The most clear advantage of using Linux is the fact that it is free to obtain,while
Microsoft products are available for a heavy and sometimes frequent fee.
Security –The security side of Linux is much stronger than that of windows. The
Linuxoperating system has managed to stay secure in the realm of widespread viruses,spyware
and adware for all these years.
Choice (Freedom) – The power of choice is a great Linux advantage. With Linux,you have the
power to control just about every aspect of the operating system.
Software - There are so many software choices when it comes to doing any specifictask.
Hardware - Linux is perfect for those old computers with barely any processing poweror
memory you have sitting in your garage or basement collecting dust.
No crashes- Windows users will be familiar with the infamous “blue screen of death”that greets
them whenever the system crashes. In contrast, Linux users have reporteduptimes exceeding
over a year, which means that their computers have beencontinuously running over a year
without a single crash or reboot.
Disadvantages:
Understanding – Becoming familiar with the Linux operating system requires patienceas well
as a strong learning habit.
Compatibility – Because of its free nature, Linux is sometimes behind the curve whenit comes
to brand new hardware compatibility. Though the kernel contributors andmaintainers work
hard at keeping the kernel up to date.
Different working mechanism - If you’re a lifelong Windows user, you may take awhile to get
used to the way Linux works. From installing software to runningprograms, things are a little
different in Linux-based systems.
“Files are arranged in proper way so user or system can access file easily is called File System”.
Different operating system manages these files in different way. All the files in your Linux
system are connected into one overall directory tree.Files on a particular storage device are
organized into what is referred to asa file system.
A file system is a formatted device, with its own tree of directories and files.Your Linux
directory tree may encompass several file systems, each ondifferent storage devices.
On a hard drive with several partitions, you have a file system for eachpartition.For example,
a floppy disk with Linux files has its own tree of directories.
Linux distributions, developers, and administrators all follow the FHS toprovide a consistent
organization to the Linux file system.
You have access to these directories and files only as the systemadministrator..
Root Directory: /
The subdirectories held in the root directory, indicate by/ .Directories that you may commonly
access as an administrator are the /etcdirectory., which holds configuration files.
For managing different versions of the kernel, you may need to access the/boot and
/lib/modules directories as well as /usr/src/linux.
Directory Function
/boot Holds the kernel image files and associated boot information andfiles.
System Directories
Your Linux directory tree contains certain directories whose files are usedfor different system
functions.
For basic system administration, you should be familiar with the systemprogram directories
where applications are kept, the system configurationdirectory (/etc) where most configuration
files are placed
Directory Description
Program Directories
Directories with bin in the name are used to hold programs.The /bin directory holds basic user
programs, such as login, shells and filecommands.
The /sbin directory holds specialized system programs for such tasks as filesystem
management.
When you configure different elements of your system, configuration filesare placed in the /etc
directory.
The /usr directory contains a multitude of important subdirectories used tosupport users,
providing applications, libraries, and documentation.
/media Directory
The /media directory is used for mountpoints for removable media like CDROM,DVD, floppy,
or Zip drives etc..
/mnt Directory
The /mnt directory is usually used for mountpoints for other mounted filesystems such as
Windows partitions.
/home Directory
The /home directory holds user home directories. When a user account is setup, a home
directory is set up here for that account, usually with the samename as the user.
The /var directory holds subdirectories for tasks whose files changefrequently, such as lock
files, log files, web server files, or printer spool files.How do you find out information about
file system in Linux?The file systems on each storage device are formatted to take up a
specifiedamount of space.
To find out how much space you have free on a filesystem, you can use the dfcommand or, on
the desktop, either the GNOME SystemMonitor or the KDEKDiskFree utility.
For the System Monitor, click the Resources tab todisplay a list of the freespace on your file
systems.
KDiskFree displays a list of devices,showing how much space is free on eachpartition, and the
percentage used.
Df :
The df command reports file system disk space usage. It lists all your filesystems by theirdevice
names, how much disk space they take up, and thepercentage of the disk spaceused, as well as
where they are mounted.
With the -h option, it displays information in amore readable formatThedf command is also a
safe way to obtain a listing of all your partitions.
$ df -h
Output:
$ df .
Output:
To check the consistency of the file system and repair it if it is damaged, youcan use filesystem
checking tools.
fsck checks and repairs a Linux file system. e2fsck is designed tosupport ext2and ext3 file
systems.
The ext2 and ext3 file systems are the file systems normally used forLinuxhard disk partitions
and floppy disks.Linux file systems are normally ext3, which you usee2fsck to check. fsck
ande2fsck take as their argument the device name of the hard diskpartition thatthe file system
uses.
fsck device-name
Before you check a file system, be sure that the file system is unmounted.
To use e2fsck, enter e2fsck and the device namethat references the filesystem.
The -p option automatically repairs a file system.The following examples check thedisk in the
floppy drive and the primaryhard drive:
# e2fsck /dev/fd0
# e2fsck /dev/hda1
With fsck, the -t option lets you specify the type of file system to check.
Syn :pwd
Exam :pwd
Exam :
(2) cd..
(3) cd /user/lib
(4) cd doc/letters
Use : it is used to rename a directory or move files from one directory toanother directory.
Syn : mv old_directoryNew_directory
Use : This command is used to create, display and append content of a file.
Options :
Function : This option use to display lines of a file with line number.
2) -e
Function : This option use to display $ sign at the end of each line of afile.
Options :
1) –i
Function : This option will ask to user for overwrite or not by linux.
2) –r
3) –s
(3) rm (remove) :
Options :
Use : it is used to rename a file or move a file from one directory to anotherdirectory.
Exam :
(5) ln (link)
Options :
(6) ls (list)
Use :ls with no option list files and directories in bare format.
Exa :ls
Options :
1) –l (long list)
Function : It shows file or directory, size, modified date and time, file or folder
Example :ls -l
2) –a (all)
Function: List all files including hidden file starting with ‘.‘.
Example :ls -a
4) –F
Function: Using -F option with ls command, it will add the ‘/’ Character at theend each
directory, ‘*’ character at the end each executable file and‘@’ character at the end each
symbolic link.
Example: ls –F
5) –r (Reverse Order)
Example: ls –r
Example: ls -R
7) –S (Sort)
Function: This option displays file size in order, will display big in size first.
Example: ls –lS
Example :ls -i
9) --version
10) -n
Function : This options display UID and GID of files and directories.
Example: ls -n
(11) –color
Function : It is used to display list of directory and filed name with differentcolor.
(12) –t (time)
Function : This option display sorted list of all files and directory according todate and time.
Example :ls –t
(13) –X (extension)
Function : This option display sorted list of all files according to file extension.
Example :ls –X
Use : This way of writing ls command display list files under specified directory.
Note : You can press the tab key to auto complete the file or folder names.
Syn :ls /
Exam :ls /
Exam :ls ..
Syn :ls ~
Exam :ls ~
Syn :ls -d */
Exam :ls –d */
Use : It is used to display all the files and subdirectory with full path.
Syn : There are two way to give permission (1) Character arguments (2) octalnotation.
Instead of the character arguments, we can give numeric arguments tothe “chmod” command.
The notation takes the form of an octalrepresentation of the permission and it is assign as follow
:
Read 4
Write 2
Execution 1
Total 7
Here, 7 is used for user permission, 7 is total of4(read)+2(write)+1(execute) that means user
have all read, write andexecute permission. 6 is used for group permission, 6 is total of 4(read)
+2 (write) that means group have only read and write permission. 1 isused for other permission.
1 is total of 1(execute) means others have onlypermission of execution.
Use : It is used to count number of characters, words and lines in the given file.
Exam: wc –l xyz.txt
Options :
Use : This command used to display input files are different or same. If both thefiles are same
it will not display message, otherwise it will display from whichcharacter and line it is deferred.
Example :cmpprog.o.bakprog.o
Options :
1) –l
Function : This option is used to compares the files, and then displays thebyte number (in
decimal) and the differing bytes (in octal) for eachdifference.
2) –s
Use : This command is used to display two files and prints the lines that aredifferent.
Options :
1) –q
Function : This option is display message when two files are differedotherwise it will not
display any message.
2) –s
Function : This option is display message when two files are same otherwise itwill not display
any message.
3) –i
(11) tty :
Use : It is used to display file name associated with terminal, remember thatall devices are
treated as file.
Syn :tty
(12) head
1) -c
2) –n
3) –q
Function : This option is used to display first N lines of file/s without headergiven in the file/s.
4) –v
Function : This option is used to display first N lines of file/s with header given inthe file/s.
(13) tail
Option:
1) -c
2) –n
3) –q
Function : This option is used to display last N lines of file/s without headergiven in the file/s.
4) –v
Function : This option is used to display last N lines of file/s with header given inthe file/s.
(14) cut :
Use : It is used to cut a file vertically, extract specific coloums or fields from aninput file.
Options :
(15) Paste:
Use : It is used to join content of files vertically. It will not add content of the file at
Options :
1) -s
Function : This option joins all the lines in a file. Since no delimiter is specified,default
delimiter tab is used to separate the columns.
Use : it is merge the lines of a file in two coloums instead of in a single line.
(2) Merge a file by pasting the data into 2 columns using a colon separator
Use : It is merge the lines of a file in two coloums and separate the coloum by aspecified
character.
(16) sort
Use : This command is used to sort lines of text file. This command sort lines of afile by default
ascending order.
Options :
1) –b
2) –f
3) –n
Function : This option is used to sort the file according to numerical value.
4) –r
5) –c
Function : This option is used to check that input file is sorted or not sorted.
6) –m list
7) –o
Function : This option is used to store sorted file/s in another file instead ofdisplay on standard
output.
8) –t
Function : This option is used to make separate fields in the text file for sort.
9) –u
Function: This option is used to remove duplicate lines of files for sorting.
10) –k n
11) –k m,n
Function : This option is used to start sort on mth field and end sort on nth field.
12) –K m,n
Function: This option is used to start sort on nth coloum of mth field.
(17) tr (Translate)
Options :
(1) –c
Function : It will replace those characters in the input string which does notcontain in set1 with
the character define in set2.
(2) –s
Function : This option is used to replace of that character which repeated inthe input string and
contain that character in set1 with thecharacter define in set2.
Function : It is used to display content of a file from lower case into upper case.
Or
Or
Or
Or
(18) grep
Options :
1) –i
Function: This option is used to ignore case while it is search specified pattern.
2) –w
Function : This option is used to search whole pattern in a file instead of part ofthe pattern.
3) –B
Function : This option is used to display n lines before match the pattern line.
4) –A
Function : This option is used to display n lines after match the pattern line.
5) -C
Function : This option is used to display n lines before and after match thepattern line.
6) –r
7) –v
Function : This option is used to display the lines that are not matched with thespecified search
sting pattern.
8) –c
Function : This option is used to count number of lines that match the specifiedunderstring
pattern.
9) –l
Funtion : This option is used to display only those file name which contain thelines match the
specified pattern.
10) –o
Function : This option is used to display on match pattern instead of displaywhole line that
contain specified pattern.
11) –n
Function : This option is used to display line with line number which match thespecified
pattern.
12) –b
Function : This option is used to display the character position of the matchedstring in a file.
3. Displaying the non-empty linesYou can remove the blank lines using the grep command.
4. Matching the lines that start with a stringThe ^ regular expression pattern specifies the start
of a line. This can be used ingrep to match the lines which start with the given string or pattern.
5. Matching the lines that end with a stringThe $ regular expression pattern specifies the end
of a line. This can be used ingrep to match the lines which end with the given string or pattern.
Use : This command is used to search a string in a file and replace by another
Use : This form of sed command find nth occurrence of a string in a line and replace with a
new string.
Use : This form of sed command find all the occurrence of a string and replace with a new
string. Here g means “globle”.
Use : This form of sed command find all the occurrence of a string from nth position and from
there replace all the with a new string.
Use : This form of sed command find all the occurrence of a string and replace with a new
string and display that lines twice on the screen.
Use : This form of sed command find all the occurrence of a string and replace with a new
string and display only replaced lines.
Use : This form of sed command find all the occurrence of a string and replace with a new
string at specified line number.
Use : This form of sed command find all the occurrence of a string and replace with a new
string at range of specified line numbers.
(2) Use : This form of sed command delete lines from specified number to end of file.
Use : This form of sed command add a new line after it find a match string line.
Use : This form of sed command add a new line before it find a match string line.
Every command you give is a job that is executed. A job can be suspended, placed in the
background, moved back to the foreground or terminated.
Most commands like ls are executed fast, but things like moving huge files occupy your
terminal for quite a while. In these cases the job can be placed in the background, allowing you
to execute other commands in the meantime.
While running a command (job) you can pause/suspend it with ctrl-z and kill it with ctrl-c.
When a job is suspended it can be moved back to the foreground with `fg` and placed in the
background (where it will continue to execute) with `bg`.
Example :ps
Options :
1) -e
Syn :ps –e
Example :ps –e
CC-403-ADVANCE OPERATING SYSTEM AND LINUX Page 68
SHREE MARUTI VIDHYAMANDIR COLLEGE OF BUSSINESS
MANGEMNET AND COMPUTER SCIENCE – B.C.A BHAVNAGAR
2) –f
Syn :ps –f
Example :ps –f
3) –u
Function : This option is used to displays the process that belongs to a specific username.
(2) time :
Use : It is used to executes command or program and displays time use on the terminal. Here,
time usage is displayed in form of three different time values :
(1) Real time : Total time from the invocation of the command till its termination.
(3) System time : Time spent by kernel in doing work behalf of the user precess.
(3) kill :
User Commands
Explain user commands in detail.
(1) who
Use : This command is used to display who is working at present on the system.
Example : who
Options :
1) -b
Function : This option used to Indicate the time and date of the last reboot.
Example : who –b
2) –l
Syn : who –l
Example : who –l
3) –m
Function : This option is used to display the hostname and user associated withstdin.
Syn : who –m
Example: who –m
4) –r
Syn : who –r
Example : who –r
5) –u
Function : This option is used to display the list of user logged in.
Syn : who –u
Example : who –u
6) –q
Function : This option is used to display Get number of users logged-in and their user names.
Syn : who –q
Example : who –q
7) –a
Syn : who –a
Example : who –a
Misc Commands
Explain expr command with all its options.
(1) expr
Example: expr 5 + 6
Output :
11
1. Sum of numbers
$ expr 5 + 3
$ expr 1 + 2 + 3
$ expr 5+3
5+3
Here in the third expr command, space is not provided between the literals. The expr command
treated it as a string and printed on the terminal.
$ expr 10 - 6
3. Multiplying numbers
$ expr 7 \* 9
63
Here the * is shell builtin operator, that is why it needs to escaped with backslash.
4. Dividing numbers
$ expr 6 / 4
5. Remainder or modulus
$ expr 6 % 4
You can use the following comparison operators with the expr command:
• Val1 <= Val2 : Returns 1 if val1 is less than or equal to val2. Otherwise zero.
• Val1 >= Val2 : Returns 1 if val1 is greater than or equal to val2. Otherwise zero.
• val1 | val2 : Returns val1 if val1 is neither null nor zero. Otherwise val2.
• val1 &val2 : Returns val1 if both val1 and val2 is neither null nor zero. Otherwise 0.
Note: You have to escape most of the operators with backslash as they are shell built in.
$ expr 1 \< 2
$ expr 1 \<= 1
$ expr 2 \> 5
$ expr 2 \>= 5
$ expr 7 = 7
$ expr 9 != 18
$ expr 2 \| 5
$ expr 0 \| 5
$ expr 2 \& 5
$ expr 6 \& 3
$ expr 6 \& 0
$ expr 0 \& 3
1. Length of string
12
If you have spaces in your string escape them with backslash or quote them with double quotes.
2. Find Substring
You can extract a portion of the string by using the substr function. The syntax of substr
function is
substr string position length Here position is the character position in the string. length is the
number of
$ exprsubstrunixserver 5 6
server
3. Index of the substring You can find the position of a string in the main string using the index
index string chars If the chars string is found in the main string, then the index function returns
the position of the chars. Otherwise it returns 0. See the following examples:
4. Matching a regexp
The match function is used to find anchored pattern match of regexp in the string. The syntax
of match function is shown below:
The match function returns the number of characters in the pattern is a match is found.
Otherwise, it returns 0. Alternative synatx is
string : pattern
(2) tee:
Use : It is used to splits input into two components. Saves one component in a file and displays
the other to the standard output.
(3) read
(4)man :
Exam : man ls
(1) cal :
Exam :cal
(6) date :
Syn : date
(7) echo
Options:
1) –n
2) –e
\\ Backslash
\a alert (BELL)
\e Escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
CTRL+W Deletes the last word typed. For example, if you typed 'mv file1 file2' this shortcut
would delete file2.
CTRL+Z Cancels current operation, moves back a directory or takes the current operation and
moves it to the background