Basic Linux Shell Scripting for DevOps Engineers: A Beginner’s Guide | Day 4 of 90 Days of DevOps Journey🐧

Basic Linux Shell Scripting for DevOps Engineers: A Beginner’s Guide | Day 4 of  90 Days of DevOps Journey🐧

Welcome to Day 4 of our DevOps training! Today, we’ll be diving into the world of Linux shell scripting and exploring its importance for DevOps engineers.

Let’s get started! 🚀

What is the Kernel? 🤔

The kernel is the central part of an operating system that manages the system’s resources and controls how the hardware interacts with the software. It acts as a bridge between the hardware and software, allowing them to communicate with each other.

What is the Shell? 🐚

The shell is a command-line interface that allows users to interact with the operating system by entering commands. It acts as an interpreter, translating user commands into actions that the operating system can perform.

What is Linux Shell Scripting for DevOps? 🤖

Linux shell scripting is a powerful tool for DevOps engineers, allowing them to automate tasks and streamline their workflows. By writing scripts, DevOps engineers can automate repetitive tasks, such as deploying code or managing infrastructure, saving time and increasing efficiency.

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

#!/bin/bash is known as a shebang or hashbang. It specifies which interpreter should be used to execute the script. In this case, it specifies that the script should be run using the bash shell. Yes, you can also write #!/bin/sh, which specifies that the script should be run using the sh shell.

Example 1: Write a Shell Script that prints “I will complete #90DaysOfDevOps challenge” 📝

Here’s an example of a simple shell script that prints “I will complete #90DaysOfDevOps challenge”:

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

Output:

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

Here’s an example of a shell script that takes user input and input from arguments and prints the variables:

#!/bin/bash
echo "Enter your name:"
read name
echo "Hello $name!"
echo "You entered $# arguments: $@"

Output:

Example 3: Write an Example of If-else in Shell Scripting by comparing 2 numbers 📝

Here’s an example of using if-else in shell scripting to compare two numbers:

#!/bin/bash
num1=5
num2=10
if [ $num1 -gt $num2 ]
then
    echo "$num1 is greater than $num2"
else
    echo "$num1 is less than $num2"
fi

Output:

That’s all for today! We hope you enjoyed learning about basic Linux shell scripting for DevOps engineers. Stay tuned for more exciting content in our DevOps training series! 💻👨‍💻👩‍💻

#DevOps #Linux #ShellScripting #Automation #Efficiency #90DaysOfDevOps

Did you find this article valuable?

Support Ajit Fawade by becoming a sponsor. Any amount is appreciated!