SlideShare a Scribd company logo
1
Ex.No.1 UTILITY COMMANDS
Date:
AIM:
To execute the various basic,filedirectory handling and utility commands.
OUTPUT:
RESULT:
Hence the output is verified.
2
Ex.No.2 SYSTEM VARIABLE
Date:
AIM:
To write a variable value type such as PATH,SHELL, HOST NAME and IFS etc.
PROGRAM:
echo $PATH
echo $HOME
echo $SHELL
echo $HOSTNAME
echo $IFS
OUTPUT:
RESULT:
Hence the output is verified.
3
Ex.No.3 ADMINISTRATIVE COMMANDS
Date:
AIM:
To execute the various system administrative commands such as make directory, remove
directory and various list options.
OUTPUT:
RESULT:
Hence the output is verified.
4
Ex.No.4 DISPLAY THE LIST OF USERS
Date
AIM:
To write a program to display the list of users currently logged in.
PROGRAM:
function line ()
{
echo “ ******* ”
}
echo “yours username: $ (echo $ user)”
line
echo “current date and time : $ (date)”
line
echo “ currently logged on yours: ”
who
line
OUTPUT:
yours user name:
******
current date and time:
thu mar 12 2020, 1.40pm
currently logged on yours:
mtnc lab4 ++y7 2020,1.40pm
********
RESULT:
Hence the output is verified.
5
Ex.No.5 DISPLAY THE LIST OF USERS
Date
AIM:
To write a shell script that displays a list of all files in the current directory to which the user has
read ,write and execute permissions.
PROGRAM:
echo "enter the directory name"
read dir
if [ -d $dir ]
then
cd $dir
ls > f
exec < f
while read line
do
if [ -f $line ]
then
if [ -r $line -a -w $line -a -x $line ]
then
echo "$line has all permissions"
else
echo "files not having all permissions"
fi
fi
done
fi
OUTPUT:
RESULT :
Hence the output is verified.
6
Ex.No.6 DELETE THE FILES
Date
AIM:
To write a shell script to delete all the temporary files.
PROGRAM:
rm -rf / tmp / *
rm -rf / var / tmp / *
fsck -A
exit
OUTPUT:
The file deleted.
RESULT:
Hence the output is verified.
7
Ex.No.7 DISPLAY SOURCE CODE IN GIVEN FILE
Date
AIM:
To write the shell script that accepts a file name, starting and ending line numbers as arguments
and display all the lines between the given line numbers.
PROCEDURE:
1. Start
2. Get the filename.
3. Get the starting and ending line number.
4. Using -n and cat command.
5. Display the given lines of the files.
6. Stop.
PROGRAM:
echo "enter the file name"
read fname
echo "enter the starting line number"
read s
echo "enter the ending number"
read n
sed -n $s,$np $fname | cat > newline
cat newline
OUTPUT:
RESULT:
Hence the output is verified.
8
Ex.No.8 DELETE A LINE CONTAINING SPECIFIED WORD
Date
AIM:
To write a shell script that deletes all lines containing a specified word in one or more files
supplied as arguments to it.
PROCEDURE:
1. Start.
2. Get the file names as command line arguments.
3. Write “enter the word to search and delete”.
4. Read word.
5. For each argument repeat step 6 to step 8.
6. if it is file then go to next step else display “error in file”.
7. Search the lines not contain specified “word”.
8. Write the above result into same file.
9. Stop.
PROGRAM:
if [ $# -eq 0 ]
then
echo NO ARUGUMENTS
else
pattern=$1
shift
for fname in $*
do
if [ -f $fname ]
then
echo DELETING $pattern FROM $fname
sed '/'$pattern'/d' $fname
else
echo $fname NOT FOUND
fi
done
fi
9
OUTPUT:
RESULT:
Hence the output is verified.
10
Ex.No.9 FILES OR DIRECTORY DOCUMENTS.
Date
AIM:
To write a shell script that receives any number of file names as its arguments, check if every
argument supplied is a file or a directory and reports accordingly. Whenever the argument is a file, the
number of lines on its to be reported.
PROCEDURE:
1. Start.
2. Get the file names and command line arguments.
3. Check the file is directory or file.
4. Display the number of lines in the file.
5. stop.
PROGRAM:
for x in $*
do
if [ -f $x ]
then
echo "$x is a file"
echo "no of lines in the files are"
wc -l $x
elif [ -d $x ]
then
echo "$x is a directory"
else
echo "enter valid filename or directory name"
fi
done
11
OUTPUT:
RESULT:
Hence the output is verified.
Ex. No.10 .ARITHMETIC AND LOGICAL CALCULATIONS
Date:
AIM:
To write a simple shell script for basic arithmetic and logical calculations.
ALGORITHM:
1. Start the program.
2. Read the two numbers.
3. Perform the arithmetic operations for addition, subtraction, multiplication and division.
4. Compare the two variables ,to find the arithmetic and logical calculations.
5. Display the arithmetic and logical values.
6. Stop.
12
PROGRAM:
#!/bin/sh
a=10
b=10
val=`expr $a + $b`
echo "a + b : $val"
val=`expr $a - $b`
echo "a - b : $val"
val=`expr $a * $b`
echo "a * b : $val"
val=`expr $b / $a`
echo "b / a : $val"
val=`expr $b % $a`
echo "b % a : $val"
if [ $a == $b ]
then
echo "a is equal to b"
fi
if [ $a != $b ]
then
echo "a is not equal to b"
fi
OUTPUT:
13
RESULT:
Hence the output is verified.
Ex .No. 11.FACTORIAL OF THE GIVEN NUMBER
Date:
AIM:
To write a shell script to find the factorial of a given number.
PROCEDURE:
1. start
2. get the number as “num”
3. calculate the factorial number
4. display the number
5. stop
SHELL COMMAND:
echo "enter a number"
read num
fact=1
while [ $num -gt 1 ]
14
do
fact=$(( fact * num ))
num=$(( num -1 ))
done
echo $fact
OUTPUT:
RESULT:
hence the output is verified.
15
Ex. No.12. STRING OPERATIONS
Date:
AIM:
To write a shell script to perform various operations on given string.
PROCEDURE:
1. start
2. get two strings
3. to perform the string operation such as string compare, string length, reverse the string,
combine the string etc.
4. display the result string
5. stop
SHELL COMMAND:
clear
choice=y
while [ "$choice" = "y" ]
do
echo "____________________________________________"
echo "1. COMPARE TWO STRINGS"
echo "2. JOIN TWO STRINGS"
echo "3. FIND THE LENGTH OF A GIVEN STRING"
echo "4. OCCURRENCE OF CHARACTER AND WORDS"
echo "5. REVERSE THE STRING"
echo "6. EXIT"
echo "____________________________________________"
echo "Enter Choice: "
read ch
echo "____________________________________________"
case $ch in
1)
echo "Enter String1: "
read str1
echo "Enter String2: "
read str2
if [ $str1 = $str2 ]
then
echo "String is equal"
else
echo "String is not equal"
fi
;;
2)
echo "Enter String1: "
read str1
16
echo "Enter String2: "
read str2
str3=$str1$str2
echo "Join String: " $str3
;;
3)
len=0
echo "Enter String1: "
read str1
len=$(echo "$str1" | wc -c)
len=`expr $len - 1`
echo "Length: " $len
;;
4)
echo "Enter String: "
read str
echo "Enter Word to find : "
read word
echo $str | cat > str1.txt
grep -o $word str1.txt | cat > str2.txt
count=`grep -c $word str2.txt`
echo "Count: "$count
;;
5)
echo "Enter String1: "
read str
len=`expr $str | wc -c`
len=`expr $len - 1`
while [ $len -gt 0 ]
do
rev=`expr $str | cut -c $len`
ans=$ans$rev
len=`expr $len - 1`
done
echo "Reverse String: "$ans
;;
6) exit ;;
*) echo "Invalid Choice ....." ;;
esac
echo "Do u want to continue.....? [y/n]"
read choice
17
case $choice in
Y|y) choice=y;;
N|n) choice=n;;
*) choice=y;;
esac
done
OUTPUT:
RESULT:
Hence the output is verified.
18
Ex. No.13 VOWELS CHECKING
Date:
AIM:
To write an awk script to find the number of lines in a file that do not contain vowels I (or) o
PROCEDURE:
1. start the program
2. to create the text file containing text with vowels and non vowels
3. read the file name (that is text)
4. check the words in the file not containing vowels
5. display the number of lines not containing vowels
6. stop
PROGRAM:
#!/bin/bash
echo "Enter file name"
read file
awk '$0!~/[aeiou]/{ count++ }
END{print "The number of lines that does not contain vowels are: ",count}' $file
OUTPUT:
new
19
RESULT:
Hence the output is verified
20
Ex. No.14. CHARACTER, WORDS AND LINE IN A FILE
Date:
AIM:
To write an awk script to find the number of character, words and lines
PROCEDURE:
1. start
2. get source file name
3. print character
4. print word
5. print lines
6. stop
PROGRAM:
echo Enter the filename
read file
w=`cat $file | wc -w`
c=`cat $file | wc -c`
l=`grep -c "." $file`
echo Number of characters in $file is $c
echo Number of words in $file is $w
echo Number of lines in $file is $l
OUTPUT:
21
RESULT:
Hence the output is verified.
22
Ex No.15 .BINARY SEARCH
Date:
AIM:
To write a shell script to search an element from an array using binary search
PROCEDURE:
1. Start
2. get the size of an array
3. get the elements one by one
4. get the target value
5. start with the middle element. If the target value is equal to the middle element of the array, then
return the index of the middle element. If not compare the middle with other value
6. when a match is found, print successful search
7. if no match is found, print unsuccessful search
8. stop the program
PROGRAM:
echo Enter array limit
read limit
echo Enter elements
n=1
while [ $n -le $limit ]
do
read num
eval arr$n=$num
n=`expr $n + 1`
done
echo Enter key element
read key
low=1
high=$n
found=0
while [ $found -eq 0 -a $high -gt $low ]
do
mid=`expr ( $low + $high ) / 2`
eval t=$arr$mid
if [ $key -eq $t ]
then
found=1
elif [ $key -lt $t ]
then
high=`expr $mid - 1`
else
low=`expr $mid + 1`
fi
done
23
if [ $found -eq 0 ]
then
echo Unsuccessfull search
else
echo Successfull search
fi
OUTPUT:
RESULT:
Hence the output is verified
24
Ex. No.16. FILE OPERATIONS
Date:
AIM:
To write a c program that takes one or more file/directory names as command line input and
reports the following information on the file.
A) file type
B) number of links
C)take of last access
D)read,write and execute permissions
PROCEDURE:
1. get the file name in the command line.
2. Display the node number
3. report the file or directory
4. display the number of link
5. display the time of last access
6. display the modification time
7. display the last change time
8. display the read,write and execute permissions
9. stop
PROGRAM:
#include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<time.h>
int main(int argc,char *argv[])
{
char *at,*mt,*ct; struct stat buf; stat(argv[1],&buf);
printf("the inode no is : %dn",buf.st_ino); if(S_ISDIR(buf.st_mode))
printf("it is a directory"); if(S_ISREG(buf.st_mode)) printf("it is regurlar filen");
printf("the no of links is %dn",buf.st_nlink); at=ctime(&buf.st_atime);
printf("the time of last access is %sn",at); mt=ctime(&buf.st_mtime);
printf("the modification time is :%sn",mt); ct=ctime(&buf.st_ctime);
printf("time of last change is : %sn",ct); if((buf.st_mode&S_IRUSR)==S_IRUSR)
printf("user has read permissionn"); if((buf.st_mode &S_IWUSR)==S_IWUSR)
printf("user has write permisssionn"); if((buf.st_mode &S_IXUSR)==S_IXUSR)
printf("user has execute permissionn"); if((buf.st_mode & S_IRGRP)==S_IRGRP)
printf("group has read permissionn"); if((buf.st_mode &S_IWGRP)==S_IWGRP)
printf("group has write permissionn"); if((buf.st_mode & S_IXGRP)==S_IXGRP)
printf("group has execute permissionn"); if((buf.st_mode &S_IROTH)==S_IROTH)
printf("others has read permissionn"); if((buf.st_mode &S_IWOTH)==S_IWOTH)
25
printf("others has write permissionn"); if((buf.st_mode &S_IXOTH)==S_IXOTH)
printf("others has execute permisssionn");
}
OUTPUT:
$ gedit sample.c
$ gcc sample.c – o sample
$./ sample
the node number is :4
it is a directory
the number of links is 5
the time of last access is: 12.30 pm
the modification time: 12:40 pm
time of last change :12.40 pm
user has read permission
user has write permission
user has execute permissions
group has read
others has read permissions
others has write permissions
others has execute permissions
RESULT:
Hence the output is verified
26
Ex. No.17 SUSPENDING AND RESUMING PROCESS
Date:
AIM:
To write the program for suspending and resuming process
PROCEDURE:
1. start
2. get the file name
3. call the process
4. enter suspend time of child process
5. enter parent sleep time
6. resume child process
7. terminate the child process
8. end the parent process
PROGRAM:
#include<stdio.h>
#include <ospace/linux.h>
int child _function( )
{
while (true)
{
printf(“child loop n”);
os_this_ process::sleep(1);
}
return 0;
}
int main()
{
os_linux_toolkit initialize;
os_process child(child function);
os_this_porocess::sleep(4);
print(“child.suspend()n”);
child.suspend();
printf(“parent sleep for 4 seconds n”);
os_this _process::sleep(4);
printf(“child.resume()n”);
child.resume();
os_this_process::sleep (4);
printf(“child.terminate()”);
child.terminate();
print(“parent finished”);
return 0;
}
27
OUTPUT:
child loop
child loop
child loop
child loop
child loop
child.suspend()
parents sleep for 4 seconds
child.resume()
child loop
child loop
child loop
child loop
child.terminate()
child loop
parent finished
RESULT:
Hence the output is verified.

