Foreward
This book was created to enable anyone to install and use Linux effectively. Its creation was made possible thanks to the help and support of the Chris Titus Tech community. The information contained in this book is drawn from thousands of comments, research, and real-world experiences from users who utilize Linux as their daily driver.
Links
Special Features of This Book
Throughout this book, you will find links to videos designed to enhance the learning experience. Some concepts are better demonstrated visually than explained in text, and these resources will help you better understand the topics discussed. This book serves as a guide to accelerate your learning, allowing you to absorb knowledge efficiently without needing to watch hundreds of hours of videos.
Chapter 1 - Starting Linux
Linux is a powerful and versatile operating system that gives you complete control over your computer. Whether you're looking for stability, security, or customization, Linux has something to offer for everyone. In this chapter, we'll explore the basics of Linux, including its distributions, release types, and modularity.
Why Choose Linux over Windows or MacOS?: https://youtu.be/DNg2M88_Hl0
Distributions
Linux by itself doesn't include programs and things to make a fully function computer. So we have Linux distributions. There are many Distributions, in fact, hundreds of them that can be rather confusing. However there are three main branches that comprise the most amount of users and will be the focus of this book.
Overview of All Distributions on Linux: https://youtu.be/DKFnqAtEOvc
Debian-Based Distributions
These are the majority of Linux users and most online guides are written with them in mind. They typically are very stable and long term support. When you hear Ubuntu, Linux Mint, Pop OS, Elementary OS, KDE Neon, Peppermint, and much more... they are all based around Debian. This means how you install programs and the package manger is all the same. This is typically where most users start from. Anytime you see the command apt install or .deb package the installation instructions are geared for a this distribution branch.
RHEL-Based Distributions
RedHat Enterprise Linux is what RHEL stands for. This is the backbone of many Linux servers as any RHEL based distribution is built with security and stability in mind. There are 3 distributions that most think of when it comes to the RHEL category. RedHat Enterprise Linux (Subscription-Based), CentOS (RHEL clone but no subscription), and Fedora. The package manager for these distributions is dnf install or yum install and utilizing the .rpm packages you download from sites.
Arch-Based Distributions
Arch Linux is a user created distribution that isn't backed by any company and has some unique features as a result. The main distributions you hear about in this category are Arch Linux and Manjaro. It's package manager syntax looks like pacman -S packagename and doesn't have downloadable packages like Debian or RHEL distros. It does however have a unique feature called the AUR (Arch User Repository) and is able to build programs on the fly. While this is incredibly powerful, it can also be dangerous as these aren't vetted and sometimes have old packages that are out of date. So if using the AUR always check the site to make sure it is up to date and is a legitimate source.
Distribution Type | Examples | Package Manager Syntax | Key Features |
---|---|---|---|
Debian-Based | Ubuntu, Linux Mint, Pop OS | apt install | Stable, beginner-friendly |
RHEL-Based | CentOS, Fedora | dnf install / yum install | Secure, server-focused |
Arch-Based | Arch Linux, Manjaro | pacman -S | Rolling release, highly customizable |
Release Types
Lets go over the two types of distribution releases you will encounter Rolling and Stable. Both have their pros and cons, but depending on how you use your PC one might better than the other for you.
LTS vs Rolling Release: https://youtu.be/B-NG5gW5QnM
Rolling Release
Arch Linux is what is called a rolling release, which is a version of Linux that isn't tied to a single version of the Linux kernel. By comparison, Ubuntu does 6 month releases where it will not update major system components. Arch can update the Linux kernel and other core system components every week or everyday in some instances. This is a double edged sword, as you get the latest and greatest features, but you are also prone to more bugs.
Stable LTS Release
Debian and RHEL based distributions are typically using a proven release cycle. Each distribution can have different release schedules and vary from a couple months to several years. The distributions that are specifically called LTS (Long Term Support) are made with longevity in mind. The support structure can range from 5 years (Ubuntu LTS) to 10 Years (CentOS Versions). The downside to using stable releases is the packages are sometimes considered old and are not as up to date. However, these versions will run for years and are extremely stable.
Modularity
The power of Linux is that no matter what distribution you choose, it is modular. You can modify and make massive changes to drastically change the user experience. This gives you the power to make Linux operate how ever you see fit and you are the only thing holding it back.
Linux's modularity allows you to tailor your system to your needs. Whether you're building a lightweight system for an old laptop or a high-performance gaming rig, Linux gives you the tools to make it happen. Here are some examples:
- Server Setup: Install only essential server packages and skip the desktop environment.
- Lightweight Desktop: Use LXDE or XFCE for older hardware.
- Gaming System: Install Steam, Proton, and GPU drivers for a complete gaming experience.
What Distribution Should You Use
I don't consider Linux complex, but more of a rabbit hole of infinite possibilities. This is very overwhelming for a new user and often misunderstood. That is why I always recommend popular distributions with widespread support and resembling the operating system they are coming from. For Windows Users, I recommend starting with Linux Mint and for MacOS users I recommend Pop OS! as it has more Mac feel out of the box.
Tips for Choosing a Distribution
- Windows Users: Start with Linux Mint for a familiar experience.
- MacOS Users: Try Pop OS for a sleek and modern interface.
- New Gaming Users: Bazzite gives an controlled environment with lots of gaming support by default. System shouldn't be
- Advanced Gaming Users: Nobara is made by Glorius Eggroll and is a gaming focused distribution with many tweaks and optimizations for gaming out of the box. It also allows for lots of system customization.
- Advanced Users: Explore Arch Linux or Fedora for more control and cutting-edge features.
Useful Links
- Linux Mint Official Site - https://linuxmint.com
- Pop OS Official Site - https://pop.system76.com
- Bazzite Official Site - https://bazzite.gg
- Nobara Official Site - https://nobaraproject.org
- Arch Linux Wiki - https://wiki.archlinux.org
Chapter 2 - What is a Linux Distribution Made of?
A Linux distribution comprises the same components that make up any operating system. Every Linux distribution has the following components, many of which can be customized to great effect. This is why there are so many options in Linux. With that in mind, here are the components of Linux:
Bootloader
The bootloader is what boots the machine. There are two types of boot processes for any operating system: EFI and Legacy boot. Most Linux distributions use a package called GRUB to handle this process. However, some newer distributions have started using systemd-boot instead of GRUB.
Display Renderer
For graphical elements to appear on the screen, either Xorg or Wayland is required to render the graphics. Both have their pros and cons. Xorg has been around since the beginning and is feature-rich, but its structure is messy. Wayland is newer and offers cleaner code. Personally, I use Xorg on most distributions because it does everything I need. However, most Linux distributions going forward will package Wayland by default and Xorg will eventually go away. Most servers don't need graphics and omit these packages altogether, relying only on a CLI (Command Line Interface).
Xorg vs Wayland: https://youtu.be/U_MBJcD3SFI
Display Manager
The display manager is essentially the login manager that boots into your desktop environment or window manager.
SDDM
This is the display manager for KDE. There are a lot of themes and support for both Wayland and Xorg.
GDM
This is the display manager for GNOME. Much like SDDM, lots of themes and support for both Wayland and Xorg.
LightDM
This is a more universal display manager that multiple desktop environments use because it is lightweight. Xorg Only, but is very lightweight and still widely used.
LightDM Customization: https://youtu.be/_dYqisDIcC0
None
You technically don't need a display manager, but this means you will boot into a CLI (Command Line Interface) prompt with no graphics. Alternatively, you could set a window manager or desktop environment to auto-launch without requiring a login.
Desktop Environments
Desktop environments are the bread and butter of many distributions. These are typically an assortment of programs that dictate how programs are launched, displayed, and configured. Think of these as the look and feel of Linux.
Overview of Desktop Environments: https://youtu.be/mZa8AMWsYdQ
KDE
This is a Windows-style desktop environment with a start menu, taskbar, and basic floating window management. The workflow is very similar to Microsoft Windows. It has extensive theming capabilities, desktop widgets, and a vast array of built-in tools.
KDE Customization Video: https://youtu.be/nRtyFtpf5yU
GNOME
GNOME has a unique workflow with window animations and extensions to expand its capabilities. It is unlike any other Desktop Environment out there but has great utility. Its strengths include robust system settings and support for scaling and tablet-style computers.
Cinnamon
This is another Windows-style desktop environment, but it is more simplistic than KDE. The menus are more intuitive, and it has everything the user needs without bundling a ton of applications. This is my first recommendation for Windows users converting to Linux.
Cinnamon Customization Video: https://youtu.be/ZWA4F95A0Vc (Note: Cinnamon is made by the Linux Mint team.)
MATE
MATE is based on GNOME 2 from the past. It looks a bit dated out of the box, but its minimal design makes it lightweight and functional. It has a traditional menu system, unlike the latest version of GNOME, and can be tweaked to the user's needs without using many resources.
XFCE
Minimal, simplistic, and modular—that is XFCE's ethos, and it does a good job of it. It is one of my favorites, even though, like MATE, it is very ugly out of the box. After customization, it can look fantastic.
XFCE Customization Video: https://youtu.be/Y_x5svD2sZQ
LXQt / LXDE
LXQt is a very minimal desktop environment with a limited feature set. It is one of the lightest desktop environments on this list and is my recommendation for those using an old PC. Using nearly no resources, it simply gets the job done. LXDE is the older version before it morphed into LXQt.
Deepin
This reminds me of macOS and is my recommendation for mac users coming to Linux who don't like GNOME. It is sleek and has a futuristic look out of the box.
Others
There are many other desktop environments that are less popular than the ones above, and I encourage you to explore them after familiarizing yourself with the ones listed.
Window Managers
Window managers are often a point of confusion for new users, as people often mix them up with desktop environments. What is the difference? Desktop environments include a suite of tools and utilities, while window managers only manage windows.
I could write another book dedicated specifically to window managers, but I'd only recommend them for advanced users who are capable of making system modifications without the assistance of utilities. For example, adjusting your display settings.
Everything is set up by the user, from adjusting volume to launching programs. Depending on the window manager, you might need to edit text files to configure them or create shortcut keys for programs. Each one is unique and not for the faint of heart. In many of my videos, I use a modified version of DWM, which can be found on my GitHub: https://github.com/ChrisTitusTech/dwm-titus
Package Manager
This is probably the biggest factor that separates distributions and also makes many of them similar. There are a variety of package managers, but I will touch on the most popular ones that most distributions are based on.
APT
Debian-based distributions (e.g., Ubuntu, Pop_OS!, Linux Mint, etc.) use APT, which is one of the oldest package managers on this list. It is also the most widely used. A good majority of Linux articles reference APT. The basic syntax is apt install package
.
DNF / YUM
RHEL-based distributions (e.g., Fedora, CentOS, Nobara, etc.) use these and dominate the business space. DNF is newer and has better dependency resolution, but you will still see YUM occasionally for legacy systems or older versions. Its basic syntax is dnf install package
.
Pacman
This is the oddball of the bunch, as it is used in Arch-based distributions (e.g., Manjaro, Garuda, EndeavourOS, etc.). It has non-standard syntax like pacman -S package
to install a package.
Others
There are many other package managers, but these encompass most of the popular Linux installations.
Flatpak / AppImage / SnapD
These are agnostic of any distribution. This means the programs aren't install on the system-level but are self contained. Any dependencies are included with the package which makes them usable on anything Linux. Flatpak and snapd are easy to manage from the command line, but also have lots of files for each package. AppImage is contained within the singular Package.AppImage
file. For managing AppImage files, I recommend using gearlever
package. For managing permissions on flatpak files, I recommend the flatseal
package. I do not recommend using SnapD at all as it is owned and poorly maintained by the company Canonical that distributes Ubuntu.
Misconceptions
It should be noted that most programs can be compiled to work on pretty much any Linux distribution, and all the package manager does is make it easy for you to perform the installation. There are many other ways to install a program, such as building from source. However, most times this isn't needed, as even if a package is not available in your package manager, you can expand it by adding a repository to it, thus giving your package manager access to install even more programs on the fly. Even if this fails or a repository isn't available, you can utilize universal packages like Flatpak, Snap, or AppImage that can install on any system, no matter what package manager you are using.
Types of Linux Installations
There are a variety of ways to install Linux, and I will go over them in depth. These methods are broken into three categories: Beginner, Intermediate, and Expert.
Beginner Installation
This is extremely easy to do and is where a beginner should start. The downside to a beginner install is that it has less customizability, but it is an easier starting place for a novice user.
Intermediate Installation
This method typically involves taking a base distribution from the server level and installing the needed packages as required. It yields a highly customized system with a minimal installation but requires the user to know which packages they want.
Expert Installation
Much like intermediate installation, this method advances to not using desktop environments or bundles that install multiple packages. While this method can be tedious, it results in the most minimal installation, as it avoids installing unnecessary packages. However, it requires an extreme skill level to achieve. Often, the user is building packages or even compiling the base Linux kernel.
Progression
The progression you will go through in Linux is much more than these types of installations, but I wanted to give you a path as you explore and move through these types of installations.
Build What You Want Video: https://youtu.be/fWHKAn5W2CA
Chapter 3 - Bootloaders: How Linux is Loaded
There are many bootloaders available, but this chapter focuses on the two most widely used: GRUB 2 and systemd-boot.
GRUB 2 - The Most Widely Used
GRUB 2 is the most popular bootloader for Linux, offering extensive functionality. It supports themes, multiboot setups, and various other features that make it highly versatile. For Windows/Linux multiboot systems, GRUB 2 is my recommended choice.
- GRUB Manual Table of Contents: https://www.gnu.org/software/grub/manual/grub/html_node/index.html
Configuration
Before installing or updating GRUB, you need to create configuration files. One of the best resources for understanding GRUB is the https://wiki.gentoo.org/wiki/GRUB2.
Files Used for Configuration
File Location | Editable | Description |
---|---|---|
/boot/grub/grub.cfg | No | Generated by grub-mkconfig and will be overwritten. Do not edit directly. |
/etc/grub.d/* | Yes | Contains scripts processed in numerical order (e.g., 10-boot , 11-os ). |
/etc/default/grub | Yes | Primary configuration file for GRUB edits. Start here for modifications. |
Editing GRUB Configuration in /etc/default/grub
Below are common configuration entries in /etc/default/grub
:
GRUB_DEFAULT
: Specifies the default boot entry. Typically set to0
for the first entry. Use1
for the second entry,2
for the third, and so on.GRUB_TIMEOUT_STYLE
: Determines whether to display a menu (MENU
) or hide it (HIDDEN
). If hidden, theGRUB_HIDDEN_TIMEOUT
variable controls the splash screen display.GRUB_TIMEOUT
: Sets the menu display duration. If set to-1
, the menu will never timeout and will wait for user input.GRUB_CMDLINE_LINUX_DEFAULT
: Adds kernel options. Common examples:quiet splash
: Hides verbose text output during boot.nomodeset
: Bypasses modesetting, useful for booting NVIDIA systems to install drivers.single
: Boots into single-user mode, useful for system modifications or resetting user passwords.- Variable declarations: Add system-specific variables, such as
keymap
orvfio
for PCI passthrough.
GRUB_DISABLE_RECOVERY
: Disables recovery entries. Setting this totrue
is recommended if recovery entries are rarely needed. You can edit GRUB directly during boot by pressinge
when the menu appears.
For a complete list of GRUB configuration variables, refer to the https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html.
Sample GRUB Configuration (/etc/default/grub
)
Here’s an example configuration with no menu:
GRUB_DEFAULT="0"
GRUB_TIMEOUT_STYLE="hidden"
GRUB_TIMEOUT="0"
GRUB_DISTRIBUTOR="`lsb_release -i -s 2> /dev/null || echo Debian`"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
GRUB_DISABLE_RECOVERY="true"
GRUB_DISABLE_LINUX_RECOVERY="true"
Make Configuration files
Make the configuration files with grub-mkconfig
or update-grub
on debian-based systems.
grub-mkconfig -o /boot/grub/grub.cfg
Manual page for grub-mkconfig: https://www.gnu.org/software/grub/manual/grub/html_node/Simple-configuration.html#Simple-configuration
OR
update-grub
Manual page for update-grub: https://manpages.debian.org/buster/grub-legacy/update-grub.8.en.html
Installation
Once your configuration files are created, you can install GRUB onto your hard disk for booting. First, determine whether the installation is EFI or Legacy BIOS.
To check if you are using EFI:
ls /sys/firmware/efi
If files are listed with the ls command you are on EFI
EFI Installation
Efi installations consist of two partitions where Legacy BIOS can have one. This makes it unique, but can also cause a multiple problems when using manual partitioning. Prior to running these commands you need to make sure the partition is mounted!
Next, we need to install EFI to this partition with this command
grub-install --efi-directory=/boot/efi
BIOS Legacy Installation
Typically in a BIOS legacy setup you have one main partition mounted to / and you run the following command to install GRUB. Note: DO NOT USE Legacy where you can use EFI!
grub-install
You can also do a variation of this if you have multiple drives or are dual booting. Find the drive you are installing it on using the command lsblk
OR blkid
as these give more information about your drive setup
Example usage when specifying a drive:
grub-install /dev/sda
For the full usage of grub-install here is the manual page: https://www.gnu.org/software/grub/manual/grub/html_node/Installing-GRUB-using-grub_002dinstall.html
GRUB Videos
These are the videos I've done on GRUB via YouTube:
- How to Repair Linux With Boot Failure: https://youtu.be/9D3hvnnby9A
- Fix Multi-Boot Systems running GRUB and Windows: https://youtu.be/3oQfnNhk7qU
- Using SuperGRUBDisk to repair GRUB: https://youtu.be/gEB6JEYZekE
- Custom Bootloader Themes Project: https://youtu.be/BAyzHP1Cqb0
- Using GRUB Rescue: https://youtu.be/r7meKJsjqfY
- Using GRUB Customizer for automated GRUB Building: https://youtu.be/3s7qBJ-H7vw
Systemd Boot - Minimal Built-In boot
Many distributions are now starting to ship with systemd boot instead of GRUB (PopOS! is one example) and is an interesting boot manager when you don't want a menu or extra packages to boot into your Linux.
Note: systemd boot has the capabilities of menus and dual boot, but setting this up is much more cumbersome and why I recommend using GRUB instead of doing this
Systemd-boot is also an EFI ONLY bootloader. So if you aren't booted in using UEFI, you can NOT install systemd-boot. Verify that you are in efi mode using ls /sys/firmware/efi
Systemd has a dedicated site for documentation. Check it out @ https://systemd.io/ and look at the Booting Section for systemd-boot. Another good source for systemd-boot information is the Arch Wiki @ https://wiki.archlinux.org/title/systemd-boot
Configuraiton
Here is the directory breakdown for systemd-boot
- Main Directory: /boot/efi (Sometimes this can be /boot in rare instances and some systems it adds a EFI subdirectory, ex. /boot/efi/EFI)
- Configuration files: /boot/efi/loader (General configuration in loader.conf)
- OS Entries: /boot/efi/loader/entries (Each .conf is a boot entry)
General Configuration
The general configuration will be the loader.conf in the root of the /loader
directory. Here is the syntax:
- default – Default boot option and it can be a wildcard like arch-*.conf.
- timeout – menu timeout in seconds before the default entry is booted. If this is not set, the menu will only be shown on key press during boot.
- editor – yes is default, but this allows editing boot entries and can be used to reset password or get system level access. Set to no if security is a concern.
- auto-entries – shows automatic entries for Windows, EFI Shell, and Default Loader if set to 1 (default), 0 to hide;
- auto-firmware – shows entry for rebooting into UEFI firmware settings if set to 1 (default), 0 to hide;
- console-mode – changes UEFI console mode:
- 0 for 80x25
- 1 for 80x50
- 2 and above for non-standard modes provided by the device firmware
- auto picks a suitable mode automatically
- max for highest available mode
- keep (default) for the firmware selected mode.
boot/efi/loader/loader.conf example
default arch.conf
timeout 4
console-mode max
editor no
Adding Boot Entries
Every boot entry will be loaded from the /loader/entries
directory. Here is that syntax:
-
title – operating system name. Required.
-
version – kernel version. Optional.
-
machine-id – machine identifier from /etc/machine-id. Optional.
-
efi – EFI program to start. Either this parameter or linux is required.
-
options – space-separated command line options to pass to the EFI program or kernel parameters.
root="UUID=3255683f-53a2-4fdf-91cf" OR root="LABEL=OS Label"
is required for booting Linux. Here are common options:- rw = Read-Write needed for most installs
- root = UUID or Label used for identifying the root partition
- silent = do NOT display any console output
- splash = display OS Splash screen
- nomodeset = disable Kernel mode setting. Often needed if using NVIDIA cards and you do not have the drivers installed.
- S = run in single mode (often required for resetting root password or modifying root file system)
Q: How do you find the UUID? A: The command
sudo blkid
_Note: To identify specific drive labels I recommend
sudo lsblk
which gives a readout of all drives and where they are mounted. When used in conjunction withblkid
you will be able to tell what each drive is.
Check all kernel parameters @ https://www.kernel.org/doc/html/v5.13/admin-guide/kernel-parameters.html
Example Arch Linux Entry /boot/efi/loader/entries/arch.conf
title Arch Linux
linux /vmlinuz-linux
initrd /intel-ucode.img
initrd /initramfs-linux.img
options root="LABEL=arch" rw
Example Windows 10 Entry /boot/efi/loader/entries/win10.conf
title Windows 10
efi /EFI/Microsoft/Boot/bootmgfw.efi
Automatic EFI Entry creation with the efibootmgr
package - You can check to see what efi options are installed to you with efibootmgr -v
.
efibootmgr --create --disk /dev/sda --part 1 --loader "\EFI\systemd\systemd-bootx64.efi" --label "Linux OS" --verbose
Note: This command is used if your Linux EFI system partition is located @ /dev/sda1 and the EFI file located @ /boot/efi/EFI/systemd/systemd-bootx64.efi
Installation
The default install is very easy once configuration is done. You simply type bootctl install
and you are done!
There are configurations with multiple boot partitions, but I do not recommend using systemd-boot for this.
In most instances this will auto update when boot options change, but you can force an update if you manually add more entries with bootctl update
Chapter 4 - Server Command Line Interface: Mastering the Terminal
This chapter covers the most important aspect of Linux: the terminal. The terminal is the beating heart of Linux, enabling you to accomplish virtually anything. For the first eight years I used Linux, I relied exclusively on the terminal, never even considering a graphical interface. The terminal is reliable, quick, and efficient, making it an indispensable tool for Linux users.
Pro Tip: The terminal is always accessible. If you're stuck on a black screen or graphical interface, press Ctrl + Alt + F2
or Ctrl + Alt + F3
to switch to a terminal. To return to the graphical interface, press Ctrl + Alt + F7
.
Navigating the Command Line Interface
Directory Movement Commands and Examples:
-
cd
(change directory):cd ..
(move up a directory)cd name
(move into the specified directory)cd /
(move to the root directory)cd ~
(move to the home directory, e.g.,/home/titus
)zoxide
- A better package for navigating the file system, using fuzzy finding and remembering past directories.
-
ls
(list files):ls -a
(show all files, including hidden ones)ls -l
(long listing format showing permissions)
-
rm
(remove files):rm -rf
(remove files/directories recursively and forcefully)rmdir
(remove empty directories)trash-cli
- An alternative torm
that moves files to the trash instead of permanently deleting them.
-
cp
(copy files):cp -r
(copy files and subdirectories recursively)rsync
- A more efficient tool for copying or syncing large amounts of files.
Directory Layout and File System Overview
/
- Root directory/bin
- System executable files/boot
- Bootloader files/dev
- Device files (requires mounting to browse)/etc
- System configuration files/home
- User files and configuration files/media
- Mounted external media/mnt
- Temporary mount points/opt
- Optional files/root
- Root user files and configurations/tmp
- Temporary files/usr
- System resources/var
- Logs, databases, and other variable data
Most interactions with the file system occur within the /home/user
directory. This includes configuration files and executable programs. Direct editing of system-wide configuration files in /etc
or adding programs to /bin
should be done sparingly.
System Services and Configuration
Modern Linux distributions use an "init system" to control system operations, primarily systemd. Systemd manages services, boot processes, networking, and more.
Controlling Services and Units
systemctl
is the primary tool for managing services and units in systemd. Units can represent services, device drivers, network mounts, timers (similar to crontab
), and more.
Common systemctl
Commands:
systemctl status servicename
- View the current status of a service.systemctl start servicename
- Start a service.systemctl stop servicename
- Stop a service.systemctl restart servicename
- Restart a service (stop and start).systemctl reload servicename
- Reload the configuration file without restarting the service.systemctl enable servicename
- Enable a service to start at system boot.systemctl is-enabled servicename
- Check if a service is enabled at startup.systemctl is-active servicename
- Check if a service is running and active.systemctl list-units
- List all running systemd units.systemctl list-units --all
- List all units, both active and inactive.systemctl list-units --all --state=inactive
- List all inactive units.systemctl list-units --all --type=service
- List all units of type "service."
Unit File Locations
Systemd unit files are typically located in the following directories:
/usr/lib/systemd
- The main location for system-created unit files./etc/systemd/system
- Contains system-wide unit files, often symbolic links to/usr/lib/systemd
. This directory has top priority when reading unit files.~/.config/systemd/user/
- Contains user-specific unit files. This directory is not created by default and requires the--user
option for systemctl commands.
Example System Unit File
Below is an example of a system unit file:
[Unit]
Description=service_description
After=network.target
[Service]
ExecStart=path_to_executable
Type=forking
[Install]
WantedBy=default.target
For a full reference, visit: Systemd Unit Documentation.
User-Based Systemd Services and Unit Files
User-specific unit files are stored in the ~/.config/systemd/user/
directory. These files can be managed using the --user
option with systemctl
.
Example Command:
systemctl --user start usercreatedfile.service
This command starts a user-created service file located in the user's home directory.
Example User Unit File:
[Unit]
Description=Run service as user
DefaultDependencies=no
After=network.target
[Service]
Type=simple
User=titus
Group=users
ExecStart=/home/titus/scripts/startup_script.sh
TimeoutStartSec=0
RemainAfterExit=yes
[Install]
WantedBy=default.target
Bluetooth Configuration
To configure Bluetooth, you can use the bluetoothctl
command-line tool. This tool allows you to manage Bluetooth devices and settings directly from the terminal.
Syntax for bluetoothctl
commands:
bluetoothctl [command]
Common bluetoothctl
Commands:
power on
- Turn on the Bluetooth adapter.power off
- Turn off the Bluetooth adapter.agent on
- Enable the agent for pairing.scan on
- Start scanning for nearby Bluetooth devices.scan off
- Stop scanning for Bluetooth devices.pair <device_address>
- Pair with a specific Bluetooth device.connect <device_address>
- Connect to a paired Bluetooth device.disconnect <device_address>
- Disconnect from a connected Bluetooth device.devices
- List all known Bluetooth devices.info <device_address>
- Show detailed information about a specific Bluetooth device.
Example Usage:
bluetoothctl
power on
agent on
scan on
This will turn on the Bluetooth adapter, enable the agent for pairing, and start scanning for nearby Bluetooth devices.
Note: blueman
is a graphical Bluetooth manager that can be used as an alternative to bluetoothctl
for those who prefer a GUI.
Audio Configuration
Linux provides several command-line tools for managing audio. The two main sound systems are ALSA (Advanced Linux Sound Architecture) and PulseAudio, with PulseAudio running on top of ALSA.
PulseAudio Commands (pactl
)
The pactl
command is used to control the PulseAudio sound server:
# List audio sources and sinks
pactl list sources # List input devices
pactl list sinks # List output devices
# Volume control
pactl set-sink-volume @DEFAULT_SINK@ 50% # Set volume to 50%
pactl set-sink-mute @DEFAULT_SINK@ toggle # Toggle mute
# List loaded modules
pactl list modules
ALSA Mixer (alsamixer
)
alsamixer
is a terminal-based mixer program for ALSA:
alsamixer # Open the mixer interface
Navigation in alsamixer
:
- Arrow keys: Navigate between channels
- Up/Down: Adjust volume
- M: Toggle mute
- F6: Select sound card
- Esc: Exit
Common Audio Troubleshooting Commands
# Restart PulseAudio
pulseaudio -k # Kill the PulseAudio daemon
pulseaudio --start # Start PulseAudio
# Check audio devices
aplay -l # List all ALSA playback devices
arecord -l # List all ALSA recording devices
# Test audio output
speaker-test -c 2 # Test stereo speakers
Audio Device Management with pavucontrol
While pavucontrol
is technically a GUI application, it can be installed and launched from the terminal:
sudo apt install pavucontrol # Install on Debian/Ubuntu
pavucontrol # Launch the control interface
Pipewire Audio System
Pipewire is the modern replacement for both PulseAudio and JACK. It maintains compatibility with PulseAudio clients, so pactl
commands work with Pipewire. Additionally, Pipewire provides its own tools:
# Check Pipewire status
pw-cli status
pw-top # Show real-time audio processing graph
# List audio devices
pw-dump # Detailed info about audio devices and nodes
pw-cli list-objects # List all Pipewire objects
# Control specific nodes
pw-cli node-id # Get ID of audio nodes
pw-metadata -n settings 0 clock.force-rate 48000 # Set sample rate
# Monitor audio
pw-mon # Monitor Pipewire events in real-time
You can still use PulseAudio tools with Pipewire:
pactl
commands work as shown abovepavucontrol
works normally- ALSA applications work without modification
Note: Most modern Linux distributions are transitioning to Pipewire as their default audio system due to its improved latency, Bluetooth handling, and compatibility with both PulseAudio and JACK applications.
Typical Pipewire Package Names:
pipewire
- Core Pipewire packagepipewire-pulse
- PulseAudio compatibility layerpipewire-jack
- JACK compatibility layerpipewire-alsa
- ALSA compatibility layerwireplumber
- Session manager for Pipewire
Note: Do NOT use pipewire-media-session, as it is deprecated and replaced by wireplumber.
Chapter 5: Drives and Filesystems
This chapter focuses on managing drives and filesystems in Linux, including mounting and unmounting drives, understanding filesystems, and using tools like fdisk
, mkfs
, and fsck
.
Understanding Drives and Filesystems
In Linux, drives and filesystems are fundamental components that allow the operating system to store and retrieve data. Each drive can have one or more partitions, and each partition can be formatted with a specific filesystem type.
Common Filesystem Types
- ext4: The most common filesystem for Linux, known for its performance and reliability.
- xfs: A high-performance filesystem often used for large files and high-capacity storage.
- btrfs: A modern filesystem with advanced features like snapshots and dynamic resizing.
- vfat: A filesystem compatible with Windows, often used for USB drives, external storage, and EFI boot partitions.
- ntfs: The Windows NT filesystem, used for compatibility with Windows systems.
- swap: A special filesystem used for swap space, which is used when the system runs out of RAM.
Mounting and Unmounting Drives
Mounting and unmounting drives is a common task in Linux, especially when dealing with external storage devices or network shares.
Fstab Configuration
The /etc/fstab
file is used to define how disk partitions, network shares, and other file systems are mounted at boot time. Each line in the file represents a file system and its mount options.
Fstab structure:
- Device: usually the given name or UUID of the mounted device (sda1/sda2/etc).
- Mount Point: designates the directory where the device is/will be mounted.
- File System Type: nothing trick here, shows the type of filesystem in use. Options: lists any active mount options. If using multiple options they must be separated by commas.
- Backup Operation: (the first digit) this is a binary system where 1 = dump utility backup of a partition. 0 = no backup. This is an outdated backup method and should NOT be used.
- File System Check Order: (second digit) Here we can see three possible outcomes. 0 means that fsck will not check the filesystem. Numbers higher than this represent the check order. The root filesystem should be set to 1 and other partitions set to 2.
Stntax:
# <device> <mount point> <file system type> <options> <backup operation> <fsck order>
Example:
UUID=1234-5678 /mnt/data ext4 defaults 0 2
/dev/sdb1 /media/usb vfat defaults,nofail 0 0
Options:
defaults
: Use default mount options.nofail
: Ignore errors when mounting the filesystem.noauto
: Do not mount automatically at boot.user
: Allow non-root users to mount the filesystem.rw
: Mount the filesystem as read-write.ro
: Mount the filesystem as read-only.exec
: Allow execution of binaries on the filesystem.noexec
: Prevent execution of binaries on the filesystem.sync
: All I/O operations are done synchronously.async
: All I/O operations are done asynchronously.uid=1000
: Set the owner of the mounted filesystem to user ID 1000.gid=1000
: Set the group of the mounted filesystem to group ID 1000.umask=022
: Set the default permissions for files and directories on the mounted filesystem.dmask=027
: Set the default permissions for directories on the mounted filesystem.fmask=133
: Set the default permissions for files on the mounted filesystem.
My fstab file with NFS mounts and multiple drives:
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme1n1p2
UUID=1188f001-7a26-4d75-819f-202e4ef2da96 / ext4 rw,relatime 0 1
# /dev/nvme1n1p1
UUID=3337-A669 /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
# /dev/nvme1n1p3
UUID=df8df26b-3bdc-427d-be86-43d6a25208b4 /home ext4 rw,relatime 0 2
# Network Drives
10.0.0.2:/volume2/Images /media/images nfs x-systemd.after=network-online.target,x-systemd.automount,x-systemd.mount-timeout=90,_netdev 0 0
Linux Hardware Compatibility
The biggest myth told by the Linux community is that Linux works on all hardware. This is not true, and it is a common misconception that leads to many users being disappointed when they try to install Linux on their machines. The reality is that while Linux supports a wide range of hardware, there are still many devices that do not work well or at all with Linux.
Incompatible Hardware
Some hardware is simply not compatible with Linux. This can be due to a lack of drivers, proprietary firmware, or other issues. For example, some Wi-Fi adapters, graphics cards, and printers may not work properly on Linux. Before installing Linux, it is essential to check the compatibility of your hardware.
Hardware I've personally had issues with includes:
- NVIDIA Graphics Cards: While NVIDIA provides proprietary drivers for Linux, they can be difficult to install and may not work with all distributions. Open-source alternatives like Nouveau exist but often lack performance and features. This is getting better with each kernel release, and nVidia open sourcing their drives, but still is a common issue. I've had issues with obscure Wayland configurations, Custom Linux Kernels, and certain desktop environments that do not play well with NVIDIA drivers. AMD graphics is still the best option for Linux users by a large margin.
- Broadcom Wi-Fi Adapters: Many Broadcom Wi-Fi adapters require proprietary drivers that are not included in the Linux kernel by default. This can lead to connectivity issues.
- Certain Printers: Some printers, especially those from manufacturers like HP and Canon, may not have Linux drivers available or may require additional configuration to work correctly.
- Fingerprint Readers: Many fingerprint readers do not have Linux support, making them unusable for authentication purposes.
- Webcams: Some webcams, particularly older models, may not be recognized by Linux or may require additional drivers to function correctly.
- Bluetooth Adapters: Some Bluetooth adapters may not work out of the box and require additional drivers or configuration.
- Touchpads: Some touchpads, especially those with advanced features, may not work correctly without additional configuration or drivers.
- Audio Devices: Some audio devices, particularly those with proprietary drivers, may not work correctly on Linux.
- Gaming Peripherals: Many gaming mice and keyboards may not have full functionality on Linux, especially those with customizable features.
- Virtual Reality Headsets: Many VR headsets do not have Linux support, making them unusable for gaming or other applications.
Checking Compatibility
Before installing Linux, it is crucial to check the compatibility of your hardware. Here are some resources to help you determine if your hardware is compatible with Linux:
- Linux Hardware Compatibility Lists: Websites like Linux Hardware provide lists of hardware that is known to work well with Linux.
- Distribution-Specific Compatibility Lists: Many Linux distributions maintain their own hardware compatibility lists. For example, Ubuntu's Hardware Compatibility page provides information on supported devices.
- Forums and Communities: Online forums and communities, such as the LinuxQuestions.org or the Linux 4 Noobs Subreddit, can be valuable resources for checking hardware compatibility. Users often share their experiences with specific hardware and Linux distributions.
- Manufacturer Websites: Some hardware manufacturers provide information on Linux compatibility for their products. Check the manufacturer's website for any available drivers or support documentation.
- Distro-Specific Tools: Some Linux distributions come with tools that can help you check hardware compatibility.
lshw
(List Hardware) is a command-line utility that provides detailed information about your system's hardware. You can use it to check if your hardware is recognized by the Linux kernel. - Live USB Testing: Before installing Linux, you can create a live USB of the distribution you want to try. Booting from the live USB allows you to test hardware compatibility without making any changes to your system. This is a great way to see if your hardware works well with Linux before committing to an installation.
Conclusion
While Linux supports a wide range of hardware, it is essential to be aware of potential compatibility issues. Before installing Linux, check the compatibility of your hardware using the resources mentioned above. By doing so, you can avoid disappointment and ensure a smooth installation and usage experience with Linux.