Advanced Linux Shell Scripting for DevOps Engineers with User management

Advanced Linux Shell Scripting for DevOps 
Engineers with User management

Task:1

Write a bash script create directories. sh that when the script is executed with three given arguments (one is the directory name and the second is the start number of directories and the third is the end number of directories ) it creates a specified number of directories with a dynamic directory name.

#!/bin/bash
directory_name=$1
start_no=$2
end_no=$3

for (( i=start_no; i<=end_no; i++))
do
         mkdir "$directory_name$i"
 done


shubham@DESKTOP-V64SLVU:~$chmod 700 directories.sh
shubham@DESKTOP-V64SLVU:~$ ./directories.sh day 1 20
shubham@DESKTOP-V64SLVU:~$ ls
day1   day11  day13  day15  day17  day19  day20  day4  day6  day8  directories.sh
day10  day12  day14  day16  day18  day2   day3   day5  day7  day9
  1. Read About Cron and Crontab, to automate the backup Script

Cron is a utility program used in Unix and Linux operating systems that allows users to schedule commands or scripts to be executed automatically at specified intervals. This can be a very useful tool for automating repetitive tasks or running maintenance scripts.

Crontab, short for "cron table", is a configuration file used by the cron daemon that specifies which commands or scripts should be run and when they should be executed. Each user can have their own crontab file, and the entries in the file are written in a specific format that specifies the timing of the command or script. The crontab file can be edited using the "crontab" command, and changes take effect immediately.

Overall, cron and crontab are powerful tools that can save time and effort by automating routine tasks, but they should be used with caution and care to avoid unintended consequences.

  1. Read about User Management

    In Linux, user management is an essential task that enables system administrators to control access to resources and ensure the security of the system. User management involves creating and deleting users, managing user accounts and permissions, and setting up authentication and access controls.

  2. Here are some common user management tasks in Linux:

    1. Creating a new user: To create a new user, you can use the "useradd"

    2. Deleting a user: To delete a user, you can use the "userdel" command

    3. Modifying user accounts: To modify a user account, you can use the "usermod"

    4. Managing user groups: In Linux, users can be organized into groups for easier management of permissions and access controls. You can use the "groupadd", "groupdel", and "groupmod" commands to manage user groups.

    5. Effective user management is critical for ensuring the security and stability of your Linux system. It's important to regularly review and update user accounts, permissions, and access controls to minimize the risk of unauthorized access or security breaches.

    6. Create 2 Users and just display their Usernames

 shubham@DESKTOP-V64SLVU:~$ sudo useradd  user1
 shubham@DESKTOP-V64SLVU:~$ sudo useradd  user2
 shubham@DESKTOP-V64SLVU:~$ tail -2 /etc/passwd | cut -d: -f1
 user1
 user2

THAT'S ALL FOR TODAY HOPE YOU LEARN SOMETHING