Sunday, July 30, 2023

Shell Scripting Overview

 

Keywords: Kernel, Shell, Terminal, Console, Command Line, Scripting, Skills, Tools

·       Key Terminologies

o   Kernel

ü  a computer program at the core of a computer operating system that always has complete control over everything in the system.

ü  It manages the following resources: File management, Process management, I/O management, Memory management, Device management, etc.

o   Shell

ü  A shell is a special user program that provides an interface for the user to use operating system services

ü  Shell accepts human-readable commands from users and converts them into something which the kernel can understand

ü  It is a command language interpreter that executes commands read from input devices such as keyboards or from files. The shell gets started when the user logs in or starts the terminal.

A diagram of a diagram

AI-generated content may be incorrect.

ü  Shell is broadly classified into two categories: Command Line Shell, Graphical shell

ü  Shell can be accessed by users using a command line interface. A special program called Terminal in Linux/macOS, or Command Prompt in Windows OS is provided to type in the human-readable commands

ü  Graphical shells provide means for manipulating programs based on the graphical user interface (GUI), by allowing for operations such as opening, closing, moving, and resizing windows, as well as switching focus between windows

ü  Window OS or Ubuntu OS can be considered as a good example which provides GUI to the user for interacting with the program. Users do not need to type in commands for every action. 

ü  Several shells are available for Linux systems like SH (Bourne shell), BASH (Bourne again shell), CSH (C-shell), KSH (Korn shell), Each shell does the same job but understands different commands and provides different built-in functions

A screenshot of a computer

AI-generated content may be incorrect. 

o   Terminal

ü  A program which is responsible for providing an interface to a user so that he/she can access the shell.

ü  It basically allows users to enter commands and see the output of those commands in a text-based interface. 

ü  Large scripts that are written to automate and perform complex tasks are executed in the terminal.

A screenshot of a computer

AI-generated content may be incorrect.

o   Terminal vs Console vs Shell vs Command Line

ü  Terminal, Console, Shell, and Command line all are ways to give the command to the computer but all these have different functions.

ü  A terminal is a text-based interface that is used to type commands or take input and view the output. Examples: Command prompt, guake, gnome-terminal, terminator, etc.

ü  A console is a type of terminal that is used to interact with operating system programs. Examples: Famicom, Xbox, PlayStation, Nintendo Switch, Wii, and Wii U, etc.

ü  Shell is used to interact with the operating system’s kernel. It interprets and processes the commands entered by the user. Examples: Bash, zsh, ksh, sh, tsch, Power Shell, pwsh, cmd, yori, etc.

ü  The Command Line is an area where the user enters the commands. Examples: Microsoft Windows, DOS Shell, Mouse Systems Power Panel, etc.

·       Shell Scripting

o   Usually, shells are interactive, which means they accept commands as input from users and execute them.

o   However, sometimes we want to execute a bunch of commands routinely, so we have to type in all commands each time in the terminal.

o   As a shell can also take commands as input from file, we can write these commands in a file and can execute them in shell to avoid this repetitive work. These files are called Shell Scripts or Shell Programs.

o   Shell scripts are similar to the batch file in MS-DOS. Each shell script is saved with ‘.sh’ file extension e.g., myscript.sh.

o   A shell script has syntax just like any other programming language.

o   A shell script comprises the following elements Shell Keywords, Shell commands, Functions, Control flow, etc.

·       Shell Scripting Skills:

o   Technical Skills Integration

ü  Proficiency in Scripting Languages

ü  Proficiency in Command Line Operations

ü  System Administration and Configuration

ü  Task Automation

ü  Integration with DevOps Practices

ü  Continuous Integration/Continuous Deployment (CI/CD)

ü  Configuration management

o   Soft Skills

ü  Efficiency and Automation

ü  Problem-Solving and Troubleshooting Abilities

·       Shell Scripting Tools

o   Operating Systems: Unix, Linux, Windows, MacOs

o   Shell: Bash, zsh, ksh, sh, tsch, Power Shell, pwsh, cmd, yori, etc.

o   Terminals: Command prompt, guake, gnome-terminal, terminator, etc.