Kirat Os
Kirat Os
INDEX
3 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)
4 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)(
5 Create and verify a new file using the cat command.
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.
7 Write a shell script to display users who have currently logged in
8 Write a shell script to find the factorial of given integer
9 Write shell scripts that list the all files in a directory.
10 Process commands using ps with options , jobs, kill, nice, renice, top,
last.
11 Write a C program to create a Process using System Call().What do you
observe?
12 Write a C program to create a child process and allow the parent to
display “ parent “ and Child to display on the screen.
13 Write a C program to create a Zombie process..
14 Write a C program that illustrates how an orphan is created.
15 Write a C program to illustrate one way communication using pipe()
system call.
HARKIRAT SINGH BCA M2 SEM-V 07113702021
18 Write basic shell script to input a character from user and then check
whether it is uppercase, lowercase or digit.
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.
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.
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
date
hostname
Fig 1.4-
man
ls
Fig 1.6-Directory
HARKIRAT SINGH BCA M2 SEM-V 07113702021
arch
Whoami
uname
uptime
whatis
echo
df
Du
Fig 1.14-Disuses
w
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),
HARKIRAT SINGH BCA M2 SEM-V 07113702021
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)
HARKIRAT SINGH BCA M2 SEM-V 07113702021
d) All the files that contain at least a single digit anywhere in a file name.
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.
HARKIRAT SINGH BCA M2 SEM-V 07113702021
2kirat.txt 28@kirat.
txt
Q6. Write a shell script to print Hello World with current date and time.
Ans. Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q7. Write a shell script to display user who have currently logged in.
Ans. Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q9. Write a shell script that list all the files in a directory.
Ans.
Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q10. Process commands using ps with options , jobs, kill, nice, renice, top, last.
PS
JOBS
KILL
HARKIRAT SINGH BCA M2 SEM-V 07113702021
TOP
LAST
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q11. Write a C program to create a Process using System call(). What do you observe?
Ans.
Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
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:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Ans. Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q15. Write a C program to illustrate one way communication using pipe() system call.
Ans. Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Chmod commands : set permission to file: 644, 541, 421, 766, 725, 022
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q17. To demonstrate the difference between local and global shell variables, and make local variables
as global
HARKIRAT SINGH BCA M2 SEM-V 07113702021
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:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q20. Write a shell script to input the month number and generate corresponding calendar.
Ans.
Code:
Output;
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
Q23. Write a basic shell script to check whether the number entered by the user is prime or not.
Ans. Code:
Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021
*
***
*****
*******
Ans. Code:
Output: