general linux question about distro/kernel
Started by 6 years ago●4 replies●latest reply 6 years ago●154 viewsI understand the basic function of the kernel and how it interacts with the hardware, but where exactly the distro and its gui come in, im confused
If you could point me to some good resources that address this issue, that would be great. Thanks for the help in advance!
Forget the distro for a second.
The way Linux (and any unix system) boots is, roughly, the following:
Bootloader gets loaded and starts
It loads the kernel and a very minimal file system, then jumps into the kernel
The kernel initialises the hardware, starts the device drivers, sets up the memory manager, mounts the minimal file system, then starts the first process (program), called 'init'
The init program mounts the actual disks, starts the system services, background processes (demons), the network services, the firewall and pretty much everything that comprises the system. It then changes to multi-user mode and usually starts a login for each virtual terminal. If you have a graphical system, then after all that init spawns the display manager process.
The display manager starts the X server, which then gets control over the video card and opens its internal port(s) to receive graphical client commands. The display manager then either prompts for a user login or automatically logs in the default user and starts the desktop environment and goes to sleep until the desktop terminates.
The desktop then starts the window manager, which handles all the windows and then puts out all the graphical thingummies that you can click on. It also starts a bunch of other programs, like your taskbar and whatever else appears on your screen automatically. Then you can start to work.
For all of the above the kernel provides system calls, a standardised API to all services from memory allocation to hardware access, manages the processes, resource allocations and the like. You usually don't deal with kernel directly, but call the standard C library which contains zillions of functions, many of which will actually issue system calls.
The above is a general description of what happens on any system. Distros are different mostly on what they provide on top of the kernel and the bare minimum of essential services and how they handle the various programs (packages) and what their update policies are and what their target audience is (casual desktop use, development use, server use etc) and how system administration works. You can build the same system pretty much with every distro. Just for certain usage patterns some distros are more convenient, that's all.
I think there is some confusion here. A Linux distribution consists of the Linux kernel and many software: shell (bash), X window system, compiler (GCC), etc.
At the end of boot process the Linux kernel loads a user-space SW, which was originally the 'init' script, but now systemd is used by most of the distros to start the background processes (daemons) and other user-space software.
The programs use system calls when wants to open a file, change directory in user-space.
As ivanop states, the distro is like a collection of bundled software.
Debian distro has it's "bundle" . Same with Ubuntu, Red Hat, .... etc.
You can even make your own distro if you feel adventurous :).
" Processes running under the user space have access only to a limited part of memory, whereas the kernel has access to all of the memory. Processes running in user space also don't have access to the kernel space. User space processes can only access a small part of the kernel via an interface exposed by the kernel - the system calls. If a process performs a system call, a software interrupt is sent to the kernel, which then dispatches the appropriate interrupt handler and continues its work after the handler has finished."
This may help a little, all the various distros use pretty much the same Linux kernel which is common all all the distros. The kernel is advancing all the time and is identified by its version number. I believe 5.0 is currently being queued up for release.
I find the easiest way to distinguish between the distros built on the kernel is the GUI desktop environment, and the package manager. For example Red Hat (and its derivatives) using Gnome desktop and RPM (in conjunction with YUM or more recently DNF) too manage software packages, Debian (and its derivatives) using Gnome with the Aptitude suite of package management tools or SUSE with KDE desk top and YaST package manager. There are many distros often geared to a particular area such as Scientific Linux (a red hat derivative) which has tools for calculation and analysis included, or Kali Linux which is geared to security and penetration testing. There are a number of different desktop environments and they are typically interchangeable and can be swapped out.
From a very high level the kernel sits on the hardware, the shell sits on the kernel, and then the window manager/server sits on the shell with the desktop or gui sitting on the window manager. Most every thing needed to run the system can be done from the shell command line and so it is possible switch off the gui and continue run an install with just the kernel and shell.
Most distros derive from a grand daddy upstream distro like Red Hat, Debian or Arch. For example Ubuntu, a very popular easy to use distro, is derived from the upstream Debian distro.
Check out the link below to find out more about the many various distros.