Day 5 - Elevating Linux Shell Scripting with User Management ๐Ÿš€

Day 5 - Elevating Linux Shell Scripting with User Management ๐Ÿš€

ยท

2 min read

Exploring Advanced Shell Scripting ๐Ÿ“œ

Automatic Directory Creation Magic ๐ŸŽฉโœจ

If you've ever wondered how I created 90 directories, it's done in seconds with a simple command:

command: mkdir day{1..90}

1: Create Directories with a Bash Script ๐Ÿ“‚๐Ÿš€

Let's turn that command into a dynamic bash script, createDirectories.sh, allowing you to create a specified number of directories with a custom name.

Execute with:

chmod createDirectories.sh

./createDirectories.sh day 1 90

2: Script to Backup Your Work ๐Ÿ“๐Ÿ’พ

Backups are essential! Create a script, backupScript.sh, to back up all your work.

3: Automate Backups with Cron ๐Ÿ”„โฐ

Explore Cron and Crontab to automate your backup script. Schedule tasks at specific intervals for unattended execution.

Cron โฐ: Cron is like the timekeeper for your Linux system. It helps you schedule and automate tasks at specific times or intervals. Imagine it as your system's personal assistant that knows when to perform certain actions without you manually triggering them.

Crontab ๐Ÿ—“๏ธ: Crontab is the schedule manager. It's like a to-do list for your system tasks. You use it to set up the when and what for your scheduled jobs. Think of it as your system's planner, where you jot down the times and tasks it needs to handle.

In short, Cron is the clock, and Crontab is the schedule it follows! โฐ๐Ÿ—“๏ธ

4: User Management ๐Ÿง‘โ€๐Ÿ’ป๐Ÿ”‘

Create two users and display their usernames using the following commands:

commands:

sudo adduser user1

sudo adduser user2

Display Usernames:

command: awk -F':' '{ print $1}' /etc/passwd | tail -n 2

Reflections on Day 5 ๐Ÿค”๐Ÿ”—

What a journey! ๐Ÿš€ Day 5 brought automation magic with directory creation, the safety net of backups, and a glimpse into user management. These skills are the building blocks of a resilient DevOps journey. ๐Ÿ› ๏ธ๐Ÿ’ป

Did you find this article valuable?

Support Nilkanth Mistry by becoming a sponsor. Any amount is appreciated!

ย