Detailed Explanation: Understanding the Shell
The slide introduces the concept of the shell in operating systems, particularly
emphasizing its importance for power users, administrators, and anyone working in
technical fields like pentesting, system administration, or development. Let's break down
each bullet point in detail.
1. "The shell is the part of the operating system that interprets commands and
translates them to machine code that is executed by the kernel"
• What is the shell? The shell is a command-line interpreter—a program that acts
as an intermediary between the user and the operating system's kernel (the core
component that manages hardware, memory, processes, etc.).
• How it works:
1. You type a command (e.g., ls, dir, whoami, netstat).
2. The shell parses and interprets that command (checks syntax, expands
wildcards like *, handles variables, pipes , redirects >, etc.).
3. The shell then asks the kernel to execute the corresponding program or
system call.
4. The kernel performs the actual low-level operations (reading files, creating
processes, accessing network, etc.).
5. Results are sent back through the shell to your screen.
• Key point: The shell itself doesn't directly manipulate hardware or files—it
translates human-readable commands into instructions the kernel understands.
• Examples:
o Typing rm [Link] → shell interprets it → requests kernel to delete the file.
o ps aux | grep ssh → shell handles the pipe (), runs both commands, connects
their input/output.
2. "Computer operating systems can use either a command line interface (CLI) or
graphical user interface (GUI) as shell"
• CLI (Command Line Interface): Text-based interaction via a terminal/shell (e.g.,
Windows Command Prompt, PowerShell, Linux Terminal, macOS Terminal).
• GUI (Graphical User Interface): Visual interaction via windows, icons, mouse (e.g.,
Windows Explorer, macOS Finder, GNOME/KDE on Linux).
• Important clarification: Technically, the GUI is not a shell in the traditional sense.
The slide simplifies this for beginners.
o The true "shell" refers to the CLI program (like Bash, [Link], PowerShell).
o Modern desktop environments (e.g., Windows Explorer, GNOME) provide a
graphical shell that also interprets user actions (clicks, drags) and translates
them to kernel calls.
o So both CLI and GUI serve as user interfaces to the OS, but only the CLI is
classically called "the shell."
• Why the distinction matters: CLI shells give direct, precise, scriptable control.
GUIs are user-friendly but limited.
3. "As GUIs often only offer a limited subset of functionality that is available on the
CLI, it makes sense to learn how to work with a shell to unleash the operating system
full power"
• This is the core motivation for learning the shell.
• Why GUI is limited:
o GUIs expose only common features (e.g., File Explorer lets you copy/delete
files but not easily filter by size/date via complex logic).
o No easy automation/repetition (e.g., renaming 1000 files with a pattern).
o Limited chaining of operations (no direct equivalent to pipes or scripting).
o Harder to work remotely (GUI often requires graphical session; CLI works
over SSH/WinRM easily).
• Advantages of CLI/shell:
o Full access: Every feature the OS supports is available via commands.
o Automation & scripting: Write scripts (bash, PowerShell, batch) to automate
repetitive tasks.
o Precision & speed: Experienced users perform tasks faster (e.g., find . -
name "*.log" -delete vs. manually hunting files).
o Remote administration: Manage servers without GUI (most servers are
headless).
o Chaining tools: Combine simple tools into powerful workflows (grep, awk,
netstat, ps, etc.).
• Real-world example:
o GUI: Right-click → Properties → Security tab to check permissions.
o CLI: icacls "C:\Path\To\File" or Get-Acl in PowerShell → faster, scriptable,
works remotely.
4. "In Linux, Bash is the default shell"
• Bash = Bourne Again Shell.
o Successor to the original Bourne Shell (sh).
o Default interactive shell on most Linux distributions (Ubuntu, Debian,
CentOS, Kali, etc.) and macOS (until recent versions switched to zsh).
o Also available on Windows via WSL (Windows Subsystem for Linux), Git
Bash, or Cygwin.
• Other common shells on Linux/Unix:
o zsh (Z Shell): More feature-rich, popular on macOS now, highly customizable
(Oh My Zsh).
o fish (Friendly Interactive Shell): User-friendly with autosuggestions.
o dash, ksh, tcsh — less common for interactive use.
• How to check your shell: echo $SHELL or ps $$
• Why Bash matters: Most tutorials, scripts, and system admin tasks assume Bash
knowledge.
Summary: Why Learn the Shell?
• Efficiency: Faster task completion once proficient.
• Power: Access to all system capabilities.
• Automation: Essential for scripting and DevOps/SecOps.
• Remote work: Critical for managing servers, pentesting (e.g., reverse shells, post-
exploitation via WinRM/SSH).
• Foundation: Understanding the shell helps you understand how operating systems
truly work under the GUI hood.
In pentesting/red teaming contexts (like your earlier scenarios), shells are crucial: getting a
shell (via exploit), stabilizing it (PsExec vs. WinRM), escalating privileges, and performing
post-exploitation—all done primarily through CLI commands.
Start simple: Learn basic commands (ls/dir, cd, pwd, whoami, cat/type, grep/findstr), then
pipes/redirection, then scripting. You'll quickly see the "full power" the slide mentions!
Example of output redirection:
Use help to see the internal commands
Using which and man commands you can get details.
Variable by nature is local.
Every single command that you are going to run is starting a sub shell by itself. And if you
want your variables to be available, then you will use export
export mynewvar=red