Advanced Linux Shell Scripting with User management

Advanced Linux Shell Scripting with User management

Write a bash script createdirectories.sh when the script is executed with three given arguments (one is the directory name, second is the start number of directories and third is the end number of directories ) it creates a specified number of directories with a dynamic directory name.

here is a bash script that creates directories with a dynamic directory name based on the given arguments:

You can save this script in a file named createDirectories.sh and then execute it from the terminal using the command ./createDirectories.sh <directory-name> <start-number> <end-number>.

For example, to create 90 directories with names day1 to day90, you can execute the following command:

Create a Script to backup all your work done till now

shell script that creates a backup of all your work done till now:

You can save this script in a file named backup.sh.

You can then execute this script from the terminal using the command ./backup.sh. This will create a backup of all your work in a compressed archive file with a timestamped name, and store it in the backup directory you specified.

You can also automate the backup process by adding this script as a cron job to run at regular intervals.

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.

User Management

In Linux, user management involves creating, modifying, and deleting user accounts, as well as managing user permissions and access to system resources. Here are some common tasks related to user management in Linux:

Creating a new user account: To create a new user account in Linux with the username "King", you can use the useradd command followed by the username. For example, to create a user account named "King", you can use the command:

This will create a new user account with default settings and a home directory located at /home/King

Setting a password for the user account: To set a password for the user account, you can use the passwd command followed by the username. For example, to set a password for the user account, you can use the command:

Modifying user account settings: To modify user account settings such as the user's home directory or shell, you can use the usermod command followed by the appropriate options and the username. For example, to change the home directory of the user "King" account to /home/devopsadmin, you can use the command:

Create 2 users and just display their Usernames

#useradd devopsadmin1
#useradd devopsadmin2

Thanks for reading.