Day 4 :- TASK
• What is Kernel ?
Kernel is the core component of a operating system, acting as the main interface between the computer's hardware and its processes. It manages system resources efficiently, including memory management, process management, device drivers, and system calls. The kernel operates in a protected memory space known as kernel space, while user applications run in user space. The Linux kernel is monolithic and modular, allowing for the insertion and removal of loadable kernel modules at runtime. It supports a wide range of hardware architectures and is used in various devices.
• What is Shell ?
A shell is a program that provides a way for you to interact with your computer's operating system. Think of it as a translator between you and the computer. When you type commands into the shell, it translates those commands into actions that the computer can understand and execute.
For example, if you want to see a list of files in a folder, you can type a command in the shell, and it will show you the list. The shell can also help you run programs, manage files, and perform many other tasks.
There are different types of shells, but they all serve the same basic purpose: making it easier for you to communicate with your computer. Some common examples of shells are the Command Prompt in Windows and the Terminal in macOS and Linux.
• What is Linux shell scripting ?
Linux shell scripting is a way to automate tasks on your computer by writing a series of commands in a file, known as a script. Think of it like writing a recipe for your computer to follow. Instead of doing things manually, you write down the steps, and the computer does them for you.
For example, if you often need to create a backup of your files, you can write a shell script that tells the computer to copy your files to a backup folder. Then, whenever you need to make a backup, you just run the script, and the computer does all the work for you.
Shell scripting is useful because it saves time and reduces the chance of making mistakes. It's like having a personal assistant that can handle repetitive tasks for you. Even if you're not a tech expert, you can learn to write simple scripts to make your computer work more efficiently for you.
• Explain in your own words and with examples what Shell Scripting means for DevOps.
Shell scripting in DevOps refers to the practice of writing scripts using shell commands to automate and streamline various tasks involved in the development, deployment, and management of software applications.
Example: A shell script can be written to install necessary software packages like nginx
• What is #!/bin/bash? Can we write #!/bin/sh as well ?
#!/bin/bash
is known as a shebang or hashbang. It is used at the beginning of a script to specify the interpreter that should be used to execute the script. In this case, #!/bin/bash
tells the system to use the Bash shell to run the script.
Yes, you can write #!/bin/sh
as well. This specifies that the script should be executed using the sh
shell, which is typically a more basic shell compared to Bash. While sh
is often linked to a more minimal shell like dash
on some systems, bash
includes more features and is more commonly used for complex scripting.
• Write a Shell Script that prints I will complete #90DaysOfDevOps challenge
.
#!/bin/bash
echo "I will complete #90DaysOfDevOps challenge."
• Write a Shell Script that takes user input, input from arguments, and prints the variables.
#!/bin/bash
read -p "Enter value" value
echo "Value:$value"
• Provide an example of an If-Else statement in Shell Scripting by comparing two numbers.
#!/bin/bash
<<readme
This file will compare two numbers
readme
read -p "Enter Number-1:" number1
read -p "Enter Number-2:" number2
if [ $number1 -gt $number2 ]; then
echo "$number1 is greater than $number2"
elif [ $number1 -lt $number2 ]; then
echo "$number1 is less than $number2"
else
echo "Numbers are equal"
fi
Thank you for reading!
© 2024 Anand Raval. All rights reserved.