Linux anatomy: Difference between revisions

m typo
Add Kernel and Init system sections, add some links.
 
Line 10: Line 10:
"Linux" is a term that has a few meanings, and sometimes you will see debates online (often jokingly) about what part of the software actually counts as Linux. Though some pedants might take issue with this, in this guide we will be using the term "Linux" to refer to '''an entire system''' that runs software on top of the Linux Kernel.  
"Linux" is a term that has a few meanings, and sometimes you will see debates online (often jokingly) about what part of the software actually counts as Linux. Though some pedants might take issue with this, in this guide we will be using the term "Linux" to refer to '''an entire system''' that runs software on top of the Linux Kernel.  


The basic gist is that Linux is a set of programs and utilities, as well as a core program called a "kernel", that work together to create a system which can be used for many different purposes, and be customized in many ways. Keep reading to gain a better understanding of how these pieces all fit together.
The basic gist is that Linux is a set of programs and utilities, as well as a core program called a "[[Linux anatomy#Kernel|kernel]]", that work together to create a system which can be used for many different purposes, and be customized in many ways. Keep reading to gain a better understanding of how these pieces all fit together.


== Distribution ==
== Distribution ==
Line 19: Line 19:
In short, this is because, unlike macOS or Windows, there is no singular company or organization working on Linux as a whole. The Linux Kernel is worked on by a single large team of dedicated volunteers, but they have enough on their hands with just those responsibilities. And, for reasons that will be explained, it is impossible to have a usable system (especially a desktop system) with only a kernel.
In short, this is because, unlike macOS or Windows, there is no singular company or organization working on Linux as a whole. The Linux Kernel is worked on by a single large team of dedicated volunteers, but they have enough on their hands with just those responsibilities. And, for reasons that will be explained, it is impossible to have a usable system (especially a desktop system) with only a kernel.


So instead, many groups of volunteers have created their own organizations which do the important work of packaging together all the necessary components and building up a usable system on top of the Kernel. Distributions have the job of deciding on a ''package manager'', ''desktop environment'', ''init system'', ''windowing system'', ''compositor'', and more. They also usually come up with a unique look and branding for their distribution, and unique features that might set their distribution apart from their peers. When they do their job well, everything comes together seamlessly to create a cohesive and usable experience that gives a user the particular features they want.
So instead, many groups of volunteers have created their own organizations which do the important work of packaging together all the necessary components and building up a usable system on top of the Kernel. Distributions have the job of deciding on a ''[[Linux anatomy#Package manager|package manager]]'', ''[[Linux anatomy#Desktop environment|desktop environment]]'', ''[[Linux anatomy#Init system|init system]]'', ''[[Linux anatomy#Windowing system|windowing system]]'', ''[[Linux anatomy#Compositor|compositor]]'', and more. They also usually come up with a unique look and branding for their distribution, and unique features that might set their distribution apart from their peers. When they do their job well, everything comes together seamlessly to create a cohesive and usable experience that gives a user the particular features they want.


=== Fixed-release ===
=== Fixed-release ===
Line 38: Line 38:


=== Software ===
=== Software ===
As you likely know, a piece of software is any sort of application or tool that runs on the computer. A very general term, this might refer to a tiny tool that simply tells you the time, and it also might refer to the web browser that you're using right now. What differentiates software from libraries is the ability to ''run''.
As you likely know, a piece of software is any sort of application or tool that runs on the computer. A very general term, this might refer to a tiny tool that simply tells you the time, and it also might refer to the web browser that you're using right now. What differentiates software from libraries is that software ''is run by the user'', and libraries are ''used by the software''. Usually you will interact with software rather than libraries, unless you're a programmer.


=== Libraries ===
=== Libraries ===
Line 72: Line 72:


== Kernel ==
== Kernel ==
The Linux kernel is the core of Linux. Its job is to talk directly with the computer [[hardware]] and create the environment upon which programs and libraries can run. The kernel provides simple functions called [[Syscall|syscalls]] that programs and libraries can use to do very core system operations like opening files. It also manages when programs are allowed to use the CPU so that multiple programs can be run simultaneously, and loads [[Driver|drivers]], which are special programs that devices connected to the computer use to communicate.


== Kernelspace and userspace ==
Conceptually, it might seem that the kernel doesn't have that difficult of a job, but these sorts of core operations are actually quite complex, especially when drivers and complicated modern CPUs are involved. This means the kernel is a sophisticated program which is always being updated and tweaked!
 
Most users don't have to directly interact with the kernel very much, as there are many layers built up on top of it that you are usually using. In very rare cases though, you might see something called a "kernel panic". When this happens, the kernel has hit an error that is so bad, the entire operating system cannot recover gracefully and must be restarted. This is the same sort of problem as the so-called "Blue Screen of Death", on Windows. Luckily, these sorts of errors are very unusual to see in Linux!
 
== Kernel space and user space ==
The kernel has full control of the computer, and it only lends out its power to programs. This separation of concerns is to prevent a scenario where a program might break or tamper with other programs, take control of devices, read things it shouldn't, etc. If all the programs had unrestricted access to each other and the system, it would be hard to keep a separation between different programs. It wouldn't be possible to have a system that runs with multiple users, because each user could view and modify all files, even if they weren't an [[administrator]]. The kernel is powerful, and only lends out its full power to those with "root" access.
 
"Kernel space" refers to this "dangerous" part of the computer that only the kernel has access to, and "user space" refers to the safer portion of the computer's memory, CPU and other functionality that is reserved by the kernel for programs. In this context, the "user" refers to programs running on top of the kernel, as opposed to the kernel itself.
 
In user space, memory isn't usually shared--each program gets its own view of memory and can't peek into other memory. Programs must always run as a user, and programs can only open files that their user has access to. Most programs are not run with so-called "privileged" access, and so can only open some of the files on the computer's drives. If you want to work with kernel space in some way, you have to go through the kernel, with syscalls and such.


== Init system ==
== Init system ==