Mastering Linux: A Comprehensive Guide to Complex Topics

Mastering Linux: A Comprehensive Guide to Complex Topics

Mark Lv13

Mastering Linux: A Comprehensive Guide to Complex Topics

Modern-day Linux is super user-friendly, but to unlock its full potential, you need to familiarize yourself with some advanced concepts. Let’s look at seven key topics to elevate you from a casual Linux user to a power user.

1 Shell, Bash, and Scripts

A shell is defined as a command-line interpreter. It’s the program that takes the commands you type into a terminal/console, converts them into instructions the kernel can process, and then sends back the output to the terminal/console.

Most Linux systems use Bash (Bourne Again SHell) as the default shell—because it’s versatile and sufficient for casual use. However, there are other shells available, like Zsh, Ksh, fish, and Tcsh . To check what shell you’re running, type “echo $SHELL” into the terminal.

Checking Garuda Linux is running fish Shell

Checking Ubuntu is running Bash shell

Close

Now, a shell script is a file containing a series of commands. These commands are executed in sequence when you run the script from the terminal. This can be a powerful automation tool on Linux, allowing you to bundle complex tasks into a single command.

2 X11, Wayland, and XWayland

X11 has been the default windowing system protocol for Linux and Unix-like operating systems since it was introduced in the mid ‘80s. It uses a client-server model. The app windows you interact with are called “clients.” The “server,” aka the X server, processes input events from these clients, e.g., window movements, and then outputs how the client should respond. X11 is the windowing system protocol that carries the user input from the client to the X server and the output back to the clients.

Now, Wayland is a more modern (developed in 2008 by Red Hat) display server protocol. It simplifies the client-server architecture , enhancing security and performance. It allows the application window to directly communicate with the compositor (more about that in the next section), thereby reducing overhead and latency. The simplified architecture is also poised to improve security.

At the time of writing, most popular distros have migrated to Wayland. However, some applications optimized for X11 aren’t yet compatible with Wayland. To solve this, we have XWayland—a compatibility layer, enabling X11 applications to run in a Wayland environment.

To check if your system is using Wayland or X11, enter the following command into your terminal:

echo $XDG_SESSION_TYPE

3 Window Managers and Compositors

Have you ever moved an app window on Linux, only to find the borders of the window move while the inside remains empty and takes a few seconds to render? This happens when the window borders behave as expected, but the visuals inside the window take too long to render.

Linux Window without Content

You see, the window borders and the visuals inside the window can be controlled by two separate systems, especially in X11 systems. To control the placement and appearance of windows on your screen, you have window managers. They allow you to move, resize, minimize, and maximize windows, as well as display window borders and title bars.

On the other hand, we have compositors . They’re responsible for rendering the content inside each window. A compistor combines the final rendered image from the application with graphical effects like transparency, shadows, and animations to create a single image that is displayed inside the windows.

In traditional X11 environments, the window manager and compositor are usually separate components. This modular approach offers flexibility but can also lead to more complexity and potential system instability—like the example I shared earlier.

To fix this, Wayland combined the window manager and compositor into a single component—the Wayland compositor. This simplifies the architecture, which can lead to better performance and security. A few examples of Wayland Compositors we see in regular distros running Wayland are:

  • Sway: A tiling window manager designed to be a drop-in replacement for the X11-based i3 window manager but for Wayland.
  • Mutter (initially designed for X11): The default window manager for GNOME.
  • KWin (initially designed for X11): The default window manager for KDE Plasma.

4 Custom Linux Kernels

We often refer to Linux as an operating system, but it’s actually the name of the kernel powering the operating system. A kernel is basically the core of the operating system that bridges the hardware and the software. The official Linux kernel is maintained by Linux Torvalds and the Linux community. However, in true Linux spirit, people have modified the official kernel to include performance optimizations, improved hardware support, or additional features.

You can potentially replace the official Linux kernel on your system with one of these custom kernels to get better performance. Most distros require you to manually compile the custom kernel and install it on your distro. However, some advanced distros like Manjaro and Garuda give you a GUI app for replacing the default kernel with a custom one.

Showcasing different Custom Linux kernls available to download on Garuda Linux

Here are a few of the most popular custom Linux kernels:

  • Zen Kernel: Adds scheduler improvements and memory management optimizations to enhance performance for gaming and multimedia applications. Designed for general desktop use, it offers a stable and reliable experience.
  • Liquorix Kernel: Incorporates a custom scheduler (MuQSS ) and optimizations prioritizing low latency and responsiveness. It is ideal for gamers and heavy desktop users seeking to maximize performance, though it may be a bit unstable depending on the hardware.
  • XanMod Kernel: Includes patches for faster task scheduling and reduced input/output latency to improve overall system performance. A relatively stable option for users who prioritize raw performance for general-purpose workloads.
  • Clear Linux Kernel: Developed by Intel, this kernel includes various patches and configurations to improve Intel CPU and memory performance, making it a good choice for users with Intel processors.

