Day-5: Advanced linux shell scripting with user management ๐Ÿง

Day-5: Advanced linux shell scripting with user management ๐Ÿง

ยท

3 min read

Day 5 TASK

Click to check Day 5 task

โ€ข Write a bash script createDirectoriess1.sh that when the script is executed with three given arguments (one is the directory name and 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.

You have to do the same using Shell Script i.e using either Loops or command with start day and end day variables using arguments Example 1: When the script is executed as

./createDirectories.sh day 1 90

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

Using Command

Using Loop

โ€ข Create a script to backup all your work done till now .

Create directory name 'jay' and content is 'dir.sh' ( day01 .. day90)

Create empty directory name 'chavda' for backup. Backup script is written in 'file.sh'

Backup script looks like below ๐Ÿ‘‡

And the result is ๐Ÿ‘‡

โ€ข Read about cron and crontab, to automate the script.

A crontab file is composed of six fields, separated by spaces, that specify the schedule for a task to run. The fields, in order, are:

  1. Minute (0โ€“59)

  2. Hour (0โ€“23)

  3. Day of the month (1โ€“31)

  4. Month (1โ€“12)

  5. Day of the week (0โ€“7, where both 0 and 7 represent Sunday)

  6. Command to be executed

Cron jobs are jobs that are scheduled to run at specific intervals. you might have a command to perform something every hour, year, or every day. they are very powerful, especially on servers to perform maintenance and automation.

The crontab command is the entry point to work with corn jobs.

The first thing you can do is to explore which cron jobs are defined by you: crontab -l

crontab -e to edit the cron jobs, and add new ones.

You can also use crontab -r to remove your current crontab file.

crontab -d to delete a specific user crontab and

cron -l -u <username> to list a specific user crontab.

โ€ข User management

User management refers to the process of creating, modifying, and deleting user accounts on a computer system or network. It also includes managing user permissions and access to resources.

System users are created to run specific system processes or services. They are not meant for interactive logins.

Local users are created for human users who interact with the system. They may have home directories amd can log in to the system.

To create new user useradd

To Changes into user usermod

To delete user userdel

To change password passwd

Create 2 users

_Wow! You are at the end, if it is helpful please do follow โž• and like to support.๐Ÿ’š

_Thank you for reading. ๐Ÿ“–

_Jay

ย