Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management
#90DAYSOFDEVOPSCHALLENGE
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.
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 30 directories as Movie20 Movie21 Movie23 …Movie50
2. Create a Script to backup all your work done till now.
3. What is Cron and Crontab, to automate the backup Script
Cron is the system’s main scheduler for running jobs or tasks unattended. Cron is a time-based scheduling daemon that runs on Unix and Linux systems. It is used to schedule commands or scripts to run automatically at a certain time or date.
Crontabe : To edit, submit or delete in cron a command is used called as crontab which allows user to do. A crontab file is a user file that holds the scheduling information. You can use crontab to run any of your scripts or one-liners every hour, or maybe just three days a week, it’s up to you. Each user can have their own crontab file if they wish, but on large systems root usually disallows this and just uses one main crontab file for the whole system. Root is able to do this because of a file called ‘cron.deny’ and ‘cron.allow’ where root can specify who can and cannot have their own crontab.
How to use crontab to schedule a script at a certain time or date.
1. Open the crontab configuration file by running a command crontab -e
2. Add a new line to the file with the schedule and command you want to run
3. Save and exit the file Cron will automatically run the command or script at the specified time according to the configuration in the crontab file.
4. To check list of current crontab configuration use command crontab -l.
4. What is User Management
As Linux is a multi-user operating system, there is a high need of an administrator, who can manage user accounts, their rights, and the overall system security for User management in Linux. You should know the basics of Linux admin so that you can handle the user accounts and usergroups for user management in Linux such as command line tools like useradd, usermod, gpasswd, passwd and others. Server administrators are likely to use these tools, since they are familiar and very similar across many different distributions. This chapter will focus on these command line tools.
5. Create 2 users and just display their Username
I Hope you find this article useful.
Thank you so much for taking the time to read my article.
Basanagouda Patil
Click here to check LinkedIn Post..