90DaysOfDevOps:Day #4

Goutam KumarGoutam Kumar
2 min read

What is Shell?

A shell is a program that provides the traditional, text-only user interface for Linux and other Unix-like operating

systems. Its primary function is to read commands that are typed into a console or

terminal window (an all-text window) in a GUI and then execute them.

The term shell derives its name from the fact that it is an outer layer of an operating system. A shell is an interface

between the user and the internal parts of the operating system (at the very core of which is the kernel).

A user is in a shell (i.e., interacting with the shell) as soon as that user has logged into the system. A shell is the

most fundamental way that a user can interact with the system, and the shell hides the details of the underlying operating

system from the user.

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

Shell script is basically a computer program which divided into two part SHELL & SCRIPT.

• Shell is an Interpreter which converts low level & high level language in to machine language for Unix based Operating

systems .

• Script stands for Set of Commands.

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

#!/bin/bash

Essentially it tells your terminal that when you run the script it should use bash to execute it.

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

vim 90daysdevopschallenge.sh

#!/bin/bash

echo "I will complete #90DaysOofDevOps challenge"

press :wq(enter)

chmod 770 90daysdevopschallenge.sh

./90daysdevopschallenge.sh(to make executable file)

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

vim userinput.sh

echo "Enter the username:"

read username

echo "The name is :$username"

press :wq(enter)

chmod 700 userinput.sh

./userinput

#input from the argument and print the variables

vim argument.sh

#!/bin/bash

Welcome to the 90daysofDevOps Challange!Mr.$1.

let us start the practice of $2.

chmod argument.sh

./argument.sh Goutam Devops

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

#!/bin/bash

echo "enter your choice:burger/pizza!"

if [ "$1" = "burger" ]

then

echo "Enjoy the burger!"

else

echo "Enjoy the pizza!"

fi

0
Subscribe to my newsletter

Read articles from Goutam Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Goutam Kumar
Goutam Kumar