More Related Content

Similar to Linux Lab Manual.doc

ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ewout2
 
What is a shell script
What is a shell scriptWhat is a shell script
What is a shell script
Dr.M.Karthika parthasarathy
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell scriptAdvanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
Eliezer Moraes
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
NiladriDey18
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2
Kuntal Bhowmick
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Mufaddal Haidermota
 
Shell Scripts
Shell ScriptsShell Scripts
Shell ScriptsDr.Ravi
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docxIntroduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
mariuse18nolet
 
ShellProgramming and Script in operating system
ShellProgramming and Script in operating systemShellProgramming and Script in operating system
ShellProgramming and Script in operating system
vinitasharma749430
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
Krasimir Berov (Красимир Беров)
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
cskvsmi44
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
noahjamessss
 
Lecture 22
Lecture 22Lecture 22
Lecture 22rhshriva
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
AbhishekSharma2958
 

Similar to Linux Lab Manual.doc (20)

ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
What is a shell script
What is a shell scriptWhat is a shell script
What is a shell script
 
Advanced linux chapter ix-shell script
Advanced linux chapter ix-shell scriptAdvanced linux chapter ix-shell script
Advanced linux chapter ix-shell script
 
SHELL PROGRAMMING
SHELL PROGRAMMINGSHELL PROGRAMMING
SHELL PROGRAMMING
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2Solution manual of shell programming assignment 2
Solution manual of shell programming assignment 2
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Unix
UnixUnix
Unix
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docxIntroduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
Introduction to Unix - POS420Unix  Lab Exercise Week 3 BTo.docx
 
ShellProgramming and Script in operating system
ShellProgramming and Script in operating systemShellProgramming and Script in operating system
ShellProgramming and Script in operating system
 
IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
 
Devry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-filesDevry cis-170-c-i lab-7-of-7-sequential-files
Devry cis-170-c-i lab-7-of-7-sequential-files
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
PHP PPT FILE
PHP PPT FILEPHP PPT FILE
PHP PPT FILE
 

More from Dr.M.Karthika parthasarathy

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
Dr.M.Karthika parthasarathy
 
Unit 2 IoT.pdf
Unit 2 IoT.pdfUnit 2 IoT.pdf
Unit 3 IOT.docx
Unit 3 IOT.docxUnit 3 IOT.docx
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptx
Dr.M.Karthika parthasarathy
 
Unit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docxUnit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docx
Dr.M.Karthika parthasarathy
 
Introduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptxIntroduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptx
Dr.M.Karthika parthasarathy
 
IoT Unit 2.pdf
IoT Unit 2.pdfIoT Unit 2.pdf
Chapter 3 heuristic search techniques
Chapter 3 heuristic search techniquesChapter 3 heuristic search techniques
Chapter 3 heuristic search techniques
Dr.M.Karthika parthasarathy
 
Ai mcq chapter 2
Ai mcq chapter 2Ai mcq chapter 2
Ai mcq chapter 2
Dr.M.Karthika parthasarathy
 
Introduction to IoT unit II
Introduction to IoT  unit IIIntroduction to IoT  unit II
Introduction to IoT unit II
Dr.M.Karthika parthasarathy
 
Introduction to IoT - Unit I
Introduction to IoT - Unit IIntroduction to IoT - Unit I
Introduction to IoT - Unit I
Dr.M.Karthika parthasarathy
 
Internet of things Unit 1 one word
Internet of things Unit 1 one wordInternet of things Unit 1 one word
Internet of things Unit 1 one word
Dr.M.Karthika parthasarathy
 
Unit 1 q&amp;a
Unit  1 q&amp;aUnit  1 q&amp;a
Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1
Dr.M.Karthika parthasarathy
 
Examples in OS synchronization for UG
Examples in OS synchronization for UG Examples in OS synchronization for UG
Examples in OS synchronization for UG
Dr.M.Karthika parthasarathy
 
Process Synchronization - Monitors
Process Synchronization - MonitorsProcess Synchronization - Monitors
Process Synchronization - Monitors
Dr.M.Karthika parthasarathy
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
Dr.M.Karthika parthasarathy
 
.net progrmming part3
.net progrmming part3.net progrmming part3
.net progrmming part3
Dr.M.Karthika parthasarathy
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
Dr.M.Karthika parthasarathy
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
Dr.M.Karthika parthasarathy
 

