0% found this document useful (0 votes)
48 views19 pages

Yogesh Final Klss 11

Uploaded by

parthchunara799
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)
48 views19 pages

Yogesh Final Klss 11

Uploaded by

parthchunara799
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/ 19

FACULTY OF ENGINEERING AND TECHNOLOGY

BACHELOR OF TECHNOLOGY

KALI LINUX AND SHELL SCRIPTING


(303105213)

III SEMESTER

Computer Science & Engineering Department

Laboratory Manual

Session:2024-25
CERTIFICATE

This is to certify that Mr./Ms. NARWADI YOGESH with


enrolment no. 2303031260297 has successfully completed his/her
laboratory experiments in the KALI LINUX AND SHELL
SCRIPTING (303105213) from the department of COMPUTER
SCIENCE & ENGINEERING during the academic year 2024-2025.

Date of Submission:......................... Staff In charge:...........................

Head Of Department:...........................................
KALI LINUX AND SHELL SCRIPTING PRACTICAL BOOK
COMPUTER SCIENCE & ENGINEERING DEPARTMENT
PREFACE

It gives us immense pleasure to present the first edition of the KALI LINUX AND
SHELL SCRIPTING Practical Book for the B.Tech . 3rd semester students for
PARUL UNIVERSITY.

The KLSS theory and laboratory courses at PARUL UNIVERSITY,


WAGHODIA, VADODARA are designed in such a way that students
develop the basic understanding of the subject in the theory classes
and then try their hands on the experiments to realize the various
implementations of problems learnt during the theoreticalsessions.
The main objective of the KLSS laboratory course is: Learning KLSS
through Experimentations. All the experiments are designed to
illustrate various problems in different areas of KLSS and also to
expose the students to various uses.
The objective of this KLSS Practical Book is to provide a
comprehensive source for all the experiments included in the KLSS
laboratory course. It explains all the aspects related to every
experiment such as: basic underlying concept and how to analyze
a problem. It also gives sufficient information on how to interpret
and discuss the obtained results.
We acknowledge the authors and publishers of all the books which
we have consulted while developing this Practical book. Hopefully
this KLSS Practical Book will serve the purpose for which it has
been developed.
INSTRUCTIONS TO STUDENTS

1. The main objective of the KLSS laboratory is: Learning through the Experimentation. All the
experiments are designed to illustrate various problems in different areas of KLSS and also to expose
the students to various problems and their uses.
2. Be prompt in arriving to the laboratory and always come well prepared for the practical.
3. Every student should have his/her individual copy of the KLSS Practical Book.
4. Every student have to prepare the notebooks specifically reserved for the KLSS practical work: ”
KLSS Practical Book”

5. Every student has to necessarily bring his/her KLSS Practical Book, KLSS Practical Class Notebook
and KLSS Practical Final Notebook.

6. Finally find the output of the experiments along with the problem and note results in the KLSS Practical
Notebook.
7. The grades for the KLSS practical course work will be awarded based on our performance in the
laboratory, regularity, recording of experiments in the KLSS Practical Final Notebook, lab quiz,
regular viva-voce and end-term examination.
Faculty of Engineering & Technology (FET)
Parul Institute of Engineering & Technology (PIET)
Department of Computer Science & Engineering

Practical Assessment Table

Sr Page No. Mark Sign


. Practica s(10)
No l Title From To
1. Write a shell script to display a
1 greeting message using variables.
2. Create a script that uses loops to
print numbers from 1 to 10

2 Write a script to automate the process of


creating multiple directories

Experiment with different ways of


3 executing shell scripts (e.g., ./script.sh, sh
script.sh).

4 Practice text processing by writing a


script to search for a specific pattern in a
file using grep.
Write a script that demonstrates the use of
5 functions to perform repetitive tasks.

6 1. Write a script to monitor CPU


usage and send an alert if it exceeds
a certain threshold.
2. Create backup and restore scripts
for critical system files and
directories
Design custom scripts tailored to specific
7 system administration tasks in your
environment.

8 Develop a script to remotely administer


multiple Linux machines over SSH
9 Build an interactive script that prompts
users for input and performs actions
accordingly.

Kali Linux and shell scripting Laboratory 303105213


Practical 1
Practical 1

Aim:-1. Write a shell script to display a greeting message using variables.


Aim:-2. Create a script that uses loops to print numbers from 1 to 10.

Description: This practical teaches you how to create a simple shell script to greet
users using variables. In shell scripting, variables store information that scripts can use
and manipulate. This practice helps in understanding the basic usage of variables in
shell scripting and this helps you to build more complex scripts.

