Showing posts with label installing. Show all posts
Showing posts with label installing. Show all posts

Thursday, 24 January 2008

apt-cache

We've touched on installing packages from the command line, but to do so you have to know the name of the package you want to install. Sometimes you may know the kind of thing you want to install (such as a web browser or IM client) but not have any idea what different choices you have. Other times you may have some idea of the name of the package but not know exactly what it's called.

Now, you could use the package manager for this, but why go to the effort of starting up a graphical application that will take ages to work when the command line can do it quicker and more simply for you? Since Apt is the tool used by all these applications anyway, you might as well use it directly and get the job done quicker and more easily?

Apt has more than just apt-get up its sleeve. The apt-cache command allows you to search through both descriptions and package names, allowing you to look for a specific application, or for a type of application. This makes it a powerful and flexible tool.

First of all, let's run the following:
sudo apt-get update
That's just to make sure that you have the latest package lists from the repositories. Now, let's search for the Epiphany web browser:
matthew@matthew-laptop:~$ apt-cache search epiphany
epiphany - clone of Boulder Dash game
epiphany-data - required maps for epiphany game
epiphany-extension-gwget - Gwget extension for Epiphany web browser
libmozjs-dev - Development files for the Mozilla SpiderMonkey JavaScript library
libmozjs0d - The Mozilla SpiderMonkey JavaScript library
libmozjs0d-dbg - Development files for the Mozilla SpiderMonkey JavaScript library
peercast-handlers - P2P audio and video streaming handlers
flashplugin-nonfree - Adobe Flash Player plugin installer
epiphany-browser - Intuitive GNOME web browser
epiphany-browser-dev - Development files for Epiphany web browser
epiphany-extensions - Extensions for Epiphany web browser
matthew@matthew-laptop:~$
Apt-cache displays a list of all packages including the word "epiphany". There's no need for sudo as apt-cache makes no changes to your system. Similarly, if you wanted to search for a web browser, you could input the following:
apt-cache search "web browser"
In this example, as I want to search specifically for the term "web browser" rather than the two terms "web" and "browser", I've put them in quotes. That limits apt-cache to displaying applications which have the term "web browser" in their name or description, rather than either of the words individually, allowing you to narrow down the search parameters somewhat.

You can also use apt-cache to find other information about a package. For example, try this:
apt-cache depends epiphany-browser
will display a list of the dependencies required to run the Epiphany web browser. And this:
apt-cache show epiphany-browser
allows you to read the description for a package file.

In combination, apt-get and apt-cache allow you to install and remove packages, search for them and find out information about them. It's quicker and often easier to install from the command line once you get used to the tools. I hardly ever use a graphical application to install new software now - I just find it so much easier to use the command line.

If you were concerned about having to use the command line, hopefully these lessons have made you feel better about it. The best way to learn about the command line is to use it, and I hope you'll try to get into the habit of installing new packages from the command line, rather than going to the bother of starting up a resource-hungry graphical installer.

Saturday, 19 January 2008

Metapackages

What is a metapackage? Basically, there are some packages which, although they aren't dependent on each other to function, logically belong together. For instance, the different desktops for Ubuntu, Kubuntu and Xubuntu are available as metapackages, each consisting of all the applications that make up the desktop, as well as the desktop itself. The Ubuntu one includes the Firefox web browser, Pidgin IM client and so on.

In theory, it is possible to install all of these separately, but this would be rather tiresome - in Synaptic, you'd have to pick out all of the applications individually and select them to be installed, on the command line you'd have to type out the name of every package. Apt-get would only pick up on the dependencies, leaving you to select everything else - you'd quickly lose the will to live!

That's why metapackages exist. They make your life easier by allowing you to install one package that contains all the other packages. This way, you can easily install lots of packages which are logically grouped in one go.

Don't worry too much if you're struggling to understand this at the moment. We'll be using several metapackages in my next few posts, as they allow you to solve a number of common problems that newbies have with Linux, and I'm sure all will become clear at that point!

Wednesday, 16 January 2008

dpkg

