# Day 4 Task: 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** `#!/bin/bash?` **can we write** `#!/bin/sh` **as well?**

**#!/bin/bash** is called a shebang or hashbang, and it is a special syntax that appears at the beginning of a script file. It tells the operating system which interpreter to use for executing the commands in the script. In this case, **#!/bin/bash** specifies that the commands in the script should be interpreted by the Bash shell.  
Yes, it is possible to use **#!/bin/sh** instead of **#!/bin/bash**. However, it's important to note that /bin/sh may not always be the same shell as Bash, as it can vary depending on the operating system and distribution. In some cases, /bin/sh may point to a different shell, such as Dash, which may not support all of the features of Bash. If you want to use Bash-specific features in your script, it's better to specify **#!/bin/bash** to ensure that the script is executed by Bash.

**Write a Shell Script which prints** `I will complete #90DaysOofDevOps challenge ?`

**Steps:**

* Sign in to the AWS Management Console at [**console.aws.amazon.com**](http://console.aws.amazon.com) **and create an EC2 instance with Ubuntu Server 22.04 AMI**
    
* Create a shell script with the name [**devops.sh**](http://devops.sh)
    
* write down the script in DevOps.sh file to execute.
    
* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686623115738/37a3c015-dcfd-4e9a-aead-47dedf852438.png align="center")
    
    * Provide execute permission to [**devops.sh**](http://devops.sh) file via cmd: `chmod 755` [`devops.sh`](http://devops.sh)
        
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686622989838/7fef392a-dff3-43cd-bfc5-9f6367811ac6.png align="center")

* Write a Shell Script to take user input, input from arguments and print the variables.
    
    Create a shell script with the name [**age.sh**](http://input.sh) via cmd: `vi` [`age.sh`](http://input.sh)
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686624367803/29564910-c16c-4e62-adc0-62a028fdfd68.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1686624544194/cdbebe00-78ee-4043-a9cf-380f67825624.png align="center")
    

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

**Steps**:

* Create a shell script with the name [**compare.sh**](http://compare.sh) via cmd: `touch` [`compare.sh`](http://compare.sh)
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685201016280/ce588f3d-73c5-4c60-8aa4-3f02a481c130.png?auto=compress,format&format=webp align="left")

* Edit [**compare.sh**](http://compare.sh), write the below commands and save the file
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685201141977/a51ea558-9e2e-42d3-a098-fb41b0b57e43.png?auto=compress,format&format=webp align="left")

* Provide execute permission to [**compare.sh**](http://compare.sh) file via cmd: `chmod 755` [`compare.sh`](http://compare.sh)
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685201325019/2c9e595e-90ef-4823-a947-061583f8e572.png?auto=compress,format&format=webp align="left")

* run [**compare.sh**](http://compare.sh) like below
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1685202135097/31894b0d-3ead-43a2-a877-a7ee9121c44a.png?auto=compress,format&format=webp align="left")

Thank you!