More from Dr.M.Karthika parthasarathy (20)

IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
IoT Enabled Wireless Technology Based Monitoring and Speed Control of Motor U...
 
Unit 2 IoT.pdf
Unit 2 IoT.pdfUnit 2 IoT.pdf
Unit 2 IoT.pdf
 
Unit 3 IOT.docx
Unit 3 IOT.docxUnit 3 IOT.docx
Unit 3 IOT.docx
 
Unit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptxUnit 1 Introduction to Artificial Intelligence.pptx
Unit 1 Introduction to Artificial Intelligence.pptx
 
Unit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docxUnit I What is Artificial Intelligence.docx
Unit I What is Artificial Intelligence.docx
 
Introduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptxIntroduction to IoT - Unit II.pptx
Introduction to IoT - Unit II.pptx
 
IoT Unit 2.pdf
IoT Unit 2.pdfIoT Unit 2.pdf
IoT Unit 2.pdf
 
Chapter 3 heuristic search techniques
Chapter 3 heuristic search techniquesChapter 3 heuristic search techniques
Chapter 3 heuristic search techniques
 
Ai mcq chapter 2
Ai mcq chapter 2Ai mcq chapter 2
Ai mcq chapter 2
 
Introduction to IoT unit II
Introduction to IoT  unit IIIntroduction to IoT  unit II
Introduction to IoT unit II
 
Introduction to IoT - Unit I
Introduction to IoT - Unit IIntroduction to IoT - Unit I
Introduction to IoT - Unit I
 
Internet of things Unit 1 one word
Internet of things Unit 1 one wordInternet of things Unit 1 one word
Internet of things Unit 1 one word
 
Unit 1 q&amp;a
Unit  1 q&amp;aUnit  1 q&amp;a
Unit 1 q&amp;a
 
Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1Overview of Deadlock unit 3 part 1
Overview of Deadlock unit 3 part 1
 
Examples in OS synchronization for UG
Examples in OS synchronization for UG Examples in OS synchronization for UG
Examples in OS synchronization for UG
 
Process Synchronization - Monitors
Process Synchronization - MonitorsProcess Synchronization - Monitors
Process Synchronization - Monitors
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
.net progrmming part3
.net progrmming part3.net progrmming part3
.net progrmming part3
 
.net progrmming part1
.net progrmming part1.net progrmming part1
.net progrmming part1
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 

Recently uploaded

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

