Roll No.: A Laboratory Manual FOR Operating Systems
Roll No.: A Laboratory Manual FOR Operating Systems
of technology and industry and includes the all-round personal development of students
including social concerns and to become globally competitive, technology led organization.
To provide high quality technical and managerial manpower, information and consultancy
services to the industry and community to enable the industry and community to face the
QUALITY POLICY
We, at MSBTE are committed to offer the best in class academic services to the students
and institutes to enhance the delight of industry and society. This will be achieved through
development, implementation, evaluation and monitoring system along with adequate faculty
development programmes.
CORE VALUES
for
Operating System
(22516)
Semester-V
(CO/CW/CM/IF)
Maharashtra State
Board of Technical Education, Mumbai
(Autonomous) (ISO:9001:2015) (ISO/IEC 27001:2013)
Maharashtra State Board of Technical Education,
(Autonomous) (ISO:9001: 2015 ) (ISO/IEC 27001 : 2013)
Ath Floor, Government Polytechnic Building, 49, Knerwadi,
Bandra ( East ), Mumbai - 400051.
(Printed on May,2019)
Board of Technical Education
Certificate
This is to certify that Mr. / MS .............c
cece cence eee ee ee enene eens
1X0)| \ (0 ee Of 1.2... eee. Fourth Semester of
Diploma 10 2.0... cece cece eee eee eee eee eee eee ee eee ee eee e eae
Of Institute... cece cee eee eee e ene e eee eeneetneeeeeeenaeees
(Code..............00
cee ) has attained pre-defined practical
outcomes(PROs) satisfactorily in course Operating System
(22516) for the academic year 20....... to 20........ as prescribed in
the curriculum.
Seal of the
Institute
Operating System (22516)
Preface
The primary focus of any engineering laboratory/field work in the technical education system
is to develop the much needed industry relevant competencies and skills. With this in view,
MSBTE embarked on this innovative ‘I’ Scheme curricula for engineering Diploma
programmes with outcome-based education as the focus and accordingly, relatively large
amount of time is allotted for the practical work. This displays the great importance of
laboratory work making each teacher, instructor and student to realize that every minute of
the laboratory time need to be effectively utilized to develop these outcomes, rather than
doing other mundane activities. Therefore, for the successful implementation of this
outcome-based curriculum, every practical has been designed to serve as a ‘vehicle’ to
develop this industry identified competency in every student. The practical skills are difficult
to develop through ‘chalk and duster’ activity in the classroom situation. Accordingly, the ‘I’
scheme laboratory manual development team designed the practical’s to focus on outcomes,
rather than the traditional age old practice of conducting practical’s to ‘verify the theory’
(which may become a byproduct along the way).
This laboratory manual is designed to help all stakeholders, especially the students, teachers
and instructors to develop in the student the pre-determined outcomes. It is expected from
each student that at least a day in advance, they have to thoroughly read the concerned
practical procedure that they will do the next day and understand minimum theoretical
background associated with the practical. Every practical in this manual begins by identifying
the competency, industry relevant skills, course outcomes and practical outcomes which
serve as a key focal point for doing the practical. Students will then become aware about the
skills they will achieve through procedure shown there and necessary precautions to be taken,
which will help them to apply in solving real-world problems in their professional life.
This manual also provides guidelines to teachers and instructors to effectively facilitate
student-centered lab activities through each practical exercise by arranging and managing
necessary resources in order that the students follow the procedures and precautions
systematically ensuring the achievement of outcomes in the students.
Operating systems are an essential part of any computer system. Similarly, a course on
operating systems is an essential part of any computer group. We hope that students will also
find it useful. It provides a clear description of practical performance, execution and working
of Operating System.
Although all care has been taken to check for mistakes in this laboratory manual, yet it is
impossible to claim perfection especially as this is the first edition. Any such errors and
suggestions for improvement can be brought to our notice and are highly welcome.
Following programme outcomes are expected to be achieved significantly out of the ten
programme outcomes and Computer Engineering and Information Technology programme
specific outcomes through the practicals of the course on Operating System.
PO 3. Experiments and practice: Plan to perform experiments, practices and to use the
results to solve Information Technology related problems.
PO 5. The engineer and society: Assess societal, health, safety and legal issues and the
consequent responsibilities relevant to practice in the field of Information technology.
PO 8. Individual and team work: Function effectively as a leader and team member in
diverse/ multidisciplinary teams.
PO 10. Life-long learning: Engage in independent and life-long learning along with the
technological changes in the IT and allied industry.
The following industry relevant skills of the competency “Manage operations of Operating
System” are expected to be developed in you by performing practicals of this laboratory
manual.
1. Executes basic commands to work with Operating System like UNIX.
2. Execute Shell Scripts.
3. Execute program on Process Scheduling.
4. Execute programs on Page Replacement
Teacher is expected to share the skills and competencies to be developed in the students.
Teacher should ensure that the respective skills and competencies are developed in the
students after the completion of the practical exercise.
Teacher may provide additional knowledge and skills to the students even though that
may not be covered in the manual but are expected from the students by the industries.
Teacher may suggest the students to refer additional related literature of the reference
books/websites/seminar proceedings etc.
10. During assessment teacher is expected to ask questions to the students to tap their
knowledge and skill related to that practical.
Student shall read the points given below for understanding the theoretical concepts and
practical applications.
1. Students shall listen carefully the lecture given by teacher about importance of
subject, learning structure, course outcomes.
Students shall organize the work in the group of two or three members and make a
record of all observations.
Students shall understand the purpose of experiment and its practical
implementation.
Students shall write the answers of the questions during practical.
Student should feel free to discuss any difficulty faced during the conduct of
practical.
Students shall develop knowledge of Operating System fundamental and
manipulation skills as expected by the industries.
Student shall attempt to develop related hands on skills and gain confidence.
Students shall refer technical magazines; websites related to the scope of the subjects
and update their knowledge and skills.
Students shall develop self-learning techniques.
10. Students should develop habit to submit the write-ups on the scheduled dates and
time.
Content Page
List of Practicals and Progressive Assessment Sheet
Practical No. 1: Install and configure Linux (or alike) operating system.
I. Practical Significance:
Linux is the base of many of open source operating systems designed to replace
Windows and Mac OS. It is free to download and install on any computer. Because it
is open source, there are a variety of different versions, or distributions, available
developed by different groups. To prevent hacking attempts, many organizations keep
their Linux operating systems private. Many others make their variations of Linux
available publicly so the whole world can benefit at large.
Installation has started. Once the installation is completed, it will ask to restart
the Machine. Click on “Restart Now”
Step 8: Login Screen after reboot.
Use the same user and its credentials that we have set during the installation.
We will get below screen after entering the credentials.
Ubuntu Installation is Completed Now.
Similarly any open source installation shall be considered.
1 Computer System
2. | Operating System
XII. Exercise:
1. Differentiate between command line OS and GUI OS by giving example.
Draw the diagram of multiprogramming system and state concept of it.
PAWN Which are the extra facilities provided by Unix other than Windows OS?
Enlist four features of the following operating system:
Windows 98 b. Windows 2000 c. Windows XP
I. Practical Significance:
General purpose commands are inbuilt programs that can be invoked in multiple
ways. These commands work interactively from a terminal. A terminal that provides
a command line interface using a shell program.
1 Computer System
2. | Operating System
Note: Below given are few sample questions for reference. Teacher must design
more such questions to ensure the achievement of identified CO.
1. How you record all the following activities performed by the user.
2. Give a command to display calendar for month of January.
3. Give single statement command to display the calendar of previous, current and
next month.
4. Give the command to display full week day (eg.Sunday) using date command.
XIII. Exercise:
f. $cal -2000
(Attach page for output)
2. Give the syntax of commands for displaying the output. (use date)
1. This iS ............645 Month of the year .................5. (Abbreviation for month
and 4-digit year)
il. This is the ................ ’th day of this year.
Dated Tocc
signature
hes of
Marks Obtained
Process Product
Related(15) Related(35) Total(50)
Practical No. 03: Work with multiple Linux terminals and basic
commands.
Practical Significance:
Work with terminal environment to know about users and set their security. It
includes current status of all the users like details about all the users who accesses the
terminal for particular duration and path of directory.
Sr.
No Name of Resource Broad Specification Quantity Remarks (If any)
Processor (13-15), RAM-
1 Computer System 2GB and above (As per
need of OS) As per batch For all
Unix/Linux/Ubuntu/any Size Experiments
2. | Operating System other open sources
operating system
Sr.
No Name of Resource Broad Specification Quantity Remarks (If any)
1 Computer System
2. | Operating System
Dated signature
of Tecch er
Marks Obtained
Process Product
Practical Significance:
The purpose of computer systems is to allow the user to execute programs. So the
Operating systems provides an environment where the user can conveniently run
programs. The user does not have to worry about the memory allocation or
multitasking or anything. These things are taken care of by the operating systems.
An Operating System supplies different kinds of services to both the users and to the
programs as well. It also provides application programs (that run within an Operating
system) an environment to execute it freely. It provides users the services run various
programs in a convenient manner. File editing is done with the help of any editor. The
default editor that comes with the UNIX operating system is called vi (visual editor).
The UNIX vi editor is a full screen editor and has two modes of operation:
Command mode commands which cause action to be taken on the file, and
Insert mode in which entered text is inserted into the file.
Editor:
There are many ways to edit files in Unix. vi Editor works in Unix. This editor
enables you to edit lines in context with other lines in the file. You can also use this
editor to just read a text file.
An improved version of the vi editor which is called the VIM has also been made
available now. Here, VIM stands for Vi IMproved.
GUI:
Linux system provides both the interface that is GUI and CLI. As per the requirement
you can decide when you should use the Linux command line interface (CLI) and
when you should use a graphical user interface (GUI).
File Handling.
Following are the Processes commands:
Command to add and remove services in your system start-up: use chkconfig
Enter the command to show currently running services.
Is /etc/init.d
Enter the restart command.
sudo systemctl
To stop service
sudo systemctl,
To start service.
sudo systemctl
Resources required(Additional)-Nil
1 Computer System
2. Operating System
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. List various menus you observed on your system?
2. Study the GUI of your Linux system.
3. What is difference between GUI and CLI?
XIII. Exercise:
Process Product
Related(15) Related(35) Total(s0)
I. Practical Significance:
Process is program in execution. ps Commands is used to manage and to see the
active processes on Unix operating system. ps basically means ‘Process Status'
which is used to display currently running processes in Unix operating system.
2 $wait Waits until all background processes are completed and then
exits.
Options of ps commands:
$ps -f Full listing showing PPID of each process.
$ps -u username Displays processes of user ‘username’
$ps -a Processes of all users
$ps -e Processes including user and system processes.
Sr.
No Name of Resource Broad Specification Quantity Remarks (If any)
1 Computer System
2. | Operating System
XIII. Exercise:
QD. icccececccnccceceeeecuuneeeeeeeeeueuuees
Process Product
Related(35) Related(15) Total(s0)
I. Practical Significance:
Basically, the operations perform in Unix/Linux are done on a prompt / terminal
which is not stored anywhere. But most of the commands are written to store the
information. One way is to store the information in a file. Various operations that can
be performed on a file are create, open, read, write, move, close and rename.
Options Meaning
Is -a list all files including hidden file starting with '.'
Is -d list directories - with ' */'
Is -1 list file's inode index number
Is -l list with long format - show permissions
Example:
$ls -i abc. txt list contents of abc. txt file
$ls -1 List of all files along with permissions given to it.
$ls 22? List the names of files with exact three characters in it name.
$ls d*s List of files names which starts for d and ends with s
$ls —I Gives full listing of all files and directories.
Output
Termina File Edit View Search Terrpinal Help yh A 4:26PM tt
A
2 root root 16384 Jan 10:54 Lost+found
UA
drwxr-xr-x 2 root root 4096 Aug 2015 media
drwxr-xr-x 2 root root 4096 Apr 2014 mnt
=
drwxr-xr-x 2 root root 4096 Aug 2015
BUUNNUANUNURP
opt
dr-xr-xr-x 173 root root 10) Feb 16:20 proc
a
2 root root 4096 Aug 2015 root
drwxr-xr-x 23 root root 740 Feb 16:21 run
Be
drwxr-xr-x root root 12288 Jan a2 17 sbin
drwxr-xr-x root root 4096 Aug 2015 srv
dr-xr-xr-x root root 10) Feb 16:20 sys
ae
Figure 1
Options:
1. -i (Interactive): The mv command with -i option ask for confirmation
$ mv -i abc.txt aab.txt
Maharashtra state Board of Technical Education 25
Operating System (22516)
Example:
$ Is
Xyz.txt
$ cp xyz.txt zzz.txt
Check it now
$ Is
XYZ.txt ZZz.txt
join command: It is used for joining lines of two files on the basis of common field
in
each file called as a key.
Syntax:
$join [-t -o] filename filename2
-t field separator
-o Specify the column from each table that must be included.
Example:
$cat student!
Ajay 1990
Vijay 1992
Sujit 1991
$cat student2
Ajay 50
Vijay 62
Sujit 70
$join -t “:” student! student2
Ajay :1990:50
Vijay : 1992: 62
Sujit : 1991: 70
split command: It is used to split the large file into smaller files. Default size is 1000
lines per file.
Syntax:
$split -n filename tag name
-n number of lines in each smaller file.
-tag name by default the split builds the output files named xaa,xab,xac........
If tag name specified, it replaces the x with that tag name.
Example:
Split -100 student
Check it now
$ls
xaa xab- xac
cat command : It is used to create the file and displaying the contents of file/files.
Syntax:
$ cat >sample (To create a file)
This is sample file in Unix.
<cntrl d>
$ cat sample
where cat is a command and sample is argument. This is sample file in Unix.
User can display contents of more than one file and called as concatenation.
$ cat list] .txt list2.txt (List two files at a time)
head command: It is used to read the first ten lines of file. (10 lines by default)
The number of lines to be displayed may be specified in the head command.
Syntax:
Shead -n filename (-n means how many lines to be displayed)
Example:
Shead -20 student
Displays the first 20 lines of the file student.
tail command: It is a used to print last few numbers of lines (10 lines by default) of a
certain file, then terminates.
Syntax:
Stail {[+/-]n [lbc] }filename
Options Meaning
+n Displays all lines starting from nth line.
-n Displays n lines from end of the file
l Indicates Lines
b Indicates blocks
Cc Indicates characters
Example:
$tail -201 student
Displays last 20 lines of student file.
Stail +201 student
Displays all lines starting from 20" line of the student file.
1 Computer System
2. | Operating System
XIII. Exercise:
4 Create two files chapter! and chapter2 and perform the following operations
1. Copy contents of chapter! to chapter2 by asking the user before overwrite.
2. Display inodes of two files.
3. Rename the file ‘chapter’ to ‘Lesson1’
5 Execute the following commands:
$ls a*n
Practical Significance:
Data and programs are stored in files. These are organized in directories. In a simple
way, a directory is just a file that contains other files (or directories).
“ED EREREREeEeneanss
. |
Ba
alice bob eve
BSS
bin
B local sbin tmp =...
Figure 2
1. ‘mkdir’ command:
It is used to create a new directory in a current directory.
$mkdir <directory name>
Example:
$mkdir CMSI
User can create more than one directory in a single command.
$mkdir subject! subject2
If user wants to create directory on the specific path then syntax is:
Syntax :
$mkdir path/Directory_name
2. ‘cd’ command:
The ‘cd’ command is used to change directory. You can use it to change to any directory
by specifying a valid absolute or relative path.
The syntax is as given below
$cd <directory name>
Example
$ cd Directory name
$cd CMSI
$cd . To come out from current working directory.
Example:
$cd ..
$ cd / It changes to root directory.
Example:
$ cd /
3. rmdir’ command
It is used to delete/ remove a directory. If the parent directory having subdirectories then
first all subdirectories will be deleted then the parent directory is deleted.
$rmdir <directory name>
4. ‘pwd’ command
pwd stands for Present Working Directory. This is most used Linux command to see the
specific Unix Directory on which the user is working on.
$pwd
diff command:
This command is used to show difference between two text files. It also tells which line in
one has to be changed to make the two files identical.
Syntax:
$diff filenamel filename2
The options of the result should be like this —
a -Added the text to file
c -Changes are made in the file
d -Deletion operation is performed
< -Lines from the first file
> -Lines from the second file
$cat filel.txt
I need to go to the shop.
I need to buy some mangoes.
When I get home, I'll wash the cat.
$cat file2.txt
I need to go to the shop.
I need to buy some mangoes.
Oh yeah, I also need to buy cheese.
When I get home, I'll wash the cat.
comm command:
This command compares two sorted files. It compares each line of first file with its
corresponding line in the second file and generates three column output.
The first column lists the lines only in first file.
The second column lists the lines only in second file.
The third column lists the lines in both files.
Syntax:
$comm filenamel filename2
Example:
$cat student] $cat student2
Harsh Harsh
Sujay Niket
Smith Ashutosh
$comm student1 student2
pr command:
pr - convert text files for printing
The pr command does minor formatting of files on the terminal screen or for a printer. For
example, if you have a long list of names in a file, you can format it onscreen into two or
more columns.
The syntax is:
pr option(s) filename(s)
pr changes the format of the file only on the screen or on the printed copy; it doesn’t modify
the original file.
dir command:
It is used to list all files and directories.
Termina! File Edit View Search Terminal Help Ty 4) 3:33AM Yt
oc sswp1226@ubuntu:~
sswpi226@ubuntu:~§$ dir
32 archieve.tar d3 pi Templates
3241 archive.tar demo 1. p2.tar Vvaa
3241.tar asd.tar Desktop Pictures vaaa
41 a.tar dh ile pqr.tar vaa.tar
-A awt.tar dhanu ile1. Public vat
abci -cvt Documents ile -r vatshu
abecil.tar d DownLoads 5 srt.tar vat.tar
abc2 di env.txt i -t va.tar
abc.tar d2 exampLes.desktop : tar Videos
sswp1226@ubuntu:~$ |
Figure 3
chmod command:
It is used to change or set three permissions (read, write and execute) for all the three
categories of users.
Types of users are — user, group and others.
~ Read
aD Write
User Execute
@ Read
a>? Write
Group Execute a
a Read
«> Write
All Execute
Figure 4
a
42 1
Figure 5
Syntax:
$chmod <category><operation><permission><filename>
Example:
1. Assigns the execute permission for user/owner, group and others.
$chmod ugo+x abc
2. Assign all permission for group.
$chmod g+rwx abc
3. Assign execute permissions for the owner and remove read permission of group and others.
$chmod u+x,go-r abc
4. Assign read the permission to all three users and removes all remaining permissions.
$chmod ugo=r abc
Number Assignment
0 No permission
1 Execute permission
2 Write permission
4 Read permission
5(4+1) Read and execute permission
6(44+2) Read and write permission
7(4+2+1) Read, write and execute permission
Example:
$chmod 750 abc
It assigns all permissions for user, read and execute for group and no permission for others
for file abc.
cmp
This command is used to compare files when used without options. It uses two filenames as
an argument and display the differences on the terminals.
Sr.
No Name of Resource Broad Specification Quantity Remarks (If any)
Processor (13-15), RAM-
1 Computer System | 2GB and above (As per
need of OS) As per batch For all
Unix/Linux/Ubuntu/any Size Experiments
2. Operating System | other open sources
operating system
1 Computer System
2. Operating System
MSBTE
| I scheme G
scheme
Figure 6
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
XIII. Exercise:
1. Write the command for performing the following tasks sequentially
a. Display your current directory.
b. Create a directory ‘subject’ in the current directory.
c. Create a file ‘sample’ in the directory ‘subject’.
d. Remove the write permission for the owner for ‘sample’ using symbolic
method.
e. Delete the file ‘sample’. What is an error message displayed?
2. What are the permissions assigned to the file/files after execution of following
commands?
a. $chmod 700 abc
4. Assign read and write permission for the owner, write permission for the group
and execute permission for others using octal method for file mfile.
5. Write commands to assign following permissions to the file OSY using octal
method.
c. r xr xr x
6. Write commands to assign following permissions to the file OSY using symbolic
method.
a. rwxr xr |
b. _rwxrwxrwx
(Space for Answer)
Process Product
Related(15) Related(35) Total(s0)
I. Practical Significance:
There are many text processing commands. A filter is a program that takes a flow of
data from the standard input, processes or filters it and send the result to standard
output. cut, we, tr, sort, grep are all simple filters.
Syntax
The syntax of tr command is:
$ tr [OPTION] SET1 [SET2]
Translation
If both the SET1 and SET2 are specified and ‘-d’ OPTION is not specified, then tr
command will replace each character in SET1 with each character in same position in
SET2.
The we (word count) command in Unix/Linux operating systems is used to find out
number of lines, words and characters in a file.
The syntax of wc command as shown below:
$we [-l -w -c] <filename>
-] counts only number of lines
-w counts only number of words
-c counts only number of characters
Example:
$cat student
Ajay
Vijay
Sujit
$we student]
33 14
Means 3 lines, 3 words and 14 characters.
# wc [options] filenames
[root@tecmint ~]# we tecmint.txt
12 16 112 tecmint.txt
The following are the options and usage provided by the command.
3. Cut
Cut command:
It is used to copy the specified columns to the standard output file. It is used to cut
portion of a file. It takes filenames as command line arguments or input from standard
input. It does not delete the selected portion of a file.
Syntax:
$cut [-f/-c] [n1,n2] filename
Where nl ,n2 are the field/character number.
-f Displays specified field. Also uses -d for field separator.
-C Displays specified column character by character.
Example 1:
$cat student!
Ajay 1990 50
Vijay 1992 60
Sujit 1991 70
$cut -f1,2 studentl
Ajay 1990
Vijay 1992
Sujit 199]
In this output it will display 1‘ and 2" fields values
Example 2:
$cat numbers
12345
23123
45656
76543
$cut -c4,5 student2
45
23
56
43
In this output it displays 4" and 5" character from each line.
4. Paste
Paste command is one of the useful commands in Unix or Linux operating system. It
is used to join files horizontally (parallel merging) by outputting lines consisting of
lines from each file specified, separated by tab as delimiter, to the standard output.
When no file is specified, or put dash (“-“*) instead of file name, paste reads from
ce 66
standard input and gives output as it is until a interrupt command [Ctrl-c] is given.
Syntax:
paste [OPTION]... [FILES]...
Create files for demonstration:
$cat stdname
Ajay
Vijay
Sujit
$cat birthyear
1980
2001
1996
$paste stdname birthyaer
Ajay 1980
Vijay 2001
Sujit 1996
5. Spell
Spell is a spell-checking program which scans a text file for misspelled words and
prints each misspelled word on its own line.
Syntax:
spell [OPTIONS] FILE ...
-n Print line numbers.
(For each misspelled word, also print the number of the line it was in.)
-O Print file names.
(For each misspelled word, also print the name of the file it was in.)
spell -on words.txt words2.txt
Checks the spelling of files words.txt and words?2.txt, printing the file name (-o) and
the line number (-n) of each misspelled word.
Jaishree@DESKTOP-OKO5FND
i
$ cat student1
Sujay 2001
Bhavesh 2000
Pinank 2000
Jaishree@DESKTOP-OKO5FND
i
§ sort studentl
Bhavesh 2000
Pinank 2000
Sujay 2001
Jaishree@DESKTOP-OKO5FND
i
$ cat numbers
12
45
2
34
&
Jaishree@DESKTOP-OKO5FND
i
$ sort -n numbers
2
8
12
34
45
Figure 7
6. Sort
SORT command is used to sort a file,
arranging the records in a particular order. By default, the sort command sorts file
assuming the contents are ASCII. Using options in sort command, it can also be used
to sort numerically.
When we have a mix file with both uppercase and lowercase letters then first the
lower case letters would be sorted following with the upper case letters .
Option Meaning
-0 write the output to a new file
-n sort a file numerically
-r Sort in Reverse Order
8. more
If the file is too large for its contents to fit in one screen, it will scroll off your screen
when the file is displayed with cat command then use more command.
Syntax:
$more [“Space bar” /f/b/j/k/200G/G] filename
Options Meaning
[Space] scrolls the display, one screenful of data at a time
j scrolls forward one line
f Scrolls forward one screen
b scrolls backwards one screen
k scrolls backward one line
200G Goes to line number 200
G Goes to last line of the file
Sr. . . . Remarks
No, Name of Resource Broad Specification Quantity (If any)
Processor (13-15), RAM-
l Computer System 2GB and above (As per
need of OS) As per batch For all
Unix/Linux/Ubuntu/any Size Experiments
2. | Operating System other open sources
operating system
Sr. . . . Remarks
No. Name of Resource Broad Specification Quantity (If any)
1 Computer System
2. | Operating System
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. Give Applications of Paste Command.
How to move cursor to end of a line?
wn
What is difference between $cat abc and $cat abc|more (File abc shall consists of
more than 25 lines in it)
XUI. Exercise:
iii. -s (serial), Combination of -d and -s, —version (write its syntax and
example)
1. Create a new file and practice executing shell commands from within the editor.
Capture the results of some shell commands into the file.
2. How to get help?
I. Practical Significance:
There are many ways to edit files in Unix. Editing files using the screen-oriented text
editor vi is one of the best ways. This editor enables you to edit lines in context with
other lines in the file. Vi is intended as a plain text editor (similar to Notepad on
Windows, or Textedit on Mac) as opposed to a word processing suite such as Word or
Pages. It does, however have a lot more power compared to Notepad or Textedit.
r. . ue
S Command Description
No.
Following is an example to create a new file test! if it already does not exist in the current
working directory —
The above command will generate the following output
$vi test1
You will notice a tilde (~) on each line following the cursor. A tilde represents an unused
line. If a line does not begin with a tilde and appears to be blank, there is a space, tab,
newline, or some other non-viewable character present.
Operation Modes
While working with the vi editor, we usually come across the following two modes —
Command mode — This mode enables you to perform administrative tasks such as
saving the files, executing the commands, moving the cursor, cutting (yanking) and
pasting the lines or words, as well as finding and replacing. In this mode, whatever you
type is interpreted as a command.
Insert mode — This mode enables you to insert text into the file. Everything that's typed
in
this mode is interpreted as input and placed in the file.
vi always starts in the command mode. To enter text, you must be in the insert mode for
which simply type i. To come out of the insert mode, press the Esc key, which will take
you back to the command mode.
To move around within a file without affecting your text, you must be in the command mode
(press Esc twice).
Control Commands:-
Editing Files
To edit the file, you need to be in the insert mode. There are many ways to enter the insert
mode from the command mode —
5 0 Creates a new line for text entry below the cursor location
6 O Creates a new line for text entry above the cursor location
Deleting Characters
Here is a list of important commands, which can be used to delete characters and lines in an
open file —
4 d‘ Deletes from the current cursor position to the beginning of the line
5 d$ Deletes from the current cursor position to the end of the line
6 D Deletes from the cursor position to the end of the current line
Change Commands
You also have the capability to change characters, words, or lines in vi without deleting
them.
5 S Replaces the current character with the character you type. Afterward,
you are left in the insert mode.
6 S Deletes the line the cursor is on and replaces it with the new text. After
the new text is entered, vi remains in the insert mode.
2 yw- Copies the current word from the character the lowercase w cursor is on,
until the end of the word.
Ex mode command
Press Esc key and then (:) colon to enter ex-mode commands. A colon is displayed at the left
hand corner of the last line on your screen.
Command | Action
'W Saves file and remains in editing mode
X Saves file and quits editing mode
:wq Save and quit
:q Quits vi when no changes are made
:q! Quits vi cancelling the changes
‘sh Escape to Unix shell
Advanced Commands
There are some advanced commands that simplify day-to-day editing and allow for more
efficient use of vi —
6 < This is put in an expression escaped with the backslash to find the ending
or the beginning of a word.
Running Commands
The vi has the capability to run commands from within the editor. To run a command, you
only need to go to the command mode and type :! command. For example, if you want to
check whether a file exists before you try to save your file with that filename, you can
type :! Is and you will see the output of Is on the screen. You can press any key (or the
command's escape sequence) to return to your vi session.
Replacing Text
The substitution command (:s/) enables you to quickly replace words or groups of words
within your files. Following is the syntax to replace text —
:s/search/replace/g
The g stands for globally. The result of this command is that all occurrences on the cursor's
line are changed.
1 Computer System
2. | Operating System
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
XIII. Exercise:
Dated signature of
Marks Obtained
Teacher
Process Product
Related(35) | Related(15) Total(50)
I. Practical Significance:
If is a statement that allows the programmer to make a decision in the program based
on conditions he specified. If the condition is met, the program will execute certain
lines of code otherwise, the program will execute other tasks the programmer
specified.
The Shell expression is evaluated in the above syntax. If the resulting value is ¢rue,
given statement(s) are executed. If the expression is false, then no statement will be
executed.
Relational operators are used along with if statement.
Operator Meaning
-eq Equal to
-ne Not equal
-gt Greater than
-ge Greater than or equal to
-It Less than
-le Less than or equal to
General Syntax
1. Single Decision: -
Syntax:-
if [ condition ]
then
H## series of code goes here
fi
e.g.
if [ "$X" -It "0" ]
then
echo "X is less than zero"
fi
2. Double Decision: -
Syntax:-
if [ condition ]
then
Statements if the condition is satisfied
else
Statements of code if the condition is not satisfied
fi
3. Multiple if condition: -
Syntax:-
if [ condition] ]
then
Statements for condition1
elif [ condition2|
then
Statements for condition2
else
Statements if the condition is not satisfied
fi
4. Double —bracket:-
Syntax:-
if ((condition))
then
Statements goes here
fi
To type any program in Linux you need the compiler. vi editor is used for creating file in
Linux.
Write a shell script to display welcome message with today’s date in it.
In vi editor write a program code and save and quit with filename “sample.sh’.
$vi sample.sh
(Now press escape and i to change the input mode and type following program)
#sample.sh
#use of if-then statement
if whoami; then
var 1=‘whoami*
echo “Welcome $var1”
fi
if date; then
echo “It displays todays date”
fi
echo “This is end of script”
To run the script
$./sample.sh
Save this program press escapetshift+:(colon) and type wq (:wq)
“Welcome User1”
Mon Feb 25 22:29:29 PST 2019
“Tt displays todays date”
“This is end of script”
1 Computer System
2. | Operating System
XIII. Exercise:
Dated signature
Marks Obtained of Teacher
Process Product
Related(35) | Related(is) | [tal
I. Practical Significance:
The for loops iterate through a set of values until the list is exhausted. In simple terms
the for loop operates on lists of items. It repeats a set of commands for every item in a
list.
commandN
done
Example:
for varin0 123456789
do
echo $var
done
So far you have looked at creating loops and working with loops to accomplish
different tasks. Sometimes you need to stop a loop or skip iterations of the loop.
Following two statements that are used to control shell loops—
1. The break statements: The break statement is used to terminate the execution of the
entire loop, after completing the execution of all of the lines of code up to the break
statement using break keyword.
2. The continue statement: The continue statement is similar to the break command,
except that it causes the current iteration of the loop to exit, rather than the entire loop.
3. Exit:
The syntax is as follows:
exit N
The exit statement is used to exit from the shell script with a status of N.
Write a shell script to calculate the factorial of a given number.
In vi editor write a program code and save and quit with filename ‘fact.sh’.
$vi fact.sh
(Now press escape and 1 to change the input mode and type following program)
Similar other loops are also used in Linux such as while, case..esac
while statement
Syntax:
while [condition]
do
done
Example:
a=1
while [ $a -le 5 ]
do
*) Default
esac // indication of end of case statement
Example:
#!/bin/bash
NOW=$(date +"%a")
case $NOW in
Mon)
echo "Full backup";
Tue|Wed|Thu|Fri)
echo "Partial backup";
Sat|Sun)
echo "No backup";;
*) 33
esac
$cat fact.sh
echo "Enter a number"
read num
fact=1
while [ $num -gt 1 ]
do
fact=$((fact * num))
num=$((num - 1))
done
echo “factorial of a number is $fact”
Save this program press escapetshift+:(colon) and type wq (:wq)
To compile the program
$./fact.sh or $sh fact.sh
Enter the number : 5
Factorial of a given number is 120
Sr. . : . Remarks
No. Name of Resource Broad Specification Quantity (If any)
Processor (13-15), RAM-
l Computer System 2GB and above (As per
need of OS) As per batch For all
Unix/Linux/Ubuntu/any Size Experiments
2. | Operating System other open sources
operating system
1 Computer System
2. | Operating System
OK OK ok 3
2k
Write a shell script to accept five digit number and perform addition of all digits.
XIII. Exercise:
Execute the script for the following.
1. The for loop using day of week list.
2. The while loop to print different * patterns.
3. The case statement for performing various mathematical operations.
(Space for Answer)
https://www.cs.sfu.ca/~ggbaker/reference/unix/
https://www.cyberciti.biz/faq/bash-for-loop/
we
https://bash.cyberciti.biz/guide/For_loop
Practical No. 12: Write Shell script to find out whether - Given file exists?
I. Practical Significance:
In UNIX data and programs are stored in files. These are organized in directories. In a
simple way, a directory is just a file that contains other files (or directories).
It can be done to find out if a file exists or not on the file system with the help of
BASH shell and IF command,
-s file True if file exists and has a size greater than zero.
Example:
#! /bin/bash
echo -e "Enter the name of the file :"
read file_name
if [ -f $file name ]
then
else
echo "$file_name not exists"
fi
Ordinary Files — An ordinary file is a file on the system that contains data, text, or
program instructions. In this tutorial, you look at working with ordinary files.
Directories — Directories store both special and ordinary files. For users familiar with
Windows or Mac OS, Unix directories are equivalent to folders.
Special Files — Some special files provide access to hardware such as hard drives, CD-
ROM drives, modems, and Ethernet adapters. Other special files are similar to aliases or
shortcuts and enable you to access a single file using different names.
Sr. Name of . . .
No. Resource Broad Specification Quantity Remarks (If any)
1 Computer
System
Operating
2.
System
XIII. Exercise:
Write a shell script to copy source file into the destination file.
FYNP
Write a shell script which displays list of all directories in your home directory.
Write a shell script which displays list of all files in your home directory.
Write a file handling program. First check whether it is file or directory, then if it
is file the program shall ask user for choices of copying, removing and renaming
files. Use case statement.
5. Write script to copy a source file into the destination file.
(Attach the screenshots at the end)
(Space for Answer)
Dated signature of
Marks Obtained Teacher
Process Product
Related (15) | Related (38) | #9)
Practical No. 13: Write Shell script to check and grant File permissions.
I. Practical Significance:
In Unix files come with permissions, a way to decide who can read, write or execute a
file. These permissions are divided into three parts: those for the owner (user) of the
file, those for the group to which the owner belongs and then permissions for all the
other users from the point of view of what is allowed to do in a file or directory,
permissions are for reading, writing and executing.
Test Commands
Test Returns true if
-r file True if file exists and is readable.
-s file True if file exists and has a size greater than zero.
1 Computer System
2. | Operating System
Note: Below given are few sample questions for reference. Teacher must design
more such questions so as to ensure the achievement of identified CO.
1. What are permissions of a file?
2. How to assign permission to a file?
3. What happens when exception is thrown by main method?
4. How to check permissions of all files and directories?
5. What are the test commands to check the permission of a file?
XI. Exercise:
1. Write a shell script which displays the list of all executable files in the current
working directory.
2. Write a shell script which displays a list of all the files in the current directory to
which user has read, write and execute permission.
3. Write a shell script which accepts a filename and assigns it all the permissions.
(Space for Answer)
Dated signature
Marks Obtained of Teacher
Practical Significance:
In Multiprogramming systems, the Operating system schedules the processes on the
CPU to have the maximum utilization of it and this procedure is called CPU
scheduling. The Operating System uses various scheduling algorithm to schedule the
processes. First come first serve (FCFS) scheduling algorithm simply schedules the
jobs according to their arrival time.
scheduling may cause the problem of starvation if the burst time of the first process is
the longest among all the jobs.
1 Computer System
2. | Operating System
X. Program Code: Consider the processes Pl, P2, P3, P4 given in the below table,
arrives for execution in the same order, with Arrival Time 0, and given Burst Time,
Find using the FCFS scheduling algorithm.
1.Turn Around Time for each process
2.Waiting Time for each process
3.Average Turn Around time
4.average waiting time
XUI. Exercise:
3 Calculate average waiting time using RR algorithm for the following set of
processes with the length of the CPU burst time given in milliseconds. (Time
quantum 20 ms)
XV Assessment Scheme
Dated Tecc
signature
hes of
Marks Obtained
Process Product
Related(35) Related(15) Total(50)
Practical Significance:
When there is a page fault, the referenced page must be loaded. If there is no available
frame in memory, then one page is selected for replacement. If the selected page has
been modified, it must be copied back to disk (swapped out). A page replacement
algorithm is needed to decide which page needs to be replaced when new page comes
in.
Sr.
No Name of Resource Broad Specification Quantity Remarks (If any)
Processor (13-15), RAM-
1 Computer System 2GB and above (As per
need of OS) As per batch For all
Unix/Linux/Ubuntu/any Size Experiments
2. | Operating System other open sources
operating system
1 Computer System
2. | Operating System
XII. Exercise:
1 Consider the reference string 9,7,6,1,7,6,1,2,7,2 the number of frames in the
memory is 3. Find out the number of page faults and page hit respective to
1. FIFO Page replacement algorithm
2. Optimal Page replacement algorithm
3. LRU Page replacement algorithm
2 Compare FIFO and LRU.
OANODNARWN=
Bussiness Communication Using Computers 22009 Public Health Engineering 22504
OONOARWN =
Computer Peripherals & Hardware Maintenace 22013 Heat Transfer Operation 22510
Web Page Design with HTML 22014 Environmental Technology 22511
Applied Science (Chemistry) 22202 Operating Systems 22516
Applied Science (Physics) 22202 Advanced Java Programming 22517
Applied Machines 22203 Software Testing 22518
Basic Surveying 22205 Control Systems and PLC’s 22531
Applied Science (Chemistry) 22211 Embedded Systems 22532
Applied Science (Physics) 22211 Mobile and Wireless Communication 22533
10 Fundamental of Electrical Engineering 22212 Industrial Machines 22523
11 Elements of Electronics 22213 Switchgear and Protection 22524
12 Elements of Electrical Engineering 22215 Energy Conservation and Audit 22525
13 Basic Electronics 22216 Power Engineering and Refrigeration 22562
14 ‘C’ programming Language 22218 Solid Modeling and Additive Manufacturing 22053
15 Basic Electronics 22225 Guidelines & Assessment Manual for 22057
16 Programming in “C” 22226 Micro Projects & Industrial Training
17 Fundamentals of Chemical Engineering 22231 Sixth Semester:
Third Semester: Solid Modeling 17063
Highway Engineering 17602
OONDOORWN—
Secretary,
Maharashtra State Board of Technical Education
49, Kherwadi, Bandra (East), Mumbai - 400 051
Maharashtra (INDIA)
Tel: (022)26471255 (5 -lines)
Fax: 022 - 26473980
Email: [email protected]
Web -www.msbte.org.in
REGIONAL OFFICES:
MUMBAI PUNE
Deputy Secretary (T), Deputy Secretary (T),
Mumbai Sub-region, M.S. Board of Technical Education,
NAGPUR AURANGABAD
Deputy Secretary (T), Deputy Secretary (T),
M.S. Board of Technical Education M.S. Board of Technical Education,