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

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

Shell Scripting

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

    - When the script is executed as ./createDirectory.sh day 1 90

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

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

It then copies all files in the current directory and subdirectories to the backup directory, and compresses the backup directory into a .tar.gz file.

To use the script, save it to a file (e.g. backup.sh), make it executable with the command chmod +x backup.sh, and run it with ./backup.sh. The script will create a backup in the same directory as the script.

we use tar -czvf, it creates a new archive, compresses it with gzip, and lists the files being processed while creating it. The -f option followed by the filename tells tar to create the archive with the specified name.

3) Read About Cron and Crontab, to automate the backup Script.

Cron is a utility in Unix-like operating systems that allows users to schedule and automate commands or scripts to run at specified intervals. These intervals can be daily, weekly, monthly, or even every minute or every hour. Cron is commonly used for tasks such as backups, updating system indexes, or running batch jobs.

Crontab (short for "cron table") is a file that stores the schedule of tasks to be run by cron. Each user has their own crontab file that specifies the tasks they want to run at specific times.

4. Read about User Management.

User management is the process of creating, modifying, and deleting user accounts on a computer system. It involves managing user access to resources such as files, directories, applications, and system settings. User management is an important aspect of system administration, as it helps ensure the security and integrity of the system by controlling access to sensitive information and resources.

User management typically involves the following tasks:

  1. Creating new user accounts: This involves setting up a new account with a unique username and password, assigning the user to a group with specific privileges, and specifying the user's home directory.

  2. Modifying user accounts: This includes changing the user's password, updating user information such as email address and phone number, modifying user permissions, and changing the user's group membership.

  3. Deleting user accounts: This involves removing a user account from the system, deleting the user's files and directories, and revoking the user's access to system resources.

  4. Managing user groups: This includes creating new groups, adding users to existing groups, and removing users from groups.

User management is typically performed using command-line tools or graphical user interfaces (GUIs) provided by the operating system or third-party software. Common user management tools in Unix-based systems include useradd, usermod, userdel, groupadd, groupmod, and groupdel.

Thank You for reading this Article.