Kirat Os

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Practical File

OPERATING SYSTEMS WITH


LINUX LAB
(BCA-371)
Submitted in partial fulfilment of the requirements
for the award of the degree of

Bachelor of Computer Applications

Guru Gobind Singh Indraprastha University, Delhi

Submitted to: Submitted by: Harkirat Singh

Enrolment No- 07113702021

Ms. Suman Singh


(Assistant professor- IT)

Institute of Information Technology & Management,


New Delhi – 110058
Batch (2021 - 2024)

1
07113702021 OS with LINUX LAB BCA-V(M2)

INDEX

SNO Question Date Sign


1 Write complete Steps for Install VirtaulBox and then configure Linux 21-08-2023
(Ubantu) in VirtualBox.
2 Linux Basic Commands(cal with options(-3,-m,-y) date with formats, 22-08-2023
hostname, arch, uname (-r,-n options), uptime, whoami, who am i, who,w
echo, type, whatis, help, man, info, df, du, less,more

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)

SNO Question Date Sign


16 File Permission Commands using chmod commands with options: u- 7-11-2023
r,u+rw,o-r, o+x,g-x,o-r,o=x,g-x., a=rw, ugo=rwx
Chmod commands : set permission to file: 644, 541, 421, 766, 725,
022
Change ownership of file to new user BCA
Chnage group ownership of file to ‘R’
Write basic shell script to display the table of a number.
17 To demonstrate the difference between local and global shell variables, 7-11-2023
and make local variables as global.

18 Write basic shell script to input a character from user and then check 7-11-2023
whether it is uppercase, lowercase or digit.

19 Commands based on listing of files and Directories and wc command ( 11-11-2023


ls with options(-l,-a,-F,-h,-i, -s, -t, -r, -R, -ld,-li) , ls with wildcard
characters,wc (w,l,c), less)(
20 Write basic shell script to calculate factorial of a number. 11-11-2023
21 Write basic shell script to input the month number and generate 11-11-2023
corresponding calendar
22 Write basic shell script to list all directories. 21-11-2023
23 Write basic shell script to display greatest of three numbers 21-11-2023
24 Write basic shell script to check whether the number entered by user 21-11-2023
is prime or not.
25 To print the following patterns:- 21-11-2023
*
***
*****
*******

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:

Visit the official VirtualBox website: https://www.virtualbox.org/


Navigate to the "Downloads" section.
Download the version that corresponds to your operating system (Windows, macOS, Linux, etc.).

2. Install VirtualBox:

Windows: Run the installer and follow the on-screen instructions.


macOS: Open the downloaded DMG file, drag the VirtualBox application to the Applications folder.
Linux: Follow the distribution-specific instructions. On Ubuntu, you can use the following commands in the
terminal:

Configuring a Virtual Machine (VM) with Ubuntu:

1. Download Ubuntu ISO:

Visit the official Ubuntu website: https://ubuntu.com/download/desktop


Download the LTS (Long Term Support) version of Ubuntu Desktop.

2. Create a New Virtual Machine:

Open VirtualBox and click on the "New" button.


Enter a name for your VM and select "Linux" as the type and "Ubuntu" as the version.

3. Allocate Memory (RAM):

Choose the amount of RAM to allocate to the VM. A minimum of 2GB is recommended for Ubuntu.

4. Create a Virtual Hard Disk:

Choose "Create a virtual hard disk now" and click "Create."


Select "VDI (VirtualBox Disk Image)" as the hard disk file type.
Choose either "Dynamically allocated" (recommended for flexibility) or "Fixed size" (for better
performance).
Allocate at least 25 GB of space for the virtual hard disk.

5. Mount Ubuntu ISO:

With the VM selected, click on "Settings."


In the Settings window, go to the "Storage" tab.
Under "Controller: IDE," click on the empty disk icon next to "Controller: IDE."
On the right side, click on the disk icon next to "Optical Drive" and choose "Choose a disk file."
Select the Ubuntu ISO you downloaded.

2
07113702021 OS with LINUX LAB BCA-V(M2)

6. Start the Virtual Machine:

With the VM selected, click "Start."


The VM will boot from the Ubuntu ISO. Follow the on-screen instructions to install Ubuntu.

7. Install Ubuntu:

Choose your language and click "Install Ubuntu."


Follow the installation wizard, selecting options like keyboard layout, updates, and user account creation.

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.

a) Install VirtualBox Guest Additions (Optional):

