You are on page 1of 40

Name: Mustafa Shaikh Fakruddin

Enrollment no:1616080077
Class: CO5IB
Subject: Operating System
Guidence:Mudasshir mahadik
Experiment No.1
Aim: To Install Ubuntu 20.04.1 LTS on the Desktop.
Step 1) Download Ubuntu 20.04.1 LTS ISO File Please make sure you have the latest version of Ubuntu
20.04.1 LTS, If not, please download the ISO file from the link here:
https://ubuntu.com/download/desktop

Step 2) Create a Bootable Disk Once the ISO file is downloaded then next step is to burn the downloaded
ISO image into the USB/DVD or flash drive to boot the computer from that drive. Also make sure you
change the boot sequence so that system boots using the bootable CD/DVD or flash drive.

Step 3) Boot from USB/DVD or Flash Drive Once the system is booted using the bootable disk, you can
see the following screen presented before you with options including “Try Ubuntu” and “Install Ubuntu”
as shown in the image below

Step 4) Choose your Keyboard layout Choose your favorite keyboard layout and click “Continue”. By
default English (US) keyboard is selected and if you want to change, you can change here and click
“Continue”
Step 5) Preparing to Install Ubuntu and other Software In the next screen, you’ll be provided following
beneath options including:
Type of Installation: Normal Installation or Minimal installation, If you want a minimal installation
then select second option otherwise go for the Normal Installation. In my case I am doing Normal
Installation
Download Updates While Installing Ubuntu (select this option if your system has internet connectivity
during installation)
Install third party software for graphics and Wi-Fi hardware, MP3 and additional media formats
Select this option if your system has internet connectivity)

Step 6) Select the appropriate Installation Type Next the installer presents you with the following
installation options including:
Erase Disk and Install Ubuntu
Encrypt the new Ubuntu installation for security
Use LVM with the new Ubuntu installation
Something Else Where,
Erase Disk and Install Ubuntu – Choose this option if your system is going to have only Ubuntu and
erasing anything other than that is not a problem. This ensures a fresh copy of Ubuntu 18.04 LTS is
installed in your system.
Encrypt the new Ubuntu installation for security – Choose this option if you are looking for extended
security for your disks as your disks will be completely encrypted. If you are beginner, then it is better
not to worry about this option.
Use LVM with the new Ubuntu installation – Choose this option if you want to use LVM based file
systems.
Something Else – Choose this option if you are advanced user and you want to manually create your
own partitions and want to install Ubuntu along with existing OS (May be Windows or other Linux
Flavor)

Step 7) Select Your Time zone Choose your favorite time zone and then click on “Continue”
Step 8) Provide your User Credentials In the next screen you will be prompted to provide your user
credentials. In this screen provide your name, computer name, username and the password to login into
Ubuntu 20.04.1 LTS

Click “Continue” to begin the installation process.


Step 9) Start Installing Ubuntu 18.04 LTS The installation of Ubuntu 18.04 LTS starts now and will take
around 5-10 mins depending on the speed of your computer
Step 10) Restart Your System Once the installation is completed, remove the USB/DVD from the drive
and Click “Restart Now” to restart your system.

Step:11) Login to Your Ubuntu 20.04.1 desktop Once your system has been rebooted after the
installation then you will get the beneath login screen, enter the User name and password that you have
set during installation
Conclusion: we have successfully performed Ubuntu installation practical.
Experiment:02
Aim: Executing general purpose command DATE, time, cal, clear, banner, tty, script, man.
Commands are as follows:
1) date: date command is used to display the system date and time. date command is also
used to set date and time of the system. By default the date command displays the date in the
time zone on which unix/linux operating system is configured. Syntax: date[OPTION]…[+FORMAT]
date[-u|--utc|--universal][MMDDhhmm[[CC]YY][.ss]]
Example:

2) time: time command in Linux is used to execute a command and prints a summary of real-
time, user CPU time and system CPU time spent by executing a command when it terminates.
‘real‘ time is the time elapsed wall clock time taken by a command to get executed, while ‘user‘
and ‘sys‘ time are the number of CPU seconds that command uses in user and kernel mode
respectively. Syntax: time
[option][COMMAND] Example:

