Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Introduction and Overview—Getting Started 1

Chapter- 1
Introduction and
Overview—Getting Started

Chapter Objectives
Definition of operating system and the services offered by IT.
Types of operating system.
History of UNIX and LINUX along with their features.
File system architecture details.
Types of users and files in UNIX/LINUX.
Basic UNIX Commands.
Recap.
Quiz.

1.1 DEFINITION OF OPERATING SYSTEM AND THE SERVICES


OFFERED BY IT
Operating system (OS) is a set of programs that manages the activities of the
computer system and lets the user use the system resources effectively.
Most desktop and laptop PCs come pre loaded with Microsoft
Windows. Macintosh computers come with Mac OS X. Many corporate
servers use the Linux or UNIX operating systems. The operating system is
the first thing loaded onto the computer without the operating system; a
computer is of no use.
An operating system creates the ability to:
a. serve a variety of purposes
b. interact with users in more complicated ways
c. keep up with needs that change overtime
d. management of the processor, RAM, I/O
e. file and Information Management
f. management of execution of applications
2 Lin

At the simplest level, an operating system does two things:


1. It manages the hardware and software resources of the system. In a
desktop computer, these resources include such things as the processor,
disk space, memory and more.
2. It provides a stable, consistent way for applications to deal with the
hardware without having to know all the details of the hardware.
The first task, managing the hardware and software resources, is very
important, as various programs and input methods compete for the attention
of the central processing unit and demand memory, storage and input/output
bandwidth for their own purposes.
The second task, providing a consistent application interface, is
especially important if there is to be more than one of a particular type of
computer using the operating system, or if the hardware making up the
computer is ever open to change. A consistent application program interface
allows a software developer to write an application on one computer and
have a high level of confidence that it will run on another computer of the
same type, even if the amount of memory or the quantity of storage is
different on the two machines.
There are cases where processes need to communicate with each other
to exchange information. It may be between processes running on the same
computer or running on the different computers. By providing this service
the operating system relieves the user of the worry of passing messages
between processes. In case where the messages need to be passed to
processes on the other computers through a network it can be done by the
user programs. The user program may be customized to the specifics of the
hardware through which the message transits and provides the service
interface to the operating system.

1.2 TYPES OF OPERATING SYSTEM


From the previous section, we understood that Operating systems that create
a link between end users and the applications form the core of computer
systems. It dissociates the programs, the hardware and simplifies resource
management. Let us look at the different types of operating systems in this
section.
Single user and Multi user Operating Systems: In a single user OS
type, only a single person has access to all resources and in case of multi user
OS, multiple users can access a computer system concurrently. Time sharing
system can be classified as multi user systems as they enable a multiple
user access to a computer through the sharing of time. Being able to have
multiple accounts on a Windows operating system does not make it a multi
user system. Rather, only the network administrator is the real user. But for a
Unix
Introduction and Overview—Getting 3
like operating system, it is possible for two users to login at a time and this
capability of the OS makes it a multi user operating system. Some examples
of multi user operating systems are Linux, Unix, and Windows 2000.
Single tasking and Multi tasking Operating Systems: When a single
program is allowed to run at a time, the system is grouped under a single
tasking system, while in case the operating system allows the execution of
multiple tasks at one time, it is classified as a multitasking operating system.
Multitasking can be of two types namely, pre emptive or co operative. In pre
emptive multitasking, the operating system slices the CPU time and dedicates
one slot to each of the process. Unix like operating systems such as Solaris
and Linux support pre emptive multitasking. Cooperative multitasking is
achieved by relying on each process to give time to the other processes in a
defined manner. MS Windows prior to Windows 95 used to support
cooperative multitasking. UNIX and Windows 2000 are examples of
multitasking systems.
Real time Operating System: It is a multitasking operating system that
aims at executing real time applications. Real time operating systems often
use specialized scheduling algorithms so that they can achieve a
deterministic nature of behavior. The main object of real time operating
systems is their quick and predictable response to events. They either have an
event driven or a time sharing design. Time sharing operating systems
switch tasks based on the clock interrupts while an event driven system
switches between tasks based on their priorities. DSP BIOS is an example for
real time Operating system.
Distributed Operating System: An operating system that manages a
group of independent computers and makes them appear like a single
computer is known as distributed operating system. The development of
networked computers that could be linked and communicate with each other,
gave rise to distributed computing. Distributed computations are carried out
on more than one machine. When computers in a group work in cooperation,
they make a distributed system.
Embedded System: The operating systems designed for being used in
embedded computer systems are known as embedded operating systems.
They are designed to operate on small machines like PDAs with less
autonomy. They are able to operate with a limited number of resources. They
are very compact and extremely efficient by design. Windows CE, Minix 3
and Free BSD are some examples of embedded operating systems.

1.3 HISTORY OF UNIX AND LINUX ALONG WITH THEIR


FEATURES
1.3.1 Unix
In 1969-1970, Kenneth Thompson, Dennis Ritchie, and others at AT&T Bell
Labs began developing a small operating system on a little used PDP-7. The
4 Lin

operating system was soon christened UNIX, a pun on an earlier operating


system project called MULTICS. In 1972-1973, the system was rewritten
in the programming language C, an unusual step that was visionary: due to
this decision, UNIX was the first widely used operating system that could
switch from and outlive its original hardware. Other innovations were added
to UNIX as well, in part due to synergies between Bell Labs and the
academic community. In 1979, the "seventh edition'' (V7) version of UNIX
was released, the oldest of all extant UNIX systems.

1.3.2 Linux
In 1991, Linus Torvalds began developing an operating system kernel, which
he named "Linux". This kernel could be combined with the FSF material and
other components to produce a freely modifiable and very useful operating
system. This book will term the kernel itself the "Linux kernel'' and an entire
combination as "Linux''. Note that many use the term "GNU/Linux'' instead
for this combination. Linux is not derived from UNIX source code, but its
interfaces are intentionally like UNIX. Therefore, UNIX lessons learned
generally apply to both, including information on security.

1.3.3 Comparison of Unix and Linux


UNIX is copyrighted name only big companies are allowed to use the UNIX
copyright and name, so IBM AIX, Sun Solaris and HP UX all are UNIX
operating systems. Most UNIX systems are commercial in nature.
Linux is a UNIX Clone. It is just a kernel. All Linux distributions
include GUI system, GNU utilities (e.g., ls, cp, mv, date, bash etc),
installation and management tools, GNU c/c++ Compilers, Editors (VI)
and various applications (e.g., Open Office, Firefox etc). However, most
UNIX operating systems are considered as a complete operating system as
everything comes from a single source or vendor.
Linux is Free. It can be downloaded from the Internet or redistributed
under GNU licenses. There is a best community support for Linux. Most
UNIX like operating systems are not free. However, some Linux
distributions such as Red hat/Novell provides additional Linux support,
consultancy, bug fixing, and training for additional fees.
Linux is considered as most user friendly UNIX like operating systems.
It makes it easy to install sound card, flash players and other desktop
goodies. However, Apple OS X is most popular UNIX operating system for
desktop usage. Linux comes with open source netfilter/iptables based
firewall tool to protect the server and desktop from crackers and hackers.
UNIX operating system comes with its own firewall product or need to
purchase third party software such as Checkpoint UNIX firewall.
Introduction and Overview—Getting 5
1.4 FILE SYSTEM ARCHITECTURE DETAILS
Generalized file system provides a simple and unified way to access
resources. The basic unit is a file. A file consists of essential data, metadata
(data about the data), nonessential metadata, and some information. Unless
the file is a directory, the information is given "as is" and not analyzed by the
file system. Essential metadata can be edited only by the file system driver
and other privileged programs, since, improper editing may make the file
unusable. Nonessential metadata contain information useful for indexing
systems (the indexing systems are ordinary programs, and not a part of the
file system). Nonessential metadata have a nested structure.
A directory (also known as a folder) is a file that may contain other
files inside the file. Since, the file system is flexible and extensible, different
directories may have different physical implementation. Essential metadata
may include file size; date created, last modified, last accessed; directory
structure; and special storage properties. Metadata of a directory may apply
to files inside the directory.
A symbolic link is an empty file that points to a file. The link may indicate
either an absolute location or a location relative to the location of the link.
Unless requested otherwise, a reference to a symbolic link is a reference to
the file to which the link points. Files are identified by their path, such as
/file_system/folder/file. For example, name 1/name 2 identifies file name 2
inside the file name1. Copying the file copies the contents of the identified
file to the identified path. The file may then or during copying be converted
to the appropriate structure for files in that location.
The contents of the root file system must be adequate to boot, restore,
recover, and/or repair the system.
a. To boot a system, enough must be present on the root partition to mount
other file systems. This includes utilities, configuration, boot loader
infor- mation, and other essential start up data. /usr, /opt, and /var are
designed such that they may be located on other partitions or file
systems.
b. To enable recovery and/or repair of a system, those utilities needed by
an experienced maintainer to diagnose and reconstruct a damaged system
must be present on the root file system.
c. To restore a system, those utilities needed to restore from system back ups
(on floppy, tape, etc.) must be present on the root file system.
The following directories, or symbolic links to directories, are required in /.
Directory Description
bin Essential command binaries
boot Static files of the boot loader
6 Lin

