Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management

1.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 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

Ans >>

2.Create a Script to backup all your work done till now.

3.Read About Cron and Crontab, to automate the backup Script Cron is the system's main scheduler for running jobs or tasks unattended. A command called crontab allows the user to submit, edit or delete entries to cron. A crontab file is a user file that holds the scheduling information.

Ans >>

Cron is a utility or process by which we can schedule some work at particular times per requirement.

Crontab is a space where we can write commands to perform cron jobs.

Below are three commands are necessary to remember.

👉crontab -l : To see if any cron tab is active or not.

👉cron -e : Where we can edit and write our cron tab to perform that job at a particular time. It may be daily wise, maybe run every hour.

👉crontab -l : To see if any cron job has been set or not.

  1. 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.

👉groupadd --> Can create group

👉adduser --> Can create user

👉$ sudo gpasswd -a devops_eng devops_opts--> Can add one user in group with to assign particular jobs.

👉$ sudo gpasswd -m devops_eng devops_opts --> Can add multiple user in group with to assign particular jobs.

👉chmod --> to give access for read/ wirte/execute

👉grep --> to search by any word

exp:

👉awk --.> to search more specifically like row-wise and column-wise.

exp:

👉Find -->>

5.Create 2 users and just display their Usernames

  1. Ans >>

  2. sudo adduser <username>

  3. cat /etc/passwd