OS Practical File
OS Practical File
ENGINEERING COLLEGE
1
Index
1. Windows Installation.
2. Ubuntu Installation.
3. Mac Installation.
2
Practical No.: 1 Windows Installation
In order to install your copy of the Windows 7 operating systems please make sure to
have the following items:
Step1. Insert the Windows 7 operating system disk into your DVD drive, and then restart
your computer
Step2.You will see a prompt that says ‘Press any key to continue’ after the ZT logo
disappears. When you see this press any key immediately.
Step4. Language options, by default English will be set along with “time and currency
format” and “keyboard or input method”
3
Step 5. Click “Install Now”
Step 6. End User License Agreement (E.U.L.A.), check the box to accept, and click “Next”
Step7. “Which type of installation?”window will appear. Upgrade will be greyed out; the only
option you should be able to choose is Custom (advanced).
Step8. “Where do you want to install windows?” Make sure the partition is highlighted.
4
Step9.Delete the partition by clicking on Drive options (advanced) on the bottom right
corner of the field. Make sure the partition is highlighted and click on Delete. If drive
advanced options is greyed out, then the partition will not have to be deleted.
*NOTE: Deleting the partitions will erase all data on the system
Step10. Disk 0 Unallocated Space should be the only listing at this point. If it is press next, if
not please proceed to delete any additional partitions that may be listed.
Step11. The next screen will show “Installing Windows”. This process should take
approximately 10 minutes after which the system will reboot.
*NOTE: Do not press any keys during this boot up process so as to not disturb the rest of
the installation.
Step12. The next screen will show “Installing Windows” again to complete the installation
process.
5
Step13. “Setup is starting Windows” will appear on the screen, then you will be asked to
create a username and a computer name.
Step 14. The next step will prompt you to create a password for your account (optional)
Step15.The next screen will come up and ask you to choose one of three options: “Use
recommended settings”, “Install important updates only” and “Ask me later”.
6
Step16. This screen will allow you to choose your local time zone and also adjust the date
and time.
Step17. Click on the appropriate location of your computer to enable Windows 7 to apply the
correct network settings.
7
DDownload Ubuntu 15.04
(64-bit)
DDownload Ubuntu 15.04(32-
bit)
Once the iso file has been downloaded, burn it into DVD or USB drive and make it
bootable.
Make sure you have at least 6.6 GB free disk space and if you want to download updates
and third party tools at the installation, check both the boxes and make sure system is
connected to Internet
….
8
Step:4 Select the Installation Type
If your system has new hard drive and if nothing installed on it, then you can choose the
first option “Erase disk & Install Ubuntu”.
If you want LVM based file system, then use third option “Use LVM with new Ubuntu
Installation”
If you want to create customize partition table, the use last option
After the installation your PC will restart and your operating system is ready to use.
Install of macOS on your Mac using the recovery utility. Make sure your Mac is connected to a
power source and has a steady connection to the internet during the install process.
STEP: 1
Turn on or reboot your Mac. You will access recovery utility this way.
9
Your computer needs access to the internet if you do not have a local copy of macOS.
STEP: 2
Press and hold ⌘Cmd+ R right away. This key combination tells your Mac to reinstall the
same version of macOS that was already installed. If you're hoping for a different version,
check out these alternatives:
To upgrade you macOS to the most current OS that is compatible with your Mac, press
Opt+⌘Cmd+ R. For example, a Mac from early 2012 will not be compatible with
macOS10.15, Catalina.
To install the macOS your Mac came with, no matter how out-dated,
press ⇧ Shift+⌥Opt+⌘Cmd+ R. If you didn't have 10.12.14, Sierra, this key combination will
not work.
If you've never installed 10.12.14 (Sierra), using ⌘ Cmd+ R will install the OS without tying it to
your Apple ID. Use this key combination to erase your drive before giving it to someone else.
10
STEP: 3
STEP: 4
Choose if you want to erase your disk. Be warned that this will erase your disk and
you will lose all information on your computer. You can also opt to "Restore from
Time Machine Backup" if you don't want to lose everything.
STEP: 5
Click to select Reinstall macOS. This will reinstall the macOS but will keep your files
and user settings intact.
11
STEP: 6
Click Continue. You will start the process of reinstalling macOS.
STEP: 7
Follow the on-screen instructions to install MacOS. This includes selecting where
to install the OS. Please do not put your Mac to sleep or close its lid during the
installation process. You might see your Mac restart a few times, show a blank
screen, and show a few progress bars, but that does not mean installation is done.
12
Practical No.: 4
You can choose multiple features or you can start with default features.
If you want to create a shortcut on the desktop, then check on create a shortcut on
the desktop option and click on Next to proceed.
13
Ignore the warning and Click on the “Yes” button to proceed for the next step.
Click the install button. The next pop up window of UAC (Microsoft User Account
Control) will appear, click yes to proceed)
14
You will have to install drivers in Virtual Box to interact with the host machine’s
hardware as displayed in the figure. Click the install button to continue.
Now the installation process of Virtual box has been completed. Start Oracle VM
Virtual Box after installation.
15
Download the Linix Iso
Next, you need to download the ISO file of the Linux distribution. You can get this
image from the official website of the Linux distribution you are trying to use.
Install Linux using VirtualBox
You have installed VirtualBox and you have downloaded the ISO for Linux. You are
now set to install Linux in VirtualBox.
Start VirtualBox, and click on the New symbol. Give the virtual OS a relevant name.
Allocate RAM to the virtual OS. My system has 8GB of RAM and I decided to
allocate 2GB of it. You can use more RAM if your system has enough extra.
Create a virtual disk. This serves as the hard disk of the virtual Linux system. It is
where the virtual system will store its files.
16
using the VDI file type here.
You can choose either the “Dynamically allocated” or the “Fixed size” option for
creating the virtual hard disk.
17
Once everything is in place, it’s time to boot that ISO and install Linux as a virtual
operating system.
If VirtualBox doesn’t detect the Linux ISO, browse to its location by clicking the
folder icon as shown in the picture below:
Soon you’ll find yourself inside Linux. You should be presented with the option to
install it.
18
Things from here are Ubuntu-specific. Other Linux distributions may have slightly
different looking steps, but it won’t be complicated at all.
Select ‘Erase disk and install Ubuntu’. Don’t worry. It won’t delete anything on your
Windows operating system. You are using the virtual disk space of 15-20GB that
we created in previous steps. It won’t impact the real operating system.
19
Just click on Continue.
Self explanatory.
Try to choose a password that you can remember. You can also reset the password
in Ubuntu if you forget it.
20
You are almost done. It may take 10-15 minutes to complete the installation.
If it gets stuck on the screen below, you may close the VirtualBox.
21
Practical No.: 5
File Commands
1. ls Directory listing
8. cat >file Places the standard input into the file
12. tail -f file Output the contents of file as it grows,starting with the last 10
lines
22
21. ln -s file Create symbolic link link to file
link
Process management
1. ps To display the currently working processes
File permission
1. chmod octal file Change the permission of file to octal,which can be
found separately for user,group,world by adding,
• 4-read(r)
• 2-write(w)
• 1-execute(x)
Searching
1. grep pattern Search for pattern in file
23
filename period) and below it, for files and directories with
names starting with filename
6. pgrep pattern Searches for all the named processes , that matches
with the pattern and, by default, returns their ID
System Info
1. date Show the current date and time
Compression
1. tar cf file.tar file Create tar named file.tar containing file
24
5. tar cjf Create tar with Bzip2 compression
file.tar.bz2
Network
1. ping host Ping host and output results
Shortcuts
1. ctrl+c Halts the current command
25
Practical No.: 6
#include<iostream>
using namespace std;
int main()
{
int n,bt[20],wt[20],tat[20],avwt = 0, avtat = 0;
cout<<"Enter Total Number of Processor: ";
cin>>n;
cout<<endl<<"Enter Process Burst Time"<<endl;
for(int i=0;i<n;i++)
{
cout<<"Process["<<i+1<<"]: ";
cin>>bt[i];
}
wt[0]=0;
for(int i=1;i<n;i++)
26
{
wt[i]=0;
for(int j=0;j<i;j++)
wt[i]+= bt[j];
}
cout<<endl<<"Process\t Burst Time\t Watimg Time\t Turnarround
Time";
for(int i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
avwt+= wt[i];
avtat+= tat[i];
cout<<endl<<"Process["<<i+1<<"]"<<"\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
}
cout<<endl<<endl<<"Average Wating Time: "<<avwt;
cout<<endl<<"Average Turnaround Time: "<<avtat;
return 0;
}
Output:-
27
Practical No.: 7
#include<iostream>
using namespace std;
int main()
{
int bt[20],p[20],wt[20],tat[20],i,j,n,total=0,pos,temp;
float awt, atat;
cout<<"Enter number of process: ";
cin>>n;
cout<<endl<<"Enter Burst Time:"<<endl;
for(i=0;i<n;i++)
{
cout<<"p"<<i+1<<": ";
cin>>bt[i];
p[i]=i+1;
}
28
for(i=1;i<n;i++)
{
pos=i;
for(j=i+1;j<n;j++)
{
if(bt[j]<bt[pos])
pos=j;
}
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0;
for(i=0;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
total+=wt[i];
}
awt=(float)total/n;
total=0;
cout<<endl<<"Process\t Burst Time \t Waiting Time\tTurn Around Time";
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
total+=tat[i];
29
cout<<endl<<"p"<<p[i]<<"\t\t"<<bt[i]<<"\t\t"<<wt[i]<<"\t\t"<<tat[i];
}
atat=(float)total/n;
cout<<endl<<endl<<"Averge Waiting time= "<<awt;
cout<<endl<<"Average Turnaround Time= "<<atat;
return 0;
}
Output:-
30
Practical No.: 8
#include<iostream>
using namespace std;
struct process
{
int no;
int at,et,wt,tt;
int tet,t;
};
int main()
{
process p[99];
int i,j,k;
cout<<"Enter No. of Processes: ";
int np;
cin>>np;
for(i=0;i<np;i++)
31
{
cout<<endl<<"Enter Execution Time of Process "<<i+1<<": ";
cin>>p[i].et;
p[i].tet=p[i].et;
p[i].at=p[i].t=p[i].tt=p[i].wt=0;
p[i].no=i+1;
}
cout<<endl<<"Enter Time Quantum: ";
int q;
cin>>q;
cout<<endl<<"Enter Data: ";
cout<<endl<<"Process Execution Time";
for(i=0;i<np;i++)
{
cout<<endl<<p[i].no<<"\t"<<p[i].et;
}
int totaltime = 0;
for(i=0;i<np;i++){
totaltime+=p[i].et;
}
i=0;
k=0;
int rrg[99];
for(j=0;j<totaltime;j++)
{
if((k==0)&&(p[i].et!=0))
{
p[i].wt=j;
if((p[i].t!=0))
{
32
p[i].wt=q*p[i].t;
}
}
if((p[i].et!=0)&&(k!=q))
{
rrg[j]=p[i].no;
p[i].et+1;
k++;
}
else
{
if((k==q)&&(p[i].et!=0))
{
p[i].t+=1;
}
i=i+1;
if(i==np)
{
i=0;
}
k=0;
j=j+1;
}
}
int twt=0;
int ttt=0;
cout<<endl<<"\t\tResult of Round Robin"<<endl;
cout<<endl<<"Processes\tExecution Time\tWating Time\Turn Around Time";
for(i=0;i<np;i++)
{
p[i].tt=p[i].wt+p[i].tet;
33
ttt+=p[i].tt;
twt+=p[i].wt;
cout<<endl<<p[i].no<<"\t\t\t"<<p[i].tet<<"\t"<<p[i].wt<<"\t\t"<<p[i].tt;
}
cout<<endl<<"Average Waiting Time"<<(float)twt/np;
cout<<endl<<"Average Turn Around time: "<<(float)ttt/np;
return 0;
}
Output:-
Practical No.: 9
#include<iostream>
using namespace std;
int main()
{
int bt[20], p[20], wt[20], tat[20], pr[20], i, j, n, total=0, pos, temp, avgwt, avgtat;
cout<<"Enter Total Number Of Process: ";
34
cin>>n;
cout<<endl<<"Enter Burst Time and Priority:"<<endl;
for(i=0;i<n;i++)
{
cout<<endl<<"P["<<i+1<<"]\n";
cout<<"Burst Time: ";
cin>>bt[i];
cout<<"Priority: ";
cin>>pr[i];
p[i]=i+1;
}
for(i=0;i<n;i++)
{
pos=i;
for(j=i;j<n;j++)
{
if(pr[j]<pr[pos])
pos=j;
}
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;
temp=pr[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
35
wt[0]=0;
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<n;j++)
wt[i]+=bt[j];
total+=wt[i];
}
avgwt=total/n;
total=0;
cout<<endl<<"Process\t Burst Time \tWaiting Time\tTurn Around Time";
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i]; //calaulate turn around time
total+=tat[i];
cout<<endl<<"P["<<p[i]<<"]\t "<<bt[i]<<"\t\t "<<wt[i]<<"\t\t
"<<tat[i];
}
avgtat=total/n; //average turn around time
cout<<endl<<endl<<"Average Wating Time= "<<avgwt;
cout<<endl<<"Average Turn Around Time= "<<avgtat;
return (0);
}
Output:-
36
Practical No.: 10
Aim: Simulate the Bankers algorithm for deadlock avoidance and deadlock
prevention.
#include<iostream>
using namespace std;
#define MAX 20
class bankers
{
private:
int al[MAX][MAX],m[MAX][MAX],n[MAX][MAX],avail[MAX];
int nop,nor,k,result[MAX],pnum,work[MAX],finish[MAX];
public:
bankers();
void input();
void method();
int search(int);
37
void display();
};
bankers::bankers()
{
k=0;
for(int i=0;i<MAX;i++)
{
for(int j=0;j<MAX;j++)
{
al[i][j]=0;
m[i][j]=0;
n[i][j]=0;
}
avail[i]=0;
result[i]=0;
finish[i]=0;
}
}
void bankers::input()
{
int i,j;
cout<<"Enter the number of processes:";
cin>>nop;
cout<<"Enter the number of resources:";
cin>>nor;
cout<<"Enter the allocated resources for each process: "<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)
38
{
cout<<"\nResource "<<j<<":";
cin>>al[i][j];
}
}
cout<<"Enter the maximum resources that are needed for each process:
"<<endl;
for(i=0;i<nop;i++)
{
cout<<"\nProcess "<<i;
for(j=0;j<nor;j++)
{
cout<<"\nResouce "<<j<<":";
cin>>m[i][j];
n[i][j]=m[i][j]-al[i][j];
}
}
cout<<"Enter the currently available resources in the system: ";
for(j=0;j<nor;j++)
{
cout<<"Resource "<<j<<":";
cin>>avail[j];
work[j]=-1;
}
for(i=0;i<nop;i++)
finish[i]=0;
}
void bankers::method()
{
int i=0,j,flag;
while(1)
39
{
if(finish[i]==0)
{
pnum =search(i);
if(pnum!=-1)
{
result[k++]=i;
finish[i]=1;
for(j=0;j<nor;j++)
{
avail[j]=avail[j]+al[i][j];
}
}
}
i++;
if(i==nop)
{
flag=0;
for(j=0;j<nor;j++)
if(avail[j]!=work[j])
flag=1;
for(j=0;j<nor;j++)
work[j]=avail[j];
if(flag==0)
break;
else
i=0;
}
}
}
int bankers::search(int i)
40
{
int j;
for(j=0;j<nor;j++)
if(n[i][j]>avail[j])
return -1;
return 0;
}
void bankers::display()
{
int i,j;
cout<<endl<<"OUTPUT:";
cout<<endl<<"========";
cout<<endl<<"PROCESS\t ALLOTED\t MAXIMUM\t NEED";
for(i=0;i<nop;i++)
{
cout<<"\nP"<<i+1<<"\t ";
for(j=0;j<nor;j++)
{
cout<<al[i][j]<<" ";
}
cout<<"\t ";
for (j=0;j<nor;j++)
{
cout<<m[i][j]<<" ";
}
cout<<"\t";
for(j=0;j<nor;j++ )
{
cout<<n[i][j]<<" ";
}
}
41
cout<<"\nThe sequence of the safe processes are: \n";
for(i=0;i<k;i++)
{
int temp = result[i]+1 ;
cout<<"P"<<temp<<" ";
}
cout<<"\nThe sequence of unsafe processes are: \n";
int flg=0;
for (i=0;i<nop;i++)
{
if(finish[i]==0)
{
flg=1;
}
cout<<"P"<<i<<" ";
}
cout<<endl<<"RESULT:";
cout<<endl<<"=======";
if(flg==1)
cout<<endl<<"The system is not in safe state and deadlock may occur!!";
else
cout<<endl<<"The system is in safe state and deadlock will not occur!!";
}
int main()
{
cout<<" DEADLOCK BANKER’S ALGORITHM "<<endl;
bankers B;
B.input ( );
B.method ( );
B.display ( );
return 0;
42
}
Output:-
43
Practical No.: 11
rem=$(( $n % 2 ))
if [ $rem -eq 0 ]
then
echo "$n is even number"
else
echo "$n is odd number"
fi
Output:-
44
then
echo "B is Greatest"
else
echo "C is Greatest"
fi
fi
Output:-
Output:-
45
d) To write a program to display the Fibonacci series.
PROGRAM:
echo " Enter the limit for FIBONNACI SERIES"
read lim
n1=0
n2=1
var=0
echo "FIBONACCI SERIES IS "
echo "$n1"
echo "$n2"
while [ $var -lt `expr $lim - 2` ]
do
n3=`expr $n1 + $n2 `
n1=`expr $n2 `
n2=`expr $n3 `
var=`expr $var + 1 `
echo "$n2"
done
Output:-
PROGRAM:
echo “Display first 10 numbers”
46
for((i=1;i<=10;i++))
do
echo $i
done
Output:-
47