Advanced Linux Shell Scripting for DevOps Enginners with User Management

Advanced Linux Shell Scripting for DevOps Enginners with User Management

#90DaysOfDevOps

(1) Write a bash script createdirectories.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.

(2) Create a Script to back up 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.

Crontab -l: If you want to add a new cron entry, use the following command and enter it in a text editor.

Crontab -e: It is possible to programme jobs to repeat themselves. This is referred to as job scheduling. The cron service or a daemon called crond handles this process. and crontab -r removes the current crontab configuration.

(4) Read about 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. 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 hence the ids for local user begins from 1000 onwards.

  • To list out all the users in Linux

    awk -F':' '{print $1}' /etc/passwd

  • Using the id command, You can get the ID of any username

    id username

  • The command to add a user.

    sudo useradd username

  • Using passwd command to assign a password to a user.

    passwd username

  • Accessing a user configuration file.

    cat /etc/passwd

(5) Create 2 users and just display their usernames.

sudo useradd username

Thanks for giving your valuable time to read this article. If you find this insightful and want to read more kindly follow me.

~Prabhakar Yadav