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.

Architecture of linux

What is Shell

A shell is a special user program that provides an interface for users to use operating system services. Shell accepts human-readable commands from a user and converts 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.

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

    Shell scripts are essentially text files containing commands that are executed by the shell interpreter. They provide a way to automate repetitive tasks, configure servers, manage containers, deploy applications, and much more.

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

    #! is called a SHEBANG character, it tells the script to interpret the rest of the lines with an interpreter /bin/bash. So if we change that to /usr/bin/python then it will tell the script to use a Python interpreter.

    /bin/sh and /bin/bash are both Unix/Linux shell interpreters, but they have some differences in their behavior and syntax. /bin/sh is a POSIX-compliant shell that is designed to be small and efficient, while /bin/bash is a more feature-rich shell that includes many additional features and extensions.

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

     #!/bin/bash
     echo "I will complete #90DaysOofDevOps challenge"
    

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

    We would be taking inputs from users like name and age to do this we use a command called read

     #!/bin/bash
     echo "enter your name"
     read name
     echo "$name is a good boy"
     echo "enter your age"
     read age
     echo "$name is a $age year"
    

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

     #!/bin/bash
     echo "enter num1"
     read num1
    
     echo "enter num2"
     read num2
    
     if [ $num1 -gt $num2 ]
     then
       echo "$num1 is greater than $num2"
     else
       echo "$num1 is less than or equal to $num2"
     fi
    

    Thanks for reading