Basic Linux Shell Scripting for DevOps Engineers

Basic Linux Shell Scripting for DevOps Engineers

Day 4 of 90daysofdevops

What is Shell?

  • Shell is a UNIX term for an interface between a user and an operating system service.

  • Shell provides users with an interface and accepts human-readable commands into the system and executes those commands which can run automatically and give the program’s output in a shell script.

What is Kernel?

  • A Kernel is at the nucleus of a computer. It makes the communication between the hardware and software possible. While the Kernel is the innermost part of an operating system, a shell is the outermost one.

What is Linux Shell Scripting?

  • Shell Scripting is an open-source computer program designed to be run by the Unix/Linux shell. Shell Scripting is a program to write a series of commands for the shell to execute.

  • It can combine lengthy and repetitive sequences of commands into a single and simple script that can be stored and executed anytime which, reduces programming efforts.

How to write Shell Script in Linux

  • Shell Scripts are written using text editors. On your Linux system, open a text editor program, and open a new file to begin typing a shell script or shell programming.

  • Then give the shell permission to execute your shell script that is it has all Read, Write, Execute permission enabled for the file or directory and put your script at the location from where the shell can find it.

  • Once it has all the permission, the color of file / dir has changed to green for execution.

  • "#!" is an operator called shebang which directs the script to the interpreter's location. So, if we use "#! /bin/sh" the script gets directed to the bourne-shell.

  • in /bin/bash, bash is A.K.A Bourne Again SHell we can write instead of /bin/sh as both are directed to bash shell location.

TASK

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

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

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

Thank You,

Abhisek Moharana