It can be a trial-and-error process to determine which custom Linux kernel works best with your specific hardware setup. It’s useful to try out different options and see how your system performs, sticking with the one that yields the best results.

Custom kernels may not receive updates as frequently as the mainline kernel, which could impact security and compatibility over time.

5 Systemd and SysV Init

When you boot up your Linux system, the very first process to start is the init system—which has the Process ID (PID) of #1. Most modern Linux distros primarily use one of two init systems: SystemD or SysV Init. You can check which init system your distro is using by running this command in your terminal:

ps -p 1

If the output shows “systemd”, you are using SystemD. Whereas, if it shows “init,” you are using SysV Init.

SystemD is the newer, more common init system used by all popular distros, including Ubuntu, Fedora, and Arch Linux. It’s designed to be faster and more efficient. My current system running Garuda Linux, also uses SystemD. However, it has some technical issues which make it divisive in the Linux community .

As a result, a few Linux distros avoid SystemD and use an older init system—SysV Init. Other popular init systems include runit, OpenRC, and Upstart. Each has its own unique approach to managing services and system initialization.

Knowing which init system you are using is crucial if you want to start (or stop) a particular service during system boot-up. For example, I ran into an issue where UFW (Uncomplicated Firewall) would automatically get deactivated after rebooting. To solve this, I needed to use the init system to auto-start UFW during system boot. Since I was using SystemD I used the systemctl command. But if I was using SysV, I would’ve needed the service command.

6 Filesystem Types

As you become more familiar with Linux, you’ll find that it supports a wide variety of filesystems , unlike Windows, which primarily uses NTFS for its main filesystem and FAT or exFAT for external storage. Most Linux systems use ext4 by default, but there are other popular options.

  • Ext4: A reliable choice for most use cases.
  • ZFS: Developed by Sun Microsystems, ZFS offers data integrity checking, built-in RAID, and snapshotting. It’s available for Ubuntu as an opt-in feature and can be installed on other distributions.
  • XFS: The default filesystem in Red Hat Enterprise Linux distributions like Fedora, known for its scalability and resistance to fragmentation.
  • Btrfs: Focuses on data integrity, fault tolerance, and easy administration with features like snapshots and built-in RAID. It’s the default filesystem in Garuda Linux.

Linux also uses secondary filesystems for specific purposes, such as tmpfs for temporary files in memory and vfat for boot partitions or Windows compatibility.

To check the filesystems your Linux distro is using, type df -T into a terminal and hit Enter.

Checking Different filesystem types used on Garuda Linux

If you want to change filesystems on an existing Linux system, you’ll need to back up your data and then format the partition(s) to your desired filesystem type.

7 SELinux and AppArmor

Linux is famous for its security, but it isn’t invulnerable . If you have important files and data on your Linux PC, you should take an active role in ensuring it’s configured to be as safe and secure as possible. To do this, you need to learn about SELinux and AppArmor . Both of these are Linux Kernel security modules that add an extra layer of security by restricting what applications can do, reducing the risk of exploitation of security vulnerabilities.

You get SELinux by default in Fedora and Red Hat Enterprise Linux (RHEL). However, you can also install and configure it to run on another distro. This kernel security model was developed by the NSA and offers fine-grained control over applications’ access to resources using mandatory access controls (MAC). It’s complex but offers comprehensive security, making it suitable for high-security environments.

Next, we have AppArmor. It offers a simpler, path-based approach to security, making it easier to configure while still providing effective protection. AppArmor is the default on Ubuntu and SUSE Linux Enterprise Server (SLES). That said, if you’re using a different distro, AppArmor is available in all the major Linux repositories, and you can easily install it on any Linux distro you like.

To use these security modules effectively, you’ll need to set up security policies that define the allowed actions for applications. This comparison of AppArmor and SELinux should help you decide which is right for your needs and requirements.


Understanding these advanced Linux concepts is crucial for anyone looking to upskill from a casual user to a power user. By exploring the intricacies of shells, window systems, custom kernels, system initialization, filesystems, and security modules, you’ll gain a deeper appreciation for the flexibility and power of Linux.

  • Title: Mastering Linux: A Comprehensive Guide to Complex Topics
  • Author: Mark
  • Created at : 2024-08-31 06:11:08
  • Updated at : 2024-09-01 06:11:08
  • Link: https://some-guidance.techidaily.com/mastering-linux-a-comprehensive-guide-to-complex-topics/
  • License: This work is licensed under CC BY-NC-SA 4.0.