Skip to main content

Command Palette

Search for a command to run...

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

Published
1 min read
Day 5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management

What do you think if you have to create 90 directories at a time, how will create it one by one or using script or command.

Here Linux shell scripting comes into the picture. There are two different ways, we can create directories at a time using command and script.

Method 1 using command:

Method 2 using scripting:

Method 2 is called command line argument method while the time command execution we can give the input and execute it.

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

    bash
    #!/bin/bash

    backup_dir="/path/to/backup/directory"
    timestamp=$(date +"%Y%m%d_%H%M%S")

    tar -czvf "$backup_dir/backup_$timestamp.tar.gz" /path/to/source/directory
    ```

  2. User Management:

    Dive into the world of user management in Linux. Users are the backbone of operations. Create two users and display their usernames:

    ```bash
    #!/bin/bash

    user1="user1"
    user2="user2"

    # Create user1
    sudo useradd -m -s /bin/bash "$user1"

    # Create user2
    sudo useradd -m -s /bin/bash "$user2"

    echo "Users created successfully: $user1, $user2"