0% found this document useful (0 votes)
30 views37 pages

Kirat Os

The document discusses various Linux basic commands like cal, date, hostname, uname, uptime, whoami, who, w, echo, type, whatis, help, man, info, df, du, less and more. It provides the usage of these commands along with their options and descriptions.

Uploaded by

hewepo4344
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views37 pages

Kirat Os

The document discusses various Linux basic commands like cal, date, hostname, uname, uptime, whoami, who, w, echo, type, whatis, help, man, info, df, du, less and more. It provides the usage of these commands along with their options and descriptions.

Uploaded by

hewepo4344
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

Enolment No. - 07113702021

Ms. Suman Singh


(Associate professor CS)

Institute of Information Technology & Management,


New Delhi – 110058
Batch (2021 - 2024)
HARKIRAT SINGH BCA M2 SEM-V 07113702021

INDEX

SNO Question Date Sign


1 Write complete Steps for Install VirtaulBox and then configure Linux
(Ubantu) in VirtualBox.
2 Linux Basic Commands(cal with options(-3,-m,-y) date with formats,
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
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

SNO Question Date Sign


16 File Permission Commands using chmod commands with options: u-
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,
and make local variables as global.

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

19 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)(
20 Write basic shell script to calculate factorial of a number.
21 Write basic shell script to input the month number and generate
corresponding calendar
22 Write basic shell script to list all directories.
23 Write basic shell script to display greatest of three numbers
24 Write basic shell script to check whether the number entered by user
is prime or not.
25 To print the following patterns:-
*
***
*****
*******
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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.
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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.


HARKIRAT SINGH BCA M2 SEM-V 07113702021

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


HARKIRAT SINGH BCA M2 SEM-V 07113702021

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
HARKIRAT SINGH BCA M2 SEM-V 07113702021

arch

Fig 1.7-Computer Architecture

Whoami

Fig 1.8-Login Name

uname

Fig 1.9- About System

uptime

Fig 1.10-System Runtime


HARKIRAT SINGH BCA M2 SEM-V 07113702021

whatis

Fig 1.11-Online Manual Description

echo

Fig 1.12-Display Text

df

Fig 1.13- Information About File System


HARKIRAT SINGH BCA M2 SEM-V 07113702021

Du

Fig 1.14-Disuses
w

Fig 1.15-User Logged


HARKIRAT SINGH BCA M2 SEM-V 07113702021

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),
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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


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)

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

wc with (w,l,c)
HARKIRAT SINGH BCA M2 SEM-V 07113702021

Q5.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


HARKIRAT SINGH BCA M2 SEM-V 07113702021

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.
HARKIRAT SINGH BCA M2 SEM-V 07113702021

2kirat.txt 28@kirat.
txt

kirat.txt kirat28. kirat@28 kirat@sai


txt .txt ni.txt
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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

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


Ans. Code:

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

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


Ans. Code:

Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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

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

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
HARKIRAT SINGH BCA M2 SEM-V 07113702021

Change ownership of file to new user BCA

Change group ownership of file to ‘R’


HARKIRAT SINGH BCA M2 SEM-V 07113702021

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


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

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


Ans.

Code:

Output:
HARKIRAT SINGH BCA M2 SEM-V 07113702021

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


Ans. Code:

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

Q24. To print the following patterns:

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

Ans. Code:

Output:

You might also like