Introduction to Linux
By Flavio Copes
An introduction to Linux, the free and open source operating system that powers most servers, covering distributions, the kernel, shells and Bash.
Linux is an operating system, like macOS or Windows.
It is also the most popular Open Source and free, as in freedom, operating system.
It powers the vast majority of the servers that compose the Internet. It’s the base upon which everything is built upon. And not just servers: Android is based on a modified version of Linux.
The kernel and the distributions
Strictly speaking, Linux is a kernel: the core program that manages processes, memory, devices, filesystems, and communication with the hardware. Linus Torvalds started it in Finland in 1991, and it went a really long way from its humble beginnings. It became the kernel of the GNU Operating System, creating the duo GNU/Linux.
A kernel alone is not something you can use. That’s why we have distributions.
A “distro” is made by a company or organization and packages the Linux kernel with system tools, libraries, a package manager, and a maintained collection of software. This is also why there’s not just “one Linux”, like it happens on Windows or macOS.
For example you have Debian, Fedora, and Ubuntu, probably the most popular.
Many, many more exist. You can create your own distribution, too. But most likely you’ll use a popular one, one that has lots of users and a community of people around it, so you can do what you need to do without losing too much time reinventing the wheel and figuring out answers to common problems.
One practical consequence: instructions are often distribution-specific. Ubuntu and Debian install software with apt, Fedora uses dnf. If a tutorial’s package manager command fails with command not found, you are probably reading instructions written for a different distribution.
Why people care about Linux
There’s one thing about Linux that corporations like Microsoft, Apple, or Google will never be able to offer: the freedom to do whatever you want with your computer.
They’re actually going in the opposite direction, building walled gardens, especially on the mobile side.
Linux is developed by volunteers, some paid by companies that rely on it, some independent, but there’s no single commercial company that can dictate what goes into Linux, or the project priorities. No one can dictate which apps you can run, or ship apps that “call home” and track you.
Linux can also be your day to day computer. I use macOS because I really enjoy the applications and the design, but before that I used Linux as my main desktop operating system, back in the early 2000s. My conclusion at the time was that the Mac was a better fit for my needs on the desktop, and Linux was great on a server. Your opinion might differ.
Kernel space and user space
The kernel runs with full control over the hardware. Everything else — your shell, your editor, the web server you install — runs in user space, with limited privileges.
A user space program cannot touch the disk or the network hardware directly. It asks the kernel through a system call: a controlled entry point for operations like opening a file, creating a process, or sending data over the network.
This boundary is what keeps one broken program from taking the whole system down. When a program misbehaves, the kernel terminates that process and everything else keeps running.
Where you’ll run Linux
Some desktop computers and laptops ship with Linux preinstalled, or you can install it yourself. But you don’t need to disrupt your existing computer just to get an idea of how Linux works.
If you use a Mac, you need to know that under the hood macOS is a UNIX operating system, and it shares a lot of the same ideas and software that a GNU/Linux system uses, because GNU/Linux is a free alternative to UNIX. It’s not Linux, but it’s close enough that most commands are the same.
UNIX is an umbrella term that groups many operating systems used in big corporations and institutions, starting from the 70’s
Microsoft has an official Windows Subsystem for Linux, which gives you a real Linux environment inside Windows.
But the vast majority of the time you will run a Linux computer in the cloud via a VPS (Virtual Private Server), connecting to it over SSH and working entirely in the terminal.
Shells
A shell is a command interpreter that exposes to the user an interface to work with the underlying operating system.
It allows you to execute operations using text and commands, and it provides users advanced features like being able to create scripts.
This is important: shells let you perform things in a more optimized way than a GUI (Graphical User Interface) could ever possibly let you do. Command line tools can offer many different configuration options without being too complex to use.
Many different kinds of shells exist. This post focuses on Unix shells, the ones that you will find commonly on Linux and macOS computers: Bash, Csh, Zsh, Fish and many more.
All shells originate from the Bourne Shell, called sh. “Bourne” because its creator was Steve Bourne.
Bash means Bourne-again shell. sh was proprietary and not open source, and Bash was created in 1989 to create a free alternative for the GNU project and the Free Software Foundation. Since projects had to pay to use the Bourne shell, Bash became very popular.
If you use a Mac, try opening your terminal. That by default is running Zsh (or, pre-Catalina, Bash). Most Linux distributions default to Bash.
You can set up your system to run any kind of shell, for example I use the Fish shell.
Each single shell has its own unique features and advanced usage, but they all share a common functionality: they can let you execute programs, and they can be programmed.
Related posts about cli: