What is linux shell and kernel

What is Linux Shell

Computers understand the language of zeros and ones known as binary language. In the early days of computing, instructions were provided using binary language, which is difficult for all of us to read and write. Therefore, in an operating system there is a special program called the shell. The shell accepts human readable commands and translates them into something the kernel can read and process.

Contents

What Is a Shell?

  • The shell is a user program or it is an environment provided for user interaction.
  • It is a command language interpreter that executes commands read from the standard input device such as keyboard or from a file.
  • The shell gets started when you log in or open a console (terminal).
  • Quick and dirty way to execute utilities.
  • The shell is not part of system kernel, but uses the system kernel to execute programs, create files etc.
  • Several shells are available for Linux including:
    • BASH ( Bourne-Again SHell ) — Most common shell in Linux. It’s Open Source.
    • CSH (C SHell) — The C shell’s syntax and usage are very similar to the C programming language.
    • KSH (Korn SHell) — Created by David Korn at AT & T Bell Labs. The Korn Shell also was the base for the POSIX Shell standard specifications.
    • TCSH — It is an enhanced but completely compatible version of the Berkeley UNIXC shell (CSH).

Please note that each shell does the same job, but each understands different command syntax and provides different built-in functions. Under MS-DOS, the shell name is COMMAND.COM which is also used for the same purpose, but it is by far not as powerful as our Linux Shells are!

Shell Prompt

There are various ways to get shell access:

  • Terminal — Linux desktop provide a GUI based login system. Once logged in you can gain access to a shell by running X Terminal (XTerm), Gnome Terminal (GTerm), or KDE Terminal (KTerm) application.
  • Connect via secure shell (SSH) — You will get a shell prompt as soon as you log in into remote server or workstation.
  • Use the console — A few Linux system also provides a text-based login system. Generally you get a shell prompt as soon as you log in to the system.

How do I find out my current shell name?

To find all of the available shells in your system, type the following command:

In case the /etc/shells file has more than one shell listed under it, then it means that more than one shell is supported by your platform.

Command Line Interface (CLI)

The shell provides an interface to Linux where you can type or enter commands using the keyboard. It is known as the command line interface (CLI). To find out your current shell type following command [1] .:

The following sample output indicate that I am using bash shell:

Basic Command Line Editing

You can use the following key combinations to edit and recall commands:

  • CTRL + L : Clear the screen.
  • CTRL + W : Delete the word starting at cursor.
  • CTRL + U : Clear the line i.e. Delete all words from command line.
  • Up and Down arrow keys : Recall commands (see command history).
  • Tab : Auto-complete files, directory, command names and much more.
  • CTRL + R : Search through previously used commands (see command history)
  • CTRL + C : Cancel currently running commands.
  • CTRL + T : Swap the last two characters before the cursor.
  • ESC + T : Swap the last two words before the cursor.
  • CTRL + H : Delete the letter starting at cursor.
Читайте также:  Visual html editor linux

Executing A Command

Type your command, and press enter key. Try this the date command which will display current date and time:

Command And File Completion

The Bash shell will auto complete file and command names, when possible and/or when you tell them to. For example, if you type sle and pressing Tab key will make the shell automatically complete your command name. Another example, if you type ls /e and pressing Tab key will make the shell automatically complete your word to /etc as it sees that /etc/ is a directory which starts with /e.

Источник

What is the Linux kernel?

Overview

The Linux® kernel is the main component of a Linux operating system (OS) and is the core interface between a computer’s hardware and its processes. It communicates between the 2, managing resources as efficiently as possible.

The kernel is so named because—like a seed inside a hard shell—it exists within the OS and controls all the major functions of the hardware, whether it’s a phone, laptop, server, or any other kind of computer.

What the kernel does

The kernel has 4 jobs:

