Basic Linux Shell Scripting for DevOps Engineers.

Basic Linux Shell Scripting for DevOps Engineers.

For aspiring DevOps engineers, it is essential to know shell Scripting or bash scripting. In this shell scripting for DevOps guide, I will share my tips & resources to learn Linux shell scripting the right way.

Here is what we are going to look at in this blog.

  1. What is Kernel.

A kernel is the core component of an operating system that manages system resources and provides essential services for applications to run.

The kernel is a computer program that is the core of a computer’s operating system, with complete control over everything in the system.

  1. 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.

  2. 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.

  3. Explain in your own words and examples, what is Shell Scripting for DevOps.

    Shell scripting in DevOps is like creating a set of instructions for your computer to automate repetitive tasks. It helps save time, reduce errors, and make processes smoother. Whether it's deploying software, managing configurations, or handling backups, shell scripts make these tasks easier by letting you write commands in a language your computer understands. It's a key skill for making the development and operations processes more efficient and less prone to mistakes.

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

The #!/bin/bash is called a shebang or hashbang. It's a special line at the beginning of a script that tells the system which interpreter should be used to execute the script. In this case, it specifies that the Bash shell should be used.

yes, you can also use #!/bin/sh as a shebang, and it indicates that the script should be interpreted using the system's default shell, which is often Bash but can vary depending on the Unix-like system.

Using #!/bin/sh is generally more portable because it relies on the POSIX shell standard, making it compatible with a wider range of Unix-like systems. However, if your script uses features specific to Bash, you might want to use #!/bin/bash to ensure it runs with Bash explicitly.

In many cases, both #!/bin/bash and #!/bin/sh will work fine, and the choice depends on the specific requirements and the features you use in your script.

  1. Write a Shell Script which prints I will complete #90DaysOofDevOps challenge

    if you want to write this type of shell script yeah you can do it

    #!/bin/bash

    echo "I will complete #90DaysOofDevOps challenge"

I will cover tghe shell scripting problems and solution in next blog

Thanks

Happy Learning :)