Although the Ubuntu repositories are very comprehensive, from time to time you may want to install something which isn't available from them (such as a more recent version of an application which has a feature you want). As mentioned previously, there are additional repositories you can add which may have these, but not often. More often, you'll have to download and install a .deb package yourself.

Now, apt-get is no use for this, as it only works with the repositories. But dpkg can be used to install any .deb package you wish.

Let's try it out. One of the best resources for finding .deb packages not yet in Ubuntu is GetDeb. This site has .deb packages for many applications not yet in Ubuntu, and others more up-to-date than those in the current version of Ubuntu. Follow this link to get to the page for Micropolis. Look familiar? It's the original Sim City, which has been open-sourced and is now available free for Linux! Click on the link for your version (32 or 64 bit), and download it to your desktop or home directory.

Both Ubuntu and Kubuntu now have graphical tools to install the package if you just double-click on it. But these tend to be quite slow and unwieldy, so let's use the command line. Open Konsole or Terminal, whichever you have installed. Now, you'll need to know the exact name of the package to install it. What I often do is right-click on it, select rename, then Ctrl-C to copy the name of the package to the clipboard. Then press enter to leave the name as it is - don't change it!

All you need to do now is enter the following:
sudo dpkg -i micropolis_0.0.20080114-1~getdeb1_i386.deb


And it will install it for you!

If you got fed up with it, you can remove it with the following command:
sudo dpkg -r micropolis


Note that to uninstall it you don't need the full name, it now has a record of the package and doesn't need all the same information.

Now, what about dependencies? When compared to apt-get, dpkg is not as sophisticated. All it does is install a package as it's told to, it doesn't pay attention to any dependencies. As a result, if you download and install something, you may get a message saying something like this:
matthew@matthew-laptop:~$ sudo dpkg -i pidgin_2.3.1-1~getdeb1_i386.deb pidgin-data_2.3.1-1~getdeb1_all.deb libpurple0_2.3.1-1~getdeb1_i386.deb
Selecting previously deselected package pidgin.
(Reading database ... 124149 files and directories currently installed.)
Unpacking pidgin (from pidgin_2.3.1-1~getdeb1_i386.deb) ...
Selecting previously deselected package pidgin-data.
Unpacking pidgin-data (from pidgin-data_2.3.1-1~getdeb1_all.deb) ...
Selecting previously deselected package libpurple0.
Unpacking libpurple0 (from libpurple0_2.3.1-1~getdeb1_i386.deb) ...
dpkg: dependency problems prevent configuration of pidgin:
pidgin depends on liblaunchpad-integration0 (>= 0.0patch26); however:
Package liblaunchpad-integration0 is not installed.
dpkg: error processing pidgin (--install):
dependency problems - leaving unconfigured
Setting up pidgin-data (1:2.3.1-1~getdeb1) ...

dpkg: dependency problems prevent configuration of libpurple0:
libpurple0 depends on libnm-glib0; however:
Package libnm-glib0 is not installed.
libpurple0 depends on libzephyr3; however:
Package libzephyr3 is not installed.
dpkg: error processing libpurple0 (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
pidgin
libpurple0
This is for the Pidgin IM client, which I've downloaded and installed a new version of from GetDeb. Basically, this means that there are outstanding dependencies which need to be resolved before you can use Pidgin. But here's where apt-get comes to the rescue. You see, apt-get can tell what packages are outstanding, enabling it to resolve the dependencies for you! Just enter the following command:
sudo apt-get -f install
Now, this basically says to apt-get "Resolve any outstanding dependencies", and it will do it with no further input from you.

In this way, you can get software that isn't yet available in the Ubuntu repositories quickly and easily. However, be aware that this does pose a potential security risk, so try to only get .deb packages from websites you trust. Also, packages that aren't yet in the official repositories may not be as stable as ones that are, so you take a certain amount of risk in terms of reliability.

Tuesday, 15 January 2008

apt-get

Installing software is a piece of cake in Ubuntu. For applications, you can just open Add/Remove Applications, select what you want to install and then click on a few buttons to install it. Couldn't be simpler.

For more complex things, you can use Synaptic (or Adept in Kubuntu). This allows you to search through the packages using search tools which make it easy to narrow down the choices to what you want. Synaptic doesn't just give you a list of applications, it gives you absolutely every single utility available in the repositories, making it an extremely powerful tool. Many things are available from there that you wouldn't be able to get using Add/Remove. For instance, you can use Synaptic to install the Kubuntu desktop in an Ubuntu install.

However, both Add/Remove Applications and Synaptic are just graphical front-ends to make it easy for new users to get started. The real work is done by apt-get, which you can access yourself from the command line if you wish. This has lots of advantages:
  • It's faster - since the computer doesn't have to expend a lot of processing power making it look nice, it can get on with installing it quicker.
  • It's easier to install more than one thing at once - you can just specify the names of all the software packages you wish to install.
  • And of course, you get more kudos for installing from the command line!
First of all, a quick lesson. The software available for Ubuntu is kept in the repositories. Think of them as online software libraries, the contents of which are free for you to download and install. There are other repositories available (for example, Google have their own Linux repositories , from which you can download and install things like Picasa or Google Desktop), but the main ones that come preconfigured with Ubuntu are:
  • main
  • restricted
  • universe
  • multiverse
I won't explain what each one is now, we'll come to that in the future. For now, you just need to know that they are there. The software for Ubuntu comes in packages. Ubuntu uses a package format called deb packages - if you download one from somewhere other than the repositories to install it manually, you'll notice it has the .deb suffix.

Any package may depend on other programs to function - this is known as a dependency. For instance, if you install a program written in the Java programming language, you need to have the Java Runtime Environment installed. In Windows, this issue is solved by the installer including all of the dependencies within the download - so if you download Firefox, everything you need is included in that installer. This has the disadvantage that the download can be bigger than it needs to be.

Ubuntu takes a different approach. Each package consists of only the program itself, but it includes a list of all the dependencies. apt-get can use this to determine what dependencies for a package aren't yet installed, and then automatically download and install them. This means you don't have to download any more than necessary, saving you time.

That's the theory part. How does it work in practice? I'll walk you through a few basic commands. Open the command line (Terminal in Ubuntu, Konsole in Kubuntu), enter the following and press Enter. Remember, as apt-get makes changes to your system, you'll need to preface it with the sudo command each time, and you'll be prompted for your password - just use the same one you use to log in:
sudo apt-get update
This command updates your system's record of the most recent versions of packages, to make sure it's up to date. So it's good practice to run this before you install anything, in order to make sure you get the most recent version from the repositories.

What it DOESN'T do is upgrade the packages you already have installed to the latest versions. For that you need this:
sudo apt-get upgrade
If you perform these two commands regularly (say, once a week or so), you'll be able to keep up with the latest versions of everything you have installed. Unlike in Windows, you don't have to open an application and then discover it's found a more recent version, you can do it all from the same place! Don't you think that's more convenient?

Installing is easy. For instance, say you want to install the strategy game Singularity. Just enter the following on the command line:
sudo apt-get install singularity
You'll be prompted for your password. Then take a look at the resulting message:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
python-pygame singularity-data
Suggested packages:
timidity
The following NEW packages will be installed
python-pygame singularity singularity-data
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1201kB of archives.
After unpacking 3457kB of additional disk space will be used.
Do you want to continue [Y/n]?
Don't worry if yours looks a bit different to this - you may have different things installed. Notice the line saying "The following extra packages will be installed: python-pygame singularity-data". These are dependencies that Singularity relies on to work, and apt-get has picked up on that.

Now, press Y and Enter to continue. apt-get will download and install everything you need without further need for you to do anything.

There, that wasn't hard, was it? Suppose you get fed up of Singularity and want to uninstall it. Just type the following:
sudo apt-get remove singularity
and again follow the on-screen instructions. Note that when uninstalling, apt-get doesn't automatically remove dependencies that aren't required any more. If you want to get rid of these, you can use the following command:
sudo apt-get autoremove
That's it! Now you can install anything you want from the Ubuntu repositories using the command line. You do need to know the name of the package you want to install or remove, but we'll cover how to discover that later.