There's a lot of software available for Ubuntu, in addition to that which comes installed out of the box, and most of it is not only free but also easily accessible. Because of this it's possible to suggest that, as far as
File Edit View Jerminal Tabs Help
[email protected]:~/Documents$ Is | grep -i "project"
20O7 project results.ppt
2008figu res-p roj ect.xls
Project Proposal (john).doc
[email protected]:-/Docu«ientss |
Figure 2.6: Piping the output of a command into grep active and experienced Ubuntu users are concerned, software installation is almost as common as any other activity, such as browsing the web. Part of the fun of using Ubuntu is exploring what software is available, and taking a look at offerings provided by new and interesting software projects that spring-up.
Therefore, gaining a good understanding of the software installation subsystem of Ubuntu is vital. Many tips in this book involve adding-in software to bring new functionality to Ubuntu. How software installation and removal is handled under Ubuntu is radically different compared to Windows or Mac OS X, but isn't hard to understand.
To install a program, a Windows user will double-click an installation .exe. Ubuntu is different because software installation is automated— even including download. You literally just choose what you want to install, and sit back while Ubuntu takes care of it.
Virtually all Ubuntu software is open source, and therefore available for anybody to create their own versions of. So the Ubuntu developers take the source code for thousands of software projects and compile it themselves, tweaking it to ensure it works correctly on Ubuntu, and put it
The command-line interprets a space between two words as an indication that a new command follows, or a command-option. The question therefore arises of how to deal with filenames that have spaces in them. A logical continuation of this thought is how to deal with filenames containing characters that bash would otherwise interpret—symbols such as > or |, for example, which are used in redirection and piping respectively.
The easiest solution is to simply enclose the filename in quotation marks (either single quotes or double—it doesn't matter). For example, to open the file <keir text file>.txt in less, I'd type less "<keir text file>.txt".
Another method is to escape each problematic character (including the spaces). This involves using a backslash (\) before the character to tell bash not to interpret it in the usual way. To view the file <keir text file>.txt in this case, I would type less \<keir\ text\ file\>.txt. Normally it's just easier to use quotes around the filename but with a minority of commands you must escape instead.
Ubuntu's graphical applications handle filenames containing spaces and strange characters seamlessly. You don't have to escape or use quotes.
into large publicly accessible repositories (known as repos for short).8 In nearly all cases when you install software, it'll come from these repositories. Manually downloading and installing software is rare, although not unheard of—several tips in this book do just that, in fact.
The second key difference between Ubuntu and other operating systems like Windows and Mac OS X is that Ubuntu lets you install and remove just about everything, including system components that are otherwise invisible but make everything work.
The bits of software that are installed and removed are referred to as packages. Packages are nothing more than program and/or system files bundled together in one file, complete with with scripts (chains of com-
8. Repositories are usually online but not always. The Ubuntu install CD is a small repository containing just what you need to install Ubuntu.
mands) that configure things so that the software works with everything else on the system.
Typically, to install a particular piece of software, it's necessary to install not only the program itself, which is usually provided as a single package, but several other packages containing background system software it needs to work. You might say that software installation is modular. The software you want to install is said to depend on these other packages that provide the system files. As you might be coming to expect, Ubuntu's software install/removal tools automatically take care of installing these dependencies and because of this you will often hear people talk of dependency management when discussing Ubuntu's software management system.
It isn't just about managing the dependencies when software is installed, of course. If you remove some software, you'll be told if that software is depended upon by any other software. If it is, you might see a suggestion that you remove the other software too. The other software might have its own set of dependencies. Sometimes it can be the case that removing a seemingly innocent piece of software can set in motion a cascade where half the system components get removed (although I'm being melodramatic. This is rare. Rarer than it used to be, anyway.)
Dependency management can get fiendishly complicated at times.9 But no worries. Like a good butler, the Ubuntu software subsystem hides all that from you.
Software can be installed or removed both at the command-line, and using a GUI tool called Synaptic. Let's start by taking a look at Synaptic.
Synaptic can be found on the System -> Administration menu. When it starts you'll need to enter your password when prompted because software administration affects the underlying system. See Figure 2.7, on the preceding page, for an example of Synaptic's user interface.
The first thing to do, which you should do always when starting Synap-tic, is to hit the Reload button at the left of the toolbar. This grabs the latest list of files from the repository of software on the server, so you'll have the latest list of software to choose from. The list changes pretty often so this is good practice.
The Synaptic program window is split into three parts. On the left is the package category list. This sorts the packages by what they do. On the top right is the package list—the entire list of available software you can install, including software that's already been installed. On the bottom right is where the description of each package will appear when you select one by clicking on it.
Typically you'll start by searching for the software you need. This can be done two ways. The first is to click on any package in the list in the top right of the screen, so that it's highlighted, and just start typing. Say you wanted to install Epiphany, which is an alternative web browser. Just start typing epiphany. Before you've finished typing, the list will have filtered down to a handful of possible results, and more likely just the one.
9. If the dependency management system breaks, it gets real ugly real fast. This is one argument people use if they object to package management systems, such as that used by Ubuntu. However, the counter-argument is a good one: it never breaks. Unless the user does something stupid, that is.
The second way to search is to hit the Search button, which will open the Search dialog box. This is what I do, because it lets me search not only the package names but also their descriptions. If I was looking for an alternative web browser, for example, I would click Search and then type web browser.
If you want to install a particular software package, click the checkbox that appears on the left alongside it. This will cause a menu to appear, of which one option is usually visible: Mark for installation. As you might expect, this will mark the package so it can be installed, but installation will happen only after you click the Apply button on the main toolbar. This way you can search for and add in several other packages for installation if you wish, before starting the installation process.
Immediately after clicking Mark for Installation you'll be told if the software has dependencies. A dialog box will pop-up asking if you want to "Mark additional required changes", as shown in Figure 2.8. Normally there's not much to see here, and you can click the Mark button. There are only two things to watch out for.
The first is that, along with software to be installed, Synaptic suggests the removal of some software (this will appear under the To be removed heading). This is probably because that software is incompatible with what you're about to install.
There's no easy answer in this situation. You can either go ahead, or you can click the CanceI button and not install the software. In theory you can force through the installation but that would break things and possibly leave the system in an unusable state. Never force, even if you think you know what you're doing. It causes pain.
The second thing to watch out for is if Synaptic wants to install a massive amount of dependency packages. A good example would be if you wanted to install the Konqeuror web browser. This requires most of the KDE desktop sub-system to be installed, and therefore marking Kon-queror for installation also marks 22 other packages for installation. There's no harm installing these packages. The only problem is that they might take a long time to download, and possibly weigh-in at hundreds of megabytes on your hard disk. However, if you have the bandwidth and cavernous storage then this obviously isn't an issue.
Once you've marked the software you want to install, hit the AppIy button on Synaptic's main toolbar. A dialog box will appear summarizing the selection of packages that are to be installed, and informing you of the disk space required. Assuming you're happy with this summary, click the AppIy button in the dialog box. This will then download and subsequently install the package(s). When it's finished another dialog box will appear to tell you so and you can then quit Synaptic, or install more software if you wish.
You might also see some software listed in the summary dialog box under the heading of Unchanged. This is updated versions of software already on your system that Synaptic would like to install. You can mark it for installation by clicking the Mark AII Upgrades button on the toolbar in Synaptic's main program window, but it's perhaps better to let the separate Update Manager program handle that kind of thing automatically. It'll probably pop-up as soon as Synaptic is closed anyway, having heard about all the updates it can install when you initially updated the list of software by clicking the ReIoad button. It's worth noting that only one software installation program can run at one time; you might notice that Update Manager's notification area icon grays out while Synaptic is running because of this.
Some software packages have a little Ubuntu logo alongside their checkboxes in Synaptic. This means the software is officially supported, and will therefore be updated and maintained for the life of that Ubuntu release (up until 2011 in the case of Ubuntu 8.04, for example). If there's no Ubuntu logo alongside, that means the software simply comes from the Debian repositories and might be updated in future, although there's no guarantee. The list of officially supported software is proportionally small compared to the massive list of software in the Debian archives. It's a good idea to should shy away from unsupported software because of the update issue, but few avoid it completely because there's a lot of good software in its ranks. One or two tips in this book advise you install unsupported software, for example.
In Synaptic's main program window, color-coding and icons in the checkbox alongside a package name indicate its status. For example, if the checkbox alongside a package in the package name is dark green then that software is already installed. If you then click the checkbox you can select Mark for Removal, which will remove the software but leave behind its configuration files (useful if you want to install it again in future). Alternatively, you can select Mark for Complete Removal, which will remove both the software and its configuration files.
In a nutshell, that's the basics of software installation using Synaptic. I haven't mentioned filtering search results, or reinstalling packages, or lots of other perhaps less vital things. You'll learn about these as time goes on. One handy tip is to click Help -> Icon Legend so see what the various checkbox graphics mean.
As with all things command-line related, installing software at the command-line is where the real power lies. It can also be quicker than using Synaptic, which makes the user jump through several hoops to do even simple tasks. Therefore mastering command-line software administration is a good skill for any Ubuntu user to have. Several tips in this book rely on command-line software installation.
There are essentially two methods of installing software at the command line: using the APT commands, which automate software download and installation just like Synaptic, or using the dpkg command, if you want to download a software package and install it manually.
In reality, Synaptic is just a front man for the Advanced Packaging Tool (APT) sub-system. It's actually the APT system that manages access to the software repositories, and takes care of package dependencies, and installs or removes stuff. Synaptic just asks it to do things on its behalf and then reports what it says back to you.
The APT system comes with several commands, and often using them is simply quicker than using Synaptic.
The first useful command is apt-get. This handles installation and removal of software from the repository. apt-get install will install software, while apt-get autoremove will uninstall it.
But before you do that, it's always advisable to get the most up to date list from the software repositories. This is the equivalent of hitting the Reload toolbar button in Synaptic. Type the following, remembering that you shouldn't type the opening dollar sign ($): $ sudo apt-get update
You'll notice that we precede the command with sudo. This is because all software management requires root (administrator) powers. There's one exception, as you'll see in a moment: searching.
Back to the apt-get command. The following will install the Abiword word processor: $ sudo apt-get install abiword
APT will look-up the package, see if it has any dependencies, and, if it does, add them to the list of software it intends to install. Then it will ask you to read through what it proposes to do and confirm its suggestions, which you can do by typing (y), for Yes, or [n), for No.
As with Synaptic, sometimes apt-get will need to remove additional software to avoid incompatibilities, and you'll also be told so that you can confirm the choice.
The following will remove Abiword once you've installed it: $ sudo apt-get autoremove abiword
This will remove the original software plus any unused dependencies that were installed alongside it (note that, in this way, apt-get offers a function Synaptic doesn't; Synaptic will simply leave any dependencies in place, regardless of whether they're needed by other applications or not). Bear in mind that other applications you've installed since the original application may use these dependencies, in which case they won't be removed. If for any reason you want to remove just the original software package and nothing else, use apt-get remove in place of apt-get autoremove.
Searching for files is just as easy but a different command is used. Let's say you'd heard about Epiphany web browser from a friend, but wanted to find out its actual package name so you could specify it for installation using apt-get. You need to use the apt-cache command, as follows:
$ apt-cache search epiphany
A list of results will appear, as shown in Figure 2.9, on the following page. The package name is listed on the left, with a brief description of the package following. Included in the results because they also contain the word "epiphany", are several library packages that Epiphany needs to work. These will probably be added as dependencies should we try to install it using apt-get. Also included is a video game called Epiphany, which apparently is a clone of Boulder Dash. However, it should be obvious that the one we want is epiphany-browser.
If we want more information about the package (such as its full description, as appears in Synaptic) we can use the show option: $ apt-cache show epiphany-browser
A lot of information is returned and it tends to flow off the screen so we can pipe it into the less text reader:
$ apt-cache show epiphany-browser | less
Every now and again you might need to download a software package and manually install it. This happens if the software isn't in the Ubuntu repositories, usually because it's very new, or because the Ubuntu head-honchos have decided not to offer it.
If the software isn't in the official software repositories, you may well find that the developers behind the software provide their own APT
Figure 2.9: Searching for software using apt-cache repository that you can add to your system. This is discussed in Section 2.4, Adding new software repositories, on page 48, and is certainly very handy because it means, once the repository has been added, you can use the APT tools and/or Synaptic to install the software.
However, although developers being kind enough to offer their own APT repositories is becoming more and more common, it isn't guaranteed. So let's assume that you have no choice but to download the package and install it manually. This is the case with several tips in this book.
First, let's talk about what you actually need to download. Ubuntu software packages all have the file extension .deb. This stands for Debian, and is a legacy of Ubuntu's history.
Ideally you should try and download not only the .deb package created for Ubuntu, but also for your version of Ubuntu (ie 8.04 "Hardy Heron", or 6.06 "Dapper Drake"). This is because the package will be designed to work within the system configuration of your version of Ubuntu, and will also be aware of what dependencies it needs. It will then inform you of its dependency needs when you try to install it. Package names and contents vary between Linux distributions, and even between different versions of Ubuntu. So this can be very handy.
Using aptitude to install packages at the command-line
If you browse any of the Ubuntu community websites, you might find that some people ignore apt-get and use aptitude instead. aptitude is used in exactly the same way, with the same commands as apt-get (for example, to install Abiword, you would type sudo aptitude install abiword). The difference is that, alongside updating the system log of installed software, it keeps its own log of installations. This means that it can be better at handling removal of software because it is better at tracking dependencies. In addition, packages sometimes come with a list of recommended but non-essential extras, and aptitude will automatically add-in these to the installation tally, something apt-get can't do. Furthermore, when run without options or arguments, aptitude will start in a semi-GUI mode, with a menu system that lets you administrate software.
Whether you use apt-get or aptitude is down to personal preference. apt-get has one advantage, which is that it will always be available on any system that is a Debian derivative (for example, Xandros, Mepis and Freespire). It isn't guaranteed that aptitude will be installed. For this reason along you should at least become competent at using apt-get.
If you can't find a specific Ubuntu package, look for one that works under the most recent release of Debian. Ideally you want the release of the package made for Debian Sid (Ubuntu is based on Debian Sid10), but also look out for releases made for Debian Lenny.
Download the package to your /home folder and be careful to avoid allowing Firefox to open it automatically with GDebi Package Installer.
Installing the package is then simply a matter of typing the following: $ sudo dpkg -i filename.deb
Obviously, you should replace filename.deb with the filename of the package you downloaded.
10. Every version of Ubuntu uses as its base the perennial testing release of Debian Linux, known as Debian Unstable or Debian Sid. All Debian releases are named after characters in the movie Toy Story (you might remember that the character of Sid was Andy's neighbor in Toy Story, and was pretty, well, unstable!).
If you're lucky, everything should work fine. The package will install without error. More likely, however, you'll be told you're missing dependencies. They will be named, and so it's simply a matter of installing them.
Until you can install the dependencies, you have a problem on your hands. dpkg is nowhere near as clever as APT, and installs the package even if the dependencies aren't met. It just doesn't configure the software for use because of the missing dependencies, so you can't start using it.
This leaves the software installation system in something of a state, because it now has a "broken package." You'll be warned about this the next time you run Synaptic, for example, as shown in Figure 2.10, on the following page. Synaptic will still let you attempt to install software, however, and if the missing dependency package(s) are available in the repository, Synaptic will automatically add it to the list next time you try to install anything. Alternatively, as Synaptic suggests in its error message, you can click the FiIter button in the bottom left and then click the Broken link to see what packages are causing the problem and try to enact a manual fix (including, if the dependencies simply aren't available, uninstalling the problematic package).
apt-get takes a harder line. It will refuse to work until the broken package with its missing dependencies are sorted out. It will suggest the dependency, however, and also suggest you type apt-get -f instaII, which will attempt to grab any missing dependencies to fix the problem.
dpkg can also remove software too. Say we had installed Epiphany. This will do the trick of removing it:
$ sudo dpkg -r epiphany-browser
You'll note that, in this case, we don't specify the entire package filename. We refer to the package how it's referred to by the system—within Synaptic, and so on. Usually this is just the first part of the package filename, sans the stuff afterwards, which informs us which hardware platform it works on.
If there are dependency issues (something else depends on what you're trying to remove) then dpkg will tell you and will refuse to remove the file. You can force through the removal but that's an extremely efficient recipe for disaster. Note that, even though a package is manually installed, it will still show up in Synaptic, so can be removed using Synaptic in the usual way (or via apt-get autoremove). Using Synaptic
File Edit- Package; ssttjnsíi
Synaptic Package Manager ielp
■Reload M ark All Upgrades
Apply 1 Properties 1 Search
Vbu have 1 broken package on your system
" Use the "Broken" filter to locate it.
IPeading stats nfrir-sfTmr
Figure 2.10: Synaptic telling of a broken package is infinitely preferable compared to using the basic and rather literal dpkg.
In actual fact, however, dpkg can do just about anything you'd ever need to individual packages. It's one of the most powerful administration tools on your system. However, the potential for damage is high, and you'd be damaging a very important component of your system. It's always best to stick to Synaptic or apt-get if you possibly can. That way dependencies will be taken care of automatically and the world will be a happier place.
Adding new software repositories
It might sometimes be necessary to add third-party software repositories to install software that isn't supplied by the Ubuntu project. A good example is installing the Skype VoIP package, as explained in Tip 266, on page 304. The people behind Skype provide their own software repository for Ubuntu users. The advantage of signing-up to a third-party repository rather than installing by hand using dpkg is that you can then use Synaptic to install the software (it will appear alongside all the other software in the list). Because of this, if the software requires any dependencies, they will be taken care of automatically. Additionally, if a newer version of the software is released, you'll be automatically told about it alongside all the other updated software presented regularly by Update Manager.
Adding a third-party repository isn't hard. It takes the form of an address— usually referred to as either an APT line or simply repository address11— which usually looks something like the following (this example is again taken from Tip 266, on page 304, which explains how to install Skype): deb http://download.skype.com/linux/repos/debian/ stable non-free
To add this to the system, start the Software Sources program (System ^ Administration) and then select the Third-Party Software tab. Then click the Add button and, in the APT Line text field, enter the address, as shown in Figure 2.11, on the next page. Then click the Add Source button. Upon clicking Close in the parent dialog, you'll be told that the list of software needs to be refreshed. Choose to do so.
What Software Sources actually does is update the /etc/apt/sources.list configuration file. You could just as easily open this in a text editor and add the line to the bottom manually. But using Software Sources stops you making a mistake editing a file without which the software subsystem wouldn't work, so is perhaps a better choice.
Wherever possible, in addition to adding the repository you should also import the repository's key file, which Ubuntu can use to work-out if packages are authentic. Some packages are digitally signed, which is a method of protecting the user from fake packages that contain malware. If you should try and install a package that isn't signed, Synaptic or APT will throw-up a warning (although you'll still be able to install).
All official Ubuntu packages are protected in this way, and Ubuntu is setup with the relevant key files during initial installation. If the third-party repository uses signing (not all do), a link will probably be provided to the key file on the same page that lists the APT address. Download the key file to your system and, in Software Sources, click
11. If, as described in some tips in the book, you install software from the Launchpad.net website, which is a repository for up-and-coming software projects, the APT repository address might be referred to as the Personal Package Archive, or PPA.
Figure 2.11: Adding a new repository using Software Sources the Authentication tab. Then click the Import Key File button and navigate to what you downloaded.
Perhaps it goes without saying that key files can be faked, just like packages. You should ensure you download the key file from the official website of the application in question, and not from a mirror site.
Was this article helpful?