3) cal: If a user wants a quick view of calendar in Linux terminal, cal is the command for you.
By default, cal command shows current month calendar as output. cal command is a calendar
command in Linux which is used to see the calendar of a specific month or a whole year. Syntax:
cal[[month]year] Example:

4) clear: clear is a standard Unix computer operating system command that is used to clear
the terminal screen. This command first looks for a terminal type in the environment and after
that, it figures out the terminfo database for how to clear the screen. And this command will
ignore any command-line parameters that may be present. Also, the clear command doesn’t take
any argument and it is almost similar to cls command on a number of other operating systems.
Syntax: $clear Example:
Terminal Before Executing clear command:
Terminal after Executing clear command:

5) Banner: banner command in linux is used to print the ASCII character string in large letter
to standrad output. Syntax: banner text
Example:

6) tty: The tty command of terminal basically prints the file name of the terminal connected
to standard input. tty is short of teletype, but popularly known as a terminal it allows you to
interact with the system by passing on the data (you input) to the system, and displaying the
output produced by the
system. The tty command of terminal basically prints the file name of the terminal
connected to standard input. tty is short of teletype, but popularly known as a
terminal it allows you to interact with the system by passing on the data (you
input) to the system, and displaying the output produced by the system.
Syntax: tty [OPTION]….
Example:

7) script: script command in Linux is used to make typescript or record all the terminal
activities. After executing the script command it starts recording everything printed on the screen
including the inputs and outputs until exit. Syntax: script [options] [file] Example:
8) man: man command in Linux is used to display the user manual of any command that we
can run on the terminal. It provides a detailed view of the command which includes NAME,
SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS,
EXAMPLES, AUTHORS and SEE ALSO. Syntax: $man [OPTION]… [COMMAND NAME]… Example:
Conclution: We have Successfully performed general purpose command practical.
Experiment No.3
Aim: Working with multiple Linux terminals and basic commands: who, whoami, login,
passwd, su, pwd.
Commands are as follows:
1) who: who command is used to find out the following information :
1. Time of last system boot
2. Current run level of the system 3. List of logged in users and more.
Syntax: who [options] [filename] Example:

2) whoami: whoami command is used both in Unix Operating


System and as well as in Windows Operating System.

s
invoked.
-
un. Syntax: whoami Example:
\

3) login: The login program is used to establish a new session with


the system. It is normally invoked automatically by responding to the
"login:" prompt on the user's terminal. login may be special to the shell
and may not be invoked as a sub-process.
-f: do not perform authentication, user is preauthenticated.
-h: Name of the remote Host for the login.
-p: preserve Environment.
-r: perform auto login protocol for login.
Syntax: login [ -p ] [ -d device ] [ name [ environ ] ] Example:

4)
passwd: passwd command in Linux is used to change the user account 4)
passwd: The root user reserves the privilege to change the password for
any user on the system, while a normal user can only change the account
password for his or her own account. Syntax: passwd [options] [username]
Example:
5) su: The su(switch user) utility allows you to run commands
with the privileges of another user, by default the root user. Using su is
the Simplest way to switch to the Administrative account in the current
login session. This is especially handy when the root user is not allowed
to log in to the system through ssh or using GUI display manager.
Syntax: su [OPTIONS] [USER[ARGUMENT…]] Example:

6) pwd: pwd stands for Print Working Directory. It prints the path
of the working directory, starting from the root. pwd is shell built-in
command(pwd) or an actual binary(/bin/pwd). $PWD is an
environment variable which stores the path of the current directory.
This Command has 2 flags
1.pwd -L
2.pwd -P
Syntax: pwd pwd -L pwd -P
Example:

Conclusion: we have successfully performed Linux Terminal command.

