Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management
1. 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 scriptcreate directories.shthat when the script is executed with three given arguments (one is the directory name and second is the 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
2. Create a Script to back up all your work done till now.
3. Read About Cron and Crontab, to automate the backup Script.
The crontab is a list of commands that you want to run on a regular schedule, and also the name of the command used to manage that list. Crontab stands for “cron table, ” because it uses the job scheduler cron to execute tasks; cron itself is named after “chronos, ” the Greek word for time.cron is the system process which will automatically perform tasks for you according to a set schedule. The schedule is called the crontab, which is also the name of the program used to edit that schedule.
A crontab file contains entries for each cron job, with each entry separated from the next by newline characters. Also, each entry contains six fields separated by spaces:
Minute: Range from 0 to 59
Hour: Range from 0 to 23
Day of the month: Range from 1 to 31
Month: Range from 1 to 12
Day of the week: Range from 0 to 6, where 0 = Sunday
Command (shell command)
minute hour day_of_month month weekday command
4. Read about User Management.
➢User management means managing user. ie., Creating the users, deleting the users and modifying the users.
➢ Users can login to the system by supplying username and passwords to the system.
➢ Every file on the system is owned by a user and associated with a group.
➢ Every process has an owner and group affiliation.
➢ Every user in the system is assigned a unique user id (uid) and group id (gid).
➢ User names and user id are stored in /etc/passwd file.
➢ User’s passwords are stored in /etc/shadow file in an encrypted form.
➢ Users are assigned a home directory and a shell to work with the O/S.
➢ Users cannot read, write and execute each other’s files without permission
[root@localhost Script]# sudo useradd dev
[root@localhost Script]# sudo useradd QA
cat /etc/passwd
[root@localhost Script]# sudo useradd dev
[root@localhost Script]# sudo useradd QA
Thank you
Khushbu