Table of contents
- <mark>What is a kernel?</mark>
- <mark>What is Shell?</mark>
- <mark>What is Linux Shell Scripting?</mark>
- <mark>What is</mark> #!/bin/bash? <mark>can we write</mark> #!/bin/sh <mark>as well?</mark>
- <mark>Write a Shell Script that prints </mark> I will complete the #90DaysOfDevOps challenge
- <mark>Write a Shell Script to take user input, input from arguments and print the variables.</mark>
- <mark>Write an Example of If else in Shell Scripting by comparing 2 numbers</mark>
What is a kernel?
The kernel is a computer program that is a core or heart of an operating system. Hence it has full control over everything in the system. Each operation of hardware and software is managed and administrated by the kernel.
It acts as a bridge between applications and data processing done at the hardware level. It is the central component of an OS
What is Shell?
A Shell provides you with an interface to the Linux system. It gathers input from you and executes programs based on that input. When a program finishes executing, it displays that program's output.
Shell Types
In Linux, there are two types of shells −
Bourne shell − If you are using a Bourne-type shell, the $ character is the default prompt.
C shell − If you are using a C-type shell, the % character is the default prompt.
The Bourne Shell has the following subcategories −
Bourne shell (sh)
Korn shell (ksh)
Bourne Again shell (bash)
POSIX shell (sh)
The types of C shells -
C shell(csh)
TENEX/TOPS C shell (tcsh)
What is Linux Shell Scripting?
Usually, shells are interactive that mean, they accept commands as input from users and execute them. However, the time we want to execute a bunch of commands routinely, so we have to type in all commands each time in the terminal.
As a shell can also take commands as input from the file we can write these commands in a file and can execute them in the shell to avoid this repetitive work. These files are called Shell Scripts or Shell Programs.
Features of Shell Scripting:
To avoid repetitive work and automation.
System admins use shell scripting for routine backups.
system monitoring.
What is
#!/bin/bash?
can we write#!/bin/sh
as well?This is known as shebang in Linux. Shebang is a collection of characters or letters that consist of a number sign and exclamation mark, that is (#!) at the beginning of a script. As discussed in the introduction part, the main function of a shell is to interpret the LINUX commands given by the user. Linux consists of numerous shells out of that bash is one of them that is widely used. It is the default shell assigned by Linux-based operating systems.
The shebang, #!/bin/bash when used in scripts is used to instruct the operating system to use bash as a command interpreter. Each of the systems has its shells which the system will use to execute its system scripts. This system shell can vary from OS to OS(most of the time it will be bash). Whereas, when the shebang, #!/bin/sh used in scripts instructs the internal system shell to start interpreting scripts.
Write a Shell Script that prints
I will complete the #90DaysOfDevOps challenge
create one file with vim editor vim 'helloscript.sh' and write code in it with echo command.
Assign execute permission to that script file and run the file with ./helloscript.sh command. It will give the output.
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
Thanks for reading!!!!!