Fundamental knowledge of Linux shell scripting  for DevOps engineers.

Fundamental knowledge of Linux shell scripting for DevOps engineers.

Day 4 of 90daysofdevops

Hello Readers,

Here we are Day 4 of #90daysofdevops

Before getting into the topics just want to quote for #Beginners.

"Believe in yourself and all that you are. Know that there is something inside you that is greater than any obstacle." - Christian D. Larson

This quote emphasizes the importance of self-belief and self-confidence when you are entering into a new journey, such as learning something new or starting a new career. It reminds us that we all have unique strengths and capabilities that we can tap into to overcome challenges and obstacles. With the right mindset and attitude, we can achieve great things and reach our full potential.


👣 Topics for #day4

  • What is Kernel?

  • What is Shell?

  • What is Linux Shell Scripting?

  • What is Shell Scripting for DevOps?


What is Kernel?

A kernel is the central component of most operating systems that manages the system's resources, provides a layer of abstraction between software and hardware, and facilitates communication between applications and hardware devices.

The kernel has complete control over everything in the system.

Example:

The Linux kernel, which is the core of the Linux operating system. It manages the system's resources and provides a layer of abstraction between software and hardware. It also includes device drivers for a wide range of hardware devices, allowing them to communicate with the rest of the system.

What is Shell?

A shell is a program that provides a command-line interface for interacting with an operating system. It is a user interface that allows users to write commands to the operating system by typing them into a command-line interface.

The shell interprets the commands entered by the user and communicates with the operating system to execute them.

There are different types of shells, few are as follows

  • Bourne shell (sh)

  • C shell (csh)

  • Korn shell (ksh)

  • Bash shell (bash)

Example:

In the Bash shell, a user can type the command

"ls" to list the contents of a directory,

"cd" to change the current working directory,

"mkdir" to create a new directory, and

"touch" to create a new file.

The Bash shell also supports piping and redirection, which allows users to redirect the output of one command to another command or a file.

What is Linux Shell Scripting?

Linux shell scripting is the process of writing scripts/programs using shell commands in the Linux operating system. It allows users to automate tasks and perform repetitive operations more efficiently by writing scripts that can be executed as a single command.

In Linux, the most commonly used shell is the Bash shell, which provides a powerful scripting language for writing shell scripts. Shell scripts are written in plain text files with a ".sh" extension and can be executed using the Bash shell.

How to execute a Script?

To execute the script, save the script to a file with a ".sh" extension (e.g., "my-script.sh")

my-script.sh file contains:

#!/bin/bash
echo "The current date and time is: "
date

and to make it executable we need to use the following command:

chmod +x my-script.sh

Then, to run the script we need to use the the following command:

./my-script.sh

Output:

The current date and time is:
Fri Mar 25 07:00:00 IST 2023

What is Shell Scripting for DevOps?

Shell scripting plays a very crucial role in DevOps by providing a way to automate tasks and manage the deployment and configuration of applications and infrastructure.

In terms of DevOps, shell scripting can be used to automate tasks such as:

  • Deployment of applications and infrastructure

  • Configuration of servers and applications

  • Monitoring of system metrics and logs

  • Provisioning of resources in cloud environments

  • Testing and validation of software

For example, a DevOps engineer might write a shell script to automate the deployment of a web application to a server. The script would contain commands to install dependencies, configure the web server, and copy the application files to the server. The script could then be executed with a single command, saving time and reducing the potential for human error.

Overall, shell scripting is an important tool for DevOps teams to automate tasks and manage infrastructure, enabling faster deployment and more efficient collaboration between development and operations teams.

Thank you for reading my Blog. I hope you have learnt something from it! If you find this blog helpful, please like, share, and follow me for more interesting posts like this in the future.

Pavan Kumar R

Please navigate to my GitHub Repo: GitHub Repo Link

to check my solutions for the tasks of 90daysofdevops Challenge.