Installing Ubuntu and Post-Installation Configuration - Getting Started - Ubuntu Unleashed 2017 Edition (2017)

Ubuntu Unleashed 2017 Edition (2017)

Part I: Getting Started

Chapter 1. Installing Ubuntu and Post-Installation Configuration


In This Chapter

Image Before You Begin the Installation

Image Step-by-Step Installation

Image Shutting Down

Image Finding Programs and Files

Image Software Updater

Image The sudo Command

Image Configuring Software Repositories

Image System Settings

Image Configuring Wireless Networks

Image Troubleshooting Post-Installation Configuration Problems

Image References


Not that long ago, the mere mention of installing Linux struck fear into the hearts of mortal men. Thanks to a campaign of fear, uncertainty, and doubt (commonly referred to as FUD), Linux garnered a reputation as something of an elitist operating system that could be installed, configured, and used only by extreme computer geeks and professionals. Nowadays, it is a different story entirely, and Ubuntu is one of the easiest Linux distributions (distros) to install. This chapter covers how to get started with the install disc, including booting from an Ubuntu Live DVD or USB drive to test your system. The chapter then covers the actual installation of Ubuntu, looking at the various options available. The whole process is pain free with Ubuntu, as you are about to learn.

This chapter covers installation on a typical desktop or laptop computer system. It is not intended to provide information about installing Ubuntu on a tablet device or smart phone or anything else ... yet.

Before You Begin the Installation

Installing a new operating system is a major event, and you should make sure that you have properly thought through what is going to take place. The first thing to consider is how the hardware will be affected by the software that you propose to install. Although Ubuntu runs well on a variety of hardware, it is worthwhile to check your hardware components because some bits of hardware do not work well with Ubuntu. This section provides some areas for you to investigate and think about; it might even save you hours of frustration when something goes wrong. Problems are becoming much less frequent, but they still crop up occasionally.

You start by researching and documenting your hardware. This information will prove helpful later on during the installation.

Researching Your Hardware Specifications

At the absolute minimum, you should know the basics of your system, such as how much RAM you have installed and what type of mouse, keyboard, and monitor you have. Knowing the storage capacity and type of hard drive you have is important because it helps you plan how you will divide it for Ubuntu and troubleshoot if problems occur. A small detail, such as whether your mouse uses the USB or PS/2 interface, ensures proper pointer configuration—something that should happen without any problem, but you will be glad you know it in case something does go wrong. The more information you have, the better prepared you are for any problems.

You can make an inventory or at least a quick list of some basic features of your system. Again, the items you most want to know include the amount of installed memory, the size of your hard drive, the type of mouse, the capabilities of the display monitor (such as maximum resolution), and the number of installed network interfaces (if any).


DVD Installation Jump Start

To install Ubuntu Desktop from the disc included with this book, you should first test whether your system is compatible by running Ubuntu from the DVD live. In general, a system must have at least a 1GHz processor, 5GB of hard drive space, and 512MB RAM. A monitor with a display resolution of at least 1024 × 768 is strongly recommended. Internet access is not required but is very helpful and also recommended. See https://help.ubuntu.com/community/Installation/SystemRequirements for a more detailed list of requirements.


Installation Options

Ubuntu is made available in two main forms: the Desktop DVD and the Server install DVD. (This list does not include derivative distributions like Kubuntu or Lubuntu or less commonly used methods such as the network install disk.) For most people, the Desktop DVD is what you want. The Server install DVD can get a LAMP (Linux, Apache, MySQL, and PHP) server up and running in about 20 minutes, but, as you learn in this book, all these components are available to the Ubuntu default distribution. An ISO image contains the entire contents of a CD or DVD in a single file that can be used as if it were a CD or DVD and that can be burned to a physical CD or DVD if desired. You can find a list of the currently available ISO images in a couple of places. The place that is best for most people to download from is www.ubuntu.com/download, which includes a nice graphical menu system and links to easy-to-read information and detailed instructions. Those with more specific requirements, such as a desire to use one of the official alternative Ubuntu versions like Kubuntu or Lubuntu, can find what they need by navigating the menus at cdimage.ubuntu.com.


Official Ubuntu Flavors

Ubuntu has several official variants, called flavors, as follows:

Image Ubuntu

Image Ubuntu Server

Image Ubuntu GNOME

Image Kubuntu

Image Xubuntu

Image Edubuntu

Image Mythbuntu

Image Ubuntu Studio

Image Lubuntu

Image Ubuntu Kylin

Almost everything in this book applies to any of these flavors. The exceptions include GUI-specific content, such as Unity-specific descriptions, and content that refers to programs not installed by default, such as many of the server and programming options.


To install using the DVD included with in this book, ignore the next couple of paragraphs and then keep reading this chapter.

