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

Tasks:

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 start number of directories and the third is the end number of directories ) it creates specified number of directories with a dynamic directory name.

Output:

Note: To delete multiple directories in a single command, use rm -rf dir here I have used rm -rf folder\

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

Steps:

Create a dir/folder where you want to back up your files. Copy that path.

Copy the path of the dir/folder where all your file/work resides that you want to backup.

Here i have created one folder named backups under projects directory. where all the backup will be kept.

Read About Cron and Crontab, to automate the backup Script

Cron is a utility/service which allows scheduling and automated things. whereas crontabs are files.

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.

5 Things we have to keep in mind while creating a Cron job:

Minute -> * asterisk means every minute

Hour

Day of the month

Month

Day of the week

[Command]

To check:

      Crontab -e 

  (edit user's crontab)

     Crontab  -l    

 (list user's crontab)

     Crontab  -r   

  (delete user's crontab)

     Crontab  -i   

  (prompt before deleting user's crontab)

ps aux | grep <cronjob name>

To check if my cronjob is running or not

Here i have created a very simple cronjob:

output:

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. 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 hence the ids for local user begins from 1000 onwards.

Create 2 users and just display their Usernames.

use cat /etc/passwd to display their usernames.

\===========================***==============================

Will appreciate your feedback :) #90daysofdevops

linkedin.com/in/sweety-samya-963859130

Happy learning!-