What is Kernel:
The kernel is one of the core sections of an operating system. It is responsible for each of the major actions of the Linux OS. This operating system contains distinct types of modules and cooperates with underlying hardware directly.
The kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system.
What is Shell:
It is an interface between the kernel and the user. It can afford the services of kernel. It can take commands through the user and runs the functions of the kernel.
Shell Types:
2.zsh
3.ksh
4.csh
5.bash
What is Linux Shell Scripting?
A Shell Script is a collection of Linux commands to be executed in sequence. The commands are written and stored in an ordinary text file. When the script is to be executed, the shell reads the file contents, interprets, and executes them as if they were typed on the shell command prompt.[A shell script is a computer program designed to be run by a Linux shell, a command-line interpreter. Typical operations performed by shell scripts include file manipulation, program execution, and printing text]
Using a shell script is most useful for repetitive tasks that may be time-consuming to execute by typing one line at a time. A few examples of applications shell scripts can be used for include: Automating the code compiling process. Running a program or creating a programming environment.
Tasks:
Explain in your own words and examples, what is Shell Scripting for DevOps.
Shell is a command-line interpreter and shell script is nothing but a list of commands executed by the shell, Operations performed by the shell script include file manipulation program execution and printing text.
shell scripting in terms of DevOps used to automate tasks written in a .sh file.
What is
#!/bin/bash?
can we write#!/bin/sh
as well?This is known as shebang in Unix. Shebang is a collection of characters or letters that consist of a number sign and exclamation mark, that is (#!) at the beginning of a script
#!/bin/bash at the start or top of the script to instruct our system to use bash as a default shell
yes we can use #!/bin/bash or #!/bin/sh
Difference between #!/bin/bash and #!/bin/sh:
The shebang, #!/bin/bash when used in scripts is used to instruct the operating system to use bash as a command interpreter. Each of the systems has its own shells which the system will use to execute its own system scripts. This system shell can vary from OS to OS(most of the time it will be bash). Whereas, when the shebang, #!/bin/sh used in scripts instructs the internal system shell to start interpreting scripts.
Write a Shell Script which prints
I will complete #90DaysOofDevOps challenge
#!/bin/bash echo "I will complete #90DaysOfDevops challenge"
Write a Shell Script to take user input, input from arguments and print the variables.
#!/bin/bash echo "Enter your name" read num echo "My name is $num"
Write an Example of If else in Shell Scripting by comparing 2 numbers
save the script file with .sh extension and run as ./filename.sh on terminal/shell.
#!/bin/bash num1=4 num2=2 if [$num1 -gt $num2] then echo "$num1 is greater" else echo "$num2 is greater" fi
Thank you for reading this Blog. Hope you learned something new today! If you found this blog helpful, please like, share, and follow me for more blog posts like this in the future.
I would like to connect with you at linkedin.com/in/madhuri-patil-278b19118