Table of contents
Hello learners! Today we will be learning about Shell Scripting but before that we shall learn a few terminologies that help us understand this better.
What is Kernel?
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?
A shell is a special user program which provides an interface to user to use operating system services. Shell accepts human readable commands from user and convert them into something which kernel can understand. The shell gets started when the user logs in or start the terminal.
What is Linux Shell Scripting?
A shell script is a computer program designed to be run by a linux shell, a command-line interpreter. The various dialects of shell scripts are considered to be scripting languages. In the simplest terms, shell script is a file that contains set of commands that can be executed.
How is Shell scripting helpful for a DevOps engineer?
It helps in automating most of the tasks that are handled by a DevOps engineer thereby increasing the efficiency of the work.
A simple example of this would be a shell script which can display the system memory details of a system when executed as monitoring the system's health is one of the important responsibilities of a DevOps engineer
How to write a Shell script?
Create a file with the extension .sh using vim.
Make the file executable using chmod command.
Be sure to add the shebang line.
A shell script begins with #!/bin/bash which is the very first line of any shell script. This is called a "shebang" or "bang" and starts with #! followed by the path to the interpreter which is /bin/bash. If we do not specify the interpreter,
the default is #!/bin/sh (Bash is a superset of sh, which means that Bash supports the features of sh and provides more extensions on top of that)
Write the required commands needed for the script and run the file in any of the following ways given the file name is devops.sh
Thanks for reading my bolg :)