LearnAI ToolsCareerPractice BuildsPlayDevelopmentContact
Lesson 112 min read

Introduction to Linux and the Command Line

Learn what Linux is, why it runs most of the world’s servers, what a shell and terminal are, and run your first commands.

Linux & Command Line learning pathLesson 1 of 14
View course
On this page 11 sections

Introduction

Most websites, cloud services, Android phones and supercomputers run on Linux. When developers deploy an app, connect to a server or build a Docker container, they are almost always working at a Linux command line. Learning it is one of the most useful skills in tech: it makes you faster on your own computer and is essential for backend, DevOps, cloud and security work.

What You Will Learn
  • What Linux and Linux distributions are.
  • The difference between a terminal, a shell and the command line.
  • How to run your first commands and read their output.
  • How commands, options and arguments fit together.

What Is Linux?

Linux is a free, open-source operating system kernel — the core program that manages a computer’s processor, memory, disks and devices. Linus Torvalds released the first version in 1991 as a student project, and thousands of developers and companies have contributed to it since. Combined with tools from the GNU project and others, it forms complete operating systems used everywhere:

Servers and the cloud

The large majority of web servers and cloud virtual machines run Linux, including the servers behind most websites you visit.

Containers

Docker containers are built on Linux features, and nearly all container images are based on a Linux distribution.

Phones and devices

Android is built on the Linux kernel, as are smart TVs, routers, cars and countless other embedded devices.

Supercomputers

Every one of the world’s 500 fastest supercomputers runs Linux.

Distributions

A distribution (or “distro”) packages the Linux kernel together with tools, a package manager and often a desktop. They share the same core commands, so what you learn here works almost everywhere:

DistributionKnown for
UbuntuThe most popular choice for beginners, cloud servers and WSL on Windows. Used throughout this course.
DebianStable and conservative; Ubuntu is based on it.
FedoraUp-to-date software; sponsored by Red Hat.
Red Hat Enterprise Linux, Rocky, AlmaLinuxEnterprise servers with long-term support.
AlpineTiny — very common as a base for Docker images.
ArchBuild-it-yourself; popular with enthusiasts.

Terminal, Shell and Command Line

These words are often used interchangeably, but they mean different things:

  • The terminal is the window you type into — an app such as Windows Terminal, GNOME Terminal or macOS Terminal.
  • The shell is the program inside it that reads your commands and runs them. The most common one on Linux is Bash; macOS uses Zsh, which is very similar.
  • The command line is the text interface as a whole: you type a command, press Enter, and read the result.

Before each command, the shell shows a prompt, usually in the form user@computer:folder$. For example, priya@laptop:~$ means the user priya on a computer named laptop, in her home folder (~). The $ means a normal user; a # means you are the all-powerful root user. In this course, commands are shown without the prompt so you can copy them directly.

Your First Commands

Open a terminal (the next lesson shows how on any computer) and try these. whoami prints your username:

whoami
Output

Click Run to see what this code prints.

hostname prints the computer’s name, and pwd (print working directory) shows which folder you are in:

hostname
pwd
Output

Click Run to see what this code prints.

echo prints whatever you give it — handy for testing and, later, for scripts:

echo "Hello, Linux!"
Output

Click Run to see what this code prints.

And this shows which Linux you are running. Every distribution describes itself in the file /etc/os-release:

cat /etc/os-release | head -4
Output

Click Run to see what this code prints.

Mini Challenge · Predict the Output

Your terminal shows the prompt arjun@webserver:/var/www$. What does it tell you?

Choose one answer

Anatomy of a Command

Most commands follow the same pattern: the command name, then options that change its behaviour, then arguments that say what to act on:

PartExample in ls -l /homeMeaning
CommandlsThe program to run — here, “list files”
Option (flag)-lChanges how it works — here, “long format”. Long options look like --help
Argument/homeWhat to work on — here, the /home folder

Nearly every command explains itself with --help, and man <command> opens its full manual (press q to quit):

ls --help | head -5
Output

Click Run to see what this code prints.

Mini Challenge · Put It in Order

Put the steps of running a command in the order they happen.

  1. The shell shows a prompt and waits
  2. The shell finds the program and runs it
  3. The shell splits it into the command, options and arguments
  4. The output appears, followed by a new prompt
  5. You type a command and press Enter

When Something Goes Wrong

Linux is case-sensitive and literal. A typo produces an error rather than a guess:

ehco "oops"
Output

Click Run to see what this code prints.

Read error messages carefully — they nearly always say exactly what went wrong. (On Ubuntu desktops you may also see a suggestion such as “did you mean: echo”.) Two keyboard shortcuts will save you constantly: the Up arrow brings back previous commands, and Tab completes command and file names for you.

ShortcutWhat it does
TabComplete a command or file name (press twice to see options)
Up / Down arrowsScroll through your previous commands
Ctrl+CStop the command that is running
Ctrl+LClear the screen (same as the clear command)
Ctrl+RSearch your command history

Common Mistakes

Avoid These Mistakes
  • Typing Documents when the folder is called documents — Linux treats them as different names.
  • Copying a command from the internet without understanding it, especially ones that start with sudo.
  • Typing the $ from a tutorial’s prompt as part of the command.
  • Ignoring the error message and trying random fixes instead of reading what it says.

Frequently Asked Questions

No. Windows users can use WSL, macOS has a very similar Unix terminal built in, and you can also use a free cloud server or a Docker container. Lesson 2 covers all of these.

Very much. Servers usually have no graphical interface, automation and scripts are written as commands, and many tasks are simply faster to type than to click.

Yes. The kernel and most distributions, including Ubuntu, Debian and Fedora, are free to download and use. Some companies pay for enterprise distributions mainly for support.

Key Takeaways

  • Linux is a free, open-source operating system kernel that runs most servers, clouds and containers.
  • Distributions such as Ubuntu package Linux with tools; the core commands work across them.
  • The terminal is the window, the shell (usually Bash) runs your commands.
  • Commands follow the pattern: command, options, arguments. Use --help and man to learn more.
  • Linux is case-sensitive; read error messages and use Tab completion and command history.

Summary

You know what Linux is, what the shell does and how commands are built, and you have run your first ones. Next, you will get a Linux terminal running on your own computer — whether it uses Windows, macOS or Linux.

Next Lesson →

Getting a Linux Terminal on Any Computer