My DevOps Learning Journey: Week 2 – SSH, Shell Scripting, and Automation
Hello everyone! 👋
This week has been an exciting one in my DevOps learning journey. I’ve been diving deep into shell scripting and secure connections to AWS. I also created some cool automation scripts that I’m proud to share with you!
Connecting to AWS with SSH 🖥️🔑
One of the first things I learned was how to securely connect my Linux system to an AWS EC2 instance via SSH. If you're working with AWS and Linux, this is a must-know skill! I've written a step-by-step guide on Hashnode if you'd like to see how it's done.
👉 Check out the SSH connection guide here!
Learning Shell Scripting Basics 🐚
This week, I also took a deep dive into shell scripting and learned some interesting concepts that have opened up the door to automating tasks efficiently. Here are some of the concepts I explored:
Shebang (
#!/bin/bash
): The line that tells your script which interpreter to use (in this case, bash).Variables: You can store values like this:
name="DevOps" echo "Hello, $name"
Functions: Reusable pieces of code:
greet() { echo "Hello, $1!" } greet "DevOps"
Arithmetic Operations: You can even do basic math inside scripts:
num1=10 num2=5 sum=$((num1 + num2)) echo "The sum is $sum"
Suppressing Output: One interesting thing I learned was how to hide error messages or outputs. If you don’t want to show errors or output, you can send them to
/dev/null
, which is basically a "black hole" for output.<command> &> /dev/null
: This command hides both normal output (stdout) and error messages (stderr) by sending them to/dev/null
. It’s the same as:ff &> /dev/null
Here the
ff
is a random command that returns an error.Replace
ff
with your command.ls 2> /dev/null
: This one only hides errors, while normal output is still visible. For example, if I run:ls /nonexistent/folder 2> /dev/null
The error (if the folder doesn’t exist) will be suppressed, but if it exists, the files will be listed.
Shell Scripts I Wrote 💻
To put my learning into practice, I wrote several shell scripts to automate some tasks. Here are a few that I found particularly useful:
Installing Software Across Platforms: I wrote a script where you pass the name of a software, and it installs it on the machine, regardless of whether it's a Linux or macOS system.
- GitHub Link: Install Software Script
Find the Top 5 Largest Files: This script takes a directory as an argument and lists the top 5 largest files in that directory.
- GitHub Link: Find Largest Files Script
Service Status Checker: A script that checks the status of a service passed as an argument, like checking if Apache or MySQL is running.
- GitHub Link: Service Status Checker
Disk Utilization Checker: I wrote this script to monitor disk utilization on the system. It’s great for keeping an eye on storage usage!
- GitHub Link: Disk Utilization Script
Find and Delete Old Files: This script searches for files older than a specified number of days (passed as an argument) and deletes them. Great for cleaning up old backups or logs!
- GitHub Link: Find and Delete Old Files Script
Automated Backups: A backup automation script that takes a list of directories to back up and a destination directory, making backups a breeze.
- GitHub Link: Backup Automation Script
What’s Next? 🚀
Next week, I'll continue my learning by writing even more practical scripts, like deployment scripts and other automation tasks. I’m also going to dive into computer networking concepts, which are essential for DevOps. This includes:
The OSI model and TCP/IP model
Learning about CIDR and the various networking protocols used
Setting up a VPC (Virtual Private Cloud) with subnets on AWS
I’m really excited about what's coming next and can't wait to share more updates with you all!
Thanks for reading, and feel free to drop me any tips or resources you think might be helpful!
Subscribe to my newsletter
Read articles from Abhishek Prajapati directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Abhishek Prajapati
Abhishek Prajapati
I am a passionate Software Engineer with over two years of experience in the tech industry, specializing in Full Stack Development and DevOps practices. Currently, I work on innovative projects in the automotive sector, where I develop and automate solutions that enhance user experience and streamline operations. With a keen interest in cloud technologies, automation, and infrastructure management, I am dedicated to mastering the DevOps landscape. I believe in simplifying complex concepts and sharing practical insights to help others in their learning journeys. Join me as I document my experiences, challenges, and triumphs in the world of DevOps!