Linux Shell Scripting Fundamentals for DevOps Engineers
Welcome to my journey of exploring DevOps. Now that we have an understanding of what DevOps is, it's important to emphasize that automation is a fundamental principle of DevOps. Shell scripting plays a pivotal role in automation. You might be wondering, 'Why should I invest in shell scripting when numerous automation tools are available?' The answer is straightforward: shell scripting is foundational. It serves as the glue that binds together many DevOps workflows.
What is Shell?
Shell is a command-line interface or user interface that allows users to interact with the operating system by entering commands. Shell accepts user inputs and interprets and executes commands for the user. There are different types of shells in the context of Unix-like operating systems, including Bash (Bourne Again Shell), sh (Bourne Shell), zsh (Z Shell), and more. The following diagram shows shell architecture:
What is Shell scripting?
Shell scripting is nothing but writing a series of commands in a scripting file that can be executed by a Linux shell. It allows you to utilize the powerful capabilities of the shell and automate a lot of sequential tasks.
What is Shell Scripting for DevOps?
A DevOps Engineer follows the practice of writing shell scripts, often in Bash or other shell scripting languages, to automate, manage, and streamline various workflows. Automation reduces errors, accelerates processes, and ensures consistency in deployments. DevOps often relies on configuration management tools like Ansible, Puppet, or Chef, which use shell scripts to define and enforce the desired state of infrastructure and application configurations.
What is
#!/bin/bash?
can we write#!/bin/sh
as well?#!/bin/bash is a special line called as shebang which should be written as the first line of your script to specify the interpreter that the Bash shell should be used to interpret and run the script.
You can use #!/bin/sh if you want to specify that the script should be interpreted using the Bourne shell.
Write a Shell Script which prints
I will complete #90DaysOofDevOps challenge
Write a Shell Script to take user input, input from arguments and print the variables.
Write an Example of If else in Shell Scripting by comparing 2 numbers.
In summary, shell scripting is a versatile and essential skill for DevOps engineers. It enables the automation, orchestration, and management of various tasks and processes throughout the software development and delivery.
Thank you!