Day 5 : Advanced Linux Shell Scripting with User management
1) 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 -
So 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.
Example 1: When the script is executed as
./
createDirectories.sh
day 1 90
then it creates 90 directories as day1 day2 day3 .... day90
2) Create a Script to back up all your work done till now.
3) Read About Cron and Crontab, to automate the Script
Cron is a Linux utility that schedules tasks to run automatically at specified intervals. The tasks are defined in a crontab file, which is a simple text file containing a list of commands meant to be run at specified times. Each line of the file represents a single cron job and follows a particular syntax.
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:
Minute (0–59)
Hour (0–23)
Day of the month (1–31)
Month (1–12)
Day of the week (0–7, where both 0 and 7 represent Sunday)
Command to be executed
You can use the command crontab -e
to edit your crontab file and crontab -l
to list the current crontab file.
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.
4) Read about 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.
Some common tasks related to user management are:
Creating new user accounts with a unique username and password
Assigning different levels of privileges or permissions to users, such as access to certain files or directories
Changing or resetting user passwords
Disabling or deleting user accounts
Managing groups of users and assigning group permissions
Auditing user activity and tracking changes to user accounts
On Linux systems, user management can be done using the command line tools such as useradd
, usermod
, userdel
, passwd
, and groupadd
, groupmod
, groupdel
.
5) Create 2 users and just display their Usernames
Please, feel free to drop any questions in the comments below. I would be happy to answer them.
If this post was helpful, please do follow and click the clap 👏 button below to show your support 😄