In the running VM, go to the "Devices" menu in the VirtualBox window.


Choose "Insert Guest Additions CD image."
Open a terminal in Ubuntu and run the following commands:

b) Reboot the VM:

After the Guest Additions installation is complete, restart the VM.

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.

S.No Command Name Option Description


1 cal -m , -y Cal command is used to see the calendar of a specific month or
whole year.
2 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.
3 hostname It is used to obtain the domain name system and set the system
Hostname or network information system domain name.
4 who Who command is a tool print information about users who are
currently logged in.
5 man It is used to display the user manual of any command that we
can run on the terminal.
6 ls Display directory
7 arch Arch command is used to get the current computer architecture.
8 whoami It display your login name
9 uname It display the information about the system.
10 uptime It tells how long the system has been running.
11 whatis It is used to get a outline manual page descriptions.
12 echo Echo command is used for displaying lines of text or string
which are passed as argument on the command line.
13 df It is used to display information related to file system about
total space and available space.
14 du It is used for disuses.
15 w It is used to display information about all user logged into the
Current system .

Cal

Fig 1.1 - Calendar

4
07113702021 OS with LINUX LAB BCA-V(M2)

date

Fig 1.2 – Date and Time

hostname

Fig 1.3 – Domain Name System


who

Fig 1.4-

man

Fig 1.5- Logged in Users

ls

Fig 1.6-Directory

5
07113702021 OS with LINUX LAB BCA-V(M2)

arch

Fig 1.7-Computer Architecture

Whoami

Fig 1.8-Login Name

uname

Fig 1.9- About System

uptime

Fig 1.10-System Runtime

6
07113702021 OS with LINUX LAB BCA-V(M2)

whatis

Fig 1.11-Online Manual Description

echo

Fig 1.12-Display Text

df

Fig 1.13- Information About File System

7
07113702021 OS with LINUX LAB BCA-V(M2)

Du

Fig 1.14-Disuses
w

Fig 1.15-User Logged

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)

cat>,cat ,cat >>,

cp with options(-i,-v,-r)

mv with options(-i,-v),

9
07113702021 OS with LINUX LAB BCA-V(M2)

rm WITH OPTIONS (-i,-v-r)

mkdir, rmdir, pwd, cd, cd .., cd/, touch

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)

ls with options(-l,-a,-F,-h,-i, - s, -t, -r, -R, -ld,-li)

wc with (w,l,c)

Q5.Create and verify a new file using the cat command.


a) display its contents

11
07113702021 OS with LINUX LAB BCA-V(M2)

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.

12
07113702021 OS with LINUX LAB BCA-V(M2)

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.

13
07113702021 OS with LINUX LAB BCA-V(M2)

2kirat.tx 28@kirat.
txt

kirat.txt kirat28. kirat@28 kirat@sa


txt .txt ini.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)

Q8. Write a shell script to find the factorial of given integer.


Ans. Code:

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)

Q13. Write a C program to create a zombie process.


Ans. Code:

Output:

23
07113702021 OS with LINUX LAB BCA-V(M2)

Q14. Write a C program to illustrate how an orphan is created.

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)

Q16. File Permission Commands using

chmod commands with options: u-r,u+rw,o-r, o+x,g-x,o-r,o=x,gx., a=rw, ugo=rwx

Chmod commands : set permission to file: 644, 541, 421, 766, 725, 022

26
07113702021 OS with LINUX LAB BCA-V(M2)

Change ownership of file to new user BCA

Change group ownership of file to ‘R’

27
07113702021 OS with LINUX LAB BCA-V(M2)

Write basic shell script to display the table of a number.

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)

Q21. Write a basic shell script to list all directories.


Ans.

Code:

Output:

32
07113702021 OS with LINUX LAB BCA-V(M2)

Q22. Write a basic shell script to display greatest of three number.


Ans. Code:

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)

Q24. To print the following patterns:

*
***
*****
*******

Ans. Code:

Output:

35

You might also like