To install using a DVD that you create, download the ISO image you need from www.ubuntu.com/download or cdimage.ubuntu.com. You need to download a program to enable you to burn this image to physical media. For Windows, try either InfraRecorder (http://infrarecorder.org) or ISO Recorder (http://isorecorder.alexfeinman.com/isorecorder.htm) and follow the instructions given by the authors. For Mac OS X, you can use Apple’s Disk Utility, which is installed by default. For Ubuntu, right-click the icon for an ISO image and select Write to Disc. After the DVD is created, use it as you follow the installation instructions in this section.


Ubuntu on Mac Hardware

There are often problems installing Ubuntu on Mac hardware. Apple designs and configures their devices with the intent that only their software should be run on their hardware. Be warned if you want to try to install Ubuntu or anything else on Mac hardware: Here be dragons. It can work, but be prepared to search the web and maybe ask questions in some of the places listed in Chapter 2, “Background Information and Resources.” The disc attached to this book will only boot on 64-bit Intel-processor machines. Macs require use of the 32-bit install disc, available from the download location above.


You can also install using a USB thumb drive (use one that holds at least 2GB). Download the ISO image you need. You need to download a program that enables you to use this image to create a bootable USB drive. For Windows, try Universal USB Installer (www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/) or ISO Recorder (http://isorecorder.alexfeinman.com/isorecorder.htm) and follow the instructions given by the authors. For Ubuntu, use the installed Startup Disk Creator program available by searching in the Dash. After the ISO is written to the USB drive, use it as you follow the installation instructions in this section.

32-Bit vs 64-Bit Ubuntu

All users who can use it are better off using the 64-bit version of Ubuntu. The main difference has to do with how a computer processor is able to register and use memory, but speed is also a factor. Here is why.

A computer with a 32-bit processor will be able to use a maximum of 4GB of memory (actually a bit less, but this is a more practical-focused book and not a computer science text, so the approximation is close enough for our uses; and yes, there are exceptions, but this is a reasonable rule of thumb for those just getting started). A computer with a 64-bit processor will be able to use up to a theoretical limit of 17 billion GB. More memory addresses means that you can store more data in RAM, which is much faster than processing it while reading from and writing to disks or other storage media.

If you are dealing with large amounts of data, this is a huge benefit. Processing audio or video, manipulating large databases of weather data, or playing 3D video games will be much smoother. It will also happen faster.

Speed is increased for another reason. When you have more memory addresses, it is kind of like when the supermarket has more checkout lines open. You can process more operations simultaneously. As a result of the extra capacity, variables and arrays in programs are processed more efficiently, function arguments are passed more easily, and even new data models are available for programmers and languages to use.

This requires some adaptation. Programs written for 32-bit operating systems must generally be adapted to take advantage of the capabilities of 64-bit processors. Although it is (usually, or at least often) possible to run 32-bit programs on a 64-bit processor, it is not always advantageous to do so. However, in the Linux world, including Ubuntu, most software has been refactored and recompiled to take advantage of 64-bit processors and their capabilities. Software written for 64-bit processors is not backward compatible with 32-bit processors.

Early on, driver support and adaptation of software took time and was not complete enough to recommend using 64-bit Ubuntu by default. For about a decade, nearly all Intel- and AMD-based computer systems sold have been 64-bit, and the software has caught up. There is no reason to use anything else on this equipment. The disc attached to this book only boots on 64-bit machines

If you browse to ubuntu.com/releases, you will find downloadable .iso files that will allow you to create a DVD from which you can boot/install Ubuntu. Each is intended for a different sort of processor and setting, such as server and desktop:

Image i386: This supports all Intel or compatible processors except those that require AMD64. This includes current Apple hardware. If you are not certain which you need, use this one. It works on either 32-bit or 64-bit systems, so it is the default choice.

Image AMD64: If you know you are using a processor based on the AMD64 or EM64T architecture (for example, Athlon64, Opteron, EM64T Xeon, Core2), you should choose this version because it will be a bit more efficient on your hardware. This is the one on the attached DVD.

Planning Partition Strategies

Partitioning is a topic that can make novice Linux users nervous. Coming from a Microsoft world, where you might be used to having just one hard drive, it can seem a bit strange to use an operating system that makes partitioning a hard drive possible or even preferable and common.

Depending on your needs, you can opt to have a single large partition to contain everything, which is the official recommendation of the Ubuntu community and developers. You might prefer to segment your installation across several partitions if you have advanced knowledge and specific needs.

If you are installing Ubuntu in a corporate or business environment, the needs of the business should be a primary concern. Be careful to ensure that you build in an adequate upgrade path that allows you to extend the life of the system and add any additional storage or memory.

Knowing how software is placed on your hard drive for Linux involves knowing how Ubuntu organizes its file system. This knowledge helps you make the most out of hard drive space. In some instances, such as when you’re planning to have user directories mounted via NFS or other means, this information can help head off data loss, increase security, and accommodate future needs. Create a great system, and you’ll be the hero of information services. The Linux file system is covered along with commands to manipulate files and directories in Chapter 10, “Command-Line Beginner’s Class.”

To plan the best partitioning scheme, research and know the answers to these questions:

Image How much disk space does your system require?

Image Do you expect your disk space needs to grow significantly in the future?

Image Will the system boot only Ubuntu, or do you need a dual-boot system?

Image How much data requires backup, and what backup system will work best? (See Chapter 17, “Backing Up,” for more information about backing up your system.)

The Boot Loader

During installation, Ubuntu automatically installs GRUB2 (Grand Unified Boot Loader) to the Master Boot Record (MBR) of your hard drive. Handily enough, it also detects any other operating systems, such as Windows, and adds entries in GRUB2 as appropriate. If you have a specific requirement not to install GRUB2 to the MBR, you need to install using the Alternate disc, which enables you to specify the install location for GRUB2.


Dual Boot Not Recommended, but You Can Try It If You Want

If you are attempting to create a dual-boot system using both Windows and Ubuntu, a system in which multiple operating systems exist on the hard drive and the user selects which one to use at boot time, you should install Windows first because it will overwrite the MBR and ignore any other operating systems on the disk. Ubuntu also overwrites the MBR, but does so in a way that creates a boot menu that includes all operating systems it detects on the disk. Dual-booting works, but in the past few years options have arisen that are better for most people.

If you decide you must dual boot, make sure you have your Windows recovery media available and that you either already have enough free space on your hard drive or know how to shrink the existing Windows partition and create a new partition on the hard drive for Ubuntu. No support or instructions for doing this are given in this book. If you need to use more than one operating system on the same hardware, this book recommends virtualization.

See Chapter 34, “Virtualization on Ubuntu,” for more information.


Installing from DVD or USB Drive

The BIOS of most PCs support booting directly from a CD, DVD, or USB drive and enable you to set a specific order of devices (such as floppy, hard drive, CD-ROM, or USB) to search for bootable software. Turn on your PC and set its BIOS if required (usually accessed by pressing a function key or the Del key after powering on) and then insert your Ubuntu install media and boot to install Ubuntu.


UEFI

If you have hardware that is from 2010 or newer, it probably includes a firmware interface called UEFI. The Unified Extensible Firmware Interface is a specification that defines how an operating system and the hardware interact. It replaces the BIOS mentioned above. It has also been known to cause problems when you try to install a different operating system than the default one it came with on one of these machines. The 64-bit version of Ubuntu has become more reliable in supporting installation on these machines with each Ubuntu release. However, if you encounter difficulties, see https://help.ubuntu.com/community/UEFI for assistance.


Step-by-Step Installation

This section provides a basic step-by-step installation of Ubuntu from the install DVD included with this book, but these instructions also work with media you create yourself using an ISO image you downloaded and wrote to a disk or USB drive using the instructions provided earlier; just replace mentions of DVD with your install medium. The install process itself is fairly straightforward, and you should not encounter any real problems.


Caution

If you have anything at all on your computer that you want to save, back it up first. Installing an operating system has become easier to do, but it is still a major change. Your entire hard drive will be erased and new information written to it. This is expected when installing Ubuntu to the entire hard drive, but it can even happen due to user error or gremlins (unexplained problems) when attempting a dual-boot installation. Back up anything you want to preserve. Save data and files to an external hard drive or other medium. You may even want to back up your entire operating system and current installation using something like Clonezilla (http://clonezilla.org). Whatever you do, go in with the perspective that everything currently on the computer will disappear. If this is okay, continue.


It is useful and recommended to have your computer connected to the Internet as you proceed so that you can download updates while installing.

Installing

To get started, insert the DVD into your drive and reboot your computer.


Notice

The installation process occasionally changes when new releases occur, but the overall idea is consistent. The screenshots you see here are probably accurate, but it is possible you may see a change or two. If you understand what you need to do, any changes should be trivial to you.


The initial screen offers a variety of languages for you to use during installation (see Figure 1.1) and two options. The Try Ubuntu option boots and runs Ubuntu from the DVD without making any changes to your system so that when you remove the DVD and reboot, everything will be as it was before. Install Ubuntu installs Ubuntu instead of your current operating system or alongside it (for dual booting). Select Install Ubuntu to begin.

Image

FIGURE 1.1 Choose a language for the installation in this opening screen.

Figure 1.2 shows the Preparing to Install Ubuntu screen. If you select the two check boxes at the bottom, Ubuntu downloads extra software, such as multimedia codecs and any software updates that have been released since the disk was created, and includes them in the installation. Doing so is recommended.

Image

FIGURE 1.2 Before proceeding, double-check that your system meets the requirements shown.

If other operating systems are found on your system, you are given the option to install Ubuntu alongside them or to erase them and use the whole disk for Ubuntu. See the dual-boot note and backup warning earlier in this chapter before continuing.

Next, you have the option either to erase and use the entire hard disk for your installation (recommended for people who are new to Linux and are nervous about partitioning a hard drive) or to specify partitions manually, which is not as difficult as it sounds, as shown in Figure 1.3.

Image

FIGURE 1.3 What do you want to do with your hard drive?

Because this is a book for people who want a deeper understanding of their systems, we show a simple partitioning scheme here and give some reasons for our choices.

Your needs may vary, so we give some principles to consider so that you may adjust our recommendations to your situation.


Encrypted /home?

You are given the opportunity during installation to encrypt your /home partition, which is where your personal files will be stored. Doing so ensures that a password or passphrase must be entered for anyone to access the contents. The downside is that the contents won’t be accessible even to you if you forget your password. Consider your needs and choose accordingly.


Many users benefit from three simple partitions, shown in Figure 1.4. Here we have a swap partition, a root partition (denoted by /), and a home partition in which data for each user on the system is stored. The swap partition was previously used for those times when there was not enough memory for running processes, so the Linux kernel, when moving stored information from RAM to the hard drive, could use that swap space as extra RAM. This is slow, but sometimes it is quite useful. These days, desktop systems come with more memory, and the swap space is used mainly for storing information during suspend and hibernate, which is an alternative you can use instead of turning your computer off. Having /home on a separate partition can be a good idea because it enables you to install a different Linux distribution or a different release of Ubuntu on your / partition while retaining your user data (neither of which are covered in this book).

Image

FIGURE 1.4 A simple but useful partitioning scheme.


Note

Suspend saves your current system state to RAM and then turns off power to most of the system, but it maintains just enough power use to keep that state saved in RAM. When you restart your system, it comes back quickly to the same state it was in. Hibernate saves your current system state to the hard disk. These days, it is just as fast to boot from scratch as it is to hibernate and restore, so there isn’t much point in using it.


If you choose to manually partition instead of using the entire disk, we recommend you have a / partition of at least 3GB and a swap partition that is about 1.5 to 2 times the size of your installed RAM; you can use the rest of the disk for /home. More complex partitioning schemes might be useful for more complex systems, such as servers, especially when multiple hard drives are available. Read Chapter 10, “Command-Line Beginner’s Class,” for a quick discussion of the parts of the Linux file system to get an idea of parts of the file system that could benefit from residing on their own (or even multiple!) partitions or disks.


Note

Adding, formatting, and partitioning a hard drive can be done at any time, not only during installation. You should not try to modify a drive you are currently using, such as the one on which you have installed Ubuntu, because doing so could make the computer unusable, and you would have to start over. However, if you are adding a second drive or if you want to reformat a flash drive, partitioning the drive you’re using is a useful skill to know. In any case, this is an instance where the standard warning applies: Pay attention to what you are doing and know why you are doing it, because this powerful tool both is useful and has the potential to cause you serious problems and data loss if used incorrectly.

The easiest and simplest method is to use GParted, which is a graphical partition manager. GParted is not installed by default, but it is available in the Ubuntu software repositories; see Chapter 9, “Managing Software” if you need help installing it.

In addition to being useful for adding drives, GParted can also assist you in recovering from problems. You can run it after booting Ubuntu in a live session, running from a live cd or a USB drive. In this case, the system’s hard drives are not mounted and you can manage them from the live session.


After you have made your partitioning selections, installation continues by asking about your current location; it helps you select the most appropriate keyboard layout for your system based on that location and the most common language used there, and it asks you to enter your name, a username that you will use to login to the system, and a password. You can even choose to encrypt your /home folder during the process.


A Quick Aside on Passwords

When you create your password, be sure to remember what you entered. If you forget it, you cannot use your new system because you will not be able to log on to it.

When setting a password, the common advice is to make sure that it has a mixture of letters and numbers to make it more secure. For instance, a good example of a historically recommended style of password is T1a5c0p. Although this might seem like garbage at first glance, the easy way to remember it is by remembering the phrase This Is A Good Choice Of Password, shortened to Tiagcop, and finally substituting some of the letters with similar-looking numbers.

There are some reasons why this might not be the best recommendation anymore because computer systems are much faster than they used to be. It is a true statement that the longer a password is, the harder it is to break. For this reason, the newest recommendation is to use a passphrase consisting of at least four words, perhaps something like green monkeys chortle often. There is no doubt that a password the length of four common words combined together would be harder to break than the T1a5c0p example. From that perspective, it seems like a no-brainer. On the other hand, a longer password that does not use any words found in a dictionary would be even better, but the problem here is that these passwords, and even the T1a5c0p example, can be hard to remember and may end up being written down on a sticky note next to the computer, perhaps even stuck to the monitor. That is worse, especially if you use good security and create a different password for every website and computer system that requires one.

One solution is to choose a really good password for your system, one that you will remember, like the four words example or a long passphrase like PeanutButterandJelly $andwiches, and then create one more good password to use with a password manager program like KeyPassX (available in the Ubuntu software repositories; see Chapter 9, “Managing Software,” for details on how to find and install it), which can generate long, completely random passwords for you and keep them in a list that can only be viewed by accessing your system and then accessing the program, both of which will use good passwords. Let’s get back to the installation.


While you are answering the questions asked by the installer, the Ubuntu install has already begun to copy files to your hard drive. Performing these tasks in parallel makes the process even faster than it used to be. Now that you have input all necessary information, you see a series of information screens while the installation is completed. These are filled with interesting content about Ubuntu and are worth reading while you wait.

When the process is complete, you are prompted to restart the computer. Do so and remove the install media when it is ejected. Then log in when the reboot is complete. That’s it.

In previous editions of this book, this chapter was longer and described a process that was sometimes confusing and fraught with peril. The Ubuntu developers deserve high praise for making this so incredibly easy and fast. The Linux kernel supports more hardware than ever, and the Ubuntu kernel gurus (who make the decisions about what hardware modules to enable, among other things) do a great job so that most hardware works out of the box.

First Update

It used to be that the first thing that you needed to do with your new system was update it to the latest package versions. You do this mainly to ensure that you have the latest security updates available. Remember that first installation step where we recommended checking the box to have software updates downloaded during the installation process? That means these updates were acquired during the installation and that your system should be up-to-the-minute current.

If you want to double-check that you have all the current versions of software and security updates installed, read Chapter 9, “Managing Software,” and Chapter 10, “Command-Line Beginner’s Class,” for more information.

Shutting Down

At some point, you are going to want to shut down your computer. As with most things in Linux, there are different ways to do it. You can use the power icon located in the upper-right corner of your screen and its drop-down menu, as in Figure 1.5. From there, select Switch Off.

Image

FIGURE 1.5 You have several options in the power icon menu.

If you are working at the command line, you can immediately shut down your system by using the shutdown command like this:

Click here to view code image

matthew@seymour:~$ sudo shutdown -h now

You can also use the shutdown command to restart your computer, as follows:

Click here to view code image

matthew@seymour:~$ sudo shutdown -r now

For new users, installing Ubuntu is the beginning of a new and highly rewarding journey on the path to learning Linux. For Ubuntu system administrators, the task ahead is to fine-tune the installation and to customize the server or user environment.


Note

Now that you have completed the primary task of installing Ubuntu, you can begin to customize your new operating system. This chapter looks at getting up and running with Ubuntu. Chapter 3, “Working with Unity,” gives you a tour around the desktop. You should read these two chapters. Right now, you find out how to do some basic administration tasks. By the end of this chapter, you should feel comfortable enough to move on through the rest of the book.


Finding Programs and Files

In the past, Ubuntu used a system of menus to guide users in searching for programs, but now there is an easier, faster way. Use the Dash to find programs. You access the Dash by clicking the Ubuntu logo at the upper left of the screen. This brings up the menu shown in Figure 1.6. Start typing in the Search box to find specific programs or documents on your system. The icons in the row along the bottom of the Dash provide categories you can use to narrow searches. When you click the house icon, you go to the main Dash screen as shown in the figure. Click the second icon to see installed applications and a list of other applications that are available for installation. Click the arrow next to See More Results to view all installed software. Click the third icon to see documents or the fourth icon to see media. The Dash is covered in more detail in Chapter 3, “Working with Unity.”

Image

FIGURE 1.6 The Dash is the place to find programs and files.

Software Updater

This topic is covered in greater detail in Chapter 9, “Managing Software,” but it is worthy of a quick mention now so that from the start you can benefit from any available security and bug fixes. The easiest way to check for updates is Software Updater. Open Software Updater from the Dash by typing software updater to search for it. When the window opens, Update Manager checks the Ubuntu software repositories to determine whether any updates are available. When it detects that new versions of installed software are available, they display in the window. Uncheck the check box next to any item if you don’t want to install that particular software update. Click Install Updates to complete the process (see Figure 1.7). Software repositories are discussed later in this chapter.

Image

FIGURE 1.7 Software Updater showing available software updates.

Another way of updating your system is to use the command line. This is vital on servers that do not have a GUI installed, and it is sometimes quicker than using Software Updater on a desktop computer. I like to use the command line to manage all the computers on my home network because I can use Secure Shell (SSH) to connect to each from a terminal and perform updates from another room in the house; anyone using that computer is left undisturbed while I’m making updates. You find out how to connect using the command line in Chapter 19, “Remote Access with SSH, Telnet, and VNC.”


Note

In the second half of the “Software Updater” section and in “The sudo Command” section that follows, we introduce some commands that must be entered from the command line, also known as the terminal.

Rather than a graphics-based user interface, this is a more traditional text-based user interface. Chapter 10, “Command-Line Beginner’s Class,” Chapter 11, “Command-Line Master Class Part 1” and Chapter 12, “Command-Line Master Class Part 2” cover this topic in much greater detail.

For now, the goal is to introduce you to the idea and let you know what can be done. You are not yet expected to know what a lot of this means.

To use the command line, open the Dash and type terminal.


When you open the terminal, you are greeted with a prompt similar to the one here:

matthew@seymour:~$

A blinking cursor also displays. Ubuntu is awaiting your first command. Issue the following command:

Click here to view code image

matthew@seymour:~$ sudo apt-get update

This command tells the package management utility apt-get to check the Ubuntu repositories and look for any updates to your installed software. In a matter of seconds, Ubuntu completes all of this, and your screen should look something like this:

Click here to view code image

matthew@seymour:~$ sudo apt-get update
[sudo] password for matthew:
Hit http://security.ubuntu.com xenial-security Release.gpg
Ign http://security.ubuntu.com/ubuntu/ xenial-security/main Translation-en
Hit http://us.archive.ubuntu.com xenial Release.gpg
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/main Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/main Translation-en_US
Ign http://security.ubuntu.com/ubuntu/ xenial-security/main Translation-en_US
Ign http://security.ubuntu.com/ubuntu/ xenial-security/multiverse Translation-en
Ign http://security.ubuntu.com/ubuntu/ xenial-security/multiverse Translation-en_US
Ign http://security.ubuntu.com/ubuntu/ xenial-security/restricted Translation-en
Ign http://security.ubuntu.com/ubuntu/ xenial-security/restricted Translation-en_US
Ign http://security.ubuntu.com/ubuntu/ xenial-security/universe Translation-en
Ign http://security.ubuntu.com/ubuntu/ xenial-security/universe Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/multiverse Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/restricted Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/restricted Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/universe Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial/universe Translation-en_US
Hit http://us.archive.ubuntu.com xenial-updates Release.gpg
Hit http://security.ubuntu.com xenial-security Release
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/main Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/main Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/multiverse Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/multiverse Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/restricted Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/restricted Translation-en_US
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/universe Translation-en
Ign http://us.archive.ubuntu.com/ubuntu/ xenial-updates/universe Translation-en_US
Hit http://security.ubuntu.com xenial-security/main Sources
Hit http://us.archive.ubuntu.com xenial Release
Hit http://us.archive.ubuntu.com xenial-updates Release
Hit http://security.ubuntu.com xenial-security/restricted Sources
Hit http://security.ubuntu.com xenial-security/universe Sources
Hit http://security.ubuntu.com xenial-security/multiverse Sources
Hit http://security.ubuntu.com xenial-security/main i386 Packages
Hit http://security.ubuntu.com xenial-security/restricted i386 Packages
Hit http://us.archive.ubuntu.com xenial/main Sources
Hit http://security.ubuntu.com xenial-security/universe i386 Packages
Hit http://security.ubuntu.com xenial-security/multiverse i386 Packages
Hit http://us.archive.ubuntu.com xenial/restricted Sources
Hit http://us.archive.ubuntu.com xenial/universe Sources
Hit http://us.archive.ubuntu.com xenial/multiverse Sources
Hit http://us.archive.ubuntu.com xenial/main i386 Packages
Hit http://us.archive.ubuntu.com xenial/restricted i386 Packages
Hit http://us.archive.ubuntu.com xenial/universe i386 Packages
Hit http://us.archive.ubuntu.com xenial/multiverse i386 Packages
Hit http://us.archive.ubuntu.com xenial-updates/main Sources
Hit http://us.archive.ubuntu.com xenial-updates/restricted Sources
Hit http://us.archive.ubuntu.com xenial-updates/universe Sources
Hit http://us.archive.ubuntu.com xenial-updates/multiverse Sources
Hit http://us.archive.ubuntu.com xenial-updates/main i386 Packages
Hit http://us.archive.ubuntu.com xenial-updates/restricted i386 Packages
Hit http://us.archive.ubuntu.com xenial-updates/universe i386 Packages
Hit http://us.archive.ubuntu.com xenial-updates/multiverse i386 Packages
Reading package lists... Done
matthew@seymour:~$

Upgrade your software by entering the following:

Click here to view code image

matthew@seymour:~$ apt-get dist-upgrade

Because you have already checked for updates, Ubuntu automatically knows to download and install only the packages it needs. The dist-upgrade option works intelligently to ensure that any dependencies that are needed can be satisfied and will be installed, even if major changes are needed. You can also use the option upgrade, which isn’t as smart as dist-upgrade, but it might be a better choice on a production server because upgrade does not make major changes to software installations. It only makes those changes necessary for security and simple package updates. This allows the systems administrator more flexibility to keep up to date with security while keeping running setups otherwise unchanged.

The sudo Command

You will find as you work through this book that Ubuntu relies on the sudo command while you work at the command line. This command is used in front of other commands to tell Ubuntu that you want to run the specified command with super user powers. This sounds really special, and it actually is. When you work using the sudo command, you can make wide-ranging changes to your system that affect the way it runs. Be extra careful when running any command prefixed with sudo; however, a wrong option or incorrect command can have devastating consequences.

The use of sudo is straightforward. All you have to do is enter it like this:

Click here to view code image

matthew@seymour:~$ sudo command commandoptions

Just replace the word command with the command that you want to run, along with any options. For example, the following command opens your xorg.conf file in vi and enables you to make any changes as the super user before being able to save it:

Click here to view code image

matthew@seymour:~$ sudo vi /etc/X11/xorg.conf

Whenever you execute a command using sudo, you are prompted for your password. This is the same password that you use to log in to Ubuntu, so it is important that you remember it.

Sometimes, however, you might want to work with a classic root prompt instead of having to type sudo in front of every command (perhaps if you have to work with lots of commands at the command line that require super user access, for example). sudo enables you to do this by using the sudo -i command. Again, you are prompted for your password, which you should enter, after which Ubuntu gives you the standard root prompt, as follows:

matthew@seymour:~#

From here, you can execute any command without having to keep entering sudo.


Warning

Working from the root prompt can be really dangerous unless you know what you are doing. Until you are experienced, we recommend you stick to using sudo, which is covered in more detail in Chapter 10, “Command-Line Beginner’s Class.”


Configuring Software Repositories

Ubuntu uses software repositories to get information about available software that can be installed on your system. Ubuntu is based on a much older Linux distribution called Debian. Debian has access to tens of thousands of different packages, which means that Ubuntu has access to these packages, too. The Debian packages are made available in Ubuntu’s Universe repository. A set of volunteers called Masters of the Universe (MOTUs) are well trained and follow strict guidelines to package software and make even more packages available to Ubuntu users in the Universe repository. (See Chapter 40, “Helping with Ubuntu Development,” for more about the MOTUs and how you can become one of them.) The Universe repository is filled with optional and often useful or fun software; it is enabled by default, along with other official repositories containing software necessary for Ubuntu to be installed and run in all its various official forms, security updates, and software updates.

You can adjust which repositories are enabled using the Software Sources GUI tool, available in Software Updater by clicking Settings. On the first tab (Ubuntu Software), you have five options to choose from. The default settings are shown in Figure 1.8. It is entirely up to you which options you check, but make sure that at least the first check box is selected to allow you access to Canonical-supported open source software, which includes all the packages necessary for a basic Ubuntu installation and a few more that are commonly used. The more boxes you check, the wider your selection of software. It’s also a good idea to make sure that the Proprietary Drivers for Devices box is checked so that you can benefit from drivers that might enhance your system’s performance.

Image

FIGURE 1.8 You can find or add other options under the Other Software and Updates tabs.


Open Source Versus Proprietary

You might hear some arguments about using proprietary drivers or other software in Ubuntu. Some people feel that the use of such drivers goes against what open source stands for because the program code used for the drivers or software cannot be viewed and modified by the wider community but only by the original developers or company that owns it. There is also a strong argument that says users should have to undergo the least amount of work for a fully functional system.

Ubuntu takes a middle-of-the-road stance on this and leaves it up to the user to decide. Open source software is installed by default, but options are given to allow proprietary software to be installed easily.


After you are happy with your selections, switch to the Updates tab to configure Ubuntu’s behavior when updates are available (see Figure 1.9). By default, both the important security updates and recommended updates are checked to ensure that you have the latest bug fixes and patches. You can also choose to receive proposed updates and backports (software that is released for a newer version of Ubuntu but reprogrammed to be compatible with the current release), but we recommend this only if you are happy to carry out testing for the community because any updated software from these repositories can adversely affect your system.

Image

FIGURE 1.9 In the Updates tab of Software Sources, configure which updates you want and how you want them to be handled.

Ubuntu also enables you to configure how often it checks for updates and how they are installed. By default, Ubuntu checks daily for updates and, if any are available, notifies you. However, you can change the frequency and the actions Ubuntu carries out when it finds available updates. We recommend keeping the notification-only option because this enables you to see what updates are available prior to their installation. If you want to save time, choose Download All Updates in the Background to configure Ubuntu to silently download the updates before it gives you the option to install them.

Part of the magic of Ubuntu is the ease in which you can upgrade from major version to major version, such as moving from 16.04 to 16.10. Some Ubuntu releases are called LTS, for long-term support, and are intended for production use by most people. The interim releases are for those who feel they must have the most recent version of everything or those who help work on Ubuntu development. These releases are stable, but they are only supported for a short time, so if you choose to use them you should plan to upgrade to the new release every six months. By ensuring that the release upgrade option is set to long-term support releases only, you’ll be prompted to upgrade your version of Ubuntu only every two years; the next LTS version, 18.04, is scheduled to be released in April 2018.

The Other Software tab enables you to add other repositories. It comes by default with everything you need to connect to and use Canonical’s partner repository, with nonfree (usually in the licensing sense, but occasionally for payment) software from companies that have an agreement with Canonical to make it easily available to interested users. This repository is disabled by default, and if you want to use it, you must enable it by checking a box next to its entry in the Other Software tab.

System Settings

To configure system settings, search the Dash for System Settings. This brings up the menu in Figure 1.10, from which you can make adjustments as desired. A couple of the options are described in the following sections.

Image

FIGURE 1.10 Adjust your system settings.

Detecting and Configuring a Printer

Setting up a printer in Linux used to be so difficult that previous editions of this book included an entire chapter filled with command-line magic and scary looking configuration files. The setup is no longer as difficult in most cases.

Ubuntu includes drivers for many printers, and it is usually easier to install and use a printer in Ubuntu than in other operating systems. (This is not an absolute rule, though.) Some printer manufacturers do not write and release drivers for Linux, and for some printers no open source driver exists. Before you buy a printer, it is a good idea to spend some time on the Internet searching for printers that are known to work with Linux. One great resource is the Open Printing database from The Linux Foundation, at www.openprinting.org/printers.

If you choose wisely, all you need to do is plug your printer into the computer and turn it on. In many cases, Ubuntu finds the printer and adds the driver automatically. Within a couple of minutes, you should be able to use it. You can find Printing in the System Settings menu and use it to see all installed and configured printers and change their settings. From here you can choose to enable printer sharing on a network, set options for default print quality, print a test page, and more.

Configuring Power Management in Ubuntu

Click the Power icon in the System Settings menu to control how Ubuntu handles power-saving features in specific situations (see Figure 1.11). You can have the display dim the backlight to use less power when on battery, put the display to sleep after a certain amount of inactivity, spin down your hard disks (kind of like turning them off, but not completely; this just makes them stop moving until a request is made from them, saving power in the interim), and set your computer to suspend, hibernate, or turn off when the battery reaches a certain level.

Image

FIGURE 1.11 Configure specific power-related actions with Power Management Preferences.

Ubuntu provides good support for suspend. Suspend means that your computer writes its current state to memory and goes into a low-power mode. Your computer will start much faster the next time you use it because it does not need to perform a full boot, but rather brings the system up to its previous state out of memory instead of loading and starting every program again from scratch.

Setting the Time and Date

Linux provides a system time and date; your computer hardware provides a hardware clock-based time. In many cases, it is possible for the two times to drift apart. Linux system time is based on the number of seconds elapsed since January 1, 1970. Your computer’s hardware time depends on the type of clock chips installed on your PC’s motherboard, and many motherboard chipsets are notoriously subject to drift.

Keeping accurate time is important on a single workstation, but it is critically important in a network environment. Backups, scheduled downtimes, and other network-wide actions need to be accurately coordinated.

The Ubuntu installer sets the time and date during the installation process when it asks for your location. If you move or just want to change the settings (for example, to have your computer automatically synchronize its clock with official time servers on the Internet), you can do so.

Changing the Time and Date

Ubuntu’s graphical tool is the simplest way to set your system date and time and the most obvious for a desktop user. The client is called Time & Date in the System Settings menu.

To make any changes to this tool, you need to unlock it by clicking the Unlock button. Only a user who has administrator privileges may use this tool, and you must enter your password to authenticate. After you’ve done this, you can change any of the options.

Manually set the date and time in the GUI (see Figure 1.12) or have your computer obtain updated date and time information via the Internet by selecting Automatically from the Internet. The Clock tab includes settings to adjust what is displayed at the upper right of your desktop.

Image

FIGURE 1.12 Set your system date and time with this GUI.

Using the date Command

Use the date command to display or set your Linux system time. This command requires you to use a specific sequence of numbers to represent the desired date and time. To see your Linux system’s idea of the current date and time, use the date command like this:

matthew@seymour:~$ date
Fri Sep 28 18:03:14 CDT 2013

To adjust your system’s time (for example, to September 28, 2012 at 10:33 a.m.), use a command line with the month, day, hour, minute, and year, like so:

Click here to view code image

matthew@seymour:~$ sudo date 092810332012
Fri Sep 28 18:03:14 CDT 2013

Using the hwclock Command

Use the hwclock command to display or set your Linux system time, display or set your PC’s hardware clock, or to synchronize the system and hardware times. To see your hardware time and date, use hwclock with its --showoption, like so:

Click here to view code image

matthew@seymour:~$ sudo hwclock --show
Fri 28 Sep 2013 06:04:43 PM CDT -0.281699 seconds

Use hwclock with its --set and --date options to manually set the hardware clock, as follows:

Click here to view code image

matthew@seymour:~$ sudo hwclock --set --date "09/28/13 10:33:00"
matthew@seymour:~$ hwclock --show
Fri 28 Sep 2013 10:33:09 AM MST -0.904668 seconds

In these examples, the hardware clock has been set using hwclock, which is then used again to verify the new hardware date and time. You can also use hwclock to set the Linux system time and date using your hardware clock’s values with the Linux system time and date.

For example, to set the system time from your PC’s hardware clock, use the --hctosys option, like so:

Click here to view code image

matthew@seymour:~$ sudo hwclock --hctosys

To set your hardware clock using the system time, use the --systohc option, like so:

Click here to view code image

matthew@seymour:~$ sudo hwclock --systohc

Configuring Wireless Networks

Wireless networking used to be a bear to configure for Linux, requiring a lot of complicated steps to connect to a wireless network. That has become a much easier task. Ubuntu includes a great utility called Network Manager that makes connecting to and managing wireless networks extremely easy.

When you log in to Ubuntu, the Network Manager applet appears in the top panel (see Figure 1.13). This applet handles and monitors network connections.

Image

FIGURE 1.13 The Network Manager notification applet, shown here already connected to a wireless network.

Click the icon in the toolbar to connect to a wireless network. If your wireless access point broadcasts its service set identifier (SSID), it should appear in the list under wireless networks. Click the desired network, and Network Manager detects what encryption (if any) is in use and asks you for the passkey. Enter this and Network Manager starts the wireless connection. The passkey is then stored in the default keyring, a secure area that is unique to your login. From now on, whenever you log in to Ubuntu and are in range of this network, Network Manager will start the connection automatically.

If for some reason your wireless network does not appear (you might have your SSID hidden), you must use the Connect to Other Wireless Network option, in which you enter the network name, wireless security type, and, when needed, the password for the connection.

Network Manager can handle WEP and WPA Personal encryption. You are advised to use WPA encryption because it is the stronger of the two. WEP encryption is easily broken.

Network Manager can also connect to Cisco VPN connections using the vpnc software. Install this from the Ubuntu repositories (see Chapter 9, “Managing Software”), and you can specify connection settings as appropriate, or if you have access to a predefined configuration file (PCF), you can import it directly into Network Manager.

Troubleshooting Post-Installation Configuration Problems

A lot of work has gone into Ubuntu to make it as versatile as possible, but sometimes you might come across a piece of hardware that Ubuntu is not sure about. Knowing what to do in these situations is important, especially when you are working with Ubuntu for the first time.

Because Ubuntu (and Linux in general) is built on a resilient UNIX foundation, it is much more stable than some operating systems. However, even though things might seem to be working fine, Ubuntu could have a problem that might not affect the appearance of the system. In this section, you learn how to examine some of Ubuntu’s built-in error logs to help you discover or diagnose unseen problems.

Ubuntu has a command that responds with detailed messages that are output directly by the operating system: the dmesg command, which we introduce here and cover more completely in Chapter 12, “Command-Line Master Class Part 2.” This command is commonly used with the grep command to filter output. The dmesg command takes its output directly from the /var/log/messages file, so you can choose to either run dmesg or to read the file directly by typing less /var/log/messages. The output is fairly detailed, so be prepared for an initial shock when you see how much information is generated. You might find it easier to generate a file with the dmesg output by using the following command:

Click here to view code image

matthew@seymour:~$ dmesg > dmesg.txt

This takes the output from the dmesg command and stores it in a new text file called dmesg.txt. You can then browse it at your leisure using your choice of text editor, such as vi or emacs. You can even use the lesscommand, like so:

Click here to view code image

matthew@seymour:~$ less dmesg.txt

The messages are generated by the kernel, by other software run by /etc/init.d, and by Ubuntu’s runlevel scripts. You might find what appear to be errors at first glance, but some errors are not really problems (for example, if a piece of hardware is configured but not present on your system).

Thanks to Google, troubleshooting is no longer the slow process it used to be. You can copy and paste error messages into Google’s search bar to bring up a whole selection of results similar to the problem you face. Remember, Google is your friend, especially www.google.com/linux, which provides a specialized search engine for Linux. You can also try http://marc.info, which browses newsgroup and mailing list archives. Either way, you are likely to come across people who have had the same problem as you.

It is important to work on finding and testing only one solution to one problem at a time; otherwise, you might end up getting no work done whatsoever. You should also get into the habit of making backup copies of all files that you modify, just in case you make a bad situation worse. Use the copy (cp) command like this:

Click here to view code image

matthew@seymour:~$ cp file file.backup20160101

You should not use a .bak extension on your backup file because this could get overwritten by another automatic process and leave you frustrated when you try to restore the original file. I like to use backupYYYYMMDD, as in the preceding code where I used the date for New Year’s Day 2016: 2016(year)01(month)01(day).

If something breaks as a result of your changing the original file, you can always copy the original back into place using the command like this:

Click here to view code image

matthew@seymour:~$ cp file.backup20160101 file


Note

Something as simple as this can really save you, especially when you are under pressure because you’ve changed something you shouldn’t have changed on a production system. It is better not to make sweeping changes on a production system.


If you are having trouble with booting your system, you may find it helpful to read Chapter 15, “The Boot Process,” as it details aspects like the bootloader and start up process. Understanding what happens during this process will give you an idea of what to look for and how to solve problems.

Ubuntu includes a comprehensive system testing application called Checkbox. Use it if you have problems and need some assistance tracking down the source, or if you simply want to put your system to the test. Search for Checkbox from the Dash to find and run the application.

References

Image www.ubuntu.com: The place to start when looking for news, information, and documentation about installing, configuring, and using Ubuntu.

Image www.ubuntu.com/desktop/get-ubuntu/download: This page has specific information and links for downloading, burning, and installing the current release of the Ubuntu Desktop edition. Replace desktop in the URL with server to download Ubuntu Server.

Image www.ubuntu.com/project/about-ubuntu/derivatives: This page has information about Ubuntu derivatives, or flavors. These are based on Ubuntu but are modified to include different software or interfaces.

Image www.gnu.org/software/grub/: Home page for the GRUB boot loader.