Day 4 Task: Basic Linux Shell Scripting for DevOps Engineers

Day 4 Task: Basic Linux Shell Scripting for DevOps Engineers

Hello, everyone! On Day 4 of my #90DaysOfDevOps challenge, I explored Linux shell scripting and learned some key concepts.#90daysofdevops with Shubham Londhe Here’s what I discovered:

Day 4 Task: Basic Linux Shell Scripting for DevOps Engineers

What is Kernel?

In simple terms, the kernel is like the engine of your computer's operating system. It’s the core part that acts as a bridge between the hardware (like your CPU, memory, and devices) and the software (programs and applications you run).

Here’s how it works in layman’s language:

  • Imagine your computer is like a car, and the kernel is the engine.
  • It controls the “communication” between different parts of the car (or the computer's hardware) and makes sure everything works smoothly.
  • When you click on an application (like a web browser), the kernel tells the CPU to give it the power to run and manages resources like memory or storage so things don’t crash or overload.

So, the kernel is vital for making sure your computer runs efficiently by managing all the low-level stuff behind the scenes.


What is Shell?

The shell is like a translator between you and your computer.

Here’s a simple breakdown:

  • When you type commands or click on things in your computer, the shell is what takes those actions and tells the operating system (through the kernel) what you want it to do.
  • It’s like a messenger: you give it instructions, and it passes them to the deeper parts of the system to make things happen.

If you’ve ever used a command line or terminal (where you type commands instead of clicking), that’s a type of shell. It helps you communicate directly with the computer by typing commands instead of using a mouse or icons.

So, while the kernel runs the system, the shell helps you talk to the kernel.


What is Linux Shell Scripting?

Linux shell scripting is like giving your computer a list of tasks to do automatically, instead of doing them one by one.

In simple words:

  • A shell script is a file with a series of commands written inside it.
  • These commands tell the computer what to do, like copying files, moving data, or checking for updates.
  • Instead of typing commands manually each time, you can put them all in a script, and the computer will follow the steps in the order you’ve written them.

It’s like writing a recipe for the computer, where each step in the recipe is a command, and once the script runs, the computer follows your instructions exactly, saving you time and effort.

??? Tasks I Completed:

1.????? Explain in your own words and with examples what Shell Scripting means for DevOps.

?In DevOps, shell scripting is a way to automate repetitive tasks and processes to make everything run faster and more consistently.

For example:

  • A DevOps engineer might write a script to automatically deploy code to a server, check system health, or back up files.
  • Instead of doing each task manually, the script runs the steps in one go, saving time and reducing human error.

In short, shell scripting in DevOps helps streamline workflows, making processes more efficient and reliable.

  • It controls the “communication” between different parts of the car (or the computer's hardware) and makes sure everything works smoothly.

?

2.????? What is?#!/bin/bash? Can we write?#!/bin/sh?as well?

The line #!/bin/bash or #!/bin/sh at the top of a script is called a shebang. It tells the system which shell to use to run the script.

  • #!/bin/bash means the script should run using the Bash shell, which is a popular shell with more features and flexibility.
  • #!/bin/sh means the script should run using the sh shell, which is usually a simpler, more basic shell (often a link to a smaller version of Bash).

Yes, you can write #!/bin/sh instead of #!/bin/bash, but keep in mind that some commands or features available in Bash may not work in sh.

In short:

  • Bash is more feature-rich and commonly used.
  • sh is lighter and may be available on all systems, but it has fewer features.

?

3.???? Write a Shell Script that prints?I will complete #90DaysOfDevOps challenge.

Create a new file, e.g., Devops_Script.sh


Give it execute permissions using: chmod 700 (+x) Then Run the script.


4.????? Write a Shell Script that takes user input, input from arguments, and prints the variables.


Give it execute permissions using: chmod 700 (+x) Then Run the script.


Run the script, passing arguments (e.g., "DevOps" and "Challenge")


5.????? Provide an example of an If-Else statement in Shell Scripting by comparing two numbers.

Here's a simple example of an if-else statement in shell scripting that compares two numbers:


Explanation:

  • -gt checks if the first number is greater than the second.
  • -lt checks if the first number is less than the second.
  • If both conditions are false, it means the numbers are equal.

It will prompt you to enter two numbers and then display the comparison result!

?

Rohit Raghav

Founder & CEO @ WebtechAge Pvt Ltd & Role Route | Delivering Total Talent Solutions

4 个月

Hi, I hope this message finds you well. I wanted to reach out and connect with you. As part of our recruitment services, we’re currently offering four candidate CVs free of cost to help meet your hiring needs. I believe this could be a great opportunity for your organization to find the right talent. Let’s connect to explore how we can assist in fulfilling your recruitment requirements. Looking forward to staying in touch! Best regards, Rohit Raghav Founder, (Webtech Age Pvt Ltd)

回复

要查看或添加评论,请登录

Naushad khan的更多文章

  • Day 9 : Directory Backup with Rotation Using Bash ???

    Day 9 : Directory Backup with Rotation Using Bash ???

    ?? Day 9 of #90DaysOfDevOps: Directory Backup with Rotation Using Bash ??? #Day8 #BashScripting #DevOpsJourney…

  • ?? Day 8 of #90DaysOfDevOps Challenge: Bash Scripting Basics ???

    ?? Day 8 of #90DaysOfDevOps Challenge: Bash Scripting Basics ???

    Today, I explored the essentials of bash scripting, covering key concepts step by step. Here's how I tackled each task,…

  • Day 6: File Permissions and Access Control

    Day 6: File Permissions and Access Control

    Day 6 of #90DaysOfDevOps Challenge: File Permissions and Access Control Hello everyone! On Day 6 of my #90DaysOfDevOps…

  • Basic Linux Commands with a Twist

    Basic Linux Commands with a Twist

    #90DaysOfDevOps Challenge: Basic Linux Commands with a Twist Day 3 of #90DaysOfDevOps Challenge: Basic Linux Commands…

    1 条评论
  • Basic Linux Commands Day2

    Basic Linux Commands Day2

    Welcome to Day 2 of my #90DaysOfDevOps challenge! Today, I explored some fundamental Linux commands that are super…

    1 条评论
  • Introduction to DevOps

    Introduction to DevOps

    Day 1 of #90DaysOfDevOps Challenge: Introduction to DevOps Hey everyone! I’ve officially started my #90DaysOfDevOps…

    1 条评论

社区洞察

其他会员也浏览了