Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management
Tasks
- Using either Loops or commands with start day and end day variables using arguments -
So 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.
\>To create a directory we have to use the command mkdir <directory_name>
\>To create multiple directories in one go then mkdir <directory_name>{1..10}
\>To run this script pass three arguments @name @num1 @num2
2.Create a Script to backup all your work done till now.
To create a backup first we have to generate a zip file of the data and then
use crontab
for scheduling the backup job.
\>tar -czvf backupfilename.tag.gz /path of the backup file
- \>To add scheduler use
chrontab
Note :- This job will run every min, use cronguru for scheduling the jobs
https://crontab.guru/every-5-minutes
5.Create 2 users and just display their Usernames
To create a user , use command useradd username
All the user infomation present in /etc/passwd file and default group is also same as user name.
create user without home directory
\>useradd username
create user with home directory and set password
\>useradd username -m
\>passwd
Check the user list
\>cat /etc/passwd