dev Device files


etc Host specific system configuration
lib Essential shared libraries and kernel modules
media Mount point for removable media
mnt Mount point for mounting a file system temporarily
opt Add on application software packages
sbin Essential system binaries
srv Data for services provided by this system
tmp Temporary files
usr Secondary hierarchy
var Variable data
Each directory listed above is specified in detail in separate subsections
below. /usr and /var each have a complete section in this document due to the
complexity of those directories.

1.5 TYPES OF USERS AND FILES IN UNIX/LINUX


Linux supports numerous file system types
a. Ext2: This is like UNIX file system. It has the concepts of blocks, inodes
and directories.
b. Ext3: It is ext2 file system enhanced with journaling capabilities. Journaling
allows fast file system recovery. Supports POSIX ACL (Access Control
Lists).
c. Isofs (iso9660): Used by CDROM file system.
d. Sysfs: It is a ram based file system initially based on ramfs. It is used to
exporting kernel objects so that end user can use it easily.
e. Procfs: The proc file system acts as an interface to internal data
structures in the kernel. It can be used to obtain information about the
system and to change certain kernel parameters at runtime using sysctl
command. For example, you can find out cpuinfo with following
command:
# cat /proc/cpuinfo
f. Or you can enable or disable routing/forwarding of IP packets between
interfaces with following command:
# cat /proc/sys/net/ipv4/ip_forward
# echo "1" > /proc/sys/net/ipv4/ip_forward
# echo "0" > /proc/sys/net/ipv4/ip_forward
g. NFS: Network file system allows many users or systems to share the
same files by using a client/server methodology. NFS allows sharing all
of the above file system.
Introduction and Overview—Getting 7
h. Linux also supports Microsoft NTFS, vfat and many other file systems.
See Linux kernel source tree Documentation/file system directory for list
of all supported file system.
i. You can find out what type of file systems currently mounted with mount
command:
$ mount
OR
$ cat /proc/mounts
A UNIX file system is a collection of files and directories stored. Each
file system is stored in a separate whole disk partition. The following are a
few of the file system:
a. / - Special file system that incorporates the files under several directories
including /dev, /sbin, /tmp etc
b. /usr - Stores application programs
c. /var - Stores log files, mails and other data
d. /tmp - Stores temporary files
1.6 BASIC UNIX COMMANDS
a. ls --- lists your files
ls - l --- lists your files in 'long format', which contains lots of useful
infor- mation.
ls - a --- lists all files, including the ones whose filenames begin in a dot.
b. more filename --- shows the first part of a file, as much as will fit on one
screen.
c. emacs filename --- is an editor that lets you create and edit a file.
d. mv filename1 filename2 --- moves a file
e. cp filename1 filename2 --- copies a file
f. rm filename --- removes a file.
g. diff filename1 filename2 --- compares files, and shows where they differ
h. wc filename --- tells you how many lines, words and characters there are
in a file
i. chmod options filename --- change the read, write and execute permissions
on files.
j. File Compression
i. gzip filename --- compresses files, so that they take up much less
space.
ii. gunzip filename --- uncompresses files compressed by gzip.
iii. gzcat filename --- to look at a gzipped file without actually having to
gunzip it.
8 Lin

k. printing :
i. lpr filename --- print.
ii. lpq --- check out the printer queue.
iii. lprm jobnumber --- remove something from the printer queue.
POINTS TO REMEMBER
• An operating system is a resource manager that is useful to handle all the
available resources effectively and efficiently.
• The following are the available types of operating systems:
• Single user and Multi user operating systems
• Single tasking and Multi tasking operating systems
• Real time operating system and
• Distributed operating system
• Linux and UNIX are almost the same, except that Unix is commercial
in nature.
1.7 QUIZ
1. What is the need for an operating system?
2. What are the types of operating system available?
3. How does RTOS differ from other operating systems?
4. Which one is a free ware – UNIX or Linux?
5. Define a file system.
6. What does dev correspond to?
7. How to change the ‘read’, ‘write’ and ‘execute’ permissions on files?
Answers
1. It is acting as a resource manager. It enhances the utilization of available
resources and it makes the user more comfortable.
2. There are single user, multi user, single- tasking, multi tasking, real time
OS and distributed OS are available in the market.
3. RTOS is an operating system that works for real time system, i.e. logical
correctness of the operation within a deterministic deadline is mandatory
in that kind of systems.
4. Linux.
5. A UNIX file system is a collection of files and directories stored.
6. Dev – refers to device files.
7. Chmod is the simplest way to change the file permissions. Chmod with
number followed for user, group and others will get the permissions
changed.
❏❏❏
Linux/Unix Commands—An In-depth Analysis 9

Chapter- 2
Linux/Unix Commands
—An In-depth Analysis

Chapter Objectives
Understanding Shell.
Discuss directory commands.
Discuss all file related commands.
An analysis of rest of the Linux commands.
Recap.
Quiz.

2.1 WHAT IS SHELL?


Fortunately or unfortunately computers can only understand Binary (0’s and
1’s) and humans can only understand the English or equivalent high level
language. In olden days instructions to the computer were fed in the form of
binary only. But it was highly difficult for anyone (though being expert) to
interpret and understand. In order to ward off this difficulty every operating
system has got an inbuilt interpreter! The shell accepts instruction or
command fed by user in English and will translate the same to binary
language which computer can understand without any problem. After
accepting the input it will process the same and get the output in English that
user can easily understand. So, to be short and sweet, Shell is a language
translator. Reader will be introduced to Shell of Linux and the commands
that are most commonly used.
A diagrammatic representation (Fig. 2.1) would make the above
paragraph more meaningful and reader can understand it better.

Yes, Boss! I
User Input English to Binary
Shell can
(Commands) Conversion understanding
your request

Fig. 2.1 Shell – A Diagrammatic representation.


1 Lin

And Shell is the area where user can play around with the commands
and script that has to be run. It can be called as an environment where user
can type and get response.
Table 2.1 summarizes the available types of shell in the market and
along with a brief description of each.
Table 2.1: Available shells in the market with a brief description
S.No.Name of Shell Description
1.Bourne Shell (bsh) This is the original Unix shell written by Steve Bourne of Bell Labs. This Shell is n
This Shell was written at University of Cali- fornia, Berkeley. It provides C like lang
This Shell is very advanced and all the fea- tures of the C shell together with ema
David Korn of Bell labs has written the Shell. This is made available in all Unix sys
2. C Shell (csh) Combined features of C and TC shells along with the features of Bourne shell are
This shell is written by free software founda- tion. GNU initiative helped in framing

3. TC Shell (tcsh)

4. Korn Shell (ksh)

5. Bourne Again Shell (BASH)

2.2 LINUX / UNIX COMMANDS


From here on the reader is exposed to the basic Linux commands. It would
be very easy to understand if reader has a Linux PC. To get free Linux CD
please visit www.shipit.ubuntu.com. One can get free CD from the site by
filling the information requested or can download the OS image available
from the site. If user has any other Linux OS flavours like Redhat or Fedora
it can also be used to try the following commands. Get username and
password from system administrator. Start the PC. It will prompt for typing
name and password. Type them, Linux world will welcome!

You might also like