Advanced Linux Shell Scripting:
Day 5 Task of 90daysofdevops challenge

Hello all, I'm Deepika Pinjarla! I'm a passionate Devops Engineer. I like sharing my knowledge and insights through my writing, and I'm here at Hash node. On my blog, you'll find articles covering a wide range of topics related to DevOps. My goal is to provide valuable content that helps learners in their journey. Join me on this learning adventure as we explore the wonderful world of DevOps together!
Feel Free to provide your valuable feedbacks or suggestions for the blogs, if any corrections need to update, please inform me in the comments. Thanks in Advance! Have fun while learning:)
Task 1: Write a bash script createDirectories.sh that when the script is executed with three given arguments (one is directory name and second is start number of directories and third is the end number of directories ) it creates specified number of directories with a dynamic directory name.
First of all, we need to create a file with the name createDirectories.sh

Then now open texteditor nano createDirectories.sh and start writing the script.
Start with #!/bin/bash and then pass three arguments, "first argument indicates the directory name, second argument indicates startnumber and whereas third argument indicates the endnumber"
Take a for loop putting the condition.Here mkdir reads the directoryname.
You can pass the arguments like this ./createDirectory.sh dir 1 90
dir means directoryname, 1 means startnumber, 2 means endnumber


with the help of ls command the list of directories which are created are displayed.

Task 2: Create a Script to backup all your work done till now.
Create a directory mkdir backupscripts.sh, and then with the help of chmod make it as executable file like chmod 777 backupscripts.sh.
Open a nano terminal nano backupscripts.sh and write the script.
First of all, Create two variables backup_dir, Source_dir and provide the complete paths where it needs to backup the files and for which you need backup.
Then Set the current date and time as the backup file name, Create the backup archive, put a if else condition once the condition is satisified it prints backup created successfully.

To execute the script ./backupscripts.sh and then it will provide the ouptut.

Task 3: What is Cron and Crontab, to automate the backup Script
Cron is a service or utility which allows to schedule or automate the tasks in a particular Interval.
Crontab is the command used to create, edit, and manage cron jobs.
or set of files which you want to execute at background in the given time.
Suppose if you want to automate a task which needs to run 365 days

Minute Hour DayofMonth Month DayofWeek [command]
*****
Here the asterik denotes that it should run all the time.
We can also provide particular min,hour,dayofmonth,month,dayofweek followed by command
Task 4: Write about User Management
User management involves the administration and control of user accounts on a computer system.
It includes tasks such as creating, modifying, and deleting user accounts, setting permissions and access levels, managing user passwords, and enforcing security policies.
User management is an important aspect of system administration and helps ensure the security and proper functioning of a computer system.
Task 5: Create 2 users and just display their Usernames
To Create two users by using simple commands:
adduser pen
adduser pencil

we can check the usernames by using id <username>
id pen
id pencil
Conclusion:
Mastering advanced Linux shell scripting empowers DevOps professionals to automate tasks, streamline processes, and improve overall efficiency and reliability in their daily operations. It enhances the ability to work with infrastructure as code, integrate and orchestrate various tools, and tackle complex challenges in the DevOps ecosystem.
Have Fun whiel Learning:)




