04. Linux System Overview

The Linux Operating System contains a slew of pieces: hardware connections, partition space, boot loaders, processes, terminals, window management system...phew! It can be overwhelming to think about all these bits and pieces; let's try breaking it down to three main components.

1) Hardware

The first piece to creating any computer is assemblying its hardware. Here are just some of the components that go into a computer:

Motherboard
Physically holds the components together. A special firmware called the BIOS controls all connections.
CPU
The Central Processing Unit acts as the main "brains" of the computer. It executes all mathematically-related tasks.
RAM
Stands for Random Access Memory, but also known as main memory or just memory. This is the space that currently running processes are loaded on; the bigger the RAM, the more processes are able to run simultaneously.
Buses and ports
Connects devices and sends/retrieves information to and from hardware.
The motherboard of a system connects all of a computer's components together
A motherboard with all its core components labeled.

If you're interesting in learning in much more detail about computers, try building your own PC. There's no better learning experience than being hands-on!

2) Kernel

The kernel is the software residing in memory that takes user commands and passes them onto the hardware for execution. This is often referred to the core of the OS, as it connects hardware to the user interface and processes. We'll learn more about the kernel and its functions on the next page.

The Shell

The interpreter that allows us to communicate with the kernel through commands is known as the shell. This is the lowest-level interface that a user can utilize to communicate with the computer.

There are several types of shells that you can choose from. They differ mainly in syntax and have operational features. The most common is bash which serves as the default on most machines.

A list of shells are stored in your /etc/shells file.

$ cat /etc/shells
/bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh
sh
shell
bash
bourne again shell
csh
c shell
ksh
korn shell
tcsh

The shell also provides you with a list of commands and syntax that allow you to write shell scripts. Shell scripts are reuseable lines of codes a accomplish some task. Shell scripts are a good way to create programs that are portable to another Linux machines.

3) Processes, Applications and Programs

Lastly, we have processes (aka applications or programs), which give the kernel tasks to perform. After the user assigns or opens several processes, the kernel decides how to delegate the hardware resources to simultaneously run the programs. It is these processes and applications working in conjunction with a kernel that make up UNIX and UNIX-like Operating Systems.

Kernel of an OS takes the higher level commands and translates it to computer language
How hardware, the kernel, and applications all tie in together to build the Linux Operating System.

Users

At the very top-level abstraction in this system are users - entities that may own files and run processes. Each user has a username and a user id, the latter of which is used by the kernel. Groups contain sets of users.

The root user (aka superuser) is in control of the system - they are able to shut down any user processes and access any file on the system. Some adminstrative commands may only be used by the root user. To switch to root, use the su command.

User and Kernel Spaces

RAM (Random Access Memory) can be separated into two distinct regions - the user space and the kernel space. The main difference between the two is their privileges on operating system functions and restrictions on user applications.

User Space

The processes run by ordinary users (aka user processes) are stored in the user space. The user space is the memory that is allocated by the kernel for user processes. The separated of the user and kernel space guarantees that no user-created process steps out of bounds, which could cause system crashes or memory overflow.

The area in which processes and normal programs are run in is known as the user space. The user space is more limited to what it can access, with restrictions on memory and CPU-safe operations. A broader term encompassing this is known as sand-boxing, which restricts user programs such that they don't mess parts of memory owned by other processes. This is a good thing, as it prevents the system from crashing in case something goes haywire.

Kernel Space

The kernel has its own special privileges that allow it access to all pieces of the CPU and memory. This area of control is known as the kernel space, which is where the kernel delegates all its tasks.

Note that the separation between user and kernel spaces allow for the computer to run smoothly and avoid any malfunctions. Additionally, anything that goes haywire in the user space can easily be fixed by the kernel.

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Want to avoid becoming a code monkey?

Clean Code

Want to avoid becoming a code monkey? Try Good Practice

Software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer.

$ Check price
49.9949.99Amazon 4.5 logo(427+ reviews)

More Good Practice resources

Ad