Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 95 ยท Getting Started

Getting Started with Linux and the Command Line

Learn what Linux is, how the kernel, distributions, shell and terminal fit together, and run your first real Bash commands right in your browser.

Linux runs most of the internet. The web servers behind the sites you visit, the containers your team deploys, the cloud machines you rent by the hour, most smartphones (Android is built on the Linux kernel) and every one of the world's fastest supercomputers all use it. If you write software for a living, sooner or later you will type commands into a Linux machine, and the people who do it comfortably are noticeably faster and more independent than those who do not.

This course teaches the Linux command line and the Bash language from the first command to real scripts. Every example runs in our editor on a real Linux machine with a real Bash 5 shell, so you can change a command and see what happens instead of just reading about it. This first lesson explains what the words mean (Linux, distribution, shell, terminal), why the command line is worth your time, and lets you run your first commands. The next lesson takes a command apart piece by piece.

What Linux actually is

Strictly speaking, Linux is only a kernel. The kernel is the core program of an operating system: it starts programs, hands out memory, talks to disks and network cards, and decides which program may use the processor at any moment. Everything else you touch, such as the commands, the desktop, the package installer, comes from other projects.

A distribution (or "distro") bundles the Linux kernel with a selection of those other programs, a way to install and update software, and sensible defaults. Debian, Ubuntu, Fedora, Arch, Alpine and Red Hat Enterprise Linux are distributions. They differ in how often they update, how they package software and who maintains them, but they all run the same kernel family and almost all of the same core tools. The commands you learn here work on all of them.

TEXT
  your programs and scripts
  ------------------------------------
  shell (bash)      desktop      services
  core tools: ls, cp, grep, tar, ...      <- the "GNU" part
  ------------------------------------
  C library (glibc / musl)
  ------------------------------------
  Linux kernel      <- talks to the hardware
  ------------------------------------
  CPU, memory, disk, network

Many of the everyday commands (ls, cp, sort, grep) come from the GNU project, which is why you will sometimes see the whole system called "GNU/Linux". You do not need to care about the naming, but it explains why option names on a Mac, which uses BSD tools, sometimes differ slightly. This course uses the GNU versions and points out differences where they matter.

Shell, terminal and command line

Three words are often mixed up:

  • The terminal (or terminal emulator) is the window where text appears and where your keystrokes go in. It is only a display.
  • The shell is the program running inside the terminal that reads what you type, understands it and starts other programs. When people say "the command line" they mean the shell prompt.
  • Bash is the most common shell and the one this course teaches. Its name is a pun on the older Bourne shell: the "Bourne-again shell". Others include zsh (the default on macOS), fish and the small dash.

When you open a terminal on a Linux server you see a prompt, often something like ada@server:~$, and the shell waits for a line. You type a command, press Enter, the shell runs it, prints the result and shows the prompt again. That loop is the whole interface.

In this course you will not see a prompt inside the examples. Our editor runs your code as a script: Bash reads the lines from top to bottom, runs each one and shows the output. Everything you learn works the same way at an interactive prompt, plus a few things that only make sense interactively (like tab completion), which we show as read-only snippets.

Your first commands

echo prints its arguments, and $BASH_VERSION is a variable that holds the version of the running shell. Run this and look at the result.

Bash Hello from a real Bash shell

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

uname -s asks the system for its kernel name, and it prints Linux. You are talking to a real Linux machine, and the lines you wrote ran one after another. Notice that you wrote words without any brackets, commas or semicolons: a shell command is a name followed by arguments separated by spaces, which is exactly what the next lesson explores.

Now ask for more information about the system and look at a tiny text file that describes the distribution:

Bash Which system am I on?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Three things are new here. $(command) runs a command and pastes its output into the line (command substitution, see xargs and command substitution). head -n 2 shows only the first two lines of its input. And /etc/os-release is an ordinary text file; almost all configuration on Linux is plain text you can read with simple tools. The sandbox runs Debian 10, a stable and widely used distribution, on a 64-bit Intel-compatible processor.