Linux Lab Manual.doc

  • 1. 1 Ex.No.1 UTILITY COMMANDS Date: AIM: To execute the various basic,filedirectory handling and utility commands. OUTPUT: RESULT: Hence the output is verified.
  • 2. 2 Ex.No.2 SYSTEM VARIABLE Date: AIM: To write a variable value type such as PATH,SHELL, HOST NAME and IFS etc. PROGRAM: echo $PATH echo $HOME echo $SHELL echo $HOSTNAME echo $IFS OUTPUT: RESULT: Hence the output is verified.
  • 3. 3 Ex.No.3 ADMINISTRATIVE COMMANDS Date: AIM: To execute the various system administrative commands such as make directory, remove directory and various list options. OUTPUT: RESULT: Hence the output is verified.
  • 4. 4 Ex.No.4 DISPLAY THE LIST OF USERS Date AIM: To write a program to display the list of users currently logged in. PROGRAM: function line () { echo “ ******* ” } echo “yours username: $ (echo $ user)” line echo “current date and time : $ (date)” line echo “ currently logged on yours: ” who line OUTPUT: yours user name: ****** current date and time: thu mar 12 2020, 1.40pm currently logged on yours: mtnc lab4 ++y7 2020,1.40pm ******** RESULT: Hence the output is verified.
  • 5. 5 Ex.No.5 DISPLAY THE LIST OF USERS Date AIM: To write a shell script that displays a list of all files in the current directory to which the user has read ,write and execute permissions. PROGRAM: echo "enter the directory name" read dir if [ -d $dir ] then cd $dir ls > f exec < f while read line do if [ -f $line ] then if [ -r $line -a -w $line -a -x $line ] then echo "$line has all permissions" else echo "files not having all permissions" fi fi done fi OUTPUT: RESULT : Hence the output is verified.
  • 6. 6 Ex.No.6 DELETE THE FILES Date AIM: To write a shell script to delete all the temporary files. PROGRAM: rm -rf / tmp / * rm -rf / var / tmp / * fsck -A exit OUTPUT: The file deleted. RESULT: Hence the output is verified.
  • 7. 7 Ex.No.7 DISPLAY SOURCE CODE IN GIVEN FILE Date AIM: To write the shell script that accepts a file name, starting and ending line numbers as arguments and display all the lines between the given line numbers. PROCEDURE: 1. Start 2. Get the filename. 3. Get the starting and ending line number. 4. Using -n and cat command. 5. Display the given lines of the files. 6. Stop. PROGRAM: echo "enter the file name" read fname echo "enter the starting line number" read s echo "enter the ending number" read n sed -n $s,$np $fname | cat > newline cat newline OUTPUT: RESULT: Hence the output is verified.
  • 8. 8 Ex.No.8 DELETE A LINE CONTAINING SPECIFIED WORD Date AIM: To write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it. PROCEDURE: 1. Start. 2. Get the file names as command line arguments. 3. Write “enter the word to search and delete”. 4. Read word. 5. For each argument repeat step 6 to step 8. 6. if it is file then go to next step else display “error in file”. 7. Search the lines not contain specified “word”. 8. Write the above result into same file. 9. Stop. PROGRAM: if [ $# -eq 0 ] then echo NO ARUGUMENTS else pattern=$1 shift for fname in $* do if [ -f $fname ] then echo DELETING $pattern FROM $fname sed '/'$pattern'/d' $fname else echo $fname NOT FOUND fi done fi
  • 10. 10 Ex.No.9 FILES OR DIRECTORY DOCUMENTS. Date AIM: To write a shell script that receives any number of file names as its arguments, check if every argument supplied is a file or a directory and reports accordingly. Whenever the argument is a file, the number of lines on its to be reported. PROCEDURE: 1. Start. 2. Get the file names and command line arguments. 3. Check the file is directory or file. 4. Display the number of lines in the file. 5. stop. PROGRAM: for x in $* do if [ -f $x ] then echo "$x is a file" echo "no of lines in the files are" wc -l $x elif [ -d $x ] then echo "$x is a directory" else echo "enter valid filename or directory name" fi done
  • 11. 11 OUTPUT: RESULT: Hence the output is verified. Ex. No.10 .ARITHMETIC AND LOGICAL CALCULATIONS Date: AIM: To write a simple shell script for basic arithmetic and logical calculations. ALGORITHM: 1. Start the program. 2. Read the two numbers. 3. Perform the arithmetic operations for addition, subtraction, multiplication and division. 4. Compare the two variables ,to find the arithmetic and logical calculations. 5. Display the arithmetic and logical values. 6. Stop.
  • 12. 12 PROGRAM: #!/bin/sh a=10 b=10 val=`expr $a + $b` echo "a + b : $val" val=`expr $a - $b` echo "a - b : $val" val=`expr $a * $b` echo "a * b : $val" val=`expr $b / $a` echo "b / a : $val" val=`expr $b % $a` echo "b % a : $val" if [ $a == $b ] then echo "a is equal to b" fi if [ $a != $b ] then echo "a is not equal to b" fi OUTPUT:
  • 13. 13 RESULT: Hence the output is verified. Ex .No. 11.FACTORIAL OF THE GIVEN NUMBER Date: AIM: To write a shell script to find the factorial of a given number. PROCEDURE: 1. start 2. get the number as “num” 3. calculate the factorial number 4. display the number 5. stop SHELL COMMAND: echo "enter a number" read num fact=1 while [ $num -gt 1 ]
  • 14. 14 do fact=$(( fact * num )) num=$(( num -1 )) done echo $fact OUTPUT: RESULT: hence the output is verified.
  • 15. 15 Ex. No.12. STRING OPERATIONS Date: AIM: To write a shell script to perform various operations on given string. PROCEDURE: 1. start 2. get two strings 3. to perform the string operation such as string compare, string length, reverse the string, combine the string etc. 4. display the result string 5. stop SHELL COMMAND: clear choice=y while [ "$choice" = "y" ] do echo "____________________________________________" echo "1. COMPARE TWO STRINGS" echo "2. JOIN TWO STRINGS" echo "3. FIND THE LENGTH OF A GIVEN STRING" echo "4. OCCURRENCE OF CHARACTER AND WORDS" echo "5. REVERSE THE STRING" echo "6. EXIT" echo "____________________________________________" echo "Enter Choice: " read ch echo "____________________________________________" case $ch in 1) echo "Enter String1: " read str1 echo "Enter String2: " read str2 if [ $str1 = $str2 ] then echo "String is equal" else echo "String is not equal" fi ;; 2) echo "Enter String1: " read str1
  • 16. 16 echo "Enter String2: " read str2 str3=$str1$str2 echo "Join String: " $str3 ;; 3) len=0 echo "Enter String1: " read str1 len=$(echo "$str1" | wc -c) len=`expr $len - 1` echo "Length: " $len ;; 4) echo "Enter String: " read str echo "Enter Word to find : " read word echo $str | cat > str1.txt grep -o $word str1.txt | cat > str2.txt count=`grep -c $word str2.txt` echo "Count: "$count ;; 5) echo "Enter String1: " read str len=`expr $str | wc -c` len=`expr $len - 1` while [ $len -gt 0 ] do rev=`expr $str | cut -c $len` ans=$ans$rev len=`expr $len - 1` done echo "Reverse String: "$ans ;; 6) exit ;; *) echo "Invalid Choice ....." ;; esac echo "Do u want to continue.....? [y/n]" read choice
  • 17. 17 case $choice in Y|y) choice=y;; N|n) choice=n;; *) choice=y;; esac done OUTPUT: RESULT: Hence the output is verified.
  • 18. 18 Ex. No.13 VOWELS CHECKING Date: AIM: To write an awk script to find the number of lines in a file that do not contain vowels I (or) o PROCEDURE: 1. start the program 2. to create the text file containing text with vowels and non vowels 3. read the file name (that is text) 4. check the words in the file not containing vowels 5. display the number of lines not containing vowels 6. stop PROGRAM: #!/bin/bash echo "Enter file name" read file awk '$0!~/[aeiou]/{ count++ } END{print "The number of lines that does not contain vowels are: ",count}' $file OUTPUT: new
  • 20. 20 Ex. No.14. CHARACTER, WORDS AND LINE IN A FILE Date: AIM: To write an awk script to find the number of character, words and lines PROCEDURE: 1. start 2. get source file name 3. print character 4. print word 5. print lines 6. stop PROGRAM: echo Enter the filename read file w=`cat $file | wc -w` c=`cat $file | wc -c` l=`grep -c "." $file` echo Number of characters in $file is $c echo Number of words in $file is $w echo Number of lines in $file is $l OUTPUT:
  • 22. 22 Ex No.15 .BINARY SEARCH Date: AIM: To write a shell script to search an element from an array using binary search PROCEDURE: 1. Start 2. get the size of an array 3. get the elements one by one 4. get the target value 5. start with the middle element. If the target value is equal to the middle element of the array, then return the index of the middle element. If not compare the middle with other value 6. when a match is found, print successful search 7. if no match is found, print unsuccessful search 8. stop the program PROGRAM: echo Enter array limit read limit echo Enter elements n=1 while [ $n -le $limit ] do read num eval arr$n=$num n=`expr $n + 1` done echo Enter key element read key low=1 high=$n found=0 while [ $found -eq 0 -a $high -gt $low ] do mid=`expr ( $low + $high ) / 2` eval t=$arr$mid if [ $key -eq $t ] then found=1 elif [ $key -lt $t ] then high=`expr $mid - 1` else low=`expr $mid + 1` fi done
  • 23. 23 if [ $found -eq 0 ] then echo Unsuccessfull search else echo Successfull search fi OUTPUT: RESULT: Hence the output is verified
  • 24. 24 Ex. No.16. FILE OPERATIONS Date: AIM: To write a c program that takes one or more file/directory names as command line input and reports the following information on the file. A) file type B) number of links C)take of last access D)read,write and execute permissions PROCEDURE: 1. get the file name in the command line. 2. Display the node number 3. report the file or directory 4. display the number of link 5. display the time of last access 6. display the modification time 7. display the last change time 8. display the read,write and execute permissions 9. stop PROGRAM: #include<stdio.h> #include<fcntl.h> #include<sys/stat.h> #include<time.h> int main(int argc,char *argv[]) { char *at,*mt,*ct; struct stat buf; stat(argv[1],&buf); printf("the inode no is : %dn",buf.st_ino); if(S_ISDIR(buf.st_mode)) printf("it is a directory"); if(S_ISREG(buf.st_mode)) printf("it is regurlar filen"); printf("the no of links is %dn",buf.st_nlink); at=ctime(&buf.st_atime); printf("the time of last access is %sn",at); mt=ctime(&buf.st_mtime); printf("the modification time is :%sn",mt); ct=ctime(&buf.st_ctime); printf("time of last change is : %sn",ct); if((buf.st_mode&S_IRUSR)==S_IRUSR) printf("user has read permissionn"); if((buf.st_mode &S_IWUSR)==S_IWUSR) printf("user has write permisssionn"); if((buf.st_mode &S_IXUSR)==S_IXUSR) printf("user has execute permissionn"); if((buf.st_mode & S_IRGRP)==S_IRGRP) printf("group has read permissionn"); if((buf.st_mode &S_IWGRP)==S_IWGRP) printf("group has write permissionn"); if((buf.st_mode & S_IXGRP)==S_IXGRP) printf("group has execute permissionn"); if((buf.st_mode &S_IROTH)==S_IROTH) printf("others has read permissionn"); if((buf.st_mode &S_IWOTH)==S_IWOTH)
  • 25. 25 printf("others has write permissionn"); if((buf.st_mode &S_IXOTH)==S_IXOTH) printf("others has execute permisssionn"); } OUTPUT: $ gedit sample.c $ gcc sample.c – o sample $./ sample the node number is :4 it is a directory the number of links is 5 the time of last access is: 12.30 pm the modification time: 12:40 pm time of last change :12.40 pm user has read permission user has write permission user has execute permissions group has read others has read permissions others has write permissions others has execute permissions RESULT: Hence the output is verified
  • 26. 26 Ex. No.17 SUSPENDING AND RESUMING PROCESS Date: AIM: To write the program for suspending and resuming process PROCEDURE: 1. start 2. get the file name 3. call the process 4. enter suspend time of child process 5. enter parent sleep time 6. resume child process 7. terminate the child process 8. end the parent process PROGRAM: #include<stdio.h> #include <ospace/linux.h> int child _function( ) { while (true) { printf(“child loop n”); os_this_ process::sleep(1); } return 0; } int main() { os_linux_toolkit initialize; os_process child(child function); os_this_porocess::sleep(4); print(“child.suspend()n”); child.suspend(); printf(“parent sleep for 4 seconds n”); os_this _process::sleep(4); printf(“child.resume()n”); child.resume(); os_this_process::sleep (4); printf(“child.terminate()”); child.terminate(); print(“parent finished”); return 0; }
  • 27. 27 OUTPUT: child loop child loop child loop child loop child loop child.suspend() parents sleep for 4 seconds child.resume() child loop child loop child loop child loop child.terminate() child loop parent finished RESULT: Hence the output is verified.