Back in 1991, a computer science student named Linus Torvalds announced on a newsgroup that he was creating a "hobby OS." That hobby was Linux, and today it's much more than a tinkerer's operating system, with availability on all manner of hardware and a seemingly unlimited array of flavors, or "distributions." Maybe you're new to Linux, or maybe you're itching to graduate from Ubuntu to something with a little more geek cred. Whatever the case, we're going to take the sting out of all those command prompts, using two great distros as examples.
What is Linux?
If you wanna be a jerk about it, Linux technically isn't an operating system. Linux proper is actually a kernel, which is only a portion of an OS (albeit, the main portion). When most people say "Linux" however, they are talking about a Linux distribution, which is indeed a full-fledged operating system. Luckily for any beginners out there, it's not as complicated as you might think -- what makes Linux Linux is a small combination of components, that kernel included. In fact, we can break them down into four main parts, in no specific order:
- A piece of software called the "bootloader"
- The Linux Kernel we all love so much.
- Userland (Think Firefox and Libre Office and, for those of you up on your jargon out there, the GNU part of GNU/Linux). We'll get to that later.
- The filesystem, the place where we put our music and save all those great images from reddit.com/r/earthporn.
That's the short version. Now let's take a moment to break each of these down.
For the sake of keeping things simple, the bootloader is a piece of software that helps get the Linux kernel loaded into memory so that you can use your computer. It is required. When you hit the power button, your computer does what's called a POST (Power-On Self Test) and then the BIOS (Basic Input / Output System) reads data from your disk drive, which says, "Hey, I'm a bootloader, execute me!" Your computer says, "Okay," and executes that bit of code. At that point, the bootloader tells your processor and memory to load and execute the Linux kernel that's been waiting so eagerly to run. There are three main bootloader options in the Linux World:
- LILO (The Linux Loader)
- GRUB (GNU GRand Unified Bootloader) versions 1 and 2
An oldie but goodie, LILO seems to be used less nowadays, especially compared to GRUB. One drawback is that it lacks support for EFI, which many newer computers support. There is, at least, a modified version of LILO called "elilo," which does support EFI.
- It's been around a very long time and is very stable.
- Works great on older hardware.
- Supports multiple operating systems.
- Again, no support for EFI and GPT, though if you do need EFI, there's always elilo.
GRUB has quite a few points in its favor, including the fact that you don't need to re-install it every time you change something, as with LILO. GRUB version 1 (aka GRUB Legacy) is the most commonly used bootloader today. Just keep in mind that, like LILO, it's in maintenance mode by now, which means no new features are being added. You'll find those in GRUB v2, which is used by default in the ever-popular Ubuntu, among other distributions. GRUB v2 was officially released June 26th, 2012. That's how new it is.
- GRUB is, hands down, the most commonly used bootloader, and it's very stable.
- Development remains active and ongoing, so expect to see new features for v2 and bug fixes on v1.
- Supports multiple operating systems (even Oracle Solaris).
- Supports EFI.
- We tried, and really couldn't think of any.
Syslinux is a slightly lesser-known bootloader that was originally designed to boot the Linux kernel from a FAT/MSDOS filesystem. Written by a bright guy named Hans Peter Anvin, it has a decently broad feature set and supports the bleeding-edge filesystem known as BTRFS. Also, pretty much any ISO image of any Linux distribution you boot utilizes Syslinux, in the form of Isolinux.
- Active developer community.
- Anvin is involved (trust us, this guy is awesome).
- Syslinux is actually a set of bootloaders, which includes a PXE bootloader (Network boot) and tons of other features.
- Nope, can't think of any here either.
Really, these all do the job pretty well. The beautiful thing about open source and using a Linux-based operating system is the freedom to choose exactly what you'd like to use.
The Linux Kernel
So, what is the Linux Kernel? Let's begin with the layman's version: the Linux Kernel is essentially the boss of your computer once the bootloader assists it into execution. The kernel controls memory, the CPU, input and output, and any peripherals you connect to your computer. It controls what application can access what memory, and what user can run what task.
Now, the "I've got a degree in computer science" version:
The Linux Kernel is a monolithic operating system kernel that supports loadable device drivers (kernel modules) and preemptive scheduling. It is highly portable, and runs on 90 percent of the world's top 500 super computers. It's written in the C programming language and is supported and maintained by several individuals worldwide. It's open source, meaning the code is open to anyone who would like to modify it. It's also freely available to download.
These are the bits of software that include your web browser, video games, your spreadsheets, your text editors. This is also the software you use to get around your computer's filesystem, copying file A to file B, moving a picture into a folder, creating a new folder, etc.
The most important parts of userland are the GNU core utilities, also known as coreutils. This GNU toolset contains the base tools and commands to complete a Linux distribution on the most basic levels.
Some basic commands from coreutils that you need to familiarize yourself with:
- ls -- List files in your current location on the filesystem.
-- Create a directory.
- cd -- Change directory
-- Invoke the manual or more commonly referred to as "the manpages." This is one of the most important commands. Wanna know how best to use "ls"? Type "man ls" on the command line and you'll find out.
-- This command will spit out the contents of a text file to your terminal.
-- Remove a file from the system.
The Linux filesystem
The Linux filesystem can get tricky, and seems to be the item that takes the most time for people to master. To begin, every filesystem has a filesystem type, as well as a filesystem layout. The type refers to how a hard drive is formatted, which has a direct impact on how Linux reads and writes files. Luckily for you, confused newbies, there's a boatload of filesystem types out there. For now, and for the sake of this article not becoming a Frank L. Herbert novel, we'll only discuss one here. That would be ext4, a filesystem in wide-enough use that it makes sense as a go-to choice. Once you become a Linux Jedi Master feel free to take a swim in the ocean of alternative open source filesystem types.
Now let's move onto the filesystem layout, the most detailed section of this article.
The filesystem layout in Linux is naturally different than what you're used to if you're coming from Windows. If you're coming to Linux from Mac OS X, you're in somewhat better shape. The filesystem is where your files live (obviously), as well as where all the above components are stored when the computer is turned off. The layout of the folders is what we really need to talk about. First off, if your background is in Windows, all of the \'s become /'s.
C:\myname\myfolder\myfile.txt in Windows, becomes /home/myname/myfolder/myfile.
Now, here's a more general view of the layout of a Linux filesystem. It's important you get familiar with this; almost all Linux filesystem layouts look like this, regardless of the distribution.