Are you having trouble with GPG keys when trying to upgrade to Opera 10 in Debian and Ubuntu? (Or do you want to install it for the first time?)

Opera hasn’t shipped an update of its fast (but not open-source) Web browser from its repository for quite some time, but today Opera 10 has been moved from beta to the main release of the browser, and if you’re using Opera’s repository (as opposed to one maintained by your distro), you might have the same problem I did in Debian or Ubuntu (in my case the 8.04 LTS version):

When trying to update the system, I get a GPG error, and apt (or Aptitude or Synaptic) won’t update the list of packages from Opera’s repository.

Opera has a helpful page on how to add its repository, or Canonical’s for Ubuntu users, to your /etc/apt/sources.list file if you use a Debian-derived distribution such as Ubuntu, or Debian itself. I use both and have been through this twice recently.

Canonical does offer Opera in its “partner” repository — not in the regular “non-free” repository. Debian doesn’t maintain a similar “partner” repository (how “freedom-loving” would that be?).

So Debian users who wish to use the freedom-hating (but Linux-loving) Opera Web browser and wish to use a repository to install and update the program (as opposed to downloading a binary and installing it with dpkg) need to use Opera’s own repository. This same method also works in Ubuntu. You don’t have to use the Canonical “partner” repository. For one reason or another, I thought it might be better to get Opera straight from Opera Software, and that company does have a help page that gets you most of the way toward making it happen.

Unfortunately, there are a couple of critical errors on Opera’s help page, so I’ll go through both adding Opera’s own repository to your /etc/apt/sources.list as well as properly using the command line (and invoking sudo at the right time) to set up the GPG key for that repository so the updates and code can flow properly to your Ubuntu box.

One caveat: If you’re NOT using Ubuntu and are on a Debian box that allows you to su to root, you can avoid the use of sudo at one critical point in the GPG process.

However, I’m a big sudo fan, and I always install it in Debian and use it all the time, preferring never to su to root if I don’t have to.

Here goes …

Adding the Opera’s own repository for its Web browser and installing it on your Debian or Ubuntu system

Before we begin: This tutorial works if you’re using sudo to gain rootly privileges. If you have a Debian system, which allows the use of su instead, you can su to root and forget sudo entirely. But as I say above, I always install sudo in Debian, so this “recipe” works equally well on my Debian and Ubuntu boxes.

Now let’s get to it:

First you need to add the proper repository to /etc/apt/sources.list. Open up a terminal window and at the $ prompt, use GEdit (or your favorite GUI or console editor) to add the following line to the bottom of /etc/apt/sources.list:

To open the file:

$ sudo gedit /etc/apt/sources.list

(type your password when prompted)

When you’re in /etc/apt/sources.list, go to the bottom of the file and, to use Opera’s repository, add this line in either Debian or Ubuntu (Opera maintains this repo for the various Debian branches, but the “lenny” version works great in Ubuntu):
deb http://deb.opera.com/opera lenny non-free

If you are in Ubuntu and wish to use Canonical’s repository, add this line instead:

deb http://archive.canonical.com/ubuntu hardy partner

That’s for users of Ubuntu 8.04 (Hardy). If you’re using 8.10 (Intrepid) or 9.04 (Jaunty), use the appropriate adjective instead of “hardy” in your repo line.

Like I said, I tend to use Opera’s repository, so I entered the “deb.opera.com” line into my sources.list.

Then save the file and close Gedit (or your favorite editor).

Now let’s take care of the GPG keys. In the terminal, do the following lines:

See, it’s that “hidden” sudo in the third line that Opera forgets on its help page.

(If you’re in Debian and have used su to become root, you can forget the final sudo in the third line).

I already had Opera 9 on my box but couldn’t update to Opera 10. My problem was a bad GPG key. After this change I was able to use Aptitude (my preferred choice over plain ol’ apt) to update my box. You could just as easily use GNOME’s Update Manager to swap out Opera 9 for Opera 10.

For me that was these easy lines:

$ sudo aptitude update
$ sudo aptitude upgrade

Or if you’ve never before installed Opera, either use the Synaptic Package Manager to add it, using the search function to find Opera.

But if you’re still at the command line (or as I generally say, “in the console”), you can do it this way:

$ sudo aptitude install opera

Now you should have the Opera 10 Web browser in your menu and ready to run.

I used to need Opera for one of my extremely critical Web-based applications, but the developers of said app recently added Firefox to the list of allowed browsers (previously it was IE-only, which doesn’t exactly help me in Linux and the BSDs, but did allow use of Opera). Now that Firefox is allowed, Opera has been “blacklisted” from the app.

But Opera is still a very nice browser. It’s extremely fast. In marginal hardware, of which I’ve got quite a bit, it can make the difference between a usable system and the other kind.

The “easy” way to install Opera in Ubuntu the GUI way

Did you enjoy that? There’s an easier way, I’ve learned from Ubuntu’s repository page. Basically you can add the “partner” repository in Synaptic and then search for Opera in that same application and add it the “normal,” graphical GNOMEish way. That’s probably a better way to go, but since I did it the “hard” way, I figure you should be allowed to do it that way as well. But again, if you want to use Opera’s own repository, the method above did work for me.

So if you use Ubuntu and want to shun the command line and do it all through the Synaptic Package Manager, do the following:

Check the box next to the line that reads: http://archive.canonical.com/ubuntu hardy partner

Now you should be able to update your sources (click the Reload button in Synaptic) and then search for and add Opera as an application.

OK, that’s a bit easier than my command-line, Opera’s-own-repository method above, but they both work in Ubuntu.

And if, like me, you run into a GPG key problem, you can just run the three GPG-related lines in the example above and get Opera updates flowing from the Norway-based Opera Software company into your Debian or Ubuntu box.

At some point I’ll delve a little deeper into Opera 10 for a review, but at least now I have the app (and the opportunity to do so).