#day5 Task: Advanced Linux Shell Scripting for DevOps Engineers with User management

Tasks

  1. Write a bash script createDirectories.sh which creates directories from 1 to 100

Steps:

  1. Write a bash script createMovies.sh which creates directories from 20 to 50

Steps:

  • Inside "createMovies.sh" write the code to create the directory from Movie20 to Movie50 as below:

  • Provide execute permission to "createMovies.sh"

  • Once execute permission is provided to "createMovies.sh" then execute the script

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

    Backups are an important part of DevOps Engineers' day to Day activities

Steps:

  • Create a shell script with the name "backup.sh"

  • Inside "backup.sh" write the code to take a backup from the scripts directory to the backups directory:

  • Provide execute permission to "backup.sh"

  • Once execute permission is provided to "backup.sh" then execute the script

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

    Cron is a time-based job scheduler in Unix-like operating systems, which allows users to schedule jobs (commands or scripts) to run automatically at specified times or intervals. Crontab is a file that stores the schedules for Cron jobs.

    To automate a backup script using Cron and Crontab, we can follow these steps:

    1. Create a backup script that includes the commands necessary to back up your data.

    2. Open the Crontab file by typing the following command in the terminal:

    3. Add a new line to the Crontab file that specifies the schedule for the backup script. The format of the line should be as follows:

    4. The five asterisks represent the time and date fields for the Cron job. The first asterisk represents the minute field, the second represents the hour field, the third represents the day of the month field, the fourth represents the month field, and the fifth represents the day of the week field. By using asterisks, we can set the job to run at every possible interval for each field.

    5. Replace "/path/to/backup/script.sh" with the actual path to your backup script.

    6. Save and exit the Crontab file.

    7. After completing these steps, your backup script will run automatically according to the schedule you specified in the Crontab file. You can check the status of your Cron jobs by typing the following command in the terminal:

  2. About User Management

    • User management is the process of creating, managing, and deleting user accounts on a computer system or network. In a multi-user environment, user management is an essential part of system administration, as it ensures that only authorized users have access to system resources and data.

      -- The following are some key aspects of user management:

    • Creating user accounts: System administrators create user accounts to allow users to access system resources such as files, folders, and applications. The process involves assigning a unique username and password to each user, and defining the level of access they are permitted.

    • Granting and revoking permissions: After creating user accounts, system administrators set permissions to determine what each user can access and modify. Permissions can be assigned to individual users, groups of users, or to specific files and folders. Permissions can also be revoked or modified as required.

    • Managing user roles and groups: In addition to setting individual permissions, system administrators may create roles and groups to simplify user management. Roles are predefined sets of permissions that can be assigned to users as needed. Groups are collections of users who share common permissions, and can be used to manage access to shared resources.

    • Monitoring user activity: System administrators monitor user activity to ensure that users are adhering to security policies and not engaging in unauthorized activities. They can also use logs and monitoring tools to track system usage and identify potential security threats.

    • Deactivating and deleting user accounts: When a user no longer requires access to a system, their account should be deactivated or deleted to prevent unauthorized access. Deactivating an account temporarily disables it, while deleting an account permanently removes it from the system.

  3. Create 2 users and just display their Usernames

Steps:

  • Create a shell script with the name "create_user.sh"

  • Inside "create_user.sh" write the code to create users and just display:

  • Provide execute permission to "create_user.sh"

  • Once execute permission is provided to "create_use.sh" then execute the script