DAY-4 basic linux shell scripting

DAY-4 basic linux shell scripting

what is kernel?

The kernel is a fundamental part of an operating system that acts as a bridge between the hardware and software components of a computer. It is responsible for managing the system's resources, such as memory, input/output devices, and CPU time, and providing a platform for running applications and processes.

The kernel is the core of the operating system, and all other components, such as device drivers, system libraries, and user interfaces, are built on top of it. It provides a set of services and abstractions that allow applications to interact with the hardware in a consistent and secure manner.

What is Shell?

In computing, a shell is a command-line interface (CLI) that provides an interface between the user and the operating system. It allows users to interact with the operating system and execute commands to perform various tasks, such as launching applications, managing files and directories, and manipulating system settings.

A shell is a special user program that provides an interface for the user to use operating system services. Shell accepts human-readable commands from users and converts them into something which the kernel can understand. It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or start the terminal.

What is Linux Shell Scripting?

Shell scripts are computer programs that automate repetitive tasks and perform system administration functions on a Linux system. They manipulate files and directories, execute programs and commands, and print text to the command line interface. They provide a flexible and efficient way to manage system resources and improve performance for Linux system administrators and developers.

Shell scripts are also used to execute programs and commands on a Linux system. This can include launching applications, running batch processes, and performing system backups.

What is #!/bin/bash? Can we write #!/bin/sh as well?

The shebang or hashbang at the beginning of a shell script (#!/bin/bash or #!/bin/sh) specifies which interpreter should be used to execute the script. Bash is an enhanced version of sh with more features and capabilities, while sh is a lightweight shell that is available on all Unix/Linux systems. Choosing the appropriate interpreter depends on the desired functionality and compatibility requirements of the script.

Wite a Shell Script which prints I will complete #90DaysOofDevOps challenge

syntax:

vi devops.sh

#!/bin/bash

echo " i will complete #90DaysOfDevOpsChallenge "

sh devops.sh

Write a Shell Script to take user input, input from arguments and print the variables.

syntax:

vi 2script.sh

#!/bin/bash

echo " hey what's your name? "

read name

echo " how are you , $name ? "

read remark

echo " I am $remark too. "

sh 2script.sh

Write an Example of If else in Shell Scripting by comparing 2 numbers

syntax:

vi 3script.sh

#!/bin/bash

echo "enter your first number"

read num1

echo "enter your second number"

read num2

if [ $num1 -gt $num2 ]; then

echo "first number is greater than second number"

elif [ $num1 -lt $num2 ]; then

echo "second number is greater than first number"

else

echo "first number is equal to second number"

fi

sh 3script.sh

Thank you for reading!!

~Soumya Mallick

Great initiative by the #trainwithshubham community. Thank you Shubham Londhe

#devops #90daysofdevops