Experiment No.4
Aim: a) User operating services (Editor, GUI, File Handling)
b) Run commands to start, stop, and restart the specified service in Linux.
Editor: There are many ways to edit file in Linux. The editor enables you to edit lines in context with
other lines in the file. You can also use this editor to read a text file. We use gedit for file read and Write
in Linux.
1. Open Gedit
2. Write some text
3. Save file

GUI:

1. The Control Panel the Control Panel on the left-hand side of the screen presents shortcuts for all
of the most used applications. Using these options, we can launch the LibreOffice component, the
Firefox browser, the Software Center and many other applications.

2. The Menu Bar When we launch any application, we will get the associated menu bar at the top
of the application, which will have the different menu options for that application. We can choose to
close the entire window or resize the window, if required.
3. Taskbar On the right-hand side of the screen is the task bar. The taskbar allows us to choose the
change in volume settings, view the status of your internet connect, change your language and other
settings, and view the battery status while working on a laptop.

File Handling:

Linux provides fine-grained control over system services through systemd, using the
systemctl command. Services can be turned on, turned off, restarted, reloaded, or even
enabled or disabled at boot. If you are running Debian 7, CentOS 7, or Ubuntu 15.04 (or later),
your system likely uses systemd.
start a Service systemctl
[command] [service_name]
sudo systemctl start apache2

Check If a Service is Running systemctl [command] [service_name] sudo


systemctl status apache2
stop a Service systemctl [command]
[service_name]
sudo systemctl stop apache2

Restart a Service systemctl


[command] [service_name]
sudo systemctl restart apache2
Conclusion: we have successfully performed this practical.

Experiment No.5
Aim: Execute Process Command – ps, wait, sleep, exit, kill.
1. Ps command:

Give the status of processes running for a user


2. wait and exit Command:
wait is a built-in command of Linux that waits for completing any running process. wait
command is used with a particular process id or job id. When multiple processes are running in
the shell then only the process id of the last command will be known by the current shell. If wait
command is executed this time, then it will be applied for the last command. If no process id or
job id is given with wait command then it will wait for all current child processes to complete
and returns exit status.
echo "testing wait command1" &
process_id=$!
echo "testing wait command2" &
wait $process_id
echo Job 1 exited with status $?
wait $!
echo Job 2 exited with status $?

3.Kill Command

This command terminates running processes on a Linux machine.


To use these utilities you need to know the PID (process id) of the process you want to kill
Conclusion: we successfully performed process command.

Experiment No.6
Aim: Write a program to calculate total waiting time and turnaround time of process
With first come first serve CPU scheduling algorithm.
Description: First Come First Serve (FCFS) is an operating system scheduling algorithm that
automatically executes queued requests and processes in order of their arrival. It is the
easiest and simplest CPU scheduling algorithm. In this type of algorithm, processes which
requests the CPU first get the CPU allocation first. This is managed with a FIFO queue.

Algorithm:

Start
Step 1-> In function int waitingtime(int proc[], int n, int burst_time[], int wait_time[])
Set wait_time[0] = 0
Loop For i = 1 and i < n and i++
Set wait_time[i] = burst_time[i-1] + wait_time[i-1]
End For
Step 2-> In function int turnaroundtime( int proc[], int n, int burst_time[], int wait_time[], int
tat[])
Loop For i = 0 and i < n and i++
Set tat[i] = burst_time[i] + wait_time[i]
End For
Step 3-> In function int avgtime( int proc[], int n, int burst_time[])
Declare and initialize wait_time[n], tat[n], total_wt = 0, total_tat = 0;
Call waitingtime(proc, n, burst_time, wait_time)
Call turnaroundtime(proc, n, burst_time, wait_time, tat)
Loop For i=0 and i<n and i++
Set total_wt = total_wt + wait_time[i]
Set total_tat = total_tat + tat[i]
Print process number, burstime wait time and turnaround time
End For
Print "Average waiting time =i.e. total_wt / n
Print "Average turn around time = i.e. total_tat / n
Step 4-> In int main()
Declare the input int proc[] = { 1, 2, 3}
Declare and initialize n = sizeof proc / sizeof proc[0]
Declare and initialize burst_time[] = {10, 5, 8}
Call avgtime(proc, n, burst_time)
Stop

