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

Task 2

Create Backup using Shell Scripts

One of the simplest ways to backup a system is using a shell script.

For example, a script can be used to configure which directories to backup, and pass those directories as arguments to the tar utility, which creates an archive file.

The archive file can then be moved or copied to another location.

The tar utility creates one archive file out of many files or directories. tar can also filter the files through compression utilities, thus reducing the size of the archive file.

How to Check if Backup is created on not?

Cron and Cron Tab

For example, you could set a cron job to automate repetitive tasks such as backing up databases or data, updating the system with the latest security patches, checking the disk space usage , sending emails, and so on.

The cron jobs can be scheduled to run by a minute, hour, day of the month, month, day of the week, or any combination of these.

The /etc/crontab file and the scripts inside the /etc/cron.d directory are system-wide crontab files that can be edited only by the system administrators.

crontab -e

Once Crontab File is opened it will be shown in editor as below

What is a user?

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.

sudo useradd bhawesh -m

sudo useradd dataengineer-m