29,99 €
Ubuntu 22.04 Essentials is intended to provide detailed information on the installation, use, and administration of the Ubuntu distribution. For beginners, the book covers topics such as operating system installation, the basics of the GNOME desktop environment, configuring email and web servers, and installing packages and system updates. Additional installation topics, such as dual booting with Microsoft Windows, are also covered, together with all important security topics, such as configuring a firewall and user and group administration.
For the experienced user, topics such as remote desktop access, the Cockpit web interface, logical volume management (LVM), disk partitioning, swap management, KVM virtualization, Secure Shell (SSH), Linux Containers, and file sharing using both Samba and NFS are covered in detail to provide a thorough overview of this enterprise class operating system.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Veröffentlichungsjahr: 2023
Ubuntu 22.04 Essentials
Ubuntu 22.04 Essentials
© 2023 Neil Smyth / Payload Media, Inc. All Rights Reserved.
This book is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights reserved.
The content of this book is provided for informational purposes only. Neither the publisher nor the author offers any warranties or representation, express or implied, with regard to the accuracy of information contained in this book, nor do they accept any liability for any loss or damage arising from any errors or omissions.
This book contains trademarked terms that are used solely for editorial purposes and to the benefit of the respective trademark owner. The terms used within this book are not intended as infringement of any trademarks.
Rev: 1.0a
Table of Contents
1. Introduction
1.1 Superuser Conventions
1.2 Opening a Terminal Window
1.3 Editing Files
1.4 Feedback
1.5 Errata
2. A Brief History of Ubuntu Linux
2.1 What exactly is Linux?
2.2 UNIX Origins
2.3 Who Created Linux?
2.4 The History of Ubuntu
2.5 What does the word “Ubuntu” Mean?
2.6 Summary
3. Installing Ubuntu on a Clean Disk Drive
3.1 Ubuntu Installation Options
3.2 Server vs. Desktop Editions
3.3 Obtaining the Ubuntu Installation Media
3.4 Writing the ISO Installation Image to a USB Drive
3.4.1 Linux
3.4.2 macOS
3.4.3 Windows/macOS
3.5 Booting from the Ubuntu USB Image
3.6 Installing Ubuntu
3.7 Accessing the Ubuntu Desktop
3.8 Installing Updates
3.9 Displaying Boot Messages
3.10 Summary
4. Dual Booting Ubuntu with Windows
4.1 Beginning the Ubuntu Installation
4.2 Booting Ubuntu for the First Time
4.3 Changing the Default Boot Option
4.4 Accessing the Windows Partition from the Command-line
4.5 Accessing the Windows Partition from the Desktop
4.6 Summary
5. Allocating Windows Disk Partitions to Ubuntu
5.1 Unmounting the Windows Partition
5.2 Deleting the Windows Partitions from the Disk
5.3 Formatting the Unallocated Disk Partition
5.4 Mounting the New Partition
5.5 Editing the Boot Menu
5.6 Using GNOME Disks Utility
5.7 Summary
6. A Guided Tour of the GNOME 42 Desktop
6.1 Installing the GNOME Desktop
6.2 An Overview of the GNOME 42 Desktop
6.3 Launching Activities
6.4 Managing Windows
6.5 Using Workspaces
6.6 Calendar and Notifications
6.7 Desktop Settings
6.8 Customizing the Dock
6.9 Installing Ubuntu Software
6.10 Beyond Basic Customization
6.11 Summary
7. An Overview of the Cockpit Web Interface
7.1 An Overview of Cockpit
7.2 Installing and Enabling Cockpit
7.3 Accessing Cockpit
7.4 Overview
7.5 Logs
7.6 Storage
7.7 Networking
7.8 Accounts
7.9 Services
7.10 Applications
7.11 Virtual Machines
7.12 Software Updates
7.13 Terminal
7.14 Connecting to Multiple Servers
7.15 Enabling Stored Metrics
7.16 Summary
8. Using the Bash Shell on Ubuntu 22.04
8.1 What is a Shell?
8.2 Gaining Access to the Shell
8.3 Entering Commands at the Prompt
8.4 Getting Information about a Command
8.5 Bash Command-line Editing
8.6 Working with the Shell History
8.7 Filename Shorthand
8.8 Filename and Path Completion
8.9 Input and Output Redirection
8.10 Working with Pipes in the Bash Shell
8.11 Configuring Aliases
8.12 Environment Variables
8.13 Writing Shell Scripts
8.14 Summary
9. Managing Ubuntu 22.04 Users and Groups
9.1 User Management from the Command-line
9.2 User Management with Cockpit
9.3 User Management using the Settings App
9.4 Summary
10. Managing Ubuntu 22.04 systemd Units
10.1 Understanding Ubuntu systemd Targets
10.2 Understanding Ubuntu systemd Services
10.3 Ubuntu systemd Target Descriptions
10.4 Identifying and Configuring the Default Target
10.5 Understanding systemd Units and Unit Types
10.6 Dynamically Changing the Current Target
10.7 Enabling, Disabling, and Masking systemd Units
10.8 Working with systemd Units in Cockpit
10.9 Summary
11. Ubuntu Software Package Management and Updates
11.1 Repositories
11.2 Managing Repositories with Software & Updates
11.3 Managing Packages with APT
11.4 Performing Updates
11.5 Enabling Automatic Updates
11.6 Enabling Ubuntu Pro
11.7 Summary
12. Ubuntu Snap Package Management
12.1 Managing Software with Snap
12.2 Basic Snap Commands
12.3 Working with Snap Channels
12.4 Snap Refresh Schedule
12.5 Snap Services
12.6 Summary
13. Ubuntu 22.04 Network Management
13.1 An Introduction to NetworkManager
13.2 Installing and Enabling NetworkManager
13.3 Basic nmcli Commands
13.4 Working with Connection Profiles
13.5 Interactive Editing
13.6 Configuring NetworkManager Permissions
13.7 Summary
14. Ubuntu 22.04 Firewall Basics
14.1 Understanding Ports and Services
14.2 Securing Ports and Services
14.3 Ubuntu Services and iptables Rules
14.4 Well-Known Ports and Services
14.5 Summary
15. Using gufw and ufw to Configure an Ubuntu Firewall
15.1 An Overview of gufw and ufw
15.2 Installing gufw on Ubuntu
15.3 Running and Enabling gufw
15.4 Creating a New Profile
15.5 Adding Preconfigured Firewall Rules
15.6 Adding Simple Firewall Rules
15.7 Adding Advanced Rules
15.8 Configuring the Firewall from the Command Line using ufw
15.9 Summary
16. Basic Ubuntu Firewall Configuration with firewalld
16.1 An Introduction to firewalld
16.1.1 Zones
16.1.2 Interfaces
16.1.3 Services
16.1.4 Ports
16.2 Checking firewalld Status
16.3 Configuring Firewall Rules with firewall-cmd
16.3.1 Identifying and Changing the Default Zone
16.3.2 Displaying Zone Information
16.3.3 Adding and Removing Zone Services
16.3.4 Working with Port-based Rules
16.3.5 Creating a New Zone
16.3.6 Changing Zone/Interface Assignments
16.3.7 Masquerading
16.3.8 Adding ICMP Rules
16.3.9 Implementing Port Forwarding
16.4 Managing firewalld using firewall-config
16.5 Summary
17. Configuring SSH Key-based Authentication on Ubuntu 22.04
17.1 An Overview of Secure Shell (SSH)
17.2 SSH Key-based Authentication
17.3 Setting Up Key-based Authentication
17.4 Installing and Starting the SSH Service
17.5 SSH Key-based Authentication from Linux and macOS Clients
17.6 Managing Multiple Keys
17.7 SSH Key-based Authentication from Windows Clients
17.8 SSH Key-based Authentication using PuTTY
17.9 Generating a Private Key with PuTTYgen
17.10 Summary
18. Ubuntu 22.04 Remote Desktop Access with Vino
18.1 Remote Desktop Access Types
18.2 Secure and Insecure Remote Desktop Access
18.3 Enabling Remote Desktop Access on Ubuntu
18.4 Connecting to the Shared Desktop
18.5 Connecting from Windows
18.6 Summary
19. Displaying Ubuntu 22.04 Applications Remotely (X11 Forwarding)
19.1 Requirements for Remotely Displaying Ubuntu Applications
19.2 Displaying an Ubuntu Application Remotely
19.3 Trusted X11 Forwarding
19.4 Compressed X11 Forwarding
19.5 Displaying Remote Ubuntu Apps on Windows
19.6 Summary
20. Using NFS on Ubuntu 22.04 to Share Files with Remote Systems
20.1 Ensuring NFS Services are running on Ubuntu
20.2 Configuring the Firewall to Allow NFS Traffic
20.3 Specifying the Folders to be Shared
20.4 Accessing Shared Folders
20.5 Mounting an NFS Filesystem on System Startup
20.6 Unmounting an NFS Mount Point
20.7 Accessing NFS Filesystems in Cockpit
20.8 Summary
21. Sharing Files between Ubuntu 22.04 and Windows with Samba
21.1 Accessing Windows Resources from the GNOME Desktop
21.2 Samba and Samba Client
21.3 Installing Samba on Ubuntu
21.4 Configuring the Ubuntu Firewall to Enable Samba
21.5 Configuring the smb.conf File
21.5.1 Configuring the [global] Section
21.5.2 Configuring a Shared Resource
21.5.3 Removing Unnecessary Shares
21.6 Creating a Samba User
21.7 Testing the smb.conf File
21.8 Starting the Samba and NetBIOS Name Services
21.9 Accessing Samba Shares
21.10 Accessing Windows Shares from Ubuntu
21.11 Summary
22. An Overview of Virtualization Techniques
22.1 Guest Operating System Virtualization
22.2 Hypervisor Virtualization
22.2.1 Paravirtualization
22.2.2 Full Virtualization
22.2.3 Hardware Virtualization
22.3 Virtual Machine Networking
22.4 Summary
23. Installing KVM Virtualization on Ubuntu 22.04
23.1 An Overview of KVM
23.2 KVM Hardware Requirements
23.3 Preparing Ubuntu for KVM Virtualization
23.4 Verifying the KVM Installation
23.5 Summary
24. Creating KVM Virtual Machines on Ubuntu 22.04 using Cockpit
24.1 Installing the Cockpit Virtual Machines Module
24.2 Creating a Virtual Machine in Cockpit
24.3 Starting the Installation
24.4 Working with Storage Volumes and Storage Pools
24.5 Summary
25. Creating KVM Virtual Machines on Ubuntu 22.04 using virt-manager
25.1 Starting the Virtual Machine Manager
25.2 Configuring the KVM Virtual System
25.3 Starting the KVM Virtual Machine
25.4 Summary
26. Creating KVM Virtual Machines with virt-install and virsh
26.1 Running virt-install to build a KVM Guest System
26.2 An Example Ubuntu virt-install Command
26.3 Starting and Stopping a Virtual Machine from the Command-Line
26.4 Creating a Virtual Machine from a Configuration File
26.5 Summary
27. Creating an Ubuntu 22.04 KVM Networked Bridge Interface
27.1 Getting the Current Network Manager Settings
27.2 Creating a Network Manager Bridge from the Command-Line
27.3 Declaring the KVM Bridged Network
27.4 Using a Bridge Network in a Virtual Machine
27.5 Creating a Bridge Network using nm-connection-editor
27.6 Summary
28. Managing KVM using the virsh Command-Line Tool
28.1 The virsh Shell and Command-Line
28.2 Listing Guest System Status
28.3 Starting a Guest System
28.4 Shutting Down a Guest System
28.5 Suspending and Resuming a Guest System
28.6 Saving and Restoring Guest Systems
28.7 Rebooting a Guest System
28.8 Configuring the Memory Assigned to a Guest OS
28.9 Summary
29. An Introduction to Linux Containers
29.1 Linux Containers and Kernel Sharing
29.2 Container Uses and Advantages
29.3 Ubuntu Container Tools
29.4 The Ubuntu Docker Registry
29.5 Container Networking
29.6 Summary
30. Working with Containers on Ubuntu
30.1 Installing the Container Tools
30.2 Pulling a Container Image
30.3 Running the Image in a Container
30.4 Managing a Container
30.5 Saving a Container to an Image
30.6 Removing an Image from Local Storage
30.7 Removing Containers
30.8 Building a Container with Buildah
30.9 Summary
31. Setting Up an Ubuntu 22.04 Web Server
31.1 Requirements for Configuring an Ubuntu Web Server
31.2 Installing the Apache Web Server Packages
31.3 Configuring the Firewall
31.4 Port Forwarding
31.5 Starting the Apache Web Server
31.6 Testing the Web Server
31.7 Configuring the Apache Web Server for Your Domain
31.8 The Basics of a Secure Website
31.9 Configuring Apache for HTTPS
31.10 Obtaining an SSL Certificate
31.11 Summary
32. Configuring an Ubuntu 22.04 Postfix Email Server
32.1 The Structure of the Email System
32.1.1 Mail User Agent
32.1.2 Mail Transfer Agent
32.1.3 Mail Delivery Agent
32.1.4 SMTP
32.1.5 SMTP Relay
32.2 Configuring an Ubuntu Email Server
32.3 Postfix Pre-Installation Steps
32.4 Firewall/Router Configuration
32.5 Installing Postfix on Ubuntu
32.6 Configuring Postfix
32.7 Configuring DNS MX Records
32.8 Starting Postfix on an Ubuntu System
32.9 Testing Postfix
32.10 Sending Mail via an SMTP Relay Server
32.11 Summary
33. Adding a New Disk Drive to an Ubuntu 22.04 System
33.1 Mounted File Systems or Logical Volumes
33.2 Finding the New Hard Drive
33.3 Creating Linux Partitions
33.4 Creating a File System on an Ubuntu Disk Partition
33.5 An Overview of Journaled File Systems
33.6 Mounting a File System
33.7 Configuring Ubuntu to Mount a File System Automatically
33.8 Adding a Disk Using Cockpit
33.9 Summary
34. Adding a New Disk to an Ubuntu 22.04 Volume Group and Logical Volume
34.1 An Overview of Logical Volume Management (LVM)
34.1.1 Volume Group (VG)
34.1.2 Physical Volume (PV)
34.1.3 Logical Volume (LV)
34.1.4 Physical Extent (PE)
34.1.5 Logical Extent (LE)
34.2 Getting Information about Logical Volumes
34.3 Adding Additional Space to a Volume Group from the Command-Line
34.4 Summary
35. Adding and Managing Ubuntu Swap Space
35.1 What is Swap Space?
35.2 Recommended Swap Space for Ubuntu
35.3 Identifying Current Swap Space Usage
35.4 Adding a Swap File to an Ubuntu System
35.5 Adding Swap as a Partition
35.6 Adding Space to an Ubuntu LVM Swap Volume
35.7 Adding Swap Space to the Volume Group
35.8 Summary
36. Ubuntu 22.04 System and Process Monitoring
36.1 Managing Processes
36.2 Real-time System Monitoring with top
36.3 Command-Line Disk and Swap Space Monitoring
36.4 Summary
Index
1. Introduction
Ubuntu is arguably one of the most highly regarded and widely used Linux distributions available today. Praised both for its ease of use and reliability, Ubuntu also has a loyal following of Linux users and an active community of developers.
Ubuntu 22.04 Essentials is intended to provide detailed information on the installation, use, and administration of the Ubuntu distribution. For beginners, the book covers topics such as operating system installation, the basics of the GNOME desktop environment, configuring email and web servers, and installing packages and system updates. Additional installation topics, such as dual booting with Microsoft Windows, are also covered, together with all important security topics, such as configuring a firewall and user and group administration.
For the experienced user, topics such as remote desktop access, the Cockpit web interface, logical volume management (LVM), disk partitioning, swap management, KVM virtualization, Secure Shell (SSH), Linux Containers, and file sharing using both Samba and NFS are covered in detail to provide a thorough overview of this enterprise class operating system.
1.1 Superuser Conventions
Ubuntu, in common with Linux in general, has two types of user accounts, one being a standard user account with restricted access to many of the administrative files and features of the operating system and the other a superuser (root) account with elevated privileges. Typically, a user can gain root access either by logging in as the root user or using the su - command and entering the root password. In the following example, a user is gaining root access via the su - command:
[demo@demo-server ~]$ su -
Password:
[demo@demo-server ~]#
Note that the command prompt for a regular user ends with a $ sign while the root user has a # character. When working with the command line, this is a useful indication of whether you are currently issuing commands as the root user.
If the su - command fails, the root account on the system has most likely been disabled for security reasons. In this case, the sudo command can be used instead, as outlined below.
Using sudo, a single command requiring root privileges may be executed by a non-root user. Consider the following attempt to update the operating system with the latest patches and packages:
$ apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
Optionally, user accounts may be configured so that they have access to root-level privileges. Instead of using the su - command to first gain root access, user accounts with administrative privileges are able to run otherwise restricted commands using sudo:
$ sudo apt update
[sudo] password for demo:
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
.
.
To perform multiple commands without repeatedly using the sudo command, a command prompt with persistent super-user privileges may be accessed as follows:
[demo@demo-server]$ sudo su -
[demo@demo-server]#
The reason for raising this issue so early in the book is that many of the command-line examples outlined in this book will require root privileges. Rather than repetitively preface every command-line example with directions to run the command as root, the command prompt at the start of the line will be used to indicate whether or not the command needs to be performed as root. If the command can be run as a regular user, the command will be prefixed with a $ command prompt as follows:
$ date
If, on the other hand, the command requires root privileges, the command will be preceded by a # command prompt:
# apt install openssh-server
1.2 Opening a Terminal Window
If you are using the GNOME desktop and need to access a command prompt, you will need to open a Terminal window. This can be achieved by right-clicking on the desktop background and selecting the Open in Terminal menu option as shown in Figure 1-1:
Figure 1-1
A terminal window may also be opened within the GNOME desktop using the Ctrl-Alt-T keyboard accelerator.
1.3 Editing Files
Configuring a Linux system typically involves editing files. For those new to Linux, it can be unclear which editor to use. If you are running a terminal session and do not already have a preferred editor, we recommend using the nano editor. To launch nano in a terminal window, enter the following command:
# nano <file>
Where <file> is replaced by the path to the file you wish to edit. For example:
# nano /etc/passwd
Once loaded, nano will appear as illustrated in Figure 1-2:
Figure 1-2
To create a new file run nano as follows:
# nano
When you have finished editing the file, type Ctrl-S to save the file, followed by Ctrl-X to exit. To open an existing file, use the Ctrl-R keyboard shortcut.
If you prefer to use a graphical editor within the GNOME desktop environment, gedit is a useful starting point for basic editing tasks. To launch gedit from the desktop press Alt-F2 to display the Enter a Command window as shown in Figure 1-3:
Figure 1-3
Enter gedit into the text field and press the Enter key. After a short delay, gedit will load ready to open, create, and edit files:
Figure 1-4
Alternatively, launch gedit from a terminal window either with or without the path to the file to open:
# gedit
# gedit /etc/passwd
1.4 Feedback
We want you to be satisfied with your purchase of this book. If you find any errors in the book or have any comments, questions, or concerns, please contact us at [email protected].
1.5 Errata
While we make every effort to ensure the accuracy of the content of this book, it is inevitable that a book covering a subject area of this size and complexity may include some errors and oversights. Any known issues with the book will be outlined, together with solutions, at the following URL:
https://www.ebookfrenzy.com/errata/Ubuntu2204.html
In the event that you find an error not listed in the errata, please let us know by emailing our support team at [email protected].
2. A Brief History of Ubuntu Linux
Ubuntu Linux is one of a number of variants (also referred to as distributions) of the Linux operating system and is the product of a U.K. company named Canonical Ltd. The company was founded in 1994 by Mark Shuttleworth. The origins of Linux, however, go back even further. This chapter will outline the history of both the Linux operating system and Ubuntu.
2.1 What exactly is Linux?
Linux is an operating system in much the same way that Windows is an operating system (and there any similarities between Linux and Windows end). The term operating system is used to describe the software that acts as a layer between the hardware in a computer and the applications that we all run on a daily basis. When programmers write applications, they interface with the operating system to perform such tasks as writing files to the hard disk drive and displaying information on the screen. Without an operating system, every programmer would have to write code to access the hardware of the system directly. In addition, the programmer would have to be able to support every single piece of hardware ever created to be sure the application would work on every possible hardware configuration. Because the operating system handles all of this hardware complexity, application development becomes a much easier task. Linux is just one of a number of different operating systems available today.
2.2 UNIX Origins
To understand the history of Linux, we first have to go back to AT&T Bell Laboratories in the late 1960s. During this time, AT&T had discontinued involvement in developing a new operating system named Multics. However, two AT&T engineers, Ken Thompson, and Dennis Ritchie, decided to take what they had learned from the Multics project and create a new operating system named UNIX which quickly gained popularity and wide adoption both with corporations and academic institutions.
A variety of proprietary UNIX implementations eventually came to market, including those created by IBM (AIX), Hewlett-Packard (HP-UX), and Sun Microsystems (SunOS and Solaris). In addition, a UNIX-like operating system named MINIX was created by Andrew S. Tanenbaum and designed for educational use with source code access provided to universities.
2.3 Who Created Linux?
The origins of Linux can be traced back to the work and philosophies of two people. At the heart of the Linux operating system is something called the kernel. This is the core set of features necessary for the operating system to function. The kernel manages the system’s resources and handles communication between the hardware and the applications. The Linux kernel was developed by Linus Torvalds, who, taking a dislike to MS-DOS and impatient for the availability of MINIX for the new Intel 80386 microprocessor, decided to write his own UNIX-like kernel. When he had finished the first version of the kernel, he released it under an open-source license that enabled anyone to download the source code and freely use and modify it without having to pay Linus any money.
Around the same time, Richard Stallman at the Free Software Foundation, a strong advocate of free and open-source software, was working on an open-source operating system of his own. Rather than focusing initially on the kernel, however, Stallman began by developing open-source versions of all the UNIX tools, utilities, and compilers necessary to use and maintain an operating system. By the time he had finished developing this infrastructure, the obvious solution was to combine his work with the kernel Linus had written to create a complete operating system. This combination became known as GNU/Linux. Purists insist that Linux always be referred to as GNU/Linux (in fact, at one time, Richard Stallman refused to give press interviews to any publication which failed to refer to Linux as GNU/Linux). This is not unreasonable, given that the GNU tools developed by the Free Software Foundation make up a significant and vital part of GNU/Linux. Unfortunately, most people and publications refer to Linux as Linux, which will probably always continue to be the case.
2.4 The History of Ubuntu
As mentioned previously, Ubuntu is one of a number of Linux distributions. The source code that makes up the Ubuntu distribution originates from a highly regarded Linux distribution known as Debian, created by Ian Murdoch.
A South African internet mogul named Mark Shuttleworth (who made his fortune selling his company to VeriSign for around $500 million) decided it was time for a more user-friendly Linux. He took the Debian distribution and worked to make it a more human-friendly distribution which he called Ubuntu. He subsequently formed a company called Canonical Ltd to promote and provide support for Ubuntu.
If you are new to Linux or already use Linux and want to try a different Linux distribution, it is unlikely you will find a better option than Ubuntu.
2.5 What does the word “Ubuntu” Mean?
The word “Ubuntu” is an ancient Zulu and Xhosa word that means “humanity to others”. Ubuntu also means “I am what I am because of who we all are”. It was chosen because these sentiments precisely describe the spirit of the Ubuntu distribution.
2.6 Summary
The origins of the Linux operating system can be traced back to the work of Linus Torvalds and Richard Stallman in the form of the Linux kernel combined with the tools and compilers built by the GNU project.
Over the years, the open-source nature of Linux has resulted in the release of a wide range of different Linux distributions. One such distribution is Ubuntu, based on the Debian Linux distribution created by Canonical Ltd, a company founded by Mark Shuttleworth
3. Installing Ubuntu on a Clean Disk Drive
There are now three ways in which an Ubuntu system can be deployed. One method is to either purchase new hardware or re-purpose an existing computer system on which to install and run the operating system. Alternatively, a virtualization platform such as VirtualBox or VMware can be used to install and run Ubuntu inside a virtual machine on an existing operating system. Another option is to create a cloud-based operating system instance using services such as Amazon AWS, Google Cloud, or Microsoft Azure (to name but a few). Since cloud-based instances are typically created by selecting a pre-configured, ready to run operating system image that is already optimized for the cloud platform and using that as the basis for the Ubuntu system, there is no need to perform a manual operating system installation in this situation.
If, on the other hand, you plan to install Ubuntu on your own hardware or make use of a virtualization environment, the first step on the path to learning about Ubuntu involves installing the operating system.
Ubuntu can be installed either in a clean disk environment (where an entire disk is cleared of any existing partitions and dedicated entirely to Ubuntu) or in a dual boot environment where Ubuntu co-exists with another operating system on the disk (typically a member of the Microsoft Windows family of operating systems).
In this chapter, we will cover the clean disk approach to installation from local or remote installation media. Dual boot installation with a Windows 10 system will be covered in ”Dual Booting Ubuntu with Windows”.
3.1 Ubuntu Installation Options
Ubuntu can be downloaded free of charge from the following web page:
https://ubuntu.com/download
This page provides a number of download options depending on how the operating system is to be installed and used:
•Ubuntu Desktop - Downloads the installation media for the desktop edition of the operating system. This edition is intended for use on desktop and laptop systems where a graphical desktop environment is needed and is only available for 64-bit x86 systems. The desktop edition can be downloaded in the form of an ISO image which you can then write to a USB drive using the steps outlined later in this chapter. When booted, the desktop media will allow you to test out Ubuntu by running a Live Ubuntu session prior to performing the installation.
•Ubuntu Server - Downloads the Live Server ISO installation media for the server edition of the operating system. This image is intended for performing an installation on servers on which the graphical desktop environment is not required and is available for x86, ARM, IBM POWER (PowerPC), and s390x (IBM System z mainframe) systems. The installation media does not include the option to try Ubuntu before installing and uses the text-based installer instead of the graphical installer used for Ubuntu Desktop. This allows Ubuntu to be installed on systems without a graphical console.
The Ubuntu Server image may also be used to perform Preboot Execution Environment (PXE) network installations. When using PXE to install Ubuntu, the Ubuntu image is installed on a specially configured server (referred to as a PXE boot server). The client system on which Ubuntu is to be installed is then configured to boot over the network from the image on the PXE boot server (assuming the client hardware supports PXE) to initiate the installation.
3.2 Server vs. Desktop Editions
Clearly, a decision between the Desktop and the Server Edition images needs to be made before installation can begin. If you would like to try Ubuntu before installing it, then the Desktop option is the best solution since it allows you to boot Ubuntu from the installation media without first installing it on a disk drive. This option also allows the installation to be initiated from within the live session.
If the graphical desktop environment is not required, and the destination system does not have internet access or a graphical console, then the Live Server ISO image is recommended since this allows a fully functional server to be built without the need to download any additional packages.
Regardless of the chosen installation method, packages can be added to and removed from the system after installation to configure the system to specific needs.
3.3 Obtaining the Ubuntu Installation Media
For the purposes of this chapter, the Ubuntu Desktop environment will be installed using the graphical installer. Begin, therefore, by downloading the Ubuntu Desktop 22.04 ISO image from the following URL:
https://ubuntu.com/download/desktop
The DVD ISO image is self-contained, including all of the packages necessary to install an Ubuntu system, and is named using the following convention:
ubuntu-<version>-<edition>-<architecture>.iso
For example, the Ubuntu 22.04 Desktop ISO image for 64-bit Intel/AMD systems is named as follows:
ubuntu-22.04-desktop-amd64.iso
Having downloaded the image, either burn it to disk or use the steps in the next section to write the media to a USB drive and configure your virtualization environment to treat it as a DVD drive.
3.4 Writing the ISO Installation Image to a USB Drive
These days it is more likely that an operating system installation will be performed from a USB drive than from a DVD. Having downloaded the ISO installation image for Ubuntu, the steps to write that image to a USB drive will differ depending on whether the drive is attached to a Linux, macOS, or Windows system. The steps outlined in the remainder of this section assume that the USB drive is new or has been reformatted to remove any existing data or partitions:
3.4.1 Linux
The first step in writing an ISO image to a USB drive on Linux is identifying the device name. Before inserting the USB drive, identify the storage devices already detected on the system by listing the devices in /dev as follows:
# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2
Attach the USB drive to the Linux system and run the dmesg command to get a list of recent system messages, one of which will be a report that the USB drive was detected and will be similar to the following:
[445597.988045] sd 6:0:0:0: [sdb] Attached SCSI removable disk
This output tells us that we should expect the device name to include “sdb” which we can confirm by listing device names in /dev again:
# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb
From this output, we can tell that the USB drive has been assigned to /dev/sdb. The next step before writing the ISO image to the device is to run the findmnt command to make sure it has not been auto-mounted:
# findmnt /dev/sdb?
TARGET SOURCE FSTYPE OPTIONS
/media/demo/C24E-6727 /dev/sdb1 vfat rw,nosuid,nodev, ...
If the findmnt command indicates that the USB drive has been mounted, unmount it before continuing:
# umount /media/demo/C24E-6727
Once the filesystem has been unmounted, use the dd command as follows to write the ISO image to the drive:
# dd if=/path/to/iso/<image name>.iso of=/dev/sdb bs=512k
The writing process can take some time (as long as 10 - 15 minutes) to complete depending on the image size and speed of the system on which it is running. Once the image has been written, output similar to the following will appear and the USB drive is ready to be used to install Ubuntu:
4056+1 records in
4056+1 records out
2126544896 bytes (2.1 GB, 2.0 GiB) copied, 625.911 s, 3.4 MB/s
3.4.2 macOS
The first step in writing an ISO image to a USB drive attached to a macOS system is to identify the device using the diskutil tool. Before attaching the USB device, open a Terminal window and run the following command:
$ diskutil list
/dev/disk0 (internal, physical):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_APFS Container disk2 1000.0 GB disk0s2
/dev/disk1 (internal):
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme 28.0 GB disk1
1: EFI EFI 314.6 MB disk1s1
2: Apple_APFS Container disk2 27.7 GB disk1s2
/dev/disk2 (synthesized):
#: TYPE NAME SIZE IDENTIFIER
0: APFS Container Scheme - +1.0 TB disk2
Physical Stores disk1s2, disk0s2
1: APFS Volume Macintosh HD 473.6 GB disk2s1
2: APFS Volume Preboot 42.1 MB disk2s2
3: APFS Volume Recovery 517.0 MB disk2s3
4: APFS Volume VM 1.1 GB disk2s4
Having established a baseline of detected devices, insert the USB drive into a port on the macOS system and run the command again. The same results should appear with one additional entry for the USB drive resembling the following:
/dev/disk3 (external, physical):
#: TYPE NAME SIZE IDENTIFIER
0: *16.0 GB disk3
In the above example, the USB drive has been assigned to /dev/disk3. Before proceeding, unmount the disk as follows:
$ diskutil unmountDisk /dev/disk3
Unmount of all volumes on disk3 was successful
Finally, use the dd command to write the ISO image to the device, taking care to reference the raw disk device (/dev/rdisk3) and entering your user password when prompted:
$ sudo dd if=/path/to/iso/image.iso of=/dev/rdisk3 bs=1m
Once the image has been written, the USB drive is ready.
3.4.3 Windows/macOS
Several free tools are available for Windows and macOS that will write an ISO image to a USB drive, but one written specifically for writing Linux ISO images is the Fedora Media Writer tool which can be downloaded from the following URL:
https://getfedora.org/en/workstation/download/
Once installed, insert the destination USB drive, launch the writer tool, and choose the Select .iso file option as highlighted in Figure 3-1:
Figure 3-1
Click Next to proceed to the Write Options screen and select the USB Drive before clicking on the Select... button:
Figure 3-2
In the resulting file selection dialog, navigate to and select the Ubuntu installation ISO image and click the Open button. Finally, click the Write button to start writing the image to the USB drive:
Figure 3-3
Once the image has been written, the device is ready to perform the installation.
3.5 Booting from the Ubuntu USB Image
Insert the Ubuntu installation media into the appropriate drive and power on the system. If the system tries to boot from the hard disk drive, you will need to enter the BIOS set up for your computer and change the boot order so that it boots from the installation media drive first. After the initial boot sequence completes, the GRUB menu shown in Figure 3-4 will appear:
Figure 3-4
Use the arrow keys to select the Try or Install Ubuntu menu option, then press Enter to boot into an Ubuntu Live session. After Ubuntu has booted completely, the screen shown in Figure 3-5 below will appear:
Figure 3-5
Options are provided to either try the Ubuntu Live session or to begin the installation process. If you experience a black screen when attempting to start or install Ubuntu, reboot the system and try again using the safe graphics options. If you are not ready to install Ubuntu, click on the Try Ubuntu button to safely explore the operating system without making changes to any installed hard drives.
3.6 Installing Ubuntu
From within Install dialog, select the option to begin the Ubuntu installation and wait for the initial screen of the installer to appear. Select your preferred language before clicking on the Continue button to proceed to the next screen:
Figure 3-6
Either select your keyboard layout or, if you are unsure, click on the Detect Keyboard Layout button to work through some steps to identify your keyboard before clicking on Continue. On the next screen, choose whether to perform the Normal or Minimal installation:
Figure 3-7
Select the Normal option if you have plenty of disk space and want to explore the main applications and utilities included with Ubuntu without having to manually install them later. Alternatively, to avoid cluttering the system with software you may never need, select the Minimal option. Regardless of the choice made here, all of the software provided with Ubuntu can be easily installed or removed at any point in the future if needed.
The option is also available to update the software packages that comprise the Ubuntu distribution during the installation. Ubuntu, as with most actively supported operating systems, continues to be updated with bug fixes and security patches long after it has been released to the public. If this option is selected and the system is connected to the internet, the installer will download any updates issued since the Ubuntu installation image was released and applies them to the system during installation. If you choose not to perform this update during the installation process, these updates may still be applied at any time after the installation completes.
A second option provides the choice of whether to install 3rd party non-open source software to support specific hardware devices and the playback of proprietary media files on the system. Some users object fervently to using any software which is not published under a public license. If you are one of those people, then do not select this option. If, on the other hand, you just want the best experience from your Ubuntu installation, then this option is recommended.
Having made appropriate selections, click the Continue button to proceed to the disk allocation screen:
Figure 3-8
Assuming that this is a new disk on which an existing operating system is not present, the installer will provide the option to erase the entire disk and use it for Ubuntu (in which case the installer will calculate and implement a typical and recommended partition layout). Alternatively, to define your own custom disk layout, select the Something else option to manually create and size the disk partitions that will contain the operating system and your data.
Clicking on the Advanced Features button will provide the option to use Logical Volume Management (LVM). LVM is strongly recommended to make the management of the disks and partitions on the system easier, a topic covered in detail in the chapter entitled “Adding a New Disk to an Ubuntu 22.04 Volume Group and Logical Volume”:
Figure 3-9
If the security of the data stored on the disk is of paramount concern, select the option to encrypt the Ubuntu installation. If this option is selected, the next screen will prompt you to choose a security key which will then need to be entered each time the system starts.
The option is also provided to use the ZFS filesystem. ZFS is an advanced filesystem with many of the features of Logical Volume Management built-in together with a range of other features, such as the ability to take disk snapshots and shadowing (copy-on-write). The option is also available to encrypt the data stored by Ubuntu. For this example, select the option to use LVM and click on OK.
Once the selections have been made, click on the Install Now button to begin the installation process, at which point the system will seek confirmation that the changes are to be made to the disk drive:
Figure 3-10
Click the Continue button to start the installation. While the installation is in progress, the installer will ask for information about your geographical location in order to configure time zone settings:
Figure 3-11
Next, the installer will ask you to provide a username and password for the first account on the system:
Figure 3-12
The option is also provided to dictate whether the password must be specified each time the user wishes to log into the system. By default, each time Ubuntu starts, a login screen will be presented seeking username and password credentials. If you are the sole user of the system and would like to bypass this screen and be logged in automatically each time the system boots, be sure to set the Log in automatically checkbox before proceeding.
Once all the questions have been answered, the installer will simply proceed with the installation. Depending on the speed of your system, and whether or not you opted to download updates during the installation, this process can take some time. For a more detailed view of the steps being performed by the installer, click on the status title located above the progress bar:
Figure 3-13
When the installation is complete, a dialog will appear to inform you the system is ready to be restarted:
Figure 3-14
When you are ready to reboot, press the Restart Now button. The installer may prompt you to remove the installation media, and the system will take a few moments to shut down. At this point, remove the USB flash drive and press the Enter key to proceed.
3.7 Accessing the Ubuntu Desktop
Once the system has started, if the password requirement option was enabled the GNOME Display Manager (GDM) login screen (Figure 3-15) will appear. To access the system, select the user name and enter the password specified during installation:
Figure 3-15
Alternatively, if the installation was configured to log directly into the desktop, the GNOME desktop (Figure 3-16) will appear after the system has restarted:
Figure 3-16
3.8 Installing Updates
As with most operating systems today, each particular release of the Ubuntu distribution continues to evolve after it has been released. This generally takes the form of bug fixes and security updates and, occasionally, new features that may be downloaded over the internet and installed on your system.
Best practices dictate that the first step after installing Ubuntu is to ensure any available updates are applied to the system. When updates are available, the Software Updater will display the following dialog from which updates may be installed:
Figure 3-17
Updates can also be installed via the command-line prompt in a Terminal window using the apt package manager tool. To check for the availability of updates, right-click on the desktop background and, from the resulting menu, select the Open in Terminal option:
Figure 3-18
Within the Terminal window, run the following commands to gain root privileges and update the package list:
$ sudo su -
# apt update
If updated packages are available, the command will display output similar to the following:
.
.
.
Reading package lists... Done
Building dependency tree
Reading state information... Done
220 packages can be upgraded. Run 'apt list --upgradable' to see them.
Any pending updates may be applied using the apt tool:
# apt upgrade
Upon execution, the apt tool will provide a list of packages that are available for update and prompt for permission to perform the update:
220 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 75.2 MB/286 MB of archives.
After this operation, 34.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Once the upgrade is complete, the installation is essentially finished.
3.9 Displaying Boot Messages
During the boot process, the system will display the Ubuntu splash screen, which hides from view all of the boot messages generated by the system as it loads. To make these messages visible during the boot process (as shown in Figure 3-19), simply press the keyboard Esc key while the system is starting:
Figure 3-19
The default behavior can be changed so that messages are always displayed by default by editing the /etc/default/grub file and changing the GRUB_CMDLINE_LINUX setting which, by default, will resemble the following:
GRUB_CMDLINE_LINUX="... rhgb quiet"
If you are new to Linux and are not familiar with the editors available, refer to the editor recommendations outlined in the “Introduction” chapter. For example, to use the nano editor, enter the following command to start the editor and load the grub file:
# nano /etc/default/grub
To remove the graphical boot screen so that messages are visible without pressing the Esc key, remove the “splash” and “quiet” options from the setting:
GRUB_CMDLINE_LINUX=""
This change will cause the system to display all of the boot messages generated by the system.
Once the changes have been made, run the following command to generate a new boot configuration to take effect the next time the system starts:
# grub-mkconfig --output=/boot/grub/grub.cfg
3.10 Summary
The first step in working with Ubuntu is to install the operating system. In the case of a cloud-based server, this task is typically performed automatically when an operating system image is selected for the system based on a range of options offered by the cloud service provider. Installation on your own hardware or in a virtual machine, however, involves downloading the installation media in the form of an ISO image, writing that image to suitable storage such as a DVD or USB drive and booting from it. Once installation is complete, it is important to install any operating system updates that may have been released since the original installation image was created.