Operating System Practical
Operating System Practical
Theory:-
The History of Linux began in 1991 with the commencement of a personal project
by a Finnish student, Linus Torvalds, to create a new free operating system kernel.
Since then, the resulting Linux kernel has been marked by constant growth
throughout its history. Since the initial release of its source code in 1991, it has
grown from a small number of C files under a license prohibiting commercial
distribution to its state in 2009 of over 370 megabytes of source under the GNU
General Public License.
The Unix operating system was conceived and implemented by Ken Thompson and
Dennis Ritchie (both of AT&T Bell Laboratories) in 1969 and first released in 1970.
Its availability and portability caused it to be widely adopted, copied and modified
by academic institutions and businesses. Its design became influential to authors
of other systems.
In 1983, Richard Stallman started the GNU project with the goal of creating a
free UNIX-like operating system.[2] As part of this work, he wrote the GNU
General Public License (GPL). By the early 1990s there was almost enough available
software to create a full operating system. However, the GNU kernel, called Hurd,
failed to attract enough attention from developers leaving GNU incomplete.
Another free operating system project, initially released in 1977, was the Berkeley
Software Distribution (BSD). This was developed by UC Berkeley from the 6th
edition of Unix from AT&T. Since BSD contained Unix code that AT&T owned,
AT&T filed a lawsuit (USL v. BSDi) in the early 1990s against the University of
California. This strongly limited the development and adoption of BSD.
In 1985, Intel released the 80386, the first x86 microprocessor with 32-bit
instruction set and MMU with paging.
In 1986, Maurice J. Bach, of AT&T Bell Labs, published The Design of the UNIX
Operating System. This definitive description principally covered the System V
Release 2 kernel, with some new features from Release 3 and BSD.
MINIX, a Unix-like system intended for academic use, was released by Andrew S.
Tanenbaum in 1987. While source code for the system was available, modification
and redistribution were restricted. In addition, MINIX's 16-bit design was not
well adapted to the 32-bit features of the increasingly cheap and popular Intel
386 architecture for personal computers. In the early nineties a commercial UNIX
operating system for Intel 386 PCs was too expensive for private users.
These factors and the lack of a widely adopted, free kernel provided the impetus
for Torvalds's starting his project. He has stated that if either the GNU or
386BSD kernels were available at the time, he likely would not have written his
own.
In 1991, in Helsinki, Linus Torvalds began a project that later became the Linux
kernel. It was initially a terminal emulator, which Torvalds used to access the large
UNIX servers of the university. He wrote the program specifically for the
hardware he was using and independent of an operating system because he wanted
to use the functions of his new PC with an 80386 processor. Development was done
on MINIX using the GNU C compiler, which is still the main choice for compiling
Linux today (although the code can be built with other compilers, such as the Intel
C Compiler).
As Torvalds wrote in his book Just for Fun, he eventually realized that he had
written an operating system kernel. On 25 August 1991, he announced this system
in a Usenet posting to the newsgroup "comp.os.minix.":
I'm doing a (free) operating system (just a hobby, won't be big and professional
like gnu) for 386(486) AT clones. This has been brewing since april, and is starting
to get ready. I'd like any feedback on things people like/dislike in minix, as my OS
resembles it somewhat (same physical layout of the file-system (due to practical
reasons) among other things).
I've currently ported bash(1.08) and gcc(1.40), and things seem to work. This
implies that I'll get something practical within a few months, and I'd like to know
what features most people would want. Any suggestions are welcome, but I won't
promise I'll implement them :-)
Linus ([email protected])
PS. Yes – it's free of any minix code, and it has a multi-threaded fs. It is NOT
portable (uses 386 task switching etc), and it probably never will support anything
other than AT-harddisks, as that's all I have :-(.
—Linus Torvalds
Features of LINUX:-
Following are some of the important features of Linux Operating System.
● Portable - Portability means softwares can works on different types of
hardwares in same way.Linux kernel and application programs supports their
installation on any kind of hardware platform.
● Open Source - Linux source code is freely available and it is community based
development project. Multiple teams works in collaboration to enhance the
capability of Linux operating system and it is continuously evolving.
● Multi-User - Linux is a multiuser system means multiple users can access
system resources like memory/ ram/ application programs at same time.
● Multiprogramming - Linux is a multiprogramming system means multiple
applications can run at same time.
● Hierarchical File System - Linux provides a standard file structure in which
system files/ user files are arranged.
● Shell - Linux provides a special interpreter program which can be used to
execute commands of the operating system. It can be used to do various
types of operations, call application programs etc.
● Security - Linux provides user security using authentication features like
password protection/ controlled access to specific files/ encryption of data.
Structure of LINUX:-
Practical-2
Introduction:-
Any blank lines beyond the end of the file are shown this way. At the bottom of
your screen, the filename should be shown, if you specified an existing file, and the
size of the file will be shown as well, like this:
"filename" 21 lines, 385 characters
If you started VI without a filename, the bottom line of the screen will just be
blank when VI starts.
vi opens the file you specify in filename unless it does not exist. If the file does
not exist, vi opens a new file which
will be called filename. You should see something like
The column of "~" characters indicates that your are at the end of the file.
VI Editor Modes:-
The first thing most users learn about the VI editor is that it has two modes:
Command and insert. The command mode allows the entry of commands to
manipulate text. These commands are usually one or two characters long, and can
be entered with few key strokes. The insert mode puts anything typed on the
keyboard into the current file. VI starts out in command mode. There are several
commands that put the VI editor into insert mode. The most commonly used
commands to get into insert mode are a and i.
For example, hit i key and type "This is EASY.", then hit the escape key. Once you
are in insert mode, you get out of it by hitting the escape key. You can hit escape
two times in a row and VI would definitely be in command mode. Hitting escape
while you are already in command mode doesn't take the editor out of command
mode. It may beep to tell you that you are already in that mode.
The command to quit out of VI is :q. Once in command mode, type colon, and 'q',
followed by return. If your file has been modified in any way, the editor will warn
you of this, and not let you quit. To ignore this message, the command to quit out
of VI without saving is :q!. This lets you exit VI without saving any of the changes.
Of course, normally in an editor, you would want to save the changes you have
made.The command to save the contents of the editor is :w. You can combine the
above command with the quit command, or :wq. You can specify a different file
name to save to by specifying the name after the :w.
For example, if you wanted to save the file you were working as another filename
called
example2, you would type :w example2 and hit return. At the bottom of your
screen, the filename and the size of the file will be shown like this:
In this section, we will learn and practice the basic text and command modes in
order to be able to use VI editor more efficiently and effectively.
Editing with o option:- Hit o key to enter insert mode in a new line below
the current cursor position and type "This is very very easy." and get out of the
text mode by hitting the escape key. The letter O inserts mode in a new line above
the current cursor position.
Replacing Text:-
C: Change to the end of the line from the current cursor position.
R: Replace characters on the screen with a set of characters entered, ending with
the Escape key.
S: Change an entire line.
C: Change until . "cc" changes the current line. A count changes that many lines.
R: Replace one character under the cursor. Specify a count to replace a number of
characters.
EX Commands:-
The VI editor is built upon another editor, called EX. The EX editor only edits by
line.
From the VI editor you use the : command to start entering an EX command. This
list
given here is not complete, but the commands given are the more commonly used.
:w
Write out the current file.
:w filename
:wq
Write the buffer and quit.
Operating System
Commands:
1. Mkdir – This command is used for making new directory.
Syntax – mkdir directory_name
2. Ls – This command is used for showing all the existing file.
Syntax – ls
3. Touch – This command is used for making a new file.
Syntax – touch file_name.extension
4. Cat – This command is used for showing content of a file.
Syntax – cat filename.extension
5. Cat>filename.extension – This command is used for entering contents in file.
6. Ctrl+d – This command is used for saving a file.
7. Cat file_name1.extension file_name2.extension> file_name.extension – This command is used
for merging the contents of file 1 and file 2 into a empty file.
8. Ls *.extension – This command is used for showing the file of a particular extension.
9. Pwd – this command is used for showing the present working directory.
Syntax – pwd
10. Rm – This command is used for deleting the file.
Syntax – rm file_name.extension
11. Rmdir – This command is used for deleting a directory.
Syntax – rmdir directory_name
Note: the directory should be empty for using this command
12. Mv – This command is used for moving file to directory.
Syntax – mv file_name directory_name
13. Head – This command is used for showing the first 10 lines of a file.
Syntax – head file_name.extension
14. Tail – This command is used for showing the last 10 lines of a file.
Syntax – tail file_name.extension
15. More – This command is used for showing the large content.
Syntax – more file_name.extension
16. Clear – This command is used for clearing the terminal window.
Syntax – clear
17. Tac – This command is used to reverse the order of file content.
Syntax – tac file_name.extension
18. Ping – this command is used for checking if the file is connected to the server or not.
Syntax – ping file_name.extension
19. Wc – word count tells how many words, letter, line, and characters are present in file.
Syntax – wc file_name.extension
20. Nl – shows the number of lines in a file.
Syntax – nl file_name.extension
21. History – This command shows all the commands used in terminal.
Syntax – history
22. Hostname – Tells the system name
Syntax – hostname
23. Id – this command is used to tell the system details.
Syntax – id
24. Chmod u=r – Gives the permission to only read the content of file.
Syntax – chmod u=r file_name.extension
25. Chmod u=w – Gives the permission to only write in the file.
Syntax – chmod u=w file_name.extension
26. Chmod u=rw – gives the permission to read and write in the file.
Syntax – chmod u=rw file_name.extension
Programs:
1. Arithmetic operators:
echo "enter two numbers"
read a b
echo "a= $a"
echo "b= $b"
sum=$(($a+$b))
echo "sum= $sum"
subtraction=$(($a-$b))
echo "subtraction= $subtraction"
multiplication=$(($a*$b))
echo "multiplication= $multiplication"
division=$(($a/$b))
echo "division= $division"
output:
2. Program to find if the year is leap or not:
output:
output:
4. Program to swap number using third variable:
output:
output:
6. Program of calculator using switch case statement:
output:
output:
output:
a=0
while [ $a -lt 10 ]
do
b=$a
while [ $b -ge 0 ]
do
echo -n " $b "
b=$(($b-1))
done
echo
a=$(($a+1))
done
Output:
10. Write a script to generate a Fibonacci series:
i=1
a=0
b=1
echo "$a"
while [ $i -ne 10 ]
do
b=$(( $a + $b ))
echo "$b"
c=$a
a=$b
b=$c
i=$(($i+1))
done
Output: