What is Kernel?
Kernel is central component of an Operating system that manages hardware resources and system operations. Generally has complete control over everything in the system.
What is Shell and Shell Scripting?
Shell is a user interface to use operating system services by executing commands. It allows a user to give commands to the kernel and receive responses from it.
Shell Scripting is a text file that contains series of commands executed by shell that instructs the operating system to perform certain tasks.
Shell Scripting Tutorial
To determine the path of the bash executable file:
which bash
To display a line of text to the terminal:
echo
To create a shell script text file:
nano devops.sh
To execute your shell script:
bash devops.sh
Changing file permissions through octal mode:
chmod 744 filename
To execute the script named devops.sh
located in the current directory (./
denotes the current directory in Unix-like operating systems):
./filename.sh
To print variables in a shell script:
name="Muzammil"
echo "Hi this is ${name}"
To add comments in a bash script, use ‘#'
:
#echo $BASH
To take user input:
read variable
echo "$(variable)"
To pause the execution of the script for a specified amount of time:
sleep NUMBER[SUFFIX]
# Example: sleep 5s (for 5 seconds)
To take user arguments, add a $
sign to your script along with a number to make a sequence of arguments:
To execute a script with user arguments:
Code for an if-else statement (end with fi
):
To learn more click on the given link