Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management
- You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments -
So Write a bash script create directories.sh that when the script is executed with three given arguments (one is the directory name, second is the start number of directories and third is the end number of directories ) it creates a specified number of directories with a dynamic directory name.
Example 1: When the script is executed as
./
createDirectories.sh
day 1 90
then it creates 90 directories as day1 day2 day3 ... day90
Example 2: When the script is executed as
./
createDirectories.sh
Movie 20 50
then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50
- Create a Script to backup all your work done till now.
Backups are an important part of DevOps Engineer's day to Day activities. So we will right the code.
After that we run the code and record the backup to for backup Directories. The output is:
- Read About Cron and Crontab, to automate the backup Script
cron and crontab are components in Linux that allow users to automate tasks, including backup scripts, at scheduled intervals.
cron: is a time-based job scheduler in Unix-like operating systems. It runs in the background and executes commands or scripts at predefined times without user intervention.
To access the cron configuration, you can use the following command:
This opens the crontab file for editing. Each line in the crontab file represents a scheduled task. The syntax for a cron job is as follows:
The five asterisks represent the time and date information for scheduling:
Minute (0 - 59)
Hour (0 - 23)
Day of month (1 - 31)
Month (1 - 12)
Day of week (0 - 6, where 0 is Sunday)
For example, the following cron job runs a backup script every 2 Minutes:
After saving the crontab file, this backup script will automatically execute at the specified time.
- Read about User Management
A user is an entity, in a Linux operating system, that can manipulate files and perform several other operations. Each user is assigned an ID that is unique for each user in the operating system. In this post, we will learn about users and commands which are used to get information about the users. After installation of the operating system, the ID 0 is assigned to the root user and the IDs 1 to 999 (both inclusive) are assigned to the system users and hence the ids for local user begins from 1000 onwards.
- Create 2 users and just display their Usernames
Adding 2 users :-
Thank you for reading :)
Subscribe to my newsletter
Read articles from Sarika Kamble directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Sarika Kamble
Sarika Kamble
๐ Hello, and welcome to my DevOps journey! ๐ I'm Sarika Kamble, passionate about all things AWS DevOps Technology. Currently, on a learning adventure, I'm here to share my journey and Blogs in the world of cloud and DevOps. I'll be sharing my learnings, experiences, and adventures as I dive deep into the world of continuous integration, automation, and cloud technologies. โ๏ธโ๏ธ Let's connect, learn, and grow as a vibrant DevOps community. Follow my Hashnode blog, and let's embrace the DevOps adventure together! ๐ค๐ Follow me on LinkedIn: https://www.linkedin.com/in/sarika-kamble-3153b3218/