Shell Scripting Basic and Advance.

Shell Scripting Basic and Advance.

It's great to hear about your progress in the #90DaysDevOps Challenge, especially your exploration of shell scripting and how it can be used for automation and system administration. Here's a brief overview of some of the key points you mentioned:

  1. Shell Scripting: Shell scripting is the process of creating computer programs that are designed to be run by a Linux shell, typically through a command-line interface. These scripts can automate various tasks, including file manipulation, program execution, and text printing. Shell scripts are written in scripting languages specific to the shell, like Bash, and are incredibly useful for simplifying repetitive tasks and enhancing system administration.

Basic shell scripting program

We can also use for-loop, elsif, do while conditions like any other programming language.

As part task need to create a script using either Loops or command with start day and end day variables using arguments - So Write a bash script and create directories.sh that when the script is executed with three given arguments (one is the directory name and second is start number of directories and third is the end number of directories ) it creates a 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

so I have written the program as below

while execution of the script will pass the parameter as movie and folder number as 10

"For advanced-level tasks, I've developed a backup script that automatically backs up my script folder every minute of 14 hours. To fulfill this requirement, I've crafted a shell script and automated the task using the cron tab."

crontab schedule will be reflected as below

In destination folder, we could see backup files are saved in the form tgz file.

  1. Cron and Crontab: Cron is a Linux utility that allows you to schedule tasks to run automatically at specific intervals. These tasks are defined in a crontab file, which follows a particular syntax with fields for minute, hour, day of the month, month, day of the week, and the command to be executed. Cron jobs are a powerful way to automate repetitive tasks on a schedule.

  2. User Management: Understanding user management is crucial for system administration and security. It involves working with user accounts, groups, permissions, and various commands to manage user-related tasks. It's essential for maintaining a secure and organized system.

  3. Examples of Shell Scripts:

    • Creating Users: Automating user creation and displaying usernames can save time when managing multiple user accounts.

    • Finding the Largest Number: Writing a script to find the largest number among given values is a simple but useful task.

    • Creating Dynamic Directories: Scripting to create directories with dynamic names based on user input can help organize your file system efficiently.

    • Backup Scripts: Developing scripts to automate data backup is crucial for data integrity and recovery.

    • Crontab Backup Script: Automating backups using cron jobs ensures that your data is regularly and automatically backed up.

Your enthusiasm to apply these skills to your work and share knowledge with others in the tech community is fantastic. Shell scripting is indeed about problem-solving and simplifying tasks, and it's a valuable skill in the DevOps and system administration world.

-Kishor Chavan

#devops

#90dayschallenge