Why use the command line?

Graphical interfaces are great for things you do once. The command line wins when you need to do something many times, precisely, or on a machine you cannot see.

  • It is repeatable. A command can be saved in a script and run again tomorrow, on a hundred servers, by a scheduler, with the same result. Clicks cannot be saved like that.
  • It composes. Small tools do one job each, and the pipe | connects the output of one to the input of the next. Counting the unique words in a file is one line, not a program.
  • It works remotely. Servers and containers usually have no screen. You log in over SSH and a shell is all there is.
  • It is fast. Once you know the commands, renaming 500 files or searching a gigabyte of logs takes seconds.
  • It is the lingua franca of development. Documentation, build systems, Git, Docker and cloud tools all assume a shell.

Here is a small taste of composition. The printf command writes text, and the pipeline sorts the lines and counts how many times each appears:

Bash Small tools, one pipeline

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The output is 3 apple, 2 pear and 1 fig, with the most frequent first. Four programs, none of which knows about the others, produced a frequency table. You will build pipelines like this in Building Text Pipelines, after learning the tools one at a time.

The command line is less forgiving than a mouse. A mistyped rm can delete real files and there is no recycle bin. You will learn safe habits early (see Copying, Moving and Deleting), and everything in this course runs in a throwaway directory that disappears after each run, so you can experiment freely.

Everything is a file

A core idea of Linux is that many things are presented as files in one big tree of directories: documents, of course, but also devices (/dev), information about running processes (/proc) and settings (/etc). The same tools (cat, grep, redirection) therefore work on all of them. You will meet the tree properly in The Linux Filesystem. For now, a first peek: the kernel exposes its own version as a file.

Bash The kernel as a file

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

/proc/version starts with the word Linux, followed by the kernel release and build details. We print only five characters because the rest varies from machine to machine. The second half creates note.txt with the redirection operator >, which sends output to a file instead of the screen, and cat prints the file back. The file exists only inside this one run.

What our sandbox can and cannot do

Each example runs in a fresh temporary directory on a real Linux system. Files you create live only for that run, and the next run starts empty, so every example sets up what it needs. A few limits are worth knowing:

  • No network: curl, ping and ssh to real hosts fail.
  • No sudo or root access, no installing packages, no systemd.
  • No interactive programs such as vim, nano, less or top, and no manual pages. Those appear as read-only snippets.
  • A few seconds of run time and a limited amount of output.

Everything else, including the shell, the core tools, text processing, scripting and Git, is real and works exactly as on a server. When a snippet would need something the sandbox lacks, we label it clearly as read-only, and you can try it on your own machine. If you do not run Linux yet, the easiest ways to get a real shell are Windows Subsystem for Linux, a virtual machine, a cloud server or Docker; macOS users already have a similar shell, with BSD versions of some tools.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is Linux, strictly speaking?

    Linux is the kernel. A distribution combines it with the shell, core tools, a package manager and defaults to make a complete system.
  2. 2. Which statement about shell, terminal and Bash is correct?

    The terminal is the window, the shell is the program that reads and runs your commands, and Bash is the most common shell.
  3. 3. Why are shell commands called composable?

    The pipe operator lets you chain small programs, so complex jobs become short pipelines.
  4. 4. What does $(uname -s) do inside a command line?

    $( ... ) is command substitution: the output of the inner command replaces the whole expression.
  5. 5. Which of these can you NOT do in this course's editor?

    The sandbox has no network, so commands that contact real hosts fail. Local files, scripts and Git work normally.

Summary

  • Linux is a kernel; a distribution adds the shell, tools and software installation. The core commands are shared across distributions.
  • The terminal shows text, the shell runs your commands, and Bash is the shell this course teaches.
  • The command line is repeatable, composable, works on remote machines and is the common language of development tools.
  • Many things in Linux appear as files in a single directory tree, so the same tools work on them.
  • Our examples run real Bash 5 on Debian in a throwaway directory, without network, root or interactive programs.

Next: The Shell: Commands, Arguments and Options