Kernel vs Shell
The kernel talks to the hardware; the shell is the program that reads and runs your typed commands.
It helps to picture Linux as a set of layers. You type into the outer layer and your request travels inward toward the hardware.
The two roles
- The kernel is the heart of Linux. It manages memory, the CPU, files and devices. You never talk to it directly.
- The shell is a program (usually
bash) that reads the text you type, runs the matching command, and shows the result.
This tutorial is really about mastering the shell.
Example
# Which shell am I currently using?
echo $SHELL
# Output: /bin/bash
# List the shells installed on this system
cat /etc/shellsWhen to use it
- A kernel developer writes a C module that registers a new system call, interacting with the kernel directly without a shell.
- A CI pipeline uses Bash scripts to orchestrate build steps, relying on the shell to sequence commands and capture output.
- A sysadmin switches a user's login shell from bash to zsh with 'chsh' to give them better auto-completion.
More examples
Identify active shell
Prints the path and version of the currently running shell process.
echo $SHELL
# /bin/bash
echo $BASH_VERSION
# 5.2.21(1)-releaseList available shells
Shows every shell installed on the system; only shells in this file may be set as a login shell.
cat /etc/shells
# /bin/sh
# /bin/bash
# /usr/bin/bash
# /bin/zsh
# /bin/fishTrace shell-to-kernel calls
Uses strace to reveal the kernel calls a shell command triggers, making the kernel-shell boundary visible.
# Trace system calls a simple command makes to the kernel
strace -e trace=openat echo hello 2>&1 | head -4
# openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
# openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", ...) = 3
Discussion