Skip to content

Understanding the Shell

The shell is the primary interface between you and the Linux operating system. Every command you type is interpreted by the shell before being executed. Understanding how the shell works is the first step toward becoming a confident Linux administrator or DevOps engineer.


Learning Path

Linux Mastery → Module 2: Linux Command Line Essentials → Lesson 1

Difficulty: Beginner

Reading Time: 20 Minutes

Course Progress

Course: Linux Mastery

Module: Linux Command Line Essentials

Lesson: 1 of 10


What You'll Learn

By the end of this lesson, you'll be able to:

  • Understand what the Linux Shell is
  • Differentiate the Shell, Terminal, and Kernel
  • Learn how the shell executes commands
  • Explore different shell types
  • Identify your current shell
  • Change shells
  • Understand why the shell is important in Cloud and DevOps

Prerequisites

Before starting this lesson, you should complete:

  • Module 1 – Linux Fundamentals

Why Learn the Shell?

Every interaction with Linux happens through the shell.

When you:

  • Create files
  • Start services
  • Deploy applications
  • Configure Kubernetes
  • Manage cloud servers

you're communicating with Linux through a shell.

The shell is one of the most important tools for every Linux professional.


What is a Shell?

A Shell is a command interpreter.

It reads commands entered by the user, interprets them, and asks the Linux Kernel to execute them.

Simply put:

The shell acts as a translator between the user and the operating system.


How the Shell Works

User


Shell


Kernel


Hardware


Kernel


Shell


User

Example:

mkdir projects

Execution flow:

User


Types:

mkdir projects


Shell interprets command


Kernel creates directory


Result returned


Shell displays prompt

The shell itself doesn't create the directory—it requests the kernel to do so.


Shell vs Terminal

Many beginners confuse these terms.

Terminal Shell
Application Command Interpreter
Provides a window Executes commands
GNOME Terminal, Konsole Bash, Zsh, Fish
User Interface Program

Example:

GNOME Terminal


Bash Shell


Linux Kernel

Shell vs Kernel

Shell Kernel
Accepts commands Controls hardware
Runs in User Space Runs in Kernel Space
Can be changed Core of Linux
Multiple shells available Only one running kernel

Popular Linux Shells

Linux supports multiple shells.

Shell Description
Bash Default on most Linux distributions
Zsh Powerful and customizable
Fish Beginner-friendly shell
Korn Shell (ksh) Enterprise UNIX environments
C Shell (csh) BSD systems

Among these, Bash is the most widely used and is the shell you'll use throughout this course.


Bash (Bourne Again SHell)

Bash is the default shell on most Linux distributions.

Features include:

  • Command history
  • Auto-completion
  • Variables
  • Aliases
  • Loops
  • Conditions
  • Functions
  • Shell scripting

Most DevOps tools and automation scripts assume Bash is available.


Check Your Current Shell

Display your current shell:

echo $SHELL

Example output:

/bin/bash

or

/bin/zsh

List Available Shells

View installed shells:

cat /etc/shells

Example:

/bin/bash
/bin/sh
/bin/zsh
/bin/dash

Which Shell Am I Using?

Display the current shell process:

ps -p $$

Example:

PID TTY      TIME CMD

1234 pts/0   bash

Changing Your Default Shell

Display your current shell:

echo $SHELL

Change your default shell:

chsh -s /bin/bash

or

chsh -s /bin/zsh

Log out and log back in for the change to take effect.


How the Shell Executes Commands

When you type:

ls

the shell follows these steps:

Read Command


Parse Command


Find Executable


Execute Program


Wait for Completion


Display Output


Show Prompt

This entire process happens in milliseconds.


Built-in Commands vs External Commands

Some commands are built into the shell.

Examples:

cd

pwd

history

alias

export

Others are external programs.

Examples:

ls

cp

mv

grep

find

Check command type:

type cd

type ls

Example output:

cd is a shell builtin

ls is /usr/bin/ls

Shell Prompt

Example:

basha@rebash:~$

Meaning:

Component Description
basha Username
rebash Hostname
~ Current Directory
$ Normal User

Root prompt:

root@server:~#

The # symbol indicates the root user.


Production Perspective

Cloud engineers spend most of their day working inside a shell.

Examples:

ssh server01

kubectl get pods

docker ps

terraform apply

git pull

systemctl restart nginx

Every DevOps tool is controlled through a shell.

Learning the shell is essential for automation and infrastructure management.


Hands-on Lab

Task 1

Check your current shell.

echo $SHELL

Task 2

List available shells.

cat /etc/shells

Task 3

Check which shell process is running.

ps -p $$

Task 4

Determine whether commands are built-in or external.

type cd

type ls

type echo

type pwd

Task 5

Display your shell prompt information.

echo $USER

hostname

pwd

Best Practices

  • Learn Bash thoroughly before exploring other shells.
  • Use Tab completion to reduce typing errors.
  • Understand the difference between built-in and external commands.
  • Practice using the terminal every day.
  • Avoid running commands as the root user unless necessary.

Common Mistakes

❌ Thinking the terminal and shell are the same.

✅ The terminal is the interface; the shell interprets commands.


❌ Assuming Linux has only one shell.

✅ Linux supports multiple shells such as Bash, Zsh, Fish, and Korn Shell.


❌ Believing the shell executes hardware operations.

✅ The shell requests the Linux Kernel to perform system operations.


Interview Questions

Beginner

  1. What is a Linux Shell?
  2. What is Bash?
  3. What is the difference between a Terminal and a Shell?
  4. Which command displays the current shell?

Intermediate

  1. Explain how the shell executes commands.
  2. What are shell built-in commands?
  3. How do you change your default shell?

Architect Level

  1. Why is the shell essential for DevOps and Cloud Engineering?
  2. How does understanding shell internals improve troubleshooting?
  3. Why is Bash the standard shell for automation?

Summary

In this lesson, you learned:

  • What a Linux Shell is
  • How the shell communicates with the Linux Kernel
  • Different types of Linux shells
  • Bash fundamentals
  • Built-in vs external commands
  • How to identify and change your shell

The shell is your primary tool for interacting with Linux. Mastering it will make every future topic—from file management to shell scripting and automation—much easier.


Key Takeaways

  • The shell is a command interpreter.
  • The terminal provides the interface, while the shell processes commands.
  • Bash is the most widely used Linux shell.
  • The shell communicates with the Linux Kernel to execute commands.
  • Understanding the shell is essential for Linux administration, DevOps, and Cloud Engineering.

What's Next?

Bash Basics

In the next lesson, you'll learn:

  • Bash syntax
  • Running commands
  • Variables
  • Quoting
  • Command substitution
  • Environment variables
  • Your first Bash scripts