Tools: Kali Linux, terminal.

WHAT IS SHELL

A shell is a type of computer program called a command-line interpreter that lets Linux
and Unix users control their operating systems with command-line interfaces. Shells
allow users to communicate efficiently and directly with their operating systems.

TYPES OF SHELL

1. Bourne shell (sh)


2. Bourne-Again shell (bash)
3. C shell (csh)
4. Korn shell (ksh)
5. Z Shell (zsh)

WHAT IS SHELL SCRIPTING

A shell script is a list of commands in a computer program that is run by the Unix
shell which is a command line interpreter. A shell script usually has comments that
describe the steps. The different operations performed by shell scripts are program
execution, file manipulation and text printing. A wrapper is also a kind of shell script
that creates the program environment, runs the program etc.
1. Write a shell script to display a greeting message using variables.

#!/bin/bash

#GREET THE USER USING ECHO COMMAND


echo "welcome to the cyber security"

OUTPUT:
2. Create a script that uses loops to print numbers from 1 to 10

#!/bin/bash
#use for loop to print the number
for i in {1..10}
do
echo $i
done

#second method using for loop to print the numbers


for((i=1;i<=10;i++))
do
echo $i
done

#third method using while loop to print the numbers


while((i<=10))
do
echo $1
((i++))
done

# fourth method using while loop


i=1
while [ $i -lt 11 ]
do
echo $i
i=$((i+1))
done
OUTPUT:
Practical 2
Practical 2
Aim:- Write a script to automate the process of creating multiple directories.

Description:- This practical teaches you how to create a simple shell script to auto-
mate the process of creating multiple directories. In shell scripting, variables store
information that scripts can use and manipulate. This practice helps in understanding the
basic usage of variables in shell scripting and assists you in building more complex
scripts.
Tools:- Kali linux, terminal.

Theory:- We have to use these commands to create to create multiple directories:


1. #!/bin/bash:- This shebang line specifies that the script should be executed using the
Bash shell.
2. mkdir :- This command is used to create directories in Unix-like operating systems.
3. mkdir -p :- This command is used to create multiple directory at once and avoid
errors if parents directories already exist.
4. Chmod +x file_name :- This command is used to give script permissions to file
make it executable.
5. Bash file_name: This command is used to run the script.
6. echo "Directory '${dir_path}': created successfully": Prints a message indicating
that the directory was created successfully.
7. for loop: The for dir_name in "${directory_names[@]}" is used to iterate through
each directory name in the directory_names array.
SCRIPT:
#!/bin/bash
#set the path where new directory will create
base_path="/home/kali/Documents/newdir"
#store directory names in array
directory_names=("dir1" "dir2" "dir3" "dir4" "dir5" "dir6" "dir7" "dir8" "dir9" "dir10")
for dir_name in "${directory_names[@]}"; do
mkdir -p "$base_path/$dir_name"
echo "The Directory '$dir_name' is created successfully in '$base_path'."
done

OUTPUT:
Practical 3
Pratical 3

Aim:- Experiment with different ways of executing shell scripts (e.g., ./script.sh, sh
script.sh).

Description:- This practical teaches you how to execute shell scripts using different
methods, including './script.sh' and 'sh script.sh' commands. You will learn how to run
scripts, understand the differences between execution methods, and develop skills to write
more complex scripts. This practice helps you understand the fundamental concepts of
script execution and sets the stage for advanced scripting techniques.

Theory:-
Executing Shell Scripts
There are several ways to execute shell scripts:
➢ ./script.sh: This method is used to execute a script in the current directory. The dot (.)
represents the current directory, and the forward slash (/) is used to separate the directory
from the script name.
➢ sh script.sh: This method is used to execute a script using the sh command. The sh
command is a shell that interprets the script and executes it.

Benefits of Script Execution


Some benefits of script execution include:
➢ Automation: Scripts can automate repetitive tasks, freeing up time for more important
tasks.
➢ Consistency: Scripts ensure consistency in task execution, reducing errors and
improving reliability.
➢ Flexibility: Scripts can be modified to perform different tasks, making them flexible and
versatile.
COMMANDS TO EXECUTE SHELL SCRIPT:
1. bash script.sh
2. sh script.sh
3. ./script.sh
TO CHECK THE FILE IS EXECUTABLE OR NOT
ls -ltr
TO GIVE EXECUTABLE PERMISSION TO FILE:
chmod +x script.sh

OUTPUT:
Conclusion:- Experimenting with different script execution methods (./script.sh, sh script.sh)
has provided a solid understanding of script execution,

enabling the creation of efficient scripts that automate tasks and simplify system administration.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy