© Nathan Haines 2017

Nathan Haines, Beginning Ubuntu for Windows and Mac Users , https://doi.org/10.1007/978-1-4842-3000-8_6

6. Power User Tools

Nathan Haines

(1)Lake Forest, California, USA

You’ll find that your daily use of Ubuntu is pretty straightforward and simple. You’ll run applications; get work done; relax with games, movies, or other entertainment; and generally be productive. And as you become more comfortable with Ubuntu you’ll explore Ubuntu Software and expand what you can do with your computer. The possibilities are truly endless.

As you settle in with Ubuntu, there are a lot of more advanced or technical tasks that will help you experience the full potential of your computing experience. When you search the Internet for answers to questions, these solutions will often direct you to install software from the command line. Occasionally you’ll want to use software that is built for Ubuntu but not included in the default repositories. Having become familiar with the Unity interface, you might want to try other desktop environments without actually reinstalling the entire operating system on your computer. This chapter will cover various ways to take control of your computing experience. You won’t need to perform these tasks every day, but knowing about them can save you a lot of time when you need them.

Managing Running Processes

As you work with multiple applications, you’ll find that Ubuntu handles multitasking very well in general. When your system slows down or a single application begins to freeze, you may need to look at what processes are running and how much of your computer’s resources they are taking up. While you saw a useful command-line tool called top in the previous chapter, GNOME System Monitor provides a powerful, easy-to-use graphical version, and it offers additional information about your system resources.

A process is an application (program) or part of an application. When you run an application, Ubuntu loads the program data into memory, and begins scheduling it to run. Ubuntu will manage how much time and memory each application receives so that many programs running at once are able to share the available resources. GNOME System Monitor summarizes how your computer is being utilized. You can launch it from the Dash.

When System Monitor appears, it will show the “Processes” tab, which operates much the same way as top does. This gives you an overview of the currently running processes on the computer. They are identified by name, icon where available, and the user that started them, the amount of CPU time they are using, their process ID (PID), the amount of memory they are utilizing, and their priority (see Figure 6-1). By default, System Monitor will only display the processes that are being run by the currently logged-in user. The column headers can be used to sort the list; for example, clicking the “% CPU” header will sort the list to show which processes are using the most CPU time. Clicking a header will toggle between sorting by ascending or descending order. You can also use the hamburger menu at the right of the toolbar to switch between “Active Processes,” which shows only processes which are not sleeping or suspended; “All Processes,” which shows all processes running on the system regardless of which user is running them; or “My Processes,” which shows processes that are being run by the current user. Because an application can be split into several processes or utilize other programs, the “Dependencies” option is a toggle that sorts related processes by the master process that owns them and can give further insight into CPU or memory use.

A333290_2_En_6_Fig1_HTML.jpg
Figure 6-1. System Monitor shows you what's running and how it affects your computer

Right-clicking a process brings up several different options related to process management. Most of these mirror the operations we discussed in Chapter 5 . Stopping a process suspends it so that it stops running until it receives a signal to continue. Ending a process sends a request to the process to finish up and cleanly exit, whereas killing a process causes Ubuntu to stop executing the process and clear its memory for other use. As before, it’s better to end a process unless it’s completely unresponsive and doesn’t react to end requests, because killing a running process can lead to lost or corrupted data. Changing a process’s priority will instruct Ubuntu to schedule more or less CPU time for it when system resources are limited. You can use this to make a process run faster, or to ensure a long-running process such as a video conversion doesn’t slow down the rest of the system if you don’t mind the time it takes to finish a task.

The “Resources” tab gives you a graphical overview of how your system has been performing over the past 60 seconds (see Figure 6-2). The CPU History graph is nice because it shows you how each CPU is being utilized. Ubuntu will try to schedule different applications to run on separate CPUs to maximize your system’s resources. It also shows how your memory has been used over time. Memory is physical RAM used to keep programs running smoothly, and swap memory shows disk space that is used to temporarily store memory data on disk when a program isn’t actively running and other running programs can benefit by using extra RAM. In general, the more memory being used is better, and the less swap being used is better, since Ubuntu will use spare memory to speed up access to recently accessed programs and files but will stop using it when it’s needed by a running program. You can use this graph to see how opening and closing programs affects your computer’s memory resources. Network history likewise gives you an overview of recent bandwidth usage. You can use it to judge how all running programs are using your network if you suspect slower-than-usual transfer speeds. Sometimes several applications uploading or downloading at once can add up very quickly. This only shows network traffic that is coming to and from the computer, however, so it can’t account for heavy network usage by other computers and devices on the same network.

A333290_2_En_6_Fig2_HTML.jpg
Figure 6-2. The Resources tab shows your computer usage over the last 60 seconds

The “File Systems” tab shows you a quick overview of the file systems that are mounted and in use. From their device name and mount point to their size and a breakdown of available and used capacity, this can be a quick look at what disks and partitions are being used and how much space you have available.

GNOME System Monitor gives you an up-to-the-second look at how your computer is being used and how your resources are being utilized. You can use this information to close programs you aren’t using to speed up your system, change the priority of running programs, or decide whether you need to buy extra memory or storage space for your computer. This system utility will keep you in the know for when you want a comprehensive overview of your computer’s performance.

Managing Disks and Thumb Drives

You will be able to use Ubuntu to read and write to most disks you use with your computer, but sometimes you will need to set up a blank disk or repartition or reformat a disk. Ubuntu makes this easy with Disks utility. This utility provides a way to view the layout of each drive in your computer, manage file systems and formats, and view the status and health information of each drive.

You can launch “Disks” from the Dash. When it appears, it will list all connected drives on the left side of the window, and will show specific information about the selected drive on the right side of the window (see Figure 6-3). The gear button in the top right of the window has various features that can be performed on the entire disk. You can use this to perform a full disk format that replaces the drive’s partition table, to create or restore full disk images, or to run a benchmark test that determines the speed of the drive. If an optical drive or external drive is selected, an “Eject” or “Power off” button will appear beside the Gear button, respectively.

A333290_2_En_6_Fig3_HTML.jpg
Figure 6-3. Disks provides a quick overview of drive details and data allocation

This menu also lets you open the SMART Data & Self-Tests window, which shows the current health of the drive and lets you start the drive’s internal self-tests. The Drive Settings option lets you change power saving preferences that can affect the energy usage of your drive as well as performance. You should not change these settings from the defaults unless you understand each option and its effects clearly. The “Power Off…” option saves any data waiting to be written to the selected to disk and disconnects the drive, telling it to power itself off. You can safely remove an external drive once it disappears from the Devices list on the left.

Partitions are displayed as rectangles proportionate to their size, but very small partitions are not shown to scale. Any partition that is mounted (in use) will have a small “play” icon that looks like a triangle in the bottom right-hand corner. System boot partitions will also have a small star icon in the corner. You should not unmount or edit these partitions while the system is running. If you do need to change or resize these partitions, you can boot from your Ubuntu install media and use Disks to make any necessary changes.

Underneath the partition map, you may see a “Mount selected partition” (triangle) or “Unmount selected partition” (square) icon, a “Create partition in unallocated space” (plus) icon or “Delete selected partition” (minus) icon, and a “Additional partition options” (double gear) icon. Select a partition by clicking it. If the partition contains a file system, you can use the mount and unmount icons to change whether the file system is available to use. If the file system is not in use, you can delete the partition or use the “Additional partitions” button to edit the file system or format the partition. Formatting allows you to choose between four file system formats. FAT is compatible with practically all devices and operating systems, but no single file can be over 4.3 GB. NTFS is used by Windows and lacks the file size limitation of FAT but cannot be written to by OS X without additional software. Ext4 is compatible with most Linux systems, and the “Encrypted” option creates an Ext4 file system inside a LUKS container. Ubuntu will prompt you for the decryption password each time you mount the encrypted file system. You can use the “Custom” option to specify a specific file system type if you need something different for a special purpose.

Disks displays your computer’s attached disks and enables the most common disk operations as well as a large number of very technical options, such as complex formatting, changing file system mount parameters, and adjusting performance characteristics. While caution should be used when working with drives containing important data, Disks is a powerful tool that can be used for anything from simple formatting to working on a computer while booted from the Ubuntu install media.

Using Multiple Workspaces

Monitors feature much higher resolutions than in days gone by. The advent of high-definition television has made a resolution of 1,920 by 1,080 pixels fairly standard. Just 20 years ago 640 x 480 and 800 x 600 were far more common. Special features, such as “virtual desktops” were developed to help deal with limited screen space. In Ubuntu, this feature is also called “workspaces,” and is an optional feature that can be enabled.

When you run graphical applications, they display in one or more windows. As you arrange windows on the screen, they fill up your computer’s desktop. You can set up a desktop to work for a specific task, but when you switch to a different task, you need to rearrange your windows again. This can be inefficient if you are constantly rotating between tasks. Using workspaces gives you four virtual desktops that you can assign each window to and arrange independently of the others.

To enable workspaces , click the Gear Menu ➤ System Settings…, then click on the Appearance applet. On the Behavior tab, you’ll see various settings that change the behavior of the Unity interface. Check “Enable workspaces” to add a workspace switcher icon to the Unity Launcher and enable multiple workspaces (see Figure 6-4).

A333290_2_En_6_Fig4_HTML.jpg
Figure 6-4. The Workspace Switcher icon is the last icon on the Launcher before the Trash

Once enabled, you will have four workspaces that you can arrange windows on. Everyone has a favorite way to use multiple workspaces, but one popular use is to use each workspace to perform different tasks. For example, if you’re planning a day of working at the computer, you might set up one workspace with your word processor and web browser, a second workspace with your email and instant messaging windows, a third workspace with Rhythmbox for background music, and the last workspace with Solitaire or Mines for your periodic breaks. With each workspace focused on a different activity, you can take a break by switching to one workspace, and when you’re ready to resume another task, all your applications are running and arranged just the way you had them when you switch back. This can greatly increase your productivity—as long as you’re honest about the time you spend on your “work break” desktop! Don’t forget that there’s no need to use every workspace just because they’re there. You can use only two or three if you like.

Using workspaces is fairly simple. When you launch an application, it appears on your current workspace, and you can switch to a different workspace whenever you like. The easiest way to switch is to click the “Workspace Switcher” icon on the Unity Launcher or use the shortcut key Super+S. Your view will zoom out and show all four workspaces. The current workspace is highlighted in orange and the others are dimmed (see Figure 6-5). You can select a new workspace by clicking it with the mouse, or by using the arrow keys and pressing Enter. Your view will zoom back into your new workspace and you’ll be able to work with those windows.

A333290_2_En_6_Fig5_HTML.jpg
Figure 6-5. Workspaces make it very easy to stay focused on different tasks
Tip

The “Workspace Switcher” icon also shows you which workspace is active. The darker quadrant with two window icons is your current workspace.

The Unity Launcher will show all running applications, but the Alt+Tab application switcher and Super+W window spread features will only show applications on your current workspace. You can identify which applications are running on a different workspace because the pips are hollow (see Figure 6-6). Clicking the Launcher icon for an application on another workspace will automatically switch you to its active workspace, with an animation that indicates which workspace you are now on. This gives you a nice balance: workspaces simplify Alt+Tab switching as you focus on a task, while the Launcher gives you instant access to everything running on your computer.

A333290_2_En_6_Fig6_HTML.jpg
Figure 6-6. Files is not running, Firefox is open on another workspace, and LibreOffice Writer is open on the current workspace and is focused

You can also move an application to other workspaces. There are several ways of doing this. When you click the “Workspace Switcher” or press Super+S, you can drag individual application windows from any workspace to another. You can also right-click the title bar of any window and choose from several options. “Always on Visible Workspace” will place the window in the same location on all workspaces. “Only on This Workspace” is the default setting. “Move to Another Workspace” lets you specify a specific workspace to move a window to. This is a good way of setting up workspaces when you’ve already been working in a single workspace for a while but want to change your workflow to start using the others.

Once you get accustomed to working with multiple workspaces , you can switch between them even faster by holding Ctrl and Alt and pressing an arrow key. Ubuntu will show a small thumbnail of your workspaces as your view slides to the new one. You can switch to any workspace instantly, even pressing two arrow keys at once to move diagonally. Once you let go of Ctrl and Alt, you will be on your new workspace. Holding Shift while you press Ctrl and Alt will slide the active window with you to the new workspace. This keyboard shortcut is a little more obscure but can be useful when moving a window around after your workspaces are set up. When workspaces are enabled, holding the Super key will show these shortcut keys under the “Workspaces” section.

Workspaces are an advanced feature that you can use for even greater productivity on Ubuntu. Not only do they simply application switching and multitasking, but they can help you optimize your workflow as you move from task to task—making you more efficient as you focus on work and reducing your downtime between tasks.

Installing Alternate Desktop Environments

One of the most compelling things about Ubuntu and Linux in general is the amount of customization that is available. By installing different software on top of the kernel, you can create an operating system that suits your needs perfectly. Even the default Ubuntu graphical interface is just one option out of dozens that you can change to suit your personal preferences. Ubuntu is available in the form of several “flavors” that share a core Ubuntu system but have different desktop environments built on top. Each desktop flavor has a different interface and default application selection suited for various preferences or tasks. While a brief overview of many of the officially supported desktop flavors is available in Chapter 1 , you can use Ubuntu Software to add software from any desktop environment to any Ubuntu system. All applications run in all desktop environments, and each user can choose a different desktop environment.

Installing a new desktop environment is as easy as running a command in Terminal. Ubuntu will download and configure the additional software and you can choose which desktop you wish to run on the login screen. Because Ubuntu flavors are made up of a lot of packages, it’s best to search for the main package for that flavor. Table 6-1 lists the main package names for each flavor.

Table 6-1. Desktop Environments from Ubuntu Flavors Can Be Installed by Package Name

Ubuntu Flavor

Desktop Environment

Package Name

Ubuntu

GNOME with Unity

ubuntu-desktop

Kubuntu

KDE Plasma Workspace

kubuntu-desktop

Xubuntu

XFCE Desktop Environment

xubuntu-desktop

Lubuntu

LXDE

lubuntu-desktop

Ubuntu GNOME

GNOME with GNOME Shell

ubuntu-gnome-desktop

Ubuntu MATE

MATE Desktop Environment

ubuntu-mate-desktop

Edubuntu

GNOME with Unity and educational apps

edubuntu-desktop

Ubuntu Studio

XFCE with media creation tools

ubuntu-studio-desktop

For example, to add the KDE desktop environment to any Ubuntu system, you would open Terminal, then type “sudo apt install kubuntu-desktop”, enter your password and press Enter, and then press Enter again at the confirmation prompt. Ubuntu will download and install all additional programs that were included on the Kubuntu install media (see Figure 6-7). Approximately 1.4 GB of additional software is needed on top of a standard Ubuntu system.

A333290_2_En_6_Fig7_HTML.jpg
Figure 6-7. Kubuntu and KDE can be installed like any other application with just one terminal command

Once additional desktop environments have been installed, they can be selected on a per-user basis at Ubuntu’s login screen. To the right of the username is an Ubuntu logo . Clicking this logo brings up a menu that displays all installed desktop environments (see Figure 6-8). Clicking “Plasma” will choose that new desktop environment and return you to the user and password entry prompts. The Ubuntu logo will be replaced with a stylized KDE logo to indicate your selected desktop environment. Once you enter your password and log in, the KDE Plasma Workspace will be your active desktop environment. Ubuntu will remember your choice until you change it again.

A333290_2_En_6_Fig8_HTML.jpg
Figure 6-8. You can choose between installed desktop environments before you log in

All installed software is available regardless of which desktop environment you run, so you can experiment to see which interfaces you prefer. You may even want to install several desktop environments, evaluate them, and then perform a clean install of that Ubuntu flavor on your system. Regardless, changing your desktop interface and the entire look and feel of your Ubuntu system is as simple and straightforward as installing any other software.

Installing Software from the Command Line

One of the best things about Ubuntu is that it includes thousands and thousands of software packages. Even software that isn’t included in a default install can be quickly and easily added to an existing system and receive updates through Ubuntu’s Software Updater utility. This is one of Ubuntu’s greatest strengths, because a default installation can be customized yet easily kept up to date. It’s been shown that many programs leverage the strengths and capabilities of other programs, and Ubuntu Software is no different. Ubuntu is built using a software packaging system that was created for Debian long ago. And while all of the software in the Ubuntu archives has been compiled specifically for Ubuntu, the tools used to install and manage the installed software on an Ubuntu system are the same: dpkg and apt.

An even newer technology used in Ubuntu is snap packages. Snap packages allow you to install software in a safe, confined manner that is separate from your main Ubuntu system without any additional effort on your part. Snaps are an especially safe and convenient way to try new software because they have security confinement and automatic updates but do not carry the risk of conflicting with preinstalled software. But as exciting as this new technology is, it is still receiving frequent updates and enhancements. For the latest information on working with snaps on the command line, visit https://www.ubuntu.com/desktop/snappy .

Understanding Ubuntu’s Software Collection

The Debian package tool (dpkg) is used to install and uninstall Debian packages on a Debian-based operating system like Ubuntu. However, the Advanced Package Tool (apt) also manages keeping track of what packages are installed on the system, checking for updated packages, downloading newer packages and any additional packages they need to run, and downloading them from the Internet and making sure they haven’t been tampered with. Then it runs dpkg to do the actual installation. The end result is that we can learn how to use apt instead of working with dpkg directly.

We would normally use Ubuntu Software to install software from the Ubuntu archives. But installing software on the command line is especially efficient. While the end result is identical, it is much easier to explain how to install software on the command line. For that reason, it is extremely common to see command-line instructions given in online tutorials. That makes it important to understand what is happening when an article or online solution asks you to open a terminal window and run commands to install software.

Ubuntu software is contained in a variety of software repositories. A repository is a list of available software packages and their relationship to other packages, along with the packages themselves. Ubuntu can use this list to download and install new software packages as well as determine when installed packages have been updated. Ubuntu software is separated into various groups: main, restricted, universe, and multiverse. The “main” group contains the core Ubuntu software that is directly supported by Canonical. This includes the default desktop as well as the most important server software. The “restricted” group has firmware and other software that isn’t Free software or open source and is distributed by Ubuntu and Canonical to help ensure that Ubuntu can run on a variety of hardware. The “universe” group is filled with community-supported software, and “multiverse” is software that may not be fully redistributable because of software license or patent issues.

Each Ubuntu release has three repositories. One uses the release’s short code name (for example, “xenial” for 16.04 LTS), which is an archive of Ubuntu as it existed at the moment of that release. The matching repository , “xenial-updates,” contains any packages that have been updated since 16.04 LTS was released. The last repository, “xenial-security,” contains updated packages that have been updated because of security issues. Each repository contains software from all four groups. Because apt combines these lists of software packages into one database, you can use apt to install and upgrade any software that is included in Ubuntu regardless of where it comes from.

Tip

While most online instructions use apt-get, apt-cache, and other tools, this book prefers the apt command—introduced in Ubuntu 14.04 LTS—because it has color-coded output and a progress bar that is easier to read for command-line newcomers. The two commands produce the same end result , although apt-get has more advanced options.

Keeping Software Up to Date

Before you search for or install a software package, you should ensure Ubuntu’s software index is up to date. By default, Ubuntu updates its software list once per day, but you can manually update the index by running “apt update.” This will download the current list of packages from the Ubuntu repositories. Because this modifies system files, you must run it with sudo and type your password, followed by pressing Enter:

sudo apt update

Ubuntu will check each of its repositories and only download package lists that have changed since the last time the command was run. Once this is finished, you can upgrade or install new software. The Ubuntu updates repository only keeps the latest couple of updates to any single package, so if an upgrade or install fails with a “Package not found” error on a computer that hasn’t been turned on in a while, running apt update before repeating the upgrade or install command will often succeed.

With an updated package list, Ubuntu knows which packages are available and can replace older software on your system. The command to do this is apt upgrade. If you run this with sudo, apt will list all updated and new packages and ask whether you wish to proceed with the upgrade. Here is an example of an upgrade where Ubuntu’s Linux kernel will be updated:

nathan@ubuntu-book:∼$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-3.13.0-61 linux-headers-3.13.0-61-generic
  linux-image-3.13.0-61-generic linux-image-extra-3.13.0-61-generic
The following packages will be upgraded:
  linux-generic linux-headers-generic linux-image-generic linux-libc-dev
4 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 62.3 MB of archives.
After this operation, 271 MB of additional disk space will be used.
Do you want to continue? [Y/n]

“Y” is the default option, so pressing Enter will begin the upgrade. Ubuntu will download all of the listed packages from its software repositories, and install them, with a progress bar printed at the bottom of the screen. Once it is complete, your system will be up to date.

Occasionally, apt will say that certain packages are being held back. This happens when certain packages must be removed and replaced with newer versions with new names. This isn’t common but occasionally happens with certain system libraries. You can run “sudo apt full-upgrade” or “sudo apt-get dist-upgrade” to install the held-back packages .

Searching for Software

There are over 80,000 software packages in Ubuntu 16.04 LTS, and finding new software to install can be difficult. Sometimes a package name is the same as the application title, such as “ firefox” or “inkscape.” But sometimes a package name is different, such as “nethack-console.” Using the command line to install an application is the quickest method when you know the exact package name, but apt can also be used to find software as well.

Every package has a name and a short and long description, which is part of the information stored in the Ubuntu repositories. Using the command “apt search” plus a space and a search term will search the names and descriptions in the package database on your computer and will print a list of package names and their short descriptions. For more information on any package, you can run “apt show” followed by a space and a package name. This displays a lot of information, including the installed size and the package’s long description, which allows you to narrow down a package name for software you wish to install. Using the command line to search for applications is more bare-bones, but it is much faster than using Ubuntu Software.

You can also use “apt policy” to find out more information about the installation status and availability of a package. If I run “apt policy firefox”, for instance, I see the following:

nathan@ubuntu-book:∼$ apt policy firefox
firefox:
  Installed: 53.0+build6-0ubuntu0.16.04.1
  Candidate: 53.0+build6-0ubuntu0.16.04.1
  Version table:
 *** 53.0+build6-0ubuntu0.16.04.1 500
        500 http://mirrors.us.kernel.org/ubuntu/ xenial-updates/main amd64 Packages
        500 http://mirrors.us.kernel.org/ubuntu/ xenial-security/main amd64 Packages
        100 /var/lib/dpkg/status
     45.0.2+build1-0ubuntu1 500
        500 http://mirrors.us.kernel.org/ubuntu/ xenial/main amd64 Packages

I can clearly see from the “Installed” field that Firefox 53.0 is installed. The “Candidate” field tells me the latest version that Ubuntu wants to install. Because it’s the same as the installed version, I know that my browser is the latest available in the Ubuntu repository. The version table shows me that Firefox 53.0 was included in xenial-updates and xenial-security. Because it is in xenial-security, I know it has fixed security issues since the release of Ubuntu 16.04 LTS and I should install it unless I have a good reason not to. And I can also see from the last line that Ubuntu 16.04 LTS originally shipped with Firefox 45.0.2.

Even when a package is not installed, “apt policy” provides the same information. Using the Chromium browser as an example shows the following:

nathan@ubuntu-book:∼$ apt policy chromium-browser
chromium-browser:
  Installed: (none)
  Candidate: 58.0.3029.96-0ubuntu0.16.04.1.1279
  Version table:
     58.0.3029.96-0ubuntu0.16.04.1.1279 500
        500 http://mirrors.us.kernel.org/ubuntu/ xenial-updates/universe amd64 Packages
        500 http://mirrors.us.kernel.org/ubuntu/ xenial-security/universe amd64 Packages
     49.0.2623.108-0ubuntu1.1233 500
        500 http://mirrors.us.kernel.org/ubuntu/ xenial/universe amd64 Packages

The “Installed” field clearly indicates with “(none)” that Chromium is not installed on the computer, and that using apt or Ubuntu Software to install it will result in Chromium 58.0.3029.96 being installed.

Installing New Software

Installing software from the Ubuntu repository is simple on the command line. If you know exactly what you want to install, you can start the process in mere seconds. The command “apt install” will automatically download the latest version of a package along with any additional packages it requires, and install them in the most efficient order.

Because it modifies system files, “apt install” must be run with “sudo”, along with the name of the package you wish to install. Then apt will determine what needs to be installed and if the package can be installed by itself, it will begin the download and installation immediately. If the package requires additional packages that you did not specify, it will pause after printing a summary and wait for your response. Pressing Enter will begin the install. Installing Chromium browser looks like this:

nathan@ubuntu-book:∼$ sudo apt install chromium-browser
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  chromium-browser-l10n chromium-codecs-ffmpeg-extra
Suggested packages:
  webaccounts-chromium-extension unity-chromium-extension adobe-flashplugin
The following NEW packages will be installed:
  chromium-browser chromium-browser-l10n
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 67.8 MB of archives.
After this operation, 279 MB of additional disk space will be used.
Do you want to continue? [Y/n]

This tells us that the extra package “chromium-browser-l10n” will be installed. Pressing Enter will begin the download and installation. If you wanted to know more about the additional package, you could type “n” and press Enter, then run “apt show chromium-browser-l10n”. Using “apt show” reveals that this is the language data for the browser. apt also listed three other suggested packages that work with Chromium or offer additional functionality. Suggested packages are not installed by default, but they can offer additional functionality and you can install them manually. If installing a package would require the removal of software, those package names would also be listed. Altogether, apt will download 55 MB of packages, and once they are uncompressed, installed, and configured, they will use 218 MB of disk space. This also takes into account any software that may be upgraded or replaced by apt.

Installing more than one package at a time is as easy as listing more than one package on the command line. When I install Ubuntu on a new computer, one of the first things I do is run “sudo apt install gimp inkscape vlc ubuntu-restricted-extras”. By directly asking Ubuntu to install these packages, I save a lot of time over opening Ubuntu Software, searching for each one by name, and clicking “Install.”

Occasionally, you may want to download packages now but not install them until later. You can do this by running “apt -d install [packagename]” or “apt -d upgrade”. The “-d” option tells apt to download the packages but skip installing them. The next time you run a command to upgrade or install those packages, they will not be downloaded again unless a newer version has been released.

Removing Software

Removing software is just as simple as installing it. The command “apt remove [packagename]” uninstalls software packages and frees up disk space. When you run this command, it deletes the application and associated system files. It doesn’t typically delete any configuration data in your home folder. This means that you can still back up this information, and should you reinstall the software again in the future, your old settings will still be used. If you want to completely remove a package and its configuration files, you can use the command “apt purge [packagename]”. This will leave no trace of the specified software on your computer.

Ubuntu’s basic software management tool apt is an easy-to-use and powerful way of managing your computer’s software at all steps: searching, downloading, installing, upgrading, and removing. This technology lays a foundation for Ubuntu’s ease of use and reliably security and bug fixes. By working with these tools directly, you can save yourself time and quickly install and remove software so that you can get to work.

Expand Your Software Options

Ubuntu comes with a wide array of software—over 80,000 packages at your disposal thanks to large software repositories. Sometimes, it’s not enough. Ubuntu’s update policy means that major versions of software are locked in a couple of months before release and the Ubuntu repositories only see minor maintenance or security updates to ensure stability. LibreOffice 5.1.3 was included in Ubuntu 16.04 LTS and received updates up to 5.1.6. Ubuntu won’t receive further updates of LibreOffice even though the current version is 5.3.2. Other software was not able to be packaged for Ubuntu for various reasons. Some wasn’t available or stable enough to include during Ubuntu 16.04 LTS’s development cycle. Others are released directly by third-party software manufacturers. When an application makes an Ubuntu package repository available, you can add the repository to your system and gain access to the included software.

A third-party Ubuntu repository will have two components. The first is a link to the repository, and the other is a GPG encryption key to sign the packages and ensure a package hasn’t been corrupted or tampered with. With this information you can add the repository to your software sources and interact with it using Ubuntu Software and apt. Ubuntu’s Launchpad project also offers a feature called “Personal Package Archives (PPA).” This service allows developers to create Ubuntu packages for testing or updates outside the Ubuntu release process and is slightly easier to add because Ubuntu can import the signing key automatically.

Some third-party software, such as Google’s Chrome installer and Valve Software’s Steam installer, add themselves to the software list during the install, allowing Ubuntu to automatically detect and download updates. To manually add a repository, launch “Software & Updates” from the Dash and click on the “Other Software” tab. You will see any optional repositories that have been added to your system, as well as a check box indicating whether each source is enabled or disabled (see Figure 6-9).

A333290_2_En_6_Fig9_HTML.jpg
Figure 6-9. Software sources can be added automatically or by hand

To add a repository, click the “Add…” button. Ubuntu will ask you for the “APT” line that describes the repository. This usually begins with the word “deb.” To use Oracle’s VirtualBox repository as an example, Oracle provides repository information on its web site in the VirtualBox downloads page at https://www.virtualbox.org/wiki/Linux_Downloads . Following the instructions on that page, in the “APT line:” field you would enter:

deb http://download.virtualbox.org/virtualbox/debian xenial contrib

Once you’ve entered that into the field, click “Add Source.” Ubuntu will ask you to enter your password to confirm your request. Once you click the “Authenticate” button, Ubuntu will add the repository to your system. Next, you will need to add the repository’s signing key. If the repository maintainer uses one, it should be available in the same place as the repository information. For example, Oracle provides a link to the signing key on the Linux download page as part of repository setup instructions. Download this key with your web browser and go back to the Software & Updates window and click the “Authentication” tab. Click the “Import Key File…,” select the .asc file you downloaded, and click “OK.” Ubuntu will add the key and when you click “Close,” you will receive a prompt that says “The information about available software is out-of-date.” Click the “Reload” button and Ubuntu will update its software list, including the new source you just added.

Once the Software & Updates window closes, you can install packages in the new repository using Ubuntu Software, Software Updater, or apt just like any other package. VirtualBox is now available in an additional “virtualbox-5.1” package that can be installed. If Ubuntu 16.04 LTS’s older “virtualbox” package containing version 5.0 was installed before, virtualbox-5.1 will replace the older software so that they do not conflict.

Caution

When you add a software source to Ubuntu, you are giving the source maintainer full control of your computer because the setup scripts in the packaging run with superuser rights and malicious software could be masquerading as something useful. Make sure you trust the source before adding it to your computer.

When you upgrade to a new major release of Ubuntu, these additional software sources are automatically disabled because there is no guarantee that they are compatible with the newer version of Ubuntu. You can contact the repository maintainer or carefully test the software on the newer version of Ubuntu and reenable each source on an individual basis. Sometimes you can use the “Edit” button to update the release name, from “xenial” to “zesty,” for instance, if you were upgrading to Ubuntu 17.04. If the new source is not available for the newer version of Ubuntu, the currently installed packages will remain installed but will not update until their availability changes.

Ubuntu is able to receive updates to the software it provides but is also flexible enough to receive updates from other sources as well. Used with caution, this is the perfect way to keep up with updates to Chrome, Steam, VirtualBox, and many other software projects.

Creating Application Launchers for Programs

Sometimes you might have written a script or found an interactive command-line application that you want to be able to launch using the Unity Dash or pin to the Launcher. While some command-line applications (such as Elinks) are available in the Dash after installation, the vast majority of command-line applications do not show up in the Unity Dash. Other software that isn’t available through Ubuntu’s package management, such as Minecraft, run in place but without a desktop launcher. Most software without a launcher will never be missed, but if you want to set up a custom icon, you can do so by creating a “.desktop” file.

A .desktop file is a text configuration file that describes a program to a desktop environment. Most modern desktop environments automatically detect .desktop files in either a system folder or a per-user folder. To demonstrate, let’s create a script named “spacedrive” that generates a pulsing white noise similar to a starship engine. Then, we’ll create an application launcher file so we can run it using Unity instead of the command line.

First, install the package “ sox.” This small sound file utility can convert sound files but can also be used to generate sound effects. To install SoX, open “Terminal” via the Dash, or press Ctrl+Alt+T. Then type

sudo apt install sox

Press Enter, enter your password, and press Enter again. You’ll be prompted to confirm the software installation. Press Enter to accept the default of “Yes.” Ubuntu will download and install SoX and a general MIDI sound font.

Next, click Files in the Launcher and create a new folder named “bin” in your home folder if it does not already exist. If you just created “bin,” you should log out and log back in. Ubuntu will automatically add “∼/bin” to your system path if it exists, but only when you log in. Then, launch Text Editor from the Dash and enter the following into a new file:

#!/bin/sh
echo -n "33]0;spacedrive07"
/usr/bin/play -n -c1 synth whitenoise lowpass -1 120 lowpass -1 120 lowpass -1 120 gain +14

Save that in your ∼/bin folder with the name “spacedrive”. In Files, open the “bin” folder and right-click “spacedrive,” then choose Properties from the pop-up menu. Click the “Permissions” tab, and click the “Allow executing file as program” check box until it has a dash or a check mark in it, and then close the “spacedrive Properties” window. If you have created this script correctly, you can launch Terminal from the Dash and type “spacedrive” and press Enter. You should hear gently pulsing white noise with a status and volume indicator. This will continue to play until you press Ctrl+C in the Terminal window.

Once this works, go back to Text Editor and click the “Create a new document” icon in the toolbar. In the new text file, enter the following with no blank lines at the top:

[Desktop Entry]
Version=1.0
Name=spacedrive
Comment=Engages your starship's engines for relaxing background noise.
Exec=spacedrive
Icon=/usr/share/pixmaps/faces/launch.jpg
Terminal=true
Type=Application
Categories=AudioVideo;Audio;Music;

Save this to your Desktop folder with the name “spacedrive.desktop.” On your desktop, you will see the file appear. If you try to run it, you will receive an error that says the application launcher has not been marked as trusted. Right-click the file and choose “Properties,” and go to the “Permissions” tab and allow the file to be executed as a program as you did with the “spacedrive” script. The icon file the file will change to an image of a NASA space shuttle, and the label will change from “spacedrive.desktop” to “spacedrive.” The file name has not actually changed, but its appearance on the desktop has. You have now created an application launcher.

To make the file available in the Unity Dash, you can move it to the ∼/.local/share/applications folder. It will immediately be available in the Dash, and you can even drag it to your Launcher at the left side of the screen. Once the script is running, pressing Ctrl+C or closing the terminal window will end the sound effect.

The .desktop file follows a specific format, but you should be able to modify the spacedrive.desktop file to suit your own needs. The “Name” line will be the way your application appears in the Dash and Launcher, and the “Comment” line is used for extra search keywords by Unity and often shows up as a tooltip when hovering your mouse over a menu item in other desktop environments. The “Exec” line should be the exact path and file name you use to run the script or command from a command prompt. If the application is in your path (such as applications installed by the package manager or items in your “bin” folder), you can specify just the name, but if they are outside your path you must give the full path, for example, “/home/nathan/bin/spacedrive”.

The “Icon” line is optional and can point to any file. If no path or file extension is given, Ubuntu looks in /usr/share/pixmaps for a matching file and adds the right extension. The “Terminal” line indicates whether or not to display a terminal window, and can be either “true” or “false.” If the application is graphical or runs without interaction, you will probably make this “false.” If you need to interact with the script or command, you will want to make this “true.”

The line “Type” needs to be “Application” in order to function as a launcher, and “Categories” should be one of the main categories in the specification. You can use semicolons (;) to separate additional categories on the same line as in the example. A list of valid categories to use on this line are available at

http://standards.freedesktop.org/menu-spec/1.0/apa.html

There are some additional sections you can add, both advanced features of the application launcher and Unity-specific features as well. If you are interested in adding right-click actions to application launchers that are in the Launcher, for example, you can read more details and examples at the following online documentation:

https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles

Having a shortcut for a favorite command or script can be a huge convenience. Using simple .desktop files can allow for custom launchers that range from the simple to the complex, and come in handy—especially when you are working between with software that doesn’t use Ubuntu’s software management.

Working with Virtual Machines

Finding the best software to suit your workflow can be fun but challenging. And in the end, you might find that you enjoy software that is only available on other operating systems. You may also want to experiment with different operating systems or software changes while keeping your primary computer usable. Dedicating a computer to one operating system or dual booting a single system is one option, but moving between computers or stopping work to reboot into another operating system is inconvenient. Other times you may just want to test something temporarily. The best way to do this is to create a virtual machine where your changes don’t affect your primary computer. There are many virtualization technologies, and Ubuntu supports many of them. VirtualBox is very popular, as is the VMware family of commercial products. KVM support is used in a lot of cloud computing solutions, and in fact there are many commercial virtual server providers such as DigitalOcean and ChunkHost. All of these solutions have their uses, but VirtualBox is one of the most user-friendly ways for a beginner to work with virtual machines (see Figure 6-10).

A333290_2_En_6_Fig10_HTML.jpg
Figure 6-10. This Ubuntu 16.04 LTS virtual machine was the model for this book

A virtual machine is a simulated computer that runs like a program. Once created, it behaves just like a real computer. You can define how much memory it has, create virtual disks and define their size, and connect virtual and real hardware to the virtual machine. While a virtual machine uses your computer’s CPU, memory, and disk space, it is isolated from the rest of your computer. In fact, the first thing you do after you turn on a new virtual machine for the first time is install an operating system—just like a new physical machine. Because of the way they share resources, the computer running VirtualBox is called the “host” computer and the virtual machine inside VirtualBox is called the “guest” machine.

To work with VirtualBox, you can install it from Ubuntu Software, or use apt to install the package “virtualbox.” If you want to use the latest version available from Oracle, you can look at the earlier section, “Expand Your Software Options,” as a guide to adding Oracle’s VirtualBox repository to your system. When this book was written, “virtualbox-5.1” was the latest version of VirtualBox, but check the official web site at https://www.virtualbox.org/ for updated instructions. Only members of the “virtualbox” group on your system will be able to run VirtualBox. The install process will automatically add your user account to the group, but you will need to manually add other users to this group before they can run VirtualBox, too. The first time you install VirtualBox on an Ubuntu computer, you will need to log out of Ubuntu and log back in so that the “virtualbox” group permissions take effect. Then you will be able to launch VirtualBox through the Dash .

Creating a Virtual Machine

The first time you run VirtualBox, you’ll see a welcome screen (see Figure 6-11). This screen gives instructions for creating your first virtual machine. Click the “New” button on the toolbar and the “Create Virtual Machine” wizard will appear. The wizard explains each step in detail. On the first page, you can give your machine a friendly name that will appear in the machine list, and select your target operating system from the drop-down menus. When you hit “Next,” you’ll be prompted for the amount of memory installed in the virtual machine. The important thing to remember is that when the virtual machine is running, it takes all of the allocated memory from the host operating system. The recommended memory size is based on the minimum requirements for the operating machine you specified, but you can choose any size you like. Smaller sizes can cause poor guest performance, and larger sizes can cause poor host performance that affects the entire computer and running virtual machines. When the virtual machine is powered down, it doesn’t use any memory.

A333290_2_En_6_Fig11_HTML.jpg
Figure 6-11. VirtualBox guides you through each step of the creation process

Next, you can create a virtual hard drive for the machine. The recommended size is once again based on the minimum requirements of the virtual machine. Once you choose whether to create a new virtual hard drive, a “Create Virtual Hard Drive” wizard appears and guides you through the process. Unless you have a specific need for a different format, you can safely create a VDI (VirtualBox Disk Image) format disk. If you create a “dynamically allocated” drive, then the drive file size will start at 2.1 MB regardless of the virtual capacity and will only grow when written to. A “fixed size” virtual drive file will be as large as the capacity you choose on the next screen. It can be useful if you are working with a virtual machine that will save a lot of data, because it can be faster to write to. Once you create the disk drive, the wizard will close and you will be back at the main VirtualBox window with the details of your new virtual machine displayed on the right of the window.

Some operating systems rely on 3D acceleration to display their user interface. Both Windows Vista and later along with Ubuntu 12.10 and later will be much faster with 3D acceleration enabled. You can select a virtual machine and click the “Display” settings header, then enable the “Enable 3D Acceleration” feature. If you will install Windows on the virtual machine, you can also select “Enable 2D Acceleration.” Once you install the VirtualBox Guest Additions, your virtual machine will function much more smoothly. See “Installing Guest Additions” for more details.

Running Your Virtual Machine

Selecting a virtual machine and clicking the “Start” button on the toolbar will virtually power on the machine. A display window will appear which will serve as the virtual machine’s monitor. You can type and use the mouse inside the window. Both the Ubuntu and Windows installers recognize the virtual mouse, so you’ll be able to click inside the display window at any time. If you are not running an operating system that supports the virtual mouse, the virtual machine will “capture” the mouse when you click inside the window. This can also happen with the keyboard. To free both the mouse and the keyboard, press the Right Ctrl key.

A new virtual machine will have a blank hard drive. The first time you start a virtual machine, VirtualBox will ask you to select the location of your operating system install media (see Figure 6-12). You can choose an optical drive on the host machine or an ISO disc image if you have it in your files. Clicking “Start” will insert the disk into the guest’s virtual optical drive and power on the virtual machine. At that point, you will proceed to install your guest operating system as you would on a physical computer.

