DEV Community

Kanavsingh
Kanavsingh

Posted on

2 1 1 1 1

๐ŸŒˆ Day 5 of #90DaysOfDevOps: Unlocking Advanced Linux Shell Scripting & User Management! ๐Ÿš€

Hey, Dev.to fam! ๐ŸŽ‰ Itโ€™s Day 5 of my #90DaysOfDevOps challenge, and today, weโ€™re going deeper into the magic of Linux shell scripting and user management. Let me walk you through the exciting things I learned! โœจ

๐Ÿ—๏ธ Creating 90 Directories in a Snap!
Why click and create folders when Linux does it all in seconds? ๐Ÿš€ Hereโ€™s the command that gave me 90 directories in a blink:

mkdir day{1..90}

Just like thatโ€”90 directories were created! Automation saves time, which is what DevOps is all about, right? โณ

๐Ÿ› ๏ธ Custom Directory Creation Script
To spice things up, I wrote a Bash script to create directories based on user input. Run the script with three arguments: the directory name, starting number, and ending number. For example:

./createDirectories.sh day 1 90

Creates day1, day2, all the way up to day90. ๐ŸŽฏ Hereโ€™s the full script:

_#!/bin/bash
prefix=$1
start=$2
end=$3

for i in $(seq $start $end)
do
mkdir "$prefix$i"
done
echo "Your directories are ready! ๐ŸŽ‰"_

๐Ÿ” The Power of Backups in DevOps
As a DevOps engineer, taking backups is crucial. I wrote a simple script to back up my work and will soon integrate it with cron to automate it! Imagineโ€”never worrying about losing data again. ๐Ÿ”’

๐Ÿ‘ฅ Exploring Linux User Management
Users are the lifeblood of any system, and managing them is critical. I created two new users today:

sudo useradd alice
sudo useradd bob

And voila! Alice and Bob are now part of my Linux world. ๐ŸŒ

๐Ÿค– Automating with Cron
Automation is what makes DevOps powerful, and today I read up on cron. Iโ€™ll use crontab to schedule my backup script so it runs daily without any manual input. Just set it, forget it, and relax! ๐Ÿ˜Ž

๐Ÿ“š Takeaway:
Today's focus on advanced scripting and user management has deepened my understanding of Linux as a DevOps engineer. Automating repetitive tasks frees up time to work on bigger, more important challenges. What are your favorite Linux tips? Letโ€™s chat in the comments! ๐Ÿ’ฌ

DevOps #Linux #BashScripting #Automation #CronJobs #BackupScripts #UserManagement #CodingJourney

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (1)

Collapse
 
ar0mankhan profile image
Arman Khan โ€ข

mkdir $prefie{$start..$end}

would do the same.
thanks for the knowledge though, i didn't knew
for i in $(seq thing

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs