Basic Linux Shell Scripting for DevOps Engineers.

Basic Linux Shell Scripting for DevOps Engineers.

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 special user program which provide an interface to user to use operating system services. Shell accept human readable commands from user and convert them into something which kernel can understand. It is a command language interpreter that execute 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?

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. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.

What is Shell Scripting for DevOps?

Shell scripting for DevOps is a skill that involves writing scripts using shell programming languages to automate and streamline various tasks in the field of DevOps (Development and Operations). DevOps is a set of practices that aim to automate and improve the collaboration between software development and IT operations teams. Shell scripting is a powerful tool in a DevOps engineer's toolkit for automating repetitive tasks, managing configurations, and orchestrating workflows.

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

#!/bin/bash and #!/bin/sh are shebangs or hashbangs used in the first line of a script to specify the interpreter that should be used to execute the script.

  1. #!/bin/bash:

    • This shebang indicates that the Bash (Bourne Again SHell) interpreter should be used to execute the script.

    • Bash is an enhanced version of the original Bourne shell (/bin/sh) with additional features and improvements.

  2. #!/bin/sh:

    • This shebang specifies that the system's default shell (usually a Bourne-like shell) should be used to interpret the script.

    • On many systems, /bin/sh is a symbolic link or a lightweight shell that serves as a common denominator among various Unix-like systems.

    • The choice between #!/bin/bash and #!/bin/sh depends on the requirements of your script:

      • If your script uses features specific to Bash and you want to ensure that it runs with Bash, use #!/bin/bash.

      • If your script is written in a way that is compatible with the basic features of the Bourne shell and you want to be more portable across different Unix-like systems, you might use #!/bin/sh.

      • Write a Shell Script which prints "I will complete #90DaysOfDecOps challenge"

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

      • output:-

      • Write an Example of if else in shell scripting by comparing 2 numbers

\

output:-