- Back to Home »
- My linux
Posted by : Unknown
Friday, July 26, 2013
INTRODUCTION:
LINUX is one of
the most flexible and popular operating systems in the market today.
UNIX was designed and developed in 1969 to provide an environment to
create programs. It became popular with its usage beginning to educational
institutions, scientific research laboratories and industries. Later a student
in Finland developed LINUX from UNIX and made the source code available on the
INTERNET. Later more developers added additional functions to LINUX.
Computers are used by all sections of the society. Hence it becomes
necessary to know about the various packages, languages, and the Operating
Systems (OS) available in the market.
Definition of an Operating System:
An Operating System (OS) forms a very important part of the
computer. It is a software program designed to act as an interface between a
user and computer. It controls the hardware, manages system resources and
supervises interaction between the system and its users.
Functions of an Operating System:
An operating system provides the following functions.
·
As a Command Interpreter
·
As a Peripherals Manager
·
As a Memory Manager
·
As a Process Manager
As a Command
Interpreter:
The OS interprets the command typed in by
the user and translates it to the machine language. Similarly, it also
translates the result of a command into the language, which the user
understands. This is called Command Interpretation.
As a Peripherals
Interpreter:
The OS manages the devices attached to its
system. Inputs from the keyboard are taken as commands by the computer. The
result of a command is sent to the printer or to the monitor as output. The OS
manages this task of accepting the input and producing the output. This is
called Peripheral management.
As a Memory Manager:
Within a computer there might be different
processes running which require memory from the Central Processing Unit (CPU).
The decision to allocate a certain amount of memory for a particular process is
done by the OS. This is called Memory Management.
As a Process Manager:
As said above, within a computer there might
be different processes running simultaneously. The amount of time to be spent
on a process by the CPU is also decided by the OS. This is called Process
Management.
Types of an Operating
System:
There are different types of OS available. They are
·
Single User Operating System
·
Multi User Operating System
·
Networks Operating System
Single user operating systems are those,
which are used in PCs. E.g. DOS
Multi user operating systems are those,
which can handle multiple users as well as multiple peripherals simultaneously.
E.g. LINUX
Network systems – Number of systems linked
together for the purpose of communication and centralization of data or
resources. E.g. LAN
About
LINUX:
The Linux operating system has many unique features. Linux consists
of a set of tools that enables the users to connect and use the tools to build
systems and applications. Linux is a UNIX work-alike. Some of the features are
discussed on the following types of functions.
·
Kernel Programming Interface
·
Many users at a time
·
Many tasks at a time
·
File System
Kernel programming interface:
The kernel is the heart of the operating
system, responsible for controlling the resources and scheduling user jobs in
such a manner that each user gets
equal share of system resources. All the
programs interact with the kernel through the system calls, which are special
functions.
Many users at a time:
A multi-user operating system allows many
users to access all the system resources almost simultaneously. The costly
resources are utilized to the maximum and the cost per user is minimized. This
is because one user on a machine cannot use all the devices attached to the
computer.
Many tasks at a time:
Linux is a fully protected multitasking
operating system. It allows a user to run more than one job at a time. The
processes can communicate with each other and are also protected from one
another. A user can execute different jobs in the background and at the same
time focus on another task in the forefront. We can also switch between jobs.
File System:
The Linux file system provides a file
structure where files are arranged under a directory. To ease the work of
system administrators and programmers, a group of developers over the internet
together developed the Linux file systems standard (FSSTND), which is evolving
into Linux File Systems Hierarchy (FHS). The FHS system brought all the key
programs that were previously located at different places in different Linux
distributions to a single machine.
Features
Of Linux:
1. There's no single owner for Linux. Linux is the combined effort
of many a thousand programmers. But then so is Windows, and NetWare, and Mac OS
and Delphi, and VB, and any other software that you may care to add to the
list.
2.
Cornerstone of the Linux effort has been the peer review, that not only the
software but also the source code itself is subjected to.
3. Documentation- Linux's documentation-the how-tos as they are
called -is some of the most extensive hands-on guide that you can get.
4.
Linux is customizable like no other software.
5. Support- One of the stated plus
points of commercial software is that there's a structured support program that
you can avail of. But reality is often different. Those of you who have had
occasion to ask for help would know that often it's not from the structured
support programs, but from non-structured ones like user groups and Internet
news groups that you get more precise and faster help.
6.
Linux doesn't need the latest, fastest, hardware to run on.
7.
And last but not the least, because it's free.
STRUCTURE OF LINUX
SYSTEM:
Linux is very popular due to its special features and its structure.
Its structure consists of kernel, shell, tools, and applications.
·
Kernel
·
Shell
·
Tools
·
Applications
Kernel:
Kernel forms the core of the LINUX operating
system. This interacts with the hardware. It is loaded into the memory when a
system is booted. Its functions are
Ø Managing the system resources
Ø Allocating time for different users and processes
Ø Deciding process priorities and performing them
Since the kernel isolates itself from user
programs, it can be moved across different systems. Kernel does not interact
with the user directly. Instead, it starts up a separate file called SHELL.
Shell:
Linux’s Shell interacts with the user and
the computer. Some of its features are as follows:
Interactive Processing: Communication between the user and the system tasks the form of
interactive dialogue with the Shell.
Background Processing: There are processes that are time consuming and which are
non-interactive in nature. Such processes can be done in the background while
we can continue using the system to do other tasks.
Input/Output
Redirection: Programs can be instructed to take input
from a file other than the standard input i.e. the keyboard and send the output
to a file instead of the standard output i.e. the Visual Display Unit. This is
called Redirection. Simultaneous use of Input and Output Redirection is
possible.
Pipes: Simple programs can be developed to do complex operations with
minimum effort using pipes. This reduces the necessity for writing new programs
for the complex operations.
Wild Card Patterns: files matching a particular pattern can be grouped together and
actions may be performed on it. We shall deal with Wild Card patterns in later
chapters.
Shell scripts: The shell scripts contain a sequence of commands to be performed
with a single filename. The scripts can be executed using that filename.
Shell Variables: By storing date in variable we can control the behavior of shell as
well as that of programs and utilities.
Programming Language
Constructs: Shell has features which enables it to be
used as a programming language. These help in building complex shells to
perform complex operations.
Tools and Applications:
LINUX supports business application oriented
packages like Word Processors, Electronic Spreadsheets, databases etc. Which
makes it a favorite among operating systems, used in Offices.
Some
of the simple commands:
DATE command:
The date command tells us the current date and time.
Ex: $ date
Thu Aug 23
12:23:50 PST 2001
$ _
WHO command:
The output of the who command gives us the details of the users who have
logged in to the LINUX system currently.
WHO AM I command:
The who am I command gives us details regarding the login time and the
system’s name for the connection being used.
MAN command:
If we get stuck on something, and cannot find an expert to help, we can
print any manual page on our terminal with the command ‘man’ command-name.
HEAD and TAIL command:
The head command is used to display the initial part of a text file.
This can be thought of as a complement command to the tail command, which
displays the last part of a text file. By default head command displays first
10 lines of a file and tail command the last 10 lines.
Syntax:
$ head [- count] [filename…]
$ tail [+/- number] file
Some of the directory commands:
Let us look at some directory commands.
PWD command:
The pwd command has no options. It displays the full pathname for the
current directory.
The syntax is $ pwd.
ls Command:
The ls command displays the list of files in
the current working directory.
$ ls
mkdir command:
This command is used to create a new
directory.
$ mkdir directoryname
cd Command:
The cd command is used to change from the
working directory to any other directory specified. There are no options
connected with this.
$ cd
rmdir Command:
This command is used to remove a directory
specified in the command line. It requires the specified directory to be empty
before removing it.
$ rmdir directoryname
Some of the File Commands
We shall continue with getting to know some
simple file commands.
Cat Command:
The cat command helps us to list the
contents of a file we specify. If we do not specify the name of the file, it
takes input from the standard input.
$ cat [option…] [file…].
The cat command comes with different
options. They are
Cat Takes input from
the standard input file. We can type in our
text and terminate with
Ctrl+d to take us back to $ prompt.
Cat
–s Suppresses
warnings about non-existent files.
Cp Command:
The cp command is used to create duplicate
copies ordinary files.
$ cp file target
The target is the file to which the contents
of the file have to be copied. If the name of the target file already exists,
the original contents are erased and the contents of the file are written on
the target.
ln – link Command:
The ln command is to establish an additional
filename for the same ordinary file.
$ ln firstname secondname
Here firstname is the name of the file for
which we would like to establish an additional name or link. The secondname is
the additional name of the file firstname. The advantage of link command is
that several users can have access to a common data file. Any modification made
in the additional file or in the original file is reflected in both of them.
Linking allows a user to access a file by
means of two or more names. The alternative names can be located in the same or
different directory. Since Linux is a multi-user operating system, it allows
the user to protect the data from other user.
mv command:
The mv command is used to rename and move
ordinary and directory files. To do this we need both execute and write
permissions.
$ mv file target
To move the contents of the file old to the
file new, the syntax is:
$ mv old new
rm Command:
The rm command is used to remove one or more
files from a directory. This can be used to delete all files as well as the
directory.
$ rm [option…] file
The
FILE system in LINUX:
A file is just a sequence of
bytes that may contain text, binary data or even machine language instructions.
One important thing to note in LINUX is that, all information is treated as
files.
We know that Linux is multi-user Operating System, Hence it is
necessary to protect unauthorized access of a user’s file from another user. To
do this, Linux offers a facility called File Access Permissions (FAP).
File System:
We are aware that LINUX treats all information as files. Hence files
are important part of Linux system. They are stored in a hierarchical order and
are grouped together. This enables easier search of the files. Directories and
devices are also treated as files. The directory files are prefixed with a ‘d’.
The standard input device, standard output device and the standard error device
are treated as files.
The Directory Hierarchy:
A file system is a data structure that resides on part of a disk.
The Linux file system is also called a tree. This consists of a set of files.
The structure allows the user to organize files so that a particular file can
be located easily. Every user starts with a single directory. This in turn may
contain many sub directories. Each directory contains files and other sub
directories. The set of directories from the root forms the path name. This
path name with the filename forms the absolute path of the file.
The main strength of the Linux file system is the ability to adapt
to different user’s needs. The Linux file structure is set up according to a
document called the File Hierarchy Standard (FHS).
When the system starts, an ordinary file called Linux is read from
the disk into the memory. Actually, the process occurs in two steps: first the
file /boot is read and then /Linux is read.
The /bin directory
contains the executable files for most LINUX commands. The /etc directory contains other additional
commands that are related to system maintenance and administration. The /lib directory contains all the library
functions provided by LINUX for the programmers. The /dev directory is created for each user to have a private work area
where the user can store his files. This is called the user’s HOME directory.
The /tmp directory is the directory
into which temporary files are kept. The files stored in this directory are
deleted as soon as the system is shutdown and restarted.
File Access Permissions:
There are three types of files in Linux. They are Directory files, Ordinary files and special
files. We will be dealing with directory and ordinary files only. Ordinary
files start with ‘-‘ and the directory files start with ‘d’.
When any user creates a file, the creator is said to be the
owner of the file. We can perform any operation like delete, edit on that file.
If a user wants other people to access his/her files, then permission has to be
granted by the owner of the file. This way LINUX helps in the security of
files.
There are various types of permissions available. They are
read (r), write (w) and execute (x). Associated with any LINUX file is the
owner of the file, the group which consists of users who need to share that
file and others who do not belong to that group. The “ls –l” option gives the
list of permissions granted to each file.
Changing the FAP of a file:
We can change the mode of any file or directory using the “chmod
command”.
PIPES
AND FILTERS:
In LINUX, commands are used to
perform only a specific task. It is not possible for the user to perform
multiple tasks in one command. Pipes and Filters are used to overcome this
obstacle.
Pipes: A pipe is a mechanism in which the output from one command can be
redirected as input to another command.
Example: $ who | wc –l
16
$ _
Pipes are considered as temporary files, which
store the output of one command in memory and passes it as the input to the
next command. The important advantage of the pipes is that they prevent the
user from making temporary files using I/O redirection.
Filters: A Filter accepts input from the Standard input, processes the input
and then sends the output to the Standard output. Filters also take input from
a file.
Filters
are used to extract the lines, which contain a specific pattern, to arrange the
contents of a file in a sorted order, to replace the existing characters with
other characters, etc. Filters are also used to store the intermediate results
of a long pipe. We can extract specific portions of a file and can merge two or
more files together using filters.
Generally used Filters are
·
Sort filter
·
Grep filter
Sort filter:
The
sort filter arranges the input taken from the Standard Input in the
alphabetical order. The options available with sort are –r, -f, -n, -b, -t etc.
Grep filter:
The grep
command is used to search for a particular pattern from a file or from the
Standard Input and display those lines on the Standard Output. ”grep” stands
for “global search for regular expression”.
The various options available with the “grep” command are:
-v Displays only those lines that do not
match the specified pattern
-c Displays only the count of the lines that
match the specified pattern
-n Displays only those lines
that match the specified pattern along with the line number at the beginning of
the line.
-i Displays those lines
that match the specified pattern ignoring the case distinction
These are the various ways to specify the
regular expressions or the patterns to be searched.
EDITORS:
The editor helps in creating and editing files. The editor in operating system has the same importance as the editor of a newspaper.
Linux
offers various types of editors like vi, ex, sed, ed, etc. Among the editors,
the vi editor stands as the most powerful and widely used in the LINUX
environment. Vi and ex editors are basically same. Their commands are mutually
compatible to each other. While ex is a line editor, vi is a full screen
editor.
SHELL programming:
A set of commands can also be grouped
together under a single
filename and executed. This is achieved using Shell scripts. Shell
provides features that enable it to be used as a programming language. The
features include programming constructs, logical and conditional operators, command
substitution, escape mechanisms, positional parameters, etc.
Introduction
to shell scripts:
A set of
commands to be performed repeatedly is executed using a batch file in MS-DOS.
Shell scripts are similar to the batch file in MS-DOS except that they offer
varied facilities for effective programming.
Creation and execution:
A set of
commands to be performed can be entered into a file by using any of the editors
discussed earlier or by using the CAT command.
Ex: $ cat > greet
echo “please enter your name”
read name
echo “Hi !! Welcome to the Linux programming” name
$ _
Execution: A shell script can be executed using
two methods. One method is to type “sh filename” at the $ prompt and the second
method is to grant execute permission to the file and then type the filename at
the $prompt
Ex: FIRST
METHOD
$ sh greet
Please enter your
name: VENKI
Hi !! Welcome to the
Linux programming VENKI
$ _
SECOND METHOD
$ chmod u+x
greet
$ greet
Please enter your
name: VENKI
Hi!! Welcome to the
Linux programming VENKI
$ _
Shell
variables: Shell has
different types of variables. They are user defined variables and environment
or pre-defined variables. The other category of shell variables is local
variables and global variables.
Apart from the environment
variables that are set automatically, there are also other Shell variables that
are set automatically. Some of these special shell variables are as follows…
$#, $-, $?, $$, $!, $0, $*, $@.
Shell
Features:
Comment: The # symbol
is used in shell scripts to insert a comment line.
Command substitution:
when a command is enclosed within back quotes (‘ ‘) or grave accent, the
command is replaced by the output that it produces.
Exit command: The exit
command is used to terminate the Shell script and informs the exit status of
the script.
Numerical comparisons:
Numerical comparisons are used to compare two integers within a shell script.
Some of the comparison operators are…
-eq, -ne, -gt,
-lt, -ge, and –le.
Logical operators:
Logical operators help us in writing Shell scripts in a more efficient way. A
list of the operators is given below:
! Negates
the expression following this operator.
-a Used for indicating “and”.
-o Used for indicating “or”.
Arithmetic Operators and Expressions: The arithmetic operators provided by Shell are +, -, * and /.
However, numeric strings are accepted as a series of characters by Shell,
unless specified to take their numerical value. The expr command is used in retrieving the numerical value of the
numeric string.
Ex: $ expr 6+4
10
Programming
Language constructs:
Shell offers
standard programming structures like loops and branching, operations on
variables, file creation and argument passing. This is performed using Shell
scripts. For this reason Shell scripts are more powerful than batch files in
MS-DOS.
Some of the structured language constructs are as follows:
If…then…else…fi
For…do…done
While…do…done
Until…do…done
Case…esac
test command: some
times we may want to know if the argument of a shell script is a file or a
directory or we may want to test for the equality of two given strings.
Ex: $ pet=dog
$ test pet=dog
LINUX
APPLICATIONS:
Commercial: Corel word perfect –
word processing.
Star
office - office application suite.
Acroread
from Adobe.
Database
implementations:
Mysql,
db2. Jdbc drivers from open link to
ensure that there is easy access to databases from any programming environment
into Linux.
Shell script
languages:
Bourne
shell script.
Interpreted
programming languages:
Perl,
tcl, python,c.
CONCLUSION:
Linux
is a modern, free operating system based on UNIX standards. It has been
designed to run efficiently and reliably on common PC hardware; it also runs on
a variety of other platforms. It provides a programming interface compatible
with standard UNIX systems, and can run a large number of UNIX applications,
including an increasing number of commercially supported applications.
A complete Linux system
includes many components that were developed independently of Linux. The core
Linux OS kernel is entirely original, but it allows much existing free UNIX
software to run, resulting in an entire UNIX-compatible operating system free
from proprietary code.
The Linux kernel is
implemented as a traditional monolithic kernel for performance reasons, but is
modular enough in design to allow most drivers to be dynamically loaded and
unloaded at run time.
Linux is a multi-user
operating system, providing protection between processes and running multiple
processes according to a time-sharing scheduler. It allows multithreaded
programming. To the user, the file system appears as a hierarchical
directory tree that obeys UNIX semantics. Internally, Linux uses an
abstraction layer to manage m0ultiple different file systems.
Device-oriented, networked, and virtual file systems are supported.
The memory-management system uses
page sharing and copy-on-write to minimize the duplication of data shared by
different processes. Pages are loaded on demand when they are first referenced,
and are paged back out to backing store according to an LFU algorithm if
physical memory needs to be reclaimed.