Kirat Os
Kirat Os
1
07113702021 OS with LINUX LAB BCA-V(M2)
INDEX
3 Linux Files and Directories Related Commands ( cat>,cat ,cat >>,cp with 29-08-2023
options(-i,-v,-r), mv with options(-i,-v), rm with options(-i,-v,-r), , mkdir,
rmdir, pwd, cd, cd .., cd/, touch)
4 Commands based on listing of files and Directories and wc command ( ls 12-09-2023
with options(-l,-a,-F,-h,-i, -s, -t, -r, -R, -ld,-li) , ls with wildcard
characters,wc (w,l,c), less)(
5 Create and verify a new file using the cat command. 19-09-2023
a) display its contents
b) Delete file(s) and directory(s)
c) All files that begin with an alphabet followed by at least 4 characters
d) All the files that contain at least a single digit anywhere in a file name.
e) All the files that do not end with a number.
f) All the files and directories that begins with an alphabet, numbers
followed by any character.
g) List all the files and directories that does not start with vowel followed
by any no. of characters.
6 Write a shell script to print Hello World with current date & time. 19-09-2023
7 Write a shell script to display users who have currently logged in 30-09-2023
8 Write a shell script to find the factorial of given integer 30-09-2023
9 Write shell scripts that list the all files in a directory. 30-09-2023
10 Process commands using ps with options , jobs, kill, nice, renice, top, 10-10-2023
last.
11 Write a C program to create a Process using System Call().What do you 14-10-2023
observe?
12 Write a C program to create a child process and allow the parent to 14-10-2023
display “ parent “ and Child to display on the screen.
13 Write a C program to create a Zombie process.. 17-10-2023
14 Write a C program that illustrates how an orphan is created. 17-10-2023
15 Write a C program to illustrate one way communication using pipe() 17-10-2023
system call.
0
07113702021 OS with LINUX LAB BCA-V(M2)
18 Write basic shell script to input a character from user and then check 7-11-2023
whether it is uppercase, lowercase or digit.
1
07113702021 OS with LINUX LAB BCA-V(M2)
Q1. Write complete steps to install Virtual Box and then configure Linux (ubuntu) in virtual box.
A1.
Installing VirtualBox:
1. Download VirtualBox:
2. Install VirtualBox:
Choose the amount of RAM to allocate to the VM. A minimum of 2GB is recommended for Ubuntu.
2
07113702021 OS with LINUX LAB BCA-V(M2)
7. Install Ubuntu:
8. Complete Installation:
After the installation completes, eject the ISO from the virtual optical drive.
Restart the VM, and Ubuntu should boot from the virtual hard disk.
3
07113702021 OS with LINUX LAB BCA-V(M2)
Q2. Linux Basic Commands cat with options(-e, -m, -y) date with formats, hostname, arch, uname(-r,
-n options), uptime, whoami, who, w echo, type, whatis, help, man, info, df, du, less, more.
Ans. Code:
cat - The cat command in Linux is commonly used to concatenate and display the contents of files.
Cal
4
07113702021 OS with LINUX LAB BCA-V(M2)
date
hostname
Fig 1.4-
man
ls
Fig 1.6-Directory
5
07113702021 OS with LINUX LAB BCA-V(M2)
arch
Whoami
uname
uptime
6
07113702021 OS with LINUX LAB BCA-V(M2)
whatis
echo
df
7
07113702021 OS with LINUX LAB BCA-V(M2)
Du
Fig 1.14-Disuses
w
8
07113702021 OS with LINUX LAB BCA-V(M2)
Q3. Linux Files and Directories Related Commands ( cat>,cat ,cat >>,cp with options(-i,-v,-r), mv with
options(-i,-v), rm with options(-i,-v,-r), , mkdir, rmdir, pwd, cd, cd .., cd/, touch)
cp with options(-i,-v,-r)
mv with options(-i,-v),
9
07113702021 OS with LINUX LAB BCA-V(M2)
10
07113702021 OS with LINUX LAB BCA-V(M2)
Q4. Commands based on listing of files and Directories and wc command ( ls with options(-l,-a,-F,-h,-
i, - s, -t, -r, -R, -ld,-li) , ls with wildcard characters,wc (w,l,c), less)
wc with (w,l,c)
11
07113702021 OS with LINUX LAB BCA-V(M2)
d) All the files that contain at least a single digit anywhere in a file name.
12
07113702021 OS with LINUX LAB BCA-V(M2)
f) All the files and directories that begins with an alphabet, numbers followed by any character.
g) List all the files and directories that does not start with vowel followed by any no. of characters.
13
07113702021 OS with LINUX LAB BCA-V(M2)
2kirat.tx 28@kirat.
txt
14
07113702021 OS with LINUX LAB BCA-V(M2)
Q6. Write a shell script to print Hello World with current date and time.
Ans. Code:
Output:
15
07113702021 OS with LINUX LAB BCA-V(M2)
Q7. Write a shell script to display user who have currently logged in.
Ans. Code:
Output:
16
07113702021 OS with LINUX LAB BCA-V(M2)
Output:
17
07113702021 OS with LINUX LAB BCA-V(M2)
Q9. Write a shell script that list all the files in a directory.
Ans.
Code:
Output:
18
07113702021 OS with LINUX LAB BCA-V(M2)
Q10. Process commands using ps with options , jobs, kill, nice, renice, top, last.
PS
JOBS
KILL
19
07113702021 OS with LINUX LAB BCA-V(M2)
TOP
LAST
20
07113702021 OS with LINUX LAB BCA-V(M2)
Q11. Write a C program to create a Process using System call(). What do you observe?
Ans.
Code:
Output:
21
07113702021 OS with LINUX LAB BCA-V(M2)
Q12. Write a C program to create a child process and allow the parent to display “Parent” and child
to display “child” on screen.
Ans. Code:
Output:
22
07113702021 OS with LINUX LAB BCA-V(M2)
Output:
23
07113702021 OS with LINUX LAB BCA-V(M2)
Ans. Code:
Output:
24
07113702021 OS with LINUX LAB BCA-V(M2)
Q15. Write a C program to illustrate one way communication using pipe() system call.
Ans. Code:
Output:
25
07113702021 OS with LINUX LAB BCA-V(M2)
Chmod commands : set permission to file: 644, 541, 421, 766, 725, 022
26
07113702021 OS with LINUX LAB BCA-V(M2)
27
07113702021 OS with LINUX LAB BCA-V(M2)
28
07113702021 OS with LINUX LAB BCA-V(M2)
Q17. To demonstrate the difference between local and global shell variables, and make local variables
as global
29
07113702021 OS with LINUX LAB BCA-V(M2)
Q18. Write a basic shell script to input a character from user and then check whether it is uppercase
or lowercase or digit.
Ans. Code:
Output:
30
07113702021 OS with LINUX LAB BCA-V(M2)
Q20. Write a shell script to input the month number and generate corresponding calendar.
Ans.
Code:
Output;
31
07113702021 OS with LINUX LAB BCA-V(M2)
Code:
Output:
32
07113702021 OS with LINUX LAB BCA-V(M2)
Output:
33
07113702021 OS with LINUX LAB BCA-V(M2)
Q23. Write a basic shell script to check whether the number entered by the user is prime or not.
Ans. Code:
Output:
34
07113702021 OS with LINUX LAB BCA-V(M2)
*
***
*****
*******
Ans. Code:
Output:
35