90DaysOfDevOps:Day#5

Table of contents

No heading

No headings in the article.

Example 1: When the script is executed as

./createDirectories.sh day 1 90

vim createDirectories.sh

#!/bin/bash

cd /home/kali/advshell

start=$1

stop=$2

mkdir $(eval echo day{$start..$stop})

then it creates 90 directories as day1 day2 day3 .... day90

Example 2: When the script is executed as

#!/bin/bash

cd /home/kali/advshell

dirname=$1

start=$2

stop=$3

mkdir $(eval echo $dirname{$start..$stop})

./createDirectories.sh Movie 20 50 then it creates 50 directories as Movie20 Movie21 Movie23 ...Movie50

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

mkdir backups

cd backups

vim backup.sh

#!/bin/bash

source = /home/kali/ingress

dest = /home/kali/backups

cur_timestamp = $(date "+%Y-m%-%d-%H-%M-$S")

echo "$cur_timestamp"

backup_file = $dest/$cur_timestamp.tgz

echo "$backup_file"

tar czf $backfile --absolute-names $source

echo "$backup_file"

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

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.

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.

Create 2 users and just display their Usernames

sudo useradd [options] USERNAME

sudo useradd goutam

sudo useradd rohit

cat /etc/passwd