Day 5: Advanced Linux Shell Scripting with User management

Day 5: Advanced Linux Shell Scripting with User management

ยท

3 min read

#Day5 of #90DaysofDevops challenge

Click here to view Day5 Task

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

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

  3. Read about cron and crontab to automate the script.

    'cron' is a time-based job scheduler in Unix-based operating systems. It allows users to schedule commands or scripts to run automatically at specified intervals (e.g. every minute, hour, or week).

    'crontab' is a command used to create, edit and manage 'cron' jobs. It is a text file that contains a list of commands or scripts to be executed at specific times and intervals. Each line in a crontab file represents a single cron job, and consists of six fields:

    Each field represents a value or range of values for the time unit it represents. For example, '*' means "any value", and '0-5' means "value from 0 to 5".

    To create a 'crontab' file, you can use the 'crontab -e' command, which opens the file in a text editor. Once you have created or modified the file, the changes take effect immediately and 'cron' will begin executing the scheduled commands at the specified intervals. The 'crontab -l' command is used to list the current 'cron' jobs and 'crontab -r' to remove all cron jobs for the current user.

  4. Read about User Management

    User management in Linux involves creating, modifying, and deleting user accounts on a Linux system. Each user account is associated with a unique username and user ID (UID), which is used to control access to resources and limit the actions that users can perform on a system.

    The process of user management typically involves the following tasks:

    1. Creating user accounts: The 'useradd' command is used to create new user accounts on a Linux system. The command allows you to specify the username, UID, home directory, login shell, and other account settings.

    2. Setting user passwords: The 'passwd' command is used to set or change a user's password on a Linux system. The command prompts you to enter a new password, which is then encrypted and stored in the system's password file.

    3. Modifying user accounts: The 'usermod' command is used to modify existing user accounts on a Linux system. The command allows you to change the username, UID, home directory, login shell, and other account settings.

    4. Deleting user accounts: The 'userdel' command is used to delete user accounts on a Linux system. When you delete a user account, the user's home directory and files are also deleted (unless you specify otherwise).

    5. Managing user groups: User accounts on a Linux system are typically organized into groups, which can be used to control access to resources and limit the actions that users can perform. The 'groupadd', 'groupmod' and 'groupdel' commands are used to manage user groups on a Linux system.

    6. Assigning permissions: Linux uses a permission system to control access to files, directories, and other system resources. User accounts are assigned permissions based on their group memberships and other factors.

      User management is an important aspect of Linux system administration, as it helps to ensure that the system is secure, efficient, and accessible to authorized users.

  5. Create 2 users and just display their usernames

Thank you for reading! ๐Ÿ

- Nidhi

ย