OS Lab Manual
OS Lab Manual
TECHNOLOGY
BACHELOR OF TECHNOLOGY
OPERATING SYSTEM LABORATORY
STUDENT DETAILS
● It has all of the features of the original Bourne Shell, plus additions that
make it easier to program with and use from the command line.
● Since it is Free Software, it has been adopted as the default shell on most
Linux systems.
directory DESCRIPTION:
SYNTAX:
Pwd
cd directory_name
3) cd ..
DESCRIPTION:
Move up one directory.
SYNTAX:
cd ..
SYNTAX:
ls [options]
6) head
DESCRIPTION:
head, by default, prints the first 10 lines of each FILE to standard output. With more than one
FILE, it precedes each set of output with a header identifying the file name.
If no FILE is specified, or when FILE is specified as a dash ("-"), head reads from standard input.
SYNTAX:
head [option]...[file/directory]
tail is a command which prints the last few number of lines (10 lines by default) of a certain file,
then terminates.
SYNTAX:
tail [option]...[file/directory]
10) cp : Copy
Files
DESCRIPTION:
The cp command is used to make copy of files and directories.
SYNTAX:
cp [option] source directory
SYNTAX:
rm directory_name
SYNTAX:
13) man
DESCRIPTION:
Displays on an online manual page or manpage.
SYNTAX:
man command
SYNTAX:
echo yourtext
15) clear
DESCRIPTION:
Used to clear the screen
SYNTAX:
Clear
17)wc
DESCRIPTION:
wc (word count) command, can return the number of lines, words, and characters in a file.
SYNTAX:
wc [option]... [file]...
18) grep
DESCRIPTION:
grep command uses a search term to look through a file.
SYNTAX:
grep [option]... Pattern [file]...
SYNTAX: Free
20) pipe ( | )
DESCRIPTION:
Pipe command is used to send output of one program as a input to another. Pipes “|” help
combine 2 or more commands.
SYNTAX:
Command 1 | command 2
What is a Shell?
An Operating is made of many components, but its two prime components are -
•Kernel
•Shell
A Kernel is at the nucleus of a computer. It makes the communication between the hardware and
software possible. While the Kernel is the innermost part of an operating system, a shell is the
outermost one.
A shell in a Linux operating system takes input from you in the form of commands, processes it,
and
2.The C shell: The prompt for this shell is %, and its subcategories are:
Shell scripting is writing a series of command for the shell to execute. It can combine lengthy
and repetitive sequences of commands into a single and simple script, which can be stored and
executed anytime. This reduces the effort required by the end user.
1.Create a file using a vi editor(or any other editor). Name script file with extension
.sh
"#!" is an operator called shebang which directs the script to the interpreter location. So, if we
use"#! /bin/sh" the script gets directed to the bourne-shell.
#!/bin/sh
ls
Summary:
•Kernel is the nucleus of the operating systems, and it communicates between hardware and
software
•Shell is a program which interprets user commands through CLI like Terminal
•The Bourne shell and the C shell are the most used shells in Linux
•Shell scripting is writing a series of command for the shell to execute
•Shell variables store the value of a string or a number for the shell to read
• Shell scripting can help you create complex programs containing conditional
#Output:-
#Output:-
AIM:-Write a Shell script to print the given numbers sum of all digits.
# Input: -
#!/bin/bash
echo "Enter a number"
read num
sum=0
while [ $num -gt 0 ]
do
mod=$((num % 10))
sum=$((sum + mod))
num=$((num / 10))
done
echo $sum
#Output:-
AIM:-Write a shell script to validate the entered date. (eg. Date format is:
dd-mm-yyyy).
# Input: -
#!/bin/bash
d=`date +%m-%d-%Y`
echo $d #DD-MM-YYYY
echo " Please Enter Date "
read D
echo " Please Enter Month "
read M
echo " Please Enter Year
" read Y
if [ `expr $Y % 4` -eq 0 ]
then
Mayur Pandya Division: - 4B18
echo "$Y is a leap year"
else
echo "$Y is not a leap year"
fi
#Output:-
#Output:-
#Output:-
#include <stdio.h>
#Output:-
AIM:- Finding out biggest number from given three numbers supplied as
command line arguments.
# Input: -
echo "Enter Num1"
read num1
echo "Enter Num2"
read num2
echo "Enter Num3"
read num3
if [ $num1 -gt $num2 ] && [ $num1 -gt $num3 ]
then
echo $num1
elif [ $num2 -gt $num1 ] && [ $num2 -gt $num3 ]
then
echo $num2
else
echo $num3
fi
#Output:-
AIM:- Write a program for process creation using C. (Use of gcc compiler).
# Input: -
#include <stdio.h>
#Output:-
#include <stdio.h>
#Output:-
# Input: -
RR
int main()
{
int Max[10][10], need[10][10], alloc[10][10], avail[10], completed[10];
int p, r, i, j, process, count;
count = 0;