Day04 ----> 90DaysOfDevOps Challenge @TWS

Day04 ----> 90DaysOfDevOps Challenge @TWS

What is Kernel

A kernel is a central component of an operating system that manages system resources and provides a bridge between software applications and the computer's hardware. Kernel Allows programs to interact with the computer's resources such as the CPU, memory, disk drives, and input/output devices.

What is Shell

Shell is a special program that provides a command-line interface (CLI)/ terminal so that users can interact with the operating system through special text commands. A shell allows users to run commands, execute programs, and manipulate files and directories on the system.

What is Linux Shell Scripting

It's a way of writing commands or set of instructions in a text file to run in a Linux shell/ terminal. For writing shell scripts we can use different scripting languages such as Bash, Zsh, Csh, Ksh, Fish, etc.

Bash: Bash is the default shell in most Linux distributions and is widely used for writing shell scripts.

image

In addition to these shell-specific languages, there are also general-purpose scripting languages such as Python, Perl, and Ruby that can be used for shell scripting as well.

What is Shell Scripting for DevOps

Shell scripting is used in DevOps to automate tasks and processes for managing the development and deployment of software applications in a fast-paced and dynamic environment.

Here are some examples of how shell scripting is used in DevOps:

  • Deployment automation: DevOps teams use shell scripts to automate the deployment of software applications to production, testing, and staging environments. These scripts can automate tasks such as copying files, installing dependencies, setting up servers, configuring databases, and more.

  • Infrastructure management: DevOps teams use shell scripts to manage infrastructure as code, which allows them to treat infrastructure as if it were software. Shell scripts can be used to automate the provisioning and configuration of servers, load balancers, databases, and other infrastructure components.

  • Continuous Integration and Continuous Delivery (CI/CD): Shell scripting is used to automate the build, test, and deployment stages of the CI/CD pipeline. This ensures that code changes are thoroughly tested and deployed to production quickly and reliably.

  • Monitoring and logging: DevOps teams use shell scripts to automate the monitoring and logging of software applications and infrastructure. These scripts can be used to collect performance metrics, log files, and other data that can be used to troubleshoot issues and improve system performance.

Overall, shell scripting is a powerful tool to automate repetitive tasks, manage infrastructure as code, and streamline the software development and deployment process

What is #!/bin/bash?

#!/bin/bash is the shebang line and it is written first at the beginning of the script. It is nothing but the absolute path to the bash interpreter. This line is used to specify the interpreter with which the given script will be run by default.

Syntax of shebang line is #!/bin/<shell_interpreter>

Can we write #!/bin/sh as well?

Answer is YES

image

Some of the most common shell interpreters include:

  • Bash (Bourne-Again SHell)

  • sh (Bourne Shell)

  • csh (C Shell)

  • tcsh (TENEX C Shell)

  • zsh (Z Shell)

  • ksh (KornShell)

  • fish (Friendly Interactive SHell)

Each shell interpreter has its own syntax, features, and capabilities. Bash is a popular shell interpreter in Linux environments and is known for its powerful scripting capabilities.

Write a Shell Script that prints I will complete the #90DaysOofDevOps challenge

image

image

Write a Shell Script to take user input, input from arguments and print the variables.

wdqaww

awdqs

Write an example of If else in Shell Scripting for comparing 2 numbers

image

image

Improve the above script to handle multiple conditions and invalid inputs by the users [ Use if-elif-else-fi ]

Day 4 task completed!

90DaysOfDevOps Tasks👇

github.com/Chaitannyaa/90DaysOfDevOps.git