There is an entire chapter in (Shotts, 2019) dedicated to printing, but let me tell you how I print the things I want to print. I just use the GUI of the app that I am viewing the file in. I advise you to do the same. Now, could there potentially be a situation where you are accessing a Linux machine remotely and you need to print something out and you can’t use a GUI? Sure. But, I’ve never encountered it so far and I think that using Google in that particular situation would help you.
Hope you learned something useful!
References
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 361-373
In the upcoming posts, we will talk about a whole bunch of things – printing, scheduling tasks, computer networking and building a program from source.
We won’t cover any of those (except building a program from source) in much detail. The reason is because I either haven’t used it as much and thus feel that the topic is not as relevant to everyday use or the topic is very broad and I narrowed it down to the very basics.
An interesting mix coming up. Focus on the computer networking chapter most, followed by building a program from source. Feel free to quickly read the other things.
When you want to shut down your system, the following happens: (Ward, 2014)
init asks every process to shut down
If some processes (or a process) don’t respond, init initiates a kill with a TERM signal
If some processes (or a process) don’t respond still, init initiates a kill with a KILL signal
The system makes preparations for a shutdown
The system unmounts all of the other filesystems other than root
The system remounts the root filesystem in read-only mode (meaning you can’t write, only read)
The system writes out all of the data left over in the buffers to the filesystem (this happens during the remounting process; see (“Is the root filesystem unmounted during a Linux shutdown?,” n.d.))
The kernel reboots or stops the system
My 2 cents – just know this conceptually. The only case where you will need to go deep into the details of this will be if you need to optimize something on a Linux machine (most likely you would be doing this professionally), if you need to know the details to accomplish some other task or if you are really really curious.
There are multiple versions of init out there. I just wanted to list their names out in order for you to recognize the name and know: “Ah, I’m dealing with init.”. I never had to deal with init so far, in terms of something going wrong with it and me having to fix it. I also never modified my init (in terms of enabling / disabling what services it starts or doesn’t start), but you can do so if you want. I never had the need.
Here are a couple of popular init versions: (Ward, 2014)
System V
systemd
Upstart
My Debian 10 system uses systemd. You can use Google to find out what init version your Linux distribution has and you can also use Google to find out how to tinker with it, if you must.
Hope you learned something new!
References
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Page 112
As we already learned, init is important because it is a part of the booting process, as well as a part of the user space startup process. Here we talk a little bit more about init.
init is the process which starts all system services. (Shotts, 2019) init always has a PID of 1. A lot of the services which init starts are called daemon programs – programs that don’t have any user interface and do their thing in the background.
A thing to review, if you forgot – when talking about processes in general, we can say that a parent process spawns a child process. That means that the programs that init starts are its child processes and init is the parent process.
That’s it about init. Nothing too fancy. It starts a lot of essential system services (which are daemons).
References
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Pages 134-135
Let’s talk about how the user space starts up. To remind ourselves, there is the user space, which “regular” users can access and there is the kernel (system) space, which “regular” users can’t access. If they try to, the operating system doesn’t allow them to.
Here is roughly how the user space starts up: (Ward, 2014)
init
Essential low-level services which enable managing hardware devices and system logging
Network configuration
Mid and high-level services (such as cron (used for scheduling tasks) and printing)
Login prompts, GUIs, and other high-level applications
To remind ourselves, init is the process with the PID of 1, with which it all begins. I hope you now see why this holds – because init has the PID of 1 and it is the first step here. It is also speculated that init is how the universe was made, albeit scientist are not yet sure.
Hope you learned something useful!
References
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 111-112
The dmesg command is used to display kernel messages. (Ward, 2014) You use this command when you want to see if a kernel is giving you an error for a particular hardware device, for example.
[2344706.158833] cache: parent cpu2 should not be sleeping
[2344706.158987] CPU2 is up
…
dmesg gives a lot of output, so be prepared. You can pipe it and use less to read through it, for example, or redirect its output in a file.
Another way to look at kernel messages (besides dmesg) is by looking at the contents of a file which is located in /var/log/kern.log. (Ward, 2014) Keep in mind that catting this file will produce a lot of output.
Thank you for reading!
References
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 94-95
Boot loader’s job is to start the kernel – that is, to load the kernel into memory and start the kernel with a set of kernel parameters. (Ward, 2014) Kernel parameters are text-based parameters that tell the kernel about how it should start. Boot loader also selects among multiple kernels, switches between sets of kernel parameters, allows users to meddle with the kernel parameters and kernel images and provides support for booting other operating systems.
One of the most popular boot loaders is GRUB, short for Grand Unified Boot Loader. So, if you ever see some errors related to GRUB, you now know: “Oh, it’s my boot loader that’s the problem”.
To be honest, I never had to deal with boot loader problems, but I imagine they must be bad. May the force of Google help you in your quest to resolve those.
Thank you for reading!
References
Ward, B. (2014). How Linux Works: What Every Superuser Should Know (2nd ed.). No Starch Press. Pages 97-98
Today we will talk about how your computer boots up (or, equivalently, how does it start up). We will look at the first steps your computer executes when you turn it on. This will be important to understand if you ever encounter a boot-time problem. Of course, you will use Google, but having context as to what is actually happening will prove really valuable.
Your computer boots up in the following sequence of steps: (Ward, 2014)
A boot loader is ran by machine’s BIOS or boot firmware
The boot loader finds the kernel image on disk, loads it into memory, and starts it
The kernel initializes the hardware devices and its drivers
The kernel mounts the root filesystem
The kernel starts a program called init; init has PID equal to 1
init starts all of the other necessary system processes
At some point at or near the end of this entire process, you get the option to log in to your system
Let’s clarify some terms here. Let’s go one by one:
What is BIOS? BIOS stands for Basic Input/Output System and it is used to check for hardware errors andrun the boot loader. (“BIOS,” n.d.) Think of BIOS as the starting point of your computer; when you turn your computer on, it checks if all the hardware is OK and if it is, it runs the boot loader. Instead of BIOS, you can have other boot firmware (such as UEFI – Unified Extensible Firmware Interface (“Unified Extensible Firmware Interface,” n.d.)), but its job remains the same – check the hardware, if that’s OK, run the boot loader.
What is the boot loader? The boot loader is a small program whose task is to find the kernel image on disk, load it into memory and start it. (Ward, 2014). We will talk more about boot loaders in another post, but they are a small, albeit a critical piece of code which loads the kernel.
To review, the kernel is the “core” of the operating system and the root filesystem is the hierarchical filesystem starting from the root folder (/).
What is init? init is a special process whose task is to start all of the other necessary system processes and init has a PID of 1. We will also talk more about init in another post (or posts).
I think we clarified all of the terms present in this article.
A caveat for the those of you who are interested in the nitty-gritty details: initramfs can be used to mount the root filesystem.When the kernel image gets loaded by the boot loader, the kernel can mount initramfs, if it exists. This is an advanced Linux detail, but I just wanted to mention it here. More information can be found in (“About initramfs,” n.d.).