Skip to main content

Command Palette

Search for a command to run...

Day 4 - 90 DaysOfDevOps- Basic Linux Shell Scripting

Updated
3 min read
Day 4 - 90 DaysOfDevOps- Basic Linux Shell Scripting

🖋️ Table of Content:-

✨ What is Kernel?

✨What is Shell?

✨ What is Linux Shell Scripting?

✨ What is #!/bin/bash? can we write #!/bin/sh as well?

✨Write a Shell Script that prints I will complete the #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

🔖 What is Kernel?

In terms of the Computer world, Kernel is referred to as a fundamental part of the Linux operating system. It is also considered as the heart of the system. It acts as a middleware for interaction between the applications and the computer hardware.

The kernel is also responsible for performing various tasks of the system as resource allocation, memory management, and task management. etc

🔖 What is Shell?

The Shell is the fundamental part of the Operating system which is responsible for interacting with the user and executing the commands.

Linux operating system is designed to execute from commands, so for performing any tasks, the user needs to provide the command to the system, then that command is handled by the shell. It performs the conversion of the commands into the computer understandable program, which execute the process and generated a response.

🔖 What is Linux Shell Scripting?

Linux Shell Scripting refers to the process of writing and executing scripts using a shell in the Linux operating system. A shell script is a series of commands and instructions written in a scripting language that can be executed in the Unix/Linux shell. The shell script allows users to automate tasks, execute sequences of commands, and perform various system operations efficiently.

🔖 What is #!/bin/bash? can we write #!/bin/sh as well?

The line #!/bin/bash is called a "shebang" or "hashbang," It is used at the beginning of a script to indicate which interpreter should be used to execute the script. Here the script tells the system to use a Bash interpreter to execute the commands . When the system executes the shebang line, then it knows to pass the specified script to the specified interpreter.

we can write #!/bin/sh as the shebang line in the script, and it will instruct the system to use the standard Bourne shell (sh) to execute the script.The Bourne shell (/bin/sh) is a simpler and more basic shell compared to Bash (/bin/bash). While Bash is backward-compatible with the Bourne shell and includes additional features and improvements.


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

  1. Create a new file with a .sh extension, for example, question1.sh, and add the content to it.

  2. change the permission of the file to executable.

  3. execute the script using ./question1.sh


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

  1. create a file question. sh and write the logic in it.

  2. change the permission to executable.

  3. execute the script using ./question2.sh


🔖 Write an Example of If else in Shell Scripting by comparing 2 numbers

  1. create a file question3.sh and write the logic of comparing 2 numbers in it.

  2. change the permissions of the file to make it executable

  3. and execute the script using bash question3.sh


More from this blog

Pavan Pawar's blog

18 posts