Day:05 Advanced Linux Shell Scripting For DevOps Engineers With User Management

Day:05 Advanced Linux Shell Scripting For DevOps Engineers With User Management

Table of contents

No heading

No headings in the article.

Tasks:

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 to create directories. sh that 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 a 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

when you will run the script as ./createdirectories.sh command to execute.

  1. Create a Script to back up all your work done till now.

When you will run the script as ./backup_script.sh output will be as follows :-

  1. Read About Cron and Crontab, to automate the backup Script

    Cron is a daemon that runs in the background on Unix-like operating systems, including Linux and macOS. It allows you to schedule tasks to be automatically run in the background at a specified time or interval.

    Crontab is a command that allows you to edit the cron table, which is a list of commands that are scheduled to run at specified times. Each line in the cron table represents a separate task, and consists of the following fields:

    Linux Crontab Format

     MIN HOUR DOM MON DOW CMD
    

    Crontab Fields and Allowed Ranges (Linux Crontab Syntax)

     Field    Description    Allowed Value
     MIN      Minute field    0 to 59
     HOUR     Hour field      0 to 23
     DOM      Day of Month    1-31
     MON      Month field     1-12
     DOW      Day Of Week     0-6
     CMD      Command         Any command to be executed.
    

    Examples of Cron jobs 1. Scheduling a Job For a Specific Time The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM. The time field uses 24 hours format. So, for 8 AM use 8, and for 8 PM use 20.

     30 08 10 06 * /home/maverick/full-backup
    
  2. About User Management

User management is the process of creating, modifying, and deleting user accounts on a computer system or network. It involves tasks such as setting passwords, permissions, and privileges for users, and is typically done using special tools provided by the operating system. User management is an important aspect of system administration, as it allows you to control who has access to the system and what actions they are allowed to perform.

  1. Create 2 users and just display their Username

    to see the output write cat /etc/passwd you get result as follow.

Thanks for reading this blog, See you in the next one..!!