Day 4 of My #90DaysOfDevOps Challenge: Basic Linux Shell Scripting for DevOps Engineers

👋 Hi, I'm SIDDHARTH PATIL, a DevOps learner diving into Linux and cloud computing. 🚀 Currently mastering the basics and excited for the journey ahead! 💻☁️ #DevOps #Linux #CloudComputing"
Today’s task is all about understanding the fundamentals of Linux shell scripting, an essential skill for DevOps engineers. Let’s dive into some basic concepts and hands-on tasks that will help automate various processes and manage Linux systems more efficiently.
What is a Kernel?
The kernel is the heart of an operating system. It manages all the hardware resources, like CPU, memory, and devices, and acts as a bridge between the software and the hardware. Think of it as the core program that controls everything on your machine, ensuring that applications get the resources they need while keeping the system stable.
What is a Shell?
A shell is the user interface for interacting with the operating system. It takes commands from you (the user), interprets them, and sends them to the kernel for execution. The shell can also execute commands stored in files called "scripts." In Linux, the most common shells are bash (Bourne Again Shell) and sh (Bourne Shell).
What is Linux Shell Scripting?
Linux shell scripting is writing a series of commands in a file (a script) that can be executed by the shell. This is especially useful for automating repetitive tasks, performing system administration, or configuring servers in DevOps. For example, shell scripts can be used to set up a web server, deploy an application, or monitor system performance.
Tasks
1. What Shell Scripting Means for DevOps
In DevOps, shell scripting is a crucial tool for automating manual processes. It simplifies repetitive tasks, allowing engineers to focus on more complex challenges. For example, you can use a shell script to:
Automate the deployment of applications.
Manage system backups.
Monitor server logs for errors.
Shell scripts are lightweight, and because Linux systems are prevalent in cloud and server environments, scripting becomes essential for configuring and maintaining infrastructure.
2. What is #!/bin/bash? Can We Use #!/bin/sh?
The line #!/bin/bash is called a shebang. It tells the system which interpreter to use to run the script. In this case, /bin/bash points to the Bash shell. If you write #!/bin/sh, it will invoke the sh shell, which is a simpler version of Bash with fewer features.
Both can be used, but if you’re using advanced features of Bash, you should stick with #!/bin/bash.
3. Writing a Simple Shell Script
Here’s a script that prints a motivational message for our challenge:
#!/bin/bash
echo "I will complete the #90DaysOfDevOps challenge."
Output:
I will complete the #90DaysOfDevOps challenge.
To run this script, save it as challenge.sh, and use the following commands:
chmod +x challenge.sh
./challenge.sh
4. Shell Script with User Input and Arguments
Here’s a script that takes user input and arguments from the command line:
#!/bin/bash
# Taking user input
echo "Enter your name:"
read name
echo "Hello, $name!"
# Taking input from arguments
echo "The first argument is: $1"
echo "The second argument is: $2"
To run this script, save it as input_script.sh, and execute it like this:
chmod +x input_script.sh
./input_script.sh DevOps Linux
Sample Output:
Enter your name:
Siddharth
Hello, Siddharth!
The first argument is: DevOps
The second argument is: Linux
5. Example of an If-Else Statement in Shell Scripting
Here’s a simple example to compare two numbers:
#!/bin/bash
num1=10
num2=20
if [ $num1 -gt $num2 ]; then
echo "$num1 is greater than $num2"
else
echo "$num1 is less than or equal to $num2"
fi
Output:
10 is less than or equal to 20
To run this script, save it as compare.sh and execute it:
chmod +x compare.sh
./compare.sh
Were the Tasks Challenging?
The tasks today were a great introduction to basic Linux shell scripting. The concepts were clear, and it was exciting to see how powerful scripting can be for automation in a DevOps role. The most interesting part was writing scripts to take user input and arguments. Overall, the hands-on tasks helped solidify my understanding of Linux shell scripting fundamentals.
That’s it for Day 4! Don’t forget to share your learnings with the DevOps community. Shell scripting is a skill that will serve you well throughout your journey, making your work faster, more efficient, and automated. See you tomorrow for more DevOps fun!
Let’s learn together and grow together in the world of DevOps! 🌱🚀 #DevOpsJourney #LearningTogether #GrowthMindset #TechCommunity #TrainWithShubham #90DaysOfDevOps
Follow my #90DaysOfDevOps challenge on LinkedIn, and stay tuned for more updates!




