Before starting the interview question answers First, I would like to present Linux Introduction.
What is Linux?
Linux is an open-source computer operating system(that is made up of the kernel or we can say that it is an operating system’s kernel, the base component of the OS, and the tools, apps, and services bundled along with it.) like Unix that directly manages the hardware and resources of a system such as CPU, memory, and storage, and with the help of the kernel, it manages the communication between software and hardware. Linux is a type of clone version of Unix.
History of Linux
In 1991, Linus Torvalds a University student of Helsinki, Finland, thought to have a freely available academic version of Unix started writing his own code. Later on, this project was named the Linux kernel. He wrote this program especially for his own PC as he wanted to use Unix 386 Intel computer but couldn’t afford it. He did it on MINIX using the GNU C compiler. GNU C compiler is still the main choice to compile Linux code but other compilers are also used like the Intel C compiler.
He started it just for fun but ended up with such a big project. Firstly he wanted to name it ‘Freax’ but later it became ‘Linux’.
He published the Linux kernel under his own license and was restricted to use as commercially. Linux uses most of its tools from GNU software and is under GNU copyright. In 1992, he released the kernel under GNU General Public License.
Various Linux Distributions
There are many Linux Distributions :
Ubuntu | It works like Mac OS and is easy to use. |
Linux mint | It works like windows and should be used by newcomers. |
Debian | It provides stability but is not recommended for a new user. |
Fedora | If you want to use Red hat and the latest software. |
Red hat enterprise | To be used commercially. |
CentOS | If you want to use the Red hat but without its trademark. |
OpenSUSE | It works the same as Fedora but is slightly older and more stable. |
Arch Linux | It is not for beginners because every package has to be installed by yourself. |
Linux Features
- Open Source and Free: It is freely and easily available for everyone.
- Robust and Flexible: Linux can operate for long periods without crashing and is considered to have very much immune to security threats also has a simplified update facility for all installed software.
- Better Malware Protection: It is more secure than Windows as it provides security using authentication features like password authentication, security auditing, and file system access control.
- Multiprogramming System: More than one can function or an application can run simultaneously in this OS.
- Access to Source Code: As we know it is open source, and its codes can access anyone.
- Supports various Languages: There are many different languages used throughout the world, thus Linux supports the installation of multiple language keyboards.
- GUI (Graphical User Interface): It provides an interface for users to interact with the system and allows to use of GUI applications such as VLC, Firefox, etc.
- Multiple Distribution: it has multiple distributions, and that distributions also support many programming languages like C, Java, Python, Ruby, R, etc.
What is Kernel?
The kernel is a core feature of an operating system and acts as the main interface between the computer’s hardware and the software which is running on it. Simply we can say that it is a resource manager which acts as a bridge between the hardware and software.
Its other main functions have:
- Memory Management
- Process Management
- Device Management
- Storage Management
What Is Shell?
Linux Shell is a command line interpreter, it translates the command given by users and converts them into a language that the kernel can understand. We can say that a shell is primarily an interface present between the kernel and the user. Its main function is to gather input from us and execute a program based on that input.
What is Shell Script?
Basically, a shell script is a list of commands in a computer program that are listed in the order of execution. A good shell script has proper comments, proceed by the #sign, describing the steps.
Evolution of the Shell
there are many shells present in Unix and Linux
Bourne Shell (sh): It was developed at AT&T Bell Labs by Stephen Bourne in 1977, the Bourne shell is known as the first UNIX shell ever. It is denoted as sh. At that time its gained popularity due to its consolidated nature and high speed of operation. Its grammar is very similar to algorithmic (ALGOL).
C Shell (csh): The C shell is developed by Bill Joy in 1978 with the objective of achieving a scripting language similar to the C programming language. This was useful given that C was a primary language in use back then which also made it easier and faster to use. One of the most notable features was command history.
Korn Shell (ksh): Korn Shell or KSH was developed by David Korn in 1983, which combined the features of the C shell, and Bourne Shell. It allows developers to develop and create new shell commands whenever it is required. There is the print command in the Korn shell to print the message in the terminal which is better than an echo in the Bash Shell.
Z Shell (zsh): Z Shell is a Unix-based shell or can be called a command-line interpreter. It is an extended version of the old Bourne shell with plenty of new features and support for plugins and themes.
Bourne – again Shell(Bash): bash shell is the GNU upgrade version of the Bourne shell(original UNIX shell) developed by Brian Fox in 1989. It is one of the most widely used shell distributions of GNU/Linux operating systems. It provides functional modifications over Bourne Shell for both programming and interactive uses. It incorporates command line key piping, bindings, editing, command history with unlimited size, etc.
Basically, Bourne – again Shell is a command line interpreter that typically runs in a text window where the user can interpret commands to carry out various activities. The combination of these commands as a series within a file is known as the Shell Script. It can read and run the commands from the Shell Script.
Shell Script vs bash in Linux?
Shell Script | Bash |
---|---|
The shell script can be executed in any shell in Linux. | The bash script is specifically created for Bash. |
It is a process to automate tasks as a group of commands. | It script is a subset of shell script. |
Shells may be one of Z, Korn, C shell, Bourne, Bash, etc. | The bash script is one format of the shell script. |
We can use shebang, “#!/bin/bash” if we want to use Bash if available. | We can use shebang, “#!/bin/sh” if we want to use sh. |
It is POSIX Compliance. | By default, Bash isn’t POSIX compliant, whereas .sh is. |
Linux introduction
Must Read: