SkillSprout
Chapter 1 · Lesson 1
Beginner
2 min read

Terminal, Shell and Prompt

Overview

The terminal is a window that displays text and accepts keyboard input. The shell reads that input and decides which program to run. Bash is a common Linux shell, but the same principles apply to Zsh and other shells.

Detailed Notes

What happens when you type a command

Suppose you type:

bash
echo Hello Linux

The shell separates the text into words:

  1. echo is the program to run.
  2. Hello is argument 1.
  3. Linux is argument 2.

The echo program joins its arguments and writes Hello Linux to standard output.

The prompt identifies a waiting shell. A common prompt looks like:

text
learner@ubuntu:~$
  • learner is the user.
  • ubuntu is the computer name.
  • ~ means the user's home directory.
  • $ indicates a normal user. # often indicates root.

Built-in help

bash
echo "$SHELL"
type ls
ls --help
man ls
  • echo "$SHELL" prints the configured login shell.
  • type ls shows whether ls is a program or shell alias/builtin.
  • ls --help prints a short option summary.
  • man ls opens the full manual page. Press q to quit.

Useful keyboard behavior

bash
pwd
  • Press Tab once to complete a filename or command.
  • Press Tab twice to list alternatives.
  • Press Ctrl+L to clear the visible terminal.
  • Press Up Arrow to recall the previous command.
  • Press Ctrl+C to interrupt a running foreground process.
  • Press Ctrl+D to send end-of-input or close the shell.

Practice

  1. Print your shell.
  2. Run pwd.
  3. Type ech, press Tab and finish the command.
  4. Open man pwd, read a few lines and quit.
Terminal to Running Program
Architecture
Usertypes echoTerminaltext interfaceShellparses commandechowrites outputkeypressescommand textrun
Key point. The shell manages input and output; each command is a separate program or shell builtin.

The terminal receives text, while the shell finds and starts the requested program.

Common Interview Questions

Finished this lesson?

0 of 25 lessons done · 0% of the course