Input:

// C program for implementation of FCFS


// scheduling
#include<stdio.h>
// Function to find the waiting time for all
// processes
void findWaitingTime(int processes[], int n,
int bt[], int wt[])
{
// waiting time for first process is 0
wt[0] = 0;

// calculating waiting time


for (int i = 1; i < n ; i++ )
wt[i] = bt[i-1] + wt[i-1] ;
}

// Function to calculate turn around time void


findTurnAroundTime( int processes[], int n,
int bt[], int wt[], int tat[])
{
// calculating turnaround time by adding
// bt[i] + wt[i] for
(int i = 0; i < n ; i++)
tat[i] = bt[i] + wt[i];
}

//Function to calculate average time


void findavgTime( int processes[], int n, int bt[])
{
int wt[n], tat[n], total_wt = 0, total_tat = 0;

//Function to find waiting time of all processes


findWaitingTime(processes, n, bt, wt);

//Function to find turn around time for all processes


findTurnAroundTime(processes, n, bt, wt, tat);

//Display processes along with all details


printf("Processes Burst time Waiting time Turn around time\n"); // Calculate total
waiting time and total turn
// around time
for (int i=0; i<n; i++)
{
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
printf(" %d ",(i+1)); printf("
%d ", bt[i] ); printf("
%d",wt[i] );
printf(" %d\n",tat[i] );
}
int s=(float)total_wt / (float)n; int
t=(float)total_tat / (float)n;
printf("Average waiting time = %d",s);
printf("\n");
printf("Average turn around time = %d ",t);
}

int main()
{
//process id's int
processes[] = { 1, 2, 3};
int n = sizeof processes / sizeof processes[0];
//Burst time of all processes
int burst_time[] = {10, 5, 8};

findavgTime(processes, n, burst_time);
return 0;
}

Output:

Conclusion: we have successfully performed CPU scheduling algorithm program.


Experiment No.7
Aim : Write C a program to implement FIFO page replacement algorithm

Description:
FIFO Page Replacement technique is one of the simplest one to implement amongst
other page replacement algorithms. It is a conservative algorithm.
It is a low-overhead algorithm that maintains a queue to keep a track of all the pages
in a memory.
When a page needs to be replaced, the page at the FRONT of the Queue will be
replaced. The FIFO page replacement technique is not implemented in operating
systems nowadays.

Algorithm :
Step1. Start to traverse the pages.
Step2. If the memory holds fewer pages, then the capacity else goes to step 5.
Step3. Push pages in the queue one at a time until the queue reaches its maximum capacity or
all page requests are fulfilled.
Step4. If the current page is present in the memory, do nothing.
Step5. Else, pop the topmost page from the queue as it was inserted first.
Step6. Replace the topmost page with the current page from the string.
Step7. Increment the page faults.
Step8. Stop

Input:
#include<stdio.h>

int main()
{
int reference_string[10], page_faults = 0, m, n, s, pages, frames;
printf("\nEnter Total Number of Pages:\t"); scanf("%d",
&pages);
printf("\nEnter values of Reference String:\n");
for(m = 0; m < pages; m++)
{
printf("Value No. [%d]:\t", m + 1);
scanf("%d", &reference_string[m]);
}
printf("\nEnter Total Number of Frames:\t");
{
scanf("%d", &frames);
}
int temp[frames]; for(m
= 0; m < frames; m++)
{
temp[m] = -1;
}
for(m = 0; m < pages; m++)
{
s = 0;
for(n = 0; n < frames; n++)
{
if(reference_string[m] == temp[n])
{
s++;
page_faults--;
}
}
page_faults++;
if((page_faults <= frames) && (s == 0))
{
temp[m] = reference_string[m];
}
else if(s == 0)
{
temp[(page_faults - 1) % frames] = reference_string[m];
}
printf("\n");
for(n = 0; n < frames; n++)
{
printf("%d\t", temp[n]);
}
}
printf("\nTotal Page Faults:\t%d\n", page_faults);
return 0;
}

Output:

Conclusion: we have successfully performed FIFO algorithm program.


Experiment No.8
Aim: Execute file and directory manipulation command: ls, rm, mv, cp, join, split, cat (use wild
card character) head, tail, touch
ls command: it is used to lists files in the current working directory
syntax: ls Example:

rm command : it is used to remove the file


syntax: rm <filename> Example:

mv Command: it is use to move a file from one location to another .


syntax: mv <filename>source location Example:

cp Command: it is used to copies a file to destination file


syntax: cp <source filename> <destination filename> Example:

Join Command: it is used for joining lines of two files on the basis of common field in each file
called as key.
Syntax: join file name1 file name 2 Example:
Cat Command: it is used to create the file and displaying the content of file/files.
Syntax: cat > filename Example:

Split Command: it is used split large file into smaller file.default size is 1000 lines per file
Syntax: split -n filename Example:

Head Command: it is used to read the first ten line of files


Syntax: head -n filname Example:
tail Command: it is used to print last few lines of certain file then terminate
Syntax: tail -n filename Example:

Touch Command: it is the easiest way to create new, empty file


Syntax: touch filename Example:
Conclusion: we have successfully performed directory manipulation commands.

Experiment No.9
Aim: Execute file and directory and manipulation commands-diff, comm, pr, chmod, mkdir,
rmdir, cd, pwd, dir, cmp.
Mkdir:
it is used to create a new directory in a current directory
syntax: mkdir directory name example:

cd:
it is used to change directory
syntax: cd directory name example:
rmdir:
it used to delete/remove directory
syntax: rmdir directory name example:

pwd:
this is most used linux command to see the specific unix
directory on which the user is working on.
syntax: pwd example:

diff: this command is used to show diffrence betweeen two text


files.
it also tells which lines in one has to be changed to make the two file
indentical.
syntax: diff filename1 filename2 example:

common:
this command compares two sorted files
syntax: comm filename1 filename2 example:

pr:
the pr command does minor formating of files on the terminal screen or
for a printer.
syntax: pr option filename example:

chmod:
it is used to change or set three permission(read, write and execute) for
all the three catagories of users.
syntax: chmod catagory operation permission filename example:
cmp:
this command is used to compare files when used without options syntax:
cmp filename1 filename2
example:

dir:
it is used to seen directory syntax:
dir directory name example:

Conclusion: we have successfully performed directory and manipulation commands.


Experiment No.12
Aim: write and execute shell script by using following control statement feature- if statement
If statement:
“If” statement in a shell scripting is essentially a type of Bash scripting and this type of
statement essentially helps us in making a decision on the basis of a condition. So, before we
jump on to what “If” statements actually are, let us look into the preliminary topic of Bash
Scripting.
Syntax: if
[<test_Condition>] then
<set_of_commands_to_be_executed>
fi
Input
echo "1.a<=b:" echo "2.a>=b:"
$a; $b; $a1; $b1;
a=4; a1=6;
b=6; b1=4;
if [ $a -le $b ] then if [ $a1 -ge $b1 ]
echo "a is less then equal to b"; else then
echo "a is not equal to echo "a is greater then equal to b"; else
b"; fi echo "a is not equal to
b"; fi
echo "3.a<b:" echo "4.a>b:"
$a3; $b3; $a3; $b3;
a3=6; a3=6;
b3=4; b3=4;
if [ $a3 -lt $b3 ] then if [ $a3 -lt $b3 ] then
echo "a is greater then b"; else echo "a is greater then b"; else
echo "a is greater then not b"; fi echo "a is greater then not
b"; fi

echo "5.a!=b:" echo "6.a==b:"


$a5; $b5; a5=7; $a6; $b6; a6=7;
b5=7; if [ $a5 - b6=7; if [ $a6 -
ne $b5 ] eq $b6 ]
then echo "a is equal to then echo "a is equal to
b"; else echo "a is not b"; else echo "a is not
equal to b"; fi equal to b"; fi

Output:

Conclusion: we have successfully performed if statement program.


Experiment No.13
Aim: Write and execute shell script by using following control statement feature- for
loop, while loop, until loop.
we can use loops to perform an operation a certain number of times. In shell scripting, different
types of loops are available to perform looping such as for loop, while loop, and until loop.
These loops will execute commands iteratively until a condition satisfies and comes out of the
loop when the condition is not satisfied. We can control the loops using some keywords in shell
scripting and we can use loops to automate repetitive tasks.
Syntax: while [ condition ]
do command1
command2
done syntax:
for var in list do
command 1
command 2 done
syntax: until [ conditional statement ]
do command1 command2
done
Input:
echo "for loop using list" echo "for lool using variable" echo "for loop using string
for a in 1 2 3 4 5 6 7 8 9 10 list="1 2 3 4 5 6 7 8 9 10" statement"
do echo for a in $list for a in I don\'t anything
$a do echo $a about 100
done done do echo
$a done

Output:
Input:
echo "while loop:" echo "until loop:" a=1
a=1 while [ $a -le until [ $a -gt 10 ]
10 ] do echo $a
do echo $a a=`expr $a + 1`
a=`expr $a + 1` done
done

Output:

Conclusion: we have successfully performed while statement program.


Experiment No.14
Aim: Write Shell scripts to find out whether-Given file exist?
With the help of BASH shell and IF command, it is possible to find out if a file exists or not on the
filesystem. A conditional expression (also known as “evaluating expressions”) can be
[[ used by compound command and the test ( [ ) built-in commands to test file attributes
and perform string and arithmetic comparisons. You can easily find out if a regular file
does or does not exist in Bash shell under macOS, Linux, FreeBSD, and Unix-like operating
system.
You [ expression] , [[ expression]] , test expression , or if [ can
use

expression]; then .... fi in bash shell along with a ! Operator. Let us see
various
ways to find out if a file exists or not in bash shell.

This can be done by the shell script by using test conditions. Also, if else fi statement is
used which allows us to make decisions based on the success or failure of a command:

-d file check if the file exist and is its a directory


-e file check if the file exist on system
-w file check of the file exists on system and if it is writable
-r file check of the file exists on system and if it is readable
-s file check of the file exists on system and if it is not empty
-f file check of the file exist on system and it is a file
-O file check of the file exist on system and if it is owned by the current user
-G file check of the file exist and the default group is the same as the current user
-x file check of the file exist on system and is executable
file A -nt file B checks if file A is newer than file B file A -
ot file B checks if file A is older than file B

Syntax: if [<test
Condition>] then
<set_of_commands_to_be_executed>
Fi

Input:
File exist : File read: file = File write: file = File execute: file
file = "condition.sh" "condition.sh" "condition.sh" ="condition.sh"
if [ -e $file ] if [ -r $file ] if [ -w $file ] then if [ -x $file ]
then echo "it then echo "file is write" else then
exist" else echo "file is read" echo "file is not write" echo "file is execute" else
echo "it not exist" fi else fi echo "file is not execute" fi
echo "file not read"
fi

Output:

Input:

file = "Computer" file = "b.txt"


if [ -d $file ] if [ -s $file ]
then then
echo "directory is checked" echo "file is empty"
else else
echo "directory is not checked" echo "file is not
fi empty"
fi
Output:

Input:
file A is newer than file file1="a.sh" file1="a.sh" file1="a.sh" file2="b.sh"
B: file2="b.sh" if [ file2="b.sh" if [ -G $file1 ] then
file1="a.sh" $file1 -ot $file2 ] if [ -O $file1 ] echo "Access by Group"
file2="b.sh" if [ then then echo else
$file1 -nt $file2 ] echo "A Is Older Then B" "Access by echo "Not Access"
then else Owner"
echo "A Is Older Then echo "A Is Newer Then else
B" B" echo "Not Access"
else
echo "A Is Newer Then
B"
Output:

Conclusion: we have successfully performed file existing program.

You might also like