How Linux Works Behind the Scenes (Explained for Beginners)

How Linux Works Behind the Scenes (Explained for Beginners)

Linux is awesome. It just is. It runs on so many devices. It runs on 4 billion Android devices and all of the top 500 supercomputers (Linux Foundation, 2026)! Most distributions are free and open sourced, meaning that anyone can examine the inner workings of their distribution. Lastly, Linux allows the user to customize it to their heart’s content. How does Linux work really though? Thats what we are here to do today. In this article, we are examining the inner most workings on Linux, including the hardware, kernel, and user processes. We’ll talk about important concepts including why Linux doesn’t crash very easily or and the CPU generally isn’t able to be overloaded beyond its capacity. Other OS’s may struggle with slowdowns over time, but Linux doesn’t have this issue as much. Let’s explore Linux, eh?

The Hardware

Most of us are familiar with device hardware. There’s the CPU, RAM, GPU, hard drive, ports, etc. What’s important is how Linux uses the hardware to get things done. The hardware is the foundation of the Linux system as it is the “organs” so to speak that the distribution (distro) uses to process data. It includes the aforementioned components but for this article we are going to focus on the CPU, RAM, Storage Devices, Network Interface Card (NIC) and Peripheral Ports. The way that Linux uses these devices together in such harmony is remarkable, as you’re about to find out.

CPU

As we all know, the CPU is the brain of the computer. It takes in commands and completes them. Most CPUs today have a series of cores. What Linux does it is uses a scheduling system that assigns tasks to the CPU. If Linux needs to run three different applications, it will spread the processing load across those cores.

RAM

RAM is the short term memory bank of the computer. When the Linux kernel needs the CPU to process something, it pulls the application from storage and loads it into RAM. Then. the CPU executes instructions and processes data stored in RAM.

Kernel

If Linux was an army, then the Kernel is the general. The Kernel wakes up during the boot up process and stays “on duty” until the computer is powered down. It is intimately involved in process management, memory management, scheduling, devices drivers, file systems and security. It directs and assigns resources for use, adjusts them as necessary.

The Relationship Between CPU, RAM, and the Kernel

The CPU, RAM and Kernel work together constantly to make Linux operate effectively. Here is a simple visual demonstration of how it works:

Linux Operations Example

As you can see, we have a label to denote what each graphic represents in our example.

Linux system diagram showing how an application interacts with the Linux kernel, CPU, and RAM during program execution

As you probably know, the user launches an app either by clicking on it in the GUI or launching it through the terminal. This kick starts the process for us.

Linux system diagram showing the first step of program execution, where a user launches an application before the Linux kernel loads it into memory and schedules CPU resources

When this happens, the Kernel notices it and immediate begins reserving system resources to use to open and operate the app. There’s a lot more involved in this reality but we are keeping it simple for now.

Linux kernel diagram showing the kernel reserving CPU and RAM resources for an application before execution begins

Next, the Kernel directs app components (code and libraries) into RAM so that the CPU may act on the components

The Kernel then allocates processing time in the CPU so that the app can be run and acted on.

Linux kernel scheduling diagram showing the kernel allocating CPU time to a loaded application before program execution begins

With processing time made available, the CPU gathers the operating instructions from RAM in order to let the app open up and operate.

Linux CPU and RAM diagram showing the processor retrieving application instructions from memory during program execution

As the app starts up, the CPU and RAM stay in constant communication in order to make adjustments based on the commands of the user.

Linux system diagram showing continuous communication between the CPU and RAM while an application is running

During this entire process, the Kernel oversees everything that happens, maintaining control and keeping boundaries in place to keep the OS stable and efficient

Linux kernel supervision diagram showing the kernel managing communication between an application, CPU, and RAM during program execution

The Kernel makes constant resource adjustments based on app usage as well as other activity that happens on the computer, such as activity from other apps and user commands.

Linux kernel resource management diagram showing the kernel dynamically adjusting CPU and RAM allocation based on application usage

Why doesn’t Linux Crash Very Easily?

Linux doesn’t crash very easily because at it’s core, it only allows specific, trusted processes to make critical changes to the computer. Linux accomplishes this by breaking processes into two categories: User Mode and Kernel Mode.

User Mode

The majority of Linux processes run in User Mode. Think web browsers, social media applications, office productivity, video editing apps, the things you use to get things done. This all falls under the term “User Processes.”

Here are a few things that User Processes are allowed to do

  • Read and write to its own memories
  • Open files
  • Request access to the network

Conversely, User Processes are not allowed to do these things

  • Talk to hardware
  • Control CPU scheduling
  • Load Drivers

Basically, user processes cannot change anything on the computer that help the computer stay powered on, stabilize processes of apps other than itself or anything major within the computer. Think of it this way: imagine a user process as an artist hired to paint a mural on a brick wall of a building. The artist can use whatever paint they want to compose a picture because that is the artists job. However, the artist is not allowed to remove bricks from the wall, use a sanding tool to smooth out parts of the wall and much less knock the whole wall down because that is not the artists job/purpose. I hope that makes sense

Kernel Mode

Kernel mode (as the name suggests) is like a master car mechanic: they know the ins and outs of whatever car they are trained for and are permitted to make any modification to the vehicle that they desire. Any process that Kernel Mode performs is called a Kernel Process.

Kernel Mode processes are permitted to do things like:

  • Manage virtual memory
  • Configure devices
  • Control all hardware

Kernel Threads

Kernel mode makes use a special class of process called Kernel Threads. Kernel Threads are like the backstage crew at a play or Broadway musical. They move set pieces and backdrops around to “set the stage” for the cast to perform their show. In Linux terms, Kernel threads work with the Kernel to help operate the computer.

How Kernel Mode and User Mode Work Together

Kernel and User mode work closely together to help a computer to run. A great example of this is if you connected a printer to your computer using one of your USB ports. Essentially the printer tells the computer that its a printer and would like to connect. Since this is a hardware interaction, no User Mode process gets involved. What happens is that the USB controller alerts the Kernel through what is called an interrupt (No need to know what interrupts are at this point).

Switching from Kernel Mode to User Mode

When the interrupt happens, the Kernel gets the printer connected, downloads the right driver and anything else that is needed to get the printer ready for use. Once Kernel Mode is finished doing what it does, User Mode processes are now able to use the printer. Linux is constantly switching from Kernel to User Mode and back again.

We aren’t going to get too deep into the specific details of what happens between User and Kernel mode because it is quite complex. What I will say simply is that User Mode performs a “system call,” which basically means that User Mode is asking for a task to be completed, such as when the user wants to start a video call with their best friend. Kernel Mode has to run the Linux network stack to generate the TCP/IP packets and send them through the PCs network card, so once the user clicks the call button on the video calling app, user mode switches over to Kernel mode to establish the connection so that the user and their friend can talk. As Kernel mode causes the network card to send and receive the packets that facilitate the call, the video calling app generates the live image within the application, User Mode handles this part by taking the data provided from the packets to display the live feed of the users best friend (User mode).

Why does Linux Not Crash as Easily Compared to Other OS’s?

Linux has a great reputation of being a stable operating system and it has a very good reason as you may be able to tell from the previous section: Kernel Mode and Kernel Processes prevent User Mode and User Processes from making changes to critical areas of the OS, preventing most crashes. As we discussed earlier, User Mode processes cannot talk directly to hardware, load drivers and things of that nature. Therefore, if a user mode process gets out of control, the chaos of that program is systematically contained within itself, protecting other User Processes and the computer at large from suffering critical errors, crashes and the like.

The CPU Gets Involved in Protecting the Computer from Crashes

In addition to how the Kernel is set up, the current CPUs actually have built in parameters that function to help dictate what happens with User Mode and Kernel Mode. CPUs use what are called protection rings. The rings that we are learning about are Ring 0 (Kernel Mode) and Ring 3 (User Mode). The CPU doesn’t allow code that operates on Ring 3 to do Ring 0 activities, and it all happens at the CPU. There are actually four ring levels that a CPU uses, they are Ring 0 (Kernel as we just found out) all the way to Ring 3. Ring 0 provides the highest privilege while Ring 3 is the lowest. Ring 1 is used for drivers and Ring 2 for system tools. It is one of the useful systems that Linux uses to maintain its reputation of being robust and stable as an OS.

Wrap Up

Wow! While we covered a lot today, this actually is a very rudimentary picture of what Linux does when facilitating the operation of an app, but its a great start for someone learning Linux basics. We talked about the relationship between the hardware, Kernel and user processes when it comes to Linux. We learned that a combination of Kernel, User, and CPU structures are employed to help manage resources and activities within Linux. We will get more complex in our study of Linux as we go. We are laying a good foundation indeed. Thank you for stopping by and I hope to see you on the next guide!

If this article has helped you in any way, would you consider donating to the site to help support my work? You can donate as little as 1 dollar USD. Thank you for your time!


Discover more from 3StrandTech

Subscribe to get the latest posts sent to your email.

Posted in

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.