Memory management: Keep track of how much memory is used to store what, and where

  • Process management: Determine which processes can use the central processing unit (CPU), when, and for how long
  • Device drivers: Act as mediator/interpreter between the hardware and processes
  • System calls and security: Receive requests for service from the processes
  • The kernel, if implemented properly, is invisible to the user, working in its own little world known as kernel space, where it allocates memory and keeps track of where everything is stored. What the user sees—like web browsers and files—are known as the user space. These applications interact with the kernel through a system call interface (SCI).

    Think about it like this. The kernel is a busy personal assistant for a powerful executive (the hardware). It’s the assistant’s job to relay messages and requests (processes) from employees and the public (users) to the executive, to remember what is stored where (memory), and to determine who has access to the executive at any given time and for how long.

    Where the kernel fits within the OS

    To put the kernel in context, you can think of a Linux machine as having 3 layers:

    1. The hardware: The physical machine—the bottom or base of the system, made up of memory (RAM) and the processor or central processing unit (CPU), as well as input/output (I/O) devices such as storage, networking, and graphics. The CPU performs computations and reads from, and writes to, memory.
    2. The Linux kernel: The core of the OS. (See? It’s right in the middle.) It’s software residing in memory that tells the CPU what to do.
    3. User processes: These are the running programs that the kernel manages. User processes are what collectively make up user space. User processes are also known as just processes. The kernel also allows these processes and servers to communicate with each other (known as inter-process communication, or IPC).
    Читайте также:  Linux nvidia and intel graphics

    Code executed by the system runs on CPUs in 1 of 2 modes: kernel mode or user mode. Code running in the kernel mode has unrestricted access to the hardware, while user mode restricts access to the CPU and memory to the SCI. A similar separation exists for memory (kernel space and user space). These 2 small details form the base for some complicated operations like privilege separation for security, building containers, and virtual machines.

    This also means that if a process fails in user mode, the damage is limited and can be recovered by the kernel. However, because of its access to memory and the processor, a kernel process crash can crash the entire system. Since there are safeguards in place and permissions required to cross boundaries, user process crashes usually can’t cause too many problems.

    Why choose Red Hat?

    At Red Hat, Linux is the foundation of everything we do. Red Hat is the second largest corporate contributor to the Linux kernel, bringing with it the experience and expertise of 25 years and a large community of partners, customers, and experts from across the industry. That’s a long relationship, with a history and level of experience that’s hard to come by.

    The Linux kernel is open source, and open source is at the core of Red Hat’s values. Learn why we’ve built our company on our conviction that Red Hat® Enterprise Linux is the best.

    Источник

    Kernel and Shell in Linux – Simplest Explanation

    Kernel and Shell are the most important components of Linux. We may think Shell as an examiner, if a command is suitable then only the Kernel run the command. Let’s learn it in detail.

    Table of Contents

    What is Shell in Linux?

    Whatever we do in Linux, Shell watches each and everything. Let’s take an example, please run the below commands one by one.

    and after that, run the below command.

    Did you see the difference? Well both the commands will print only Hello World. Here is the proof.

    But why they are printing the same? The second command should print the Spaces too. The multiple spaces are reduced to a single space. However the “echo” command does not print this, the Shell does this. Shell looks for some special characters. The multiple spaces seem to be a special character to the Shell. So, the shell squeezes all the multiple spaces into a single space, and that’s why it was printing without all the spaces.

    If you still want to print those spaces, you may use the below code, this time the spaces will appear.

    Types of Shell in Linux:

    Most important Types are:

    • PDKSH – Public Domain Korn Shell
    • TCSH – TENEX C Shell
    • BASH – Bourne Again Shell

    Keep in Mind

    Shell is actually the interface between the user and the Kernel. Shell has a programming capability of its own. We will see that later. Shell behaves like an examiner to each and every command. Firstly Shell analyzes the command and its arguments and then it tries to modify it to simplify. Then, after the simplification, Shell forwards the command to the Kernel, and then Kernel executes the command.

    What is Kernel in Linux?

    Many researchers said that Kernel is the “Heart of the System”, and they mean it. The Kernel actually runs the commands it gets from the Shell. A kernel is basically a collection of programs that directly communicates with the hardware. When the system boots up, it also loads in memory. The kernel does all the tasks like allocating memory, handling processes, and many other tasks. But, there is only one Kernel for any system.

    Читайте также:  Запуск неподписанных приложений mac os

    Kernel = Operating System?

    You got it right, the Kernel is often called the Operating System.

    Locations

    You can find the Kernel of your Linux in this location: /vmlinuz.

    You can find the Shell of your Linux in this Location: /bin/bash

    Do not forget to check our YouTube Channel – Tec4Tric.

    Источник

    Linux kernel structure block diagram

    There is an overall grasp of the kernel structure box, which helps to understand why the driver should write, why written applications can produce so many things.

    The library is like a «black box», providing a series of API dominant kernel operations, but you don’t know what the kernel has.

    The kernel is a very powerful super logic, abstraction of the bottom of the hardware, just need to adjust the API for the user, do not need to be used at all Register, protocol, bus . These are all made by the operating system. It is unrealistic to write an operating system.

    It is a very powerful engineer who can drive the character equipment and equipment equipment.

    Graphic Linux system system architecture

    The innermost layer is hardware, the outermost layer is user application, such as browser, and so on. Hardware is a material basis, while the application provides services.

    In order to facilitate the calling kernel, Linux makes the function interface of the kernel. System call . Users do not need to understand the complex structure of the kernel, you can use the kernel. System call is the operating systemMinimum functional unit. One operating system, as well as the operating system-based application, It is impossible to achieve the function of transcending system calls. 。

    The function provided by the system call is very basic, so it is very troublesome to use. A simple to allocate the operation of the memory space, you need to useMultiple system calls. Linux defines some Library function (library routine) To combine system calls into certain common functions. The above-mentioned allocation memory can be defined as a library function, such as commonly used malloc 。

    What is shell?

    Shell is a special application and is often called Command Line . It can be understood as a Command interpreter

    For example: When we enter » ls -l «When it, it interprets this string as

    1. Find the file (/ bin / ls) in the default path,
    2. Execute this file and come with parameter «-l».

    A philosophy of UNIX is to let each program tried to Independently do a small function . The shell acts as «glue» between these small features, allowing different programs to work with a clear interface (text stream) to enhance the functions of each program.

    A shell corresponds to a terminal (TERMINAL). Once, the terminal is a hardware device that is used to input and display the output. Today, due to the popularity of the graphical interface, the terminal tends to be like the figure below, is a graphical window.

    You can enter or output text through this window, this text is passed directly to the shell for analysis, then execute.

    Shell script

    Before there is no graphical interface, the shell acts as the user’s interface. When the user wants to run some app, run the program through the shell input command. Shell is programmable, it can be implemented Text in line with the shell grammar, such text is called shell script (Script) 。

    Источник

    Оцените статью