A333290_2_En_6_Fig12_HTML.jpg
Figure 6-12. Just like a real computer, you have to install an operating system on a virtual machine

Once you have installed an operating system, a virtual machine is almost identical to using a physical machine. You can close the virtual machine window to power off the virtual machine, although if the guest operating system allows for an automatic shutdown, you should always use it instead of forcing a power off. Your virtual machine has audio, video, and network, and storage hardware, and if the guest operating system supports USB, you can connect USB devices plugged into your host machine directly to the guest machine’s USB ports by using the Devices ➤ USB Devices menu and clicking the desired device. Once your guest machine is finished with the device, you can detach the device from your virtual machine the same way. It automatically reattaches to your host machine.

VirtualBox has a dizzying array of options and features, and if you are used to building computers, you can customize much of the virtual hardware. In the main VirtualBox window, you can right-click a virtual machine and choose “Settings” from the pop-up menu. Most settings have a tooltip that appears when you hover your mouse over them. These tips not only explain the option but often offer advice on avoiding configuration problems.

The VirtualBox manual is comprehensive and explains all of the settings and considerations when installing specific guest operating systems, and will help you get the most out of this highly complex software. Clicking the “Help ➤ Contents” menu item will bring up the manual.

Installing Guest Additions

The guest operating system in a virtual machine is isolated from the host operating system and runs completely independently. This is both a great advantage and a disadvantage. Only virtualized hardware and devices can be used on the guest machine, and features like 3D acceleration and the clipboard and folders cannot be shared. VirtualBox comes with a set of guest additions that can be installed on the guest operating system to add virtualized hardware drivers that allow the guest machine to communicate with the host machine and better share resources.

Once you have installed a guest operating system in your virtual machine, you can insert the Virtual Guest Additions CD into the virtual machine. This is not a physical CD but can be inserted with the “Devices ➤ Insert Guest Additions CD image…” menu item when the operating system is running. The guest operating system should ask if you want to run the software on the CD. Choose yes, authorize the system changes, and the installer will appear. On Windows guests, this will look like a typical program installer and you will be able to choose whether to install 3D acceleration. Follow the on-screen prompts to install the guest additions. On Ubuntu and other Linux operating systems, a terminal window will appear and show the installation progress. Once installation has completed, you can eject the CD and restart the guest machine to fully enable the guest additions. More detailed and up-to-date instructions for installation and guest operating system compatibility are available in the VirtualBox manual. When VirtualBox is upgraded, the guest additions should be updated, too. Your guest operating system will notify you if a newer update is available, and you can simply repeat the installation process. The installer will remove the old additions and replace them with the new ones.

Guest additions offer many benefits. The keyboard and mouse will no longer be “captured” by the virtual machine , and your virtual machine will have access to more graphics modes, including the ability to automatically adjust to the virtual machine window being resized. On Windows and Linux, you can also enable “Seamless Mode,” which removes the guest operating system’s desktop background. This allows you to work with the guest application windows as though they were running on your host system. While this has some restrictions, it can greatly simplify switching between applications on the host and guest machines. Guest additions even allow for the sharing of clipboard data and folders between the host and guest, and VirtualBox 5.0 adds direct drag-and-drop support for small- to medium-sized files. Once again, the VirtualBox manual will have more details as well as the latest updates on functionality.

For operating systems that rely on 3D acceleration to display their user interface, you should ensure that 3D acceleration is enabled in the virtual machine settings. While the virtual machine is powered off, select the virtual machine and click the “Display” settings header, and then enable the “Enable 3D Acceleration” feature. For Windows guest machines, you can also select “Enable 2D Acceleration.” Graphics acceleration will speed up the interface and also allow you to play many 3D accelerated games inside the virtual machine.

VirtualBox allows you to work in multiple operating systems at the same time. With the installation of guest additions, you can expand those operating systems to provide better access to your physical hardware and offer extra convenience features that make working with wildly different software much more pleasant .

Recommended Uses

VirtualBox gives you a computer in a window. In fact, you can run as many virtual machines as your physical computer’s hardware resources can accommodate. The possibilities are truly endless.

  • You can try different operating systems. If you wanted to work with Windows, or a different flavor of Ubuntu, you can safely test the install process and user experience by trying it in a virtual machine first. If you love Ubuntu but have one or two Windows applications that won’t run under Wine, you can run them in Windows with a virtual machine without having to dual boot.

  • You can run older or newer operating systems. Do you have old DOS games or are you just feeling nostalgic? You can create a virtual machine and install MS-DOS or FreeDOS. Do you want to see what Ubuntu looked like a decade ago? You can install Ubuntu 6.06 LTS as a guest operating system. The computer this book was written on always ran the latest versions of Ubuntu during writing, but two virtual machines running Ubuntu 16.04.2 LTS and Windows 10, respectively, helped ensure that all screenshots and instructions were taken from a clean, freshly installed operating system that will match your experiences (see Figure 6-10).

  • You can experiment. Snapshots save your machine’s state so you can revert if things go wrong. Test upgrades or recovery processes. You can build a virtual machine with extra storage, or floppy drives, or two network cards.

  • You can learn. Ever wanted to run an Ubuntu server? You can use a virtual machine to install Ubuntu Server and use your host operating system’s web browser to look up learning and reference material. You can run two virtual machines side by side to communicate. You can write programs and run commands and upgrade operating systems without risking your data or your computer’s stability.

  • Being able to create and destroy virtual computers in seconds is the ultimate power user tool. Whether you set up different virtual machines to handle various tasks or you occasionally create machines to test something before deleting them, the only limit is your imagination.

Summary

There are always tips, tricks, and shortcuts that perform tasks faster or in a more specific manner. Being a power user isn’t about knowing every secret, but learning these features and using them when they help (and ignoring them when they don’t!) is part of the process of becoming a power user. Not everyone will use every single feature or program in this chapter, but choosing the ones that work for you will help you accomplish more with Ubuntu, be more efficient, and achieve more with your computer.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.80.45