Parul University
FACULTY OF ENGINEERING AND TECHNOLOGY
BACHELOR OF TECHNOLOGY
OPERATING SYSTEM LABORATORY
(303105252)
IV SEMESTER
Computer Science & Engineering Department
Laboratory Manual
Session 2024-25
Page 1
Faculty of Engineering & Technology
Subject Name : OS Laboratory
Subject Code : 303105252
[Link] CSE Year 2nd Semester 4th
CERTIFICATE
This is to Certify that Mr./Ms. PRAVEEN KUMAR KASHYAP
With enrolment no. 2203051050425 has successfully
completed his/her Laboratory experiments inOperating System
laboratory (303105252) From the department of COMPUTER
SCIENCE AND ENGINEERING during the academic
year 2024 – 2025.
Date of Submission : ………………………. Staff In Charge: ……………………….
Head of department: ……………………….
Faculty of Engineering & Technology
Subject Name : OS Laboratory
Subject Code : 303105252
[Link] CSE Year 2nd Semester 4th
TABLE OF CONTENT
Sr. Date of Start Date of Marks (out of
Experiment Title Sign
No Completion 10)
1. Study of Basic commands of Linux.
2. Study the basics of shell programming.
3. Write a Shell script to print given
numbers sum of all digits.
Write a shell script to validate the
4.
entered date. (eg. Date format is:
dd-mm-yyyy).
Write a shell script to check
5.
entered string is palindrome or not.
Write a Shell script to say Good
6. morning/Afternoon/Evening as
you log in to system.
7. Write a C program to create a child
process
Finding out biggest number from given
8.
three numbers supplied as
command line arguments
9. Printing the patterns using for loop
10. Shell script to determine whether given
file exist or not.
Write a program for process creation
11.
using C. (Use of gcc
compiler).
12. Implementation of FCFS & Round
Robin Algorithm.
13. Implementation of Banker’s Algorithm.
PRACTICAL - 1
AIM: Study of Basic commands of Linux/UNIX.
BASIC LINUX COMMANDS:
1. pwd :
Print Working Directory
DESCRIPTION:
pwd prints the full pathname of the current working directory.
SYNTAX:
Pwd
OUTPUT:
2. cd:
Change Directory
DESCRIPTION:
It allows you to change your working directory. You use it to move around within the hierarchy of your
file system.
SYNTAX:
cd directory_name
OUTPUT:
3. cd .. :
DESCRIPTION:
Move up one directory from present directory we use cd .. command.
SYNTAX:
cd ..
OUTPUT:
4. ls :
list all the files and directories
DESCRIPTION:
To list all files and folders in the current directory in the column format we use ls command.
SYNTAX:
ls [options]
OUTPUT:
5. mkdir:
MakeDirectory
DESCRIPTION:
mkdir stands for "make directory". The mkdir command allows you to create directories from within the terminal.
SYNTAX:
mkdir filename
OUTPUT:
6. head
DESCRIPTION:
head, by default, prints the first 10 lines of each FILE to standard output.
SYNTAX:
head directory_name
OUTPUT:
7. tail:
DESCRIPTION:
tail is a command which prints the last few number of lines (10 lines by default) of a certain file, then
terminates.
SYNTAX:
tail directory_name
OUTPUT:
8. mv :
Moving (and Renaming) Files
DESCRIPTION:
The mv commands are equivalent to the copy-paste and cut-paste commands in Windows. But since Linux
doesn’t really have a command for renaming files, we also use the mv command to rename files and folders.
SYNTAX: mv
mv source destination(OR mv oldname newname)
OUTPUT:
9. rmdir :
Remove Directory
DESCRIPTION:
If the specified directory does exist, rmdir removes or delete it. More than one directory may be specified
when calling rmdir.
SYNTAX:
rmdir directory
OUTPUT:
10. cp :
Copy Files
DESCRIPTION:
The cp command is used to make copy of files and directories.
SYNTAX:
cp source destination
OUTPUT:
11. rm:
Romove Directory
DESCRIPTION:
The rm command deletes files and directories. But we need to caution because deleted files and directories cannot
be recovered.
SYNTAX:
rm directory_name
OUTPUT:
12. echo:
DESCRIPTION:
Display text on the screen.
SYNTAX: echo yourtext
OUTPUT:
13. clear:
DESCRIPTION:
Used to clear the screen
SYNTAX: clear
OUTPUT:
14. date :
DESCRIPTION:
display current date and time.
SYNTEX: date
OUTPUT:
15. cat:
DESCRIPTION:
The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display content of the
file, copy the content of one file to another file, and more.
SYNTEX: cat file_name
OUTPUT:
16. touch:
DESCRIPTION:
create a new empty file
SYNTEX:
touch file_name
OUTPUT:
17. tar:
DESCRIPTION:
The tar command in Linux is used to create and extract archived files. We can extract multiple different archive files using
the tar command. To create an archive, we use the -c parameter, and to extract an archive, we use the -x parameter.
SYNTEX:
tar -cvf [Link] file1 file2
tar -xvf [Link]
OUTPUT:
18. whoami:
DESCRIPTION:
The whoami command in Linux returns the current user’s username. It stands for “who am I?” and it’s often used to determine
the current user’s identity in shell scripts or the terminal.
SYNTEX:
whoami
OUTPUT:
19. man:
DESCRIPTION:
The man command in Linux is used to display the manual page for a specific command. It provides detailed information about
the command, including its syntax, options, and examples.
SYNTEX:
man command_name
OUTPUT:
20. FREE:
DESCRIPTION:
Displays RAM details in Linux machine.
SYNTEX:
free
OUTPUT:
21. grep:
DESCRIPTION:
The grep command is a powerful and versatile text search tool in Linux and Unix-based operating systems. It can search for
specific patterns or strings in one or more files and filter the output of other commands.
SYNTEX:
any_command_with_output | grep “string”
OUTPUT:
22. sort:
DESCRIPTION:
The sort command is used to sort lines in a text file or standard input in Linux and Unix-based operating systems. It can be used
to sort lines in ascending or descending order and to perform other sorting operations.
SYNTEX:
sort filename
OUTPUT:
23. alias:
DESCRIPTION:
We have some commands that we run very frequently while using the terminal. It could be rm -r or ls -l, or it could be something
longer like tar -xvzf. So it’s a time we need to create an alias. In simple terms, it’s another name for a command that we’ve
defined.
SYNTEX:
alias newName=”command”
OUTPUT:
24. passwd:
DESCRIPTION:
The passwd command lets you set the password for our own account, or if you have the permissions, set the password for other
accounts.
SYNTEX:
passwd
OUTPUT:
25. ps:
DESCRIPTION:
The ps command summarizes the status of all running processes in your Linux system at a specific time. Unlike top and htop, it
doesn’t update the information automatically.
SYNTEX:
ps
OUTPUT:
PRACTICAL NO: 2
Aim: Study the basics of shell programming.
What is a Shell? An Operating is made of many components, but its two prime components
are –
• Kernel
• Shell
A Kernel is at the nucleus of a computer. It makes the communication between the hardware
and software possible. While the Kernel is the innermost part of an operating system, a shell
is the outermost one.
A shell in a Linux operating system takes input from you in the form of commands, processes
it, and then gives an output. It is the interface through which a user works on the programs,
commands, and scripts. A shell is accessed by a terminal which runs it.
When you run the terminal, the Shell issues a command prompt (usually $), where you can
type your input, which is then executed when you hit the Enter key. The output or the result
is thereafter displayed on the terminal.
The Shell wraps around the delicate interior of an Operating system protecting it from
accidental damage. Hence the name Shell.
Types of Shell
There are two main shells in Linux:
1. The Bourne Shell: The prompt for this shell is $ and its derivatives are listed below:
• POSIX shell also is known as sh
• Korn Shell also knew as sh
• Bourne Again Shell also knew as bash (most popular)
What is Shell Scripting?
Shell scripting is writing a series of command for the shell to execute. It can combine lengthy
and repetitive sequences of commands into a single and simple script, which can be stored
and executed anytime. This reduces the effort required by the end user.
Let us understand the steps in creating a Shell Script
1. Create a file using a vi editor(or any other editor like Nano,Nano’s Pico inspired editor).
Name script file with extension .sh
2. Start the script with #! /bin/sh
3. Write some code.
4. Save the script file as [Link]
5. For executing the script type bash [Link]
"#!" is an operator called shebang which directs the script to the interpreter location. So, if
we use"#! /bin/sh" the script gets directed to the bourne-shell.
Adding shell comments
Commenting is important in any program. In Shell
programming, the syntax to add a comment is
#comment
Let understand this with an example.
1. Adding a comment
[Link] executes only the command
It ignores the comment ‘# Sample Line For Commant’
What are Shell Variables?
As discussed earlier, Variables store data in the form of
characters and numbers. Similarly, Shell variables are used to
store information and they can by the shell only.
For example, the following creates a shell variable and then
prints it:
Below is a small script which will use a variable
Let's understand, the steps to create and execute the script
[Link] the script
[Link] the [Link]
Praveen kashyap
[Link] the input
[Link] the remark
As we see, the program picked the value of the variable
'name' as SUJAL and 'remark' as Excellent.
This is a simple script. We can develop advanced scripts
which contain conditional statements, loops, and functions.
Shell scripting will makes our life easy and Linux
administration a breeze.
PRACTICAL NO: 3
Aim: Write a Shell script to print given numbers sum of all digits.
PRACTICAL NO: 4
Aim: Write a shell script to validate the entered date. (eg.
Date format is: dd-mm-yyyy).
PRACTICAL 5
AIM :- Write a shell script to check entered string is palindrome or not.
PRACTICAL 6
AIM:- Write a Shell script to say Good morning/Afternoon/Evening as you log
in to system.
PRACTICAL 7
AIM:- Write a C program to create a child process.
PRACTICAL 8
AIM:- Finding out biggest number from given three numbers supplied as
command line arguments.
PRACTICAL 9
AIM:- Printing the patterns using for loop.
PRACTICAL 10
AIM:- Shell script to determine whether given file exist or not.
PRACTICAL 11
AIM:- Write a program for process creation using C. (Use of gcc compiler).
PRACTICAL 12
AIM:- Implementation of FCFS &Round Robin Algorithm.
PRACTICAL 13
AIM:- Implementation of Banker's Algorithm.