Skip to content
C Codeloom
Linux

The Linux Terminal: A Beginner's Guide

Open a terminal, read the prompt, and learn the handful of conventions that make every command-line tool consistent. The foundation for everything else you will do on Linux.

·9 min read · By Yash Kesharwani
Beginner 10 min read

What you'll learn

  • What a terminal, shell, and prompt actually are
  • How to open a terminal on Ubuntu/Debian and macOS
  • How to read every part of the shell prompt
  • The anatomy of a command — name, options, arguments
  • Essential keyboard shortcuts and history navigation
  • How to get help for any command on the system

Prerequisites

  • Read What is Linux? first if you are new to Linux
  • A working terminal — native Linux, WSL on Windows, or Terminal on macOS

The terminal is the primary working surface for almost everything in Linux. It looks plain, but a few hours of practice turns it into the fastest way most developers can move on a computer. This post covers the conventions that make the terminal work — once you know these, every individual command becomes much easier to learn.

Terminal, shell, and prompt

Three words you will hear used loosely. They mean different things.

  • The terminal (or terminal emulator) is the window itself — the app that displays text and accepts keystrokes. Examples: GNOME Terminal on Ubuntu, Terminal.app on macOS, Windows Terminal on Windows.
  • The shell is the program running inside the terminal that reads what you type, interprets it as a command, runs it, and prints the result. The most common shells are bash (the default on most Linux servers) and zsh (the default on macOS since 2019 and on some distributions).
  • The prompt is the short string the shell prints to indicate it is waiting for input — for example yash@laptop:~$.

In day-to-day conversation people say “open a terminal” to mean all three.

Opening a terminal

Ubuntu/Debian (desktop): press Ctrl+Alt+T, or open the application menu and search for “Terminal”.

macOS: press Cmd+Space to open Spotlight, type “Terminal”, and press Enter.

Windows (WSL): open the Start menu, type “Ubuntu” (or whatever distribution you installed), and press Enter. You can also open Windows Terminal and pick the Ubuntu profile.

A remote server: use ssh user@host from any terminal — we will cover SSH later in the series.

You should see a window containing a prompt, a cursor, and nothing else. That is correct. The shell is waiting.

Reading the prompt

A typical Linux prompt looks like this:

yash@laptop:~/projects$

Each piece carries information:

  • yash — the current username.
  • @laptop — the hostname of the machine. Useful when you are logged into a remote server and want to be sure you are not about to run something dangerous on the wrong box.
  • :~/projects — the current working directory. The tilde ~ is shorthand for your home directory (/home/yash on Linux, /Users/yash on macOS). ~/projects means “the projects folder inside my home directory.”
  • $ — indicates a normal user shell. A # instead means you are running as root (the administrator account) and should be careful.

On macOS the default zsh prompt is shorter — often just laptop:projects yash % or similar — but the same pieces are there.

Type a command, press Enter, and the shell runs it. The output appears below, then a new prompt appears.

The anatomy of a command

Almost every command follows the same three-part shape:

command [options] [arguments]
  • command — the name of the program to run, e.g. ls, cat, grep.
  • options (also called flags) — modify the command’s behaviour. Short options use a single dash and one letter (-l); long options use two dashes and a word (--long). Many tools accept both forms for the same thing.
  • arguments — the things the command operates on, usually files or paths.

A concrete example:

ls -l /etc
  • ls is the command (list directory contents).
  • -l is an option (use the long, detailed format).
  • /etc is the argument (the directory to list).

Short options can usually be combined. ls -l -a and ls -la mean the same thing.

Some options take their own argument:

grep -n "TODO" notes.txt

Here -n requests line numbers, "TODO" is the pattern to search for, and notes.txt is the file to search.

Your first few commands

Run each of these and read the output. We will cover them properly in the next post, but seeing them now anchors the rest of this guide.

pwd          # print working directory
ls           # list files in the current directory
ls -la       # long listing, including hidden files
whoami       # print your username
date         # print the current date and time
echo hello   # print "hello"
clear        # clear the terminal screen (Ctrl+L also works)

None of these change anything on disk. They are safe to run anywhere.

Try it yourself. Open a terminal and run each command above in order. After ls -la, look at the leftmost column — those drwxr-xr-x strings are file permissions, which we cover in the last post in this series. For now, just notice that files beginning with . (a dot) only appear when you pass -a.

Keyboard shortcuts that pay for themselves immediately

These are the ones that genuinely change how fast you work. Learn them now.

ShortcutEffect
TabAuto-complete the current word — file names, command names, paths.
Tab TabShow all possible completions when the prompt is ambiguous.
Up Arrow / Down ArrowStep through previous commands.
Ctrl+RSearch command history. Start typing, press Ctrl+R again to cycle.
Ctrl+A / Ctrl+EJump to the start / end of the line.
Ctrl+UDelete from cursor to start of line.
Ctrl+KDelete from cursor to end of line.
Ctrl+WDelete the word before the cursor.
Ctrl+LClear the screen (same as clear).
Ctrl+CCancel the current command / line.
Ctrl+DSend end-of-file. On an empty prompt, this exits the shell.

Tab completion alone removes a huge amount of typing. If you type cd Doc and press Tab, the shell will complete to cd Documents/ if there is only one match.

Command history

Every command you run is saved to a history file (~/.bash_history for bash, ~/.zsh_history for zsh). Two commands let you inspect it directly:

history          # print the full history with line numbers
history | tail   # just the last few entries

You can also re-run a previous command by its history number with !N — for example !42 re-runs command number 42. !! re-runs the last command, which is most useful after forgetting sudo:

apt update             # permission denied
sudo !!                # re-runs as: sudo apt update

Getting help

You will not memorise every command. Nobody does. Linux comes with multiple built-in ways to look things up.

man — the manual page. Comprehensive, sometimes terse, always authoritative.

man ls

Press Space to scroll, q to quit, /text to search inside the page.

--help — most commands accept a --help flag that prints a short usage summary.

ls --help

This is faster than man for a quick reminder of what an option does.

tldr — a community-maintained collection of practical examples. It is not installed by default; install it once and you will use it daily.

# Ubuntu/Debian
sudo apt install tldr

# macOS
brew install tldr

# Then:
tldr tar

The output is a handful of common usages with explanations — much more digestible than man when you just need to remember how to extract a .tar.gz.

Try it yourself. Run man ls, scroll through the options, and find the flag that sorts files by modification time. (Hint: search with /time.) Then run ls with that flag in a directory you know to confirm it works as described.

Cancelling, exiting, and being safe

A few habits that prevent the most common beginner mistakes.

  • If a command appears stuck, press Ctrl+C to cancel it. This sends an interrupt signal to the running program.
  • If a command is producing endless output, Ctrl+C stops it. Do not close the window — the program may keep running in the background.
  • To close the shell entirely, type exit and press Enter, or press Ctrl+D on an empty prompt.
  • Be cautious with sudo. Prefixing a command with sudo runs it as the root user, with full permission to delete or change anything. Read what you are about to run.
  • Never run rm -rf on a path you have not checked twice. Linux does not have a Recycle Bin for files removed from the command line — rm deletes permanently.

A small terminal session

Here is the kind of short, useful session that becomes second nature within a week of using the shell:

pwd                       # where am I?
cd ~/projects             # go to my projects folder
ls                        # what is in here?
mkdir linux-practice      # make a new folder
cd linux-practice         # enter it
echo "hello" > note.txt   # create a file with text in it
cat note.txt              # print the file's contents
ls -la                    # confirm it's there

Every command above will be explained in the next post. The point here is the texture — short commands, immediate feedback, no waiting for windows to open.

Recap

You now know:

  • A terminal is the window, a shell is the program inside it, and the prompt tells you who and where you are
  • Commands have the shape command [options] [arguments]; short flags use -x, long flags use --name
  • Tab completion, Ctrl+R history search, and the arrow keys remove most typing
  • man, --help, and tldr cover every help case you will run into
  • Ctrl+C cancels a running command; sudo runs the next command as root and should be used deliberately

Next steps

In the next post we cover the twenty essential commands every developer should know — navigation, file inspection, copying, moving, searching, and process control. By the end of it you will be able to do real work from the shell alone.

→ Next: 20 Essential Linux Commands Every Developer Should Know

Questions or feedback? Email codeloomdevv@gmail.com.