Gnome 3: An Alternative to Unity in Ubuntu 11.10

My wife has got a Sony Vaio netbook, which we bought a year ago. The whole point was to get a lightweight laptop for Internet access, e-mail and documents, so no development VMs or gaming station. The operating system chosen was Ubuntu, at that time it shipped with Gnome.

Ubuntu 11.10 Gnome 3

However, due to some (relatively) recent updates to Ubuntu (as of version 11.04) it ships with Unity, and as of 11.10, they stopped shipping Gnome. I think Unity is good if you’re running an 8-core station with a good graphics card, but from what I heard, Unity was designed for tablets and netbooks, and it looks like somebody forgot that tablets and netbooks don’t have the horsepower of desktop workstations.

After months struggling with Unity on my wife’s netbook, it only became worse. It started freezing several times a week (that’s a lot for Linux) and it took minutes (that’s a lot for Linux) to boot up. I thought of wiping the whole thing and starting clean with Ubuntu 10.11, but then I decided to give it another chance, by installing Gnome 3.

sudo apt-get install gnome-shell

Which actually saved me from the headaches of having to reinstall a bunch of software, backup a bunch of documents, photos and videos. Gnome 3, together with some old software cleanup, gave our netbook a new life. After a reboot I was able to log into a Gnome session (as seen from the screenshot above) and everything was literally flying! Hope this lasts for at least a year, hat tip to

I can’t say I’m really loving Gnome 3, and Unity was okay from the user interface and experience point of view, but when your system becomes slow because of a desktop manager, you’ll have to switch or upgrade, no matter how funky the UI is :)

Have you had trouble with performance and Unity in Ubuntu Linux? What was your solution? I read a few forums where many people were looking to switch to other Linux distributions, what’s your take on that?

Thanks for stopping by and subscribing!

Sync Time and Date in Ubuntu Linux

Quick tip! If you’re using virtual machines to develop and test your web applications, you probably use the “save state/snapshot” feature instead of turning it off and on every time. I noticed after a while that my time was out of sync (a few weeks late) which caused a bunch of problems. Luckily, I found this simple command:

sudo ntpdate

It will sync your time with the Ubuntu Time server. You can even add a cron entry as suggested by this article. To display the current time and date, simply type date. Hope this helps :)

Ubuntu 11.10 Wireless on Sony Vaio with RT3090

Updated my Sony Vaio VPCM12M1R netbook to Ubuntu 11.10. The update went quite smooth although wireless immediately stopped working. Well it didn’t quite work with Ubuntu 10.10 either but the RT3090 package fixed it last time. Luckily I didn’t remove the package and was lucky to get things working on 11.10 simply by:

sudo dpkg -i rt3090-dkms_2.3.1.3-0ubuntu0~ppa1_all.deb

And obviously rebooting the netbook. Everything’s back to normal now so yeah, yet another successful Ubuntu upgrade. Loving the changes to Unity in 11.10!

VirtualBox and NFS for Web Development

If you’re using VirtualBox for web development and sync data between the host and guest VMs using folder sharing via Guest Additions, you might have noticed that VirtualBox is not too good ad syncing files and some of them tend to get lost too.

Here’s a good tutorial on Setting Up NFS in Ubuntu which turned out to be a great alternative, works crazy fast, no permissions issue, syncs very well and easy to snapshot too!

Regex Replace in MySQL or lib_mysqludf_preg in Ubuntu Linux

I’ve been working a lot with MySQL lately, especially after the major theme and plugin upgrades on my blog. I was dealing with a bunch of content issues like redundant shortcodes and post meta, URL changes, images directories and more.

One simple solution would be to grab the database dump, perform various search and replace operations and then feed it back in, and my goal was to do that without data loss, without going offline, without sending files back and forth but mainly for learning purposes.

I found a UDF for MySQL called lib_mysqludf_preg and here’s how I got it to run on Ubuntu 11.04, somewhere in a temporary directory:

sudo apt-get install libpcre3-dev libmysqlclient-dev
tar -xf lib_mysqludf_preg-1.0.1.tar.gz
cd lib_mysqludf_preg-1.0.1
sudo ./configure
sudo make install
sudo service mysql restart

So, install some libraries upon which the UDF may depend, download the UDF archive, extract it, browse to what has been extracted, configure, install and restart MySQL (just in case.) If you’re reading this and it’s not 2011, make sure you get the latest version and read the release notes too.

At this point the UDF library is installed but the functions are not available yet, so log in to your MySQL command line, preferably as root and create your new preg_replace function like this:


Voila! And here’s how I removed a shortcode from all posts and pages:

UPDATE wp_posts
  SET post_content = PREG_REPLACE('/[my_shortcode*?.*?]/', '', post_content)
  WHERE post_content LIKE '%[my_shortcode%';

Make sure you backup your database first though before doing any of this. I did! But everything went fine. My next goal is to get the shortcode provided by a syntax highlighting plugin replaced with a <pre> tag. Hopefully I won’t break anything so good luck to me and thank you so much for stopping by!

Lesson Learned: Backup Before Upgrading

Friday started with off quite crazy with a surprise from my web hosting server. I don’t really know why but I decided to run an apt-get upgrade last night and everything seemed fine until this morning when I was unable to log back on via SSH. So what did I do? Reboot, obviously and it broke everything. Ping was lost, services are down, websites not working, oh my!

I know my web hosting provider wouldn’t help much since I’m renting a virtual private server with root access which comes with a lot of responsibility, besides I was quite sure I’d handle it faster than I would have opened a support request and described the details, and I did!

Luckily I was able to use the Change OS feature and grabbed Ubuntu 11.04 which was installed within 20 minutes with all my old files in the /old directory. The rest was up to my typing speed — install necessary software, copy the old MySQL databases, restore the users, set up nginx and php-fpm and voila. I was back online. Approximate downtime: 45 minutes.

Lesson learned: backup your full VPS container before upgrading. Thank you Media Temple for providing the freedom to break things and the tools to fix them :)

An Almost Smooth Upgrade to Ubuntu Linux 11.04

Right, we all heard it! Ubuntu 11.04 is out, with the new Unity bundled. I was excited to hear the news and I rushed to run the upgrade on my PC at work, which luckily has an Nvidia graphics card. I can’t believe the upgrade took so long (around two hours) but in the end, seems like it was worthed.

Welcome to Unity, thought I.. Yeah, it was nice and shiny, smooth and all y’know, looked like Mac OS. I got tired of it after a few hours of usage, but promised myself I would ride it for a couple of weeks before switching back to the good old interface.

Together with a bunch of other software upgrades, came Firefox 4 and for some reason became the default browser without ever asking me! Yeah, nice.. but okay, where’s my Chromium? And Chromium keeps asking me whether to make it my default web browser every time I launch it, although I said “Yes” like a bizillion times.. Oh well, nothing’s perfect in the open source world ;) But wait, there’s more! I loved the upgrade I did at the office so much that I decided to carry it out on my home PC as well, so I did! Unfortunately, I did.

I got an ATI Radeon graphics card, which worked very well in versions 10.04 and 10.10, had all the desktop effects and 3d stuff, everything was working like a charm! So after my upgrade to Ubuntu 11.04 I got the blank screen a couple of times, and the whole interface was lagging so bad, that I had to turn off all desktop effects including Unity, and actually switch back to the old desktop interface, although that didn’t help much either.

Anyhow, the usual bundle is still working: PHP, MySQL, Python, Django, Apache and Nginx and all the relevant. I’m thinking to upgrade my Ubuntu Server to the latest, but I guess I can wait ;)

So the bottom line here is — there’s always going to be new stuff and we’ll just have to adapt to it, this applies to Unity and the fact that we’re used to seeing our launched applications in a “taskbar” at the bottom of the screen. And don’t upgrade to Ubuntu 11.04 just yet, if you’ve got an ATI card, unless you find somebody who successfully did ;) Cheers!

Update: If you’re running Unity on a different theme than the default, it looks and feels aweful, the window control buttons at the top left are awkward, so if you’re experiencing this go to Appearance and change your theme to Ambiance (I guess).

How To Create a Remote Shared Git Repository

So Github doesn’t work for you? This article is about setting up a private, remote and shared Git repository for you and your team. I’m using Ubuntu 10.10 and 10.04, as well as Fedora Linux (assuming you replace apt-get with yum), anyhow this should work on all other distros with minor modifications.

I’m not going to tell you what Git is, and I’m not going to teach you how to use it. What I will do is guide you through the steps of setting up a Git repository on your VPS and giving you and your team access to that repository over SSH. You have to be familiar with the Git command-line client, so don’t come back and comment if you can’t get it right using TortoiseGit or whatsoever. So, without further ado.

Step 1: Preparation & Accounts Setup

This is one step you wouldn’t like to miss when setting up new repositories. You have to figure out a plan of what you want to achieve and do some initial setup on your VPS (let’s call this the Git server) and your local machines.

Let’s keep it simple for this tutorial — we’ve got small development team: John, Andrew and Robert; and we’ve got a project for which we’d like a git repo. So first of all make sure that john, andrew and robert have SSH access to the Git server. Let’s also keep them in a group called developers — this is the group who’s members will have read and write access to the contents of the repository.

$ sudo groupadd developers
$ sudo useradd -G developers -d /home/john -m -s /bin/bash john
$ sudo useradd -G developers -d /home/andrew -m -s /bin/bash andrew
$ sudo useradd -G developers -d /home/robert -m -s /bin/bash robert

This will create the three users and add them to the developers group. Go ahead and set some initial passwords for your team mates:

$ sudo passwd john
$ sudo passwd andrew
$ sudo passwd robert

And make sure that they can now login to your VPS over the SSH protocol.

Connecting to the Git Server Without a Password

The next step is optional, but really helps you save quite some time. I’m talking about SSH auto-logins, these will prevent the Git server from asking John, Andrew and Robert their passwords every time they’d like to push or pull something. I listed below the code for only John, so you should repeat the same for everybody else on the team. Lines that begin with the hash symbol # are either comments or command line output, you don’t have to type them.

So, get on John’s computer and start by browsing to the .ssh directory and creating an RSA keypair. More about RSA keys in Wikipedia.

$ cd ~/.ssh
$ ssh-keygen -t rsa -C ""
# Generating public/private rsa key pair.
# (text omitted)
# Your public key has been saved in /home/john/.ssh/

Great! Now let’s see the contents of the public key, should look something like the following

$ cat
# ssh-rsa AAAAb4kzaC1 (text omitted) 86n3iEEQ78cPVazr

Now what you have to do is copy the contents of the created file to your clipboard, we’ll have to write it to a file on our Git server. Start by logging on to the Git server as john (assuming it’s, proceed to the user’s .ssh directory and paste your public key into a file called authorized_keys (create it if it doesn’t exist). Save the file and close it, check that the contents have been written to the file and finally disconnect from the Git server.

$ ssh
# Password: ...
$ cd ~/.ssh
$ vi authorized_keys
$ cat authorized_keys
# ssh-rsa AAAAb4kzaC1 (text omitted) 86n3iEEQ78cPVazr
$ exit

If you’ve done everything right, you should now be able to log on to the Git server from John’s computer without having to input a password:

$ ssh
# Linux 2.6.18-028stab069.5 #1 SMP Tue May 18 17:26:16 MSD 2010 x86_64 GNU/Linux

Repeat this for Andrew and Robert, then proceed to the next step.

Step 2: Setting Up a Shared Git Repository

This step should be done by somebody who has sudo access to the server or the root user himself. The latter is more dangerous, although saves you from typing sudo every time ;)

So, let’s assume there’s manager user account with sudo access, and the /home/manager home directory. We’ll create our Git repositories there, the manager will own them while the developers will have read and write access. Start by creating a directory called repositories and another one inside called project.git which will host our first project. Initiate a bare repository with the shared flag inside the project.git directory and then change the group of all the files and directories to developers:

$ cd ~
$ mkdir -p repositories/project.git
$ cd repositories/project.git
$ git init --bare --shared=group
# Initialized empty shared Git repository in repositories/project.git/
$ ls
# branches  config  description  HEAD  hooks  info  objects  refs

Being in the project.git directory use sudo to run the chgrp command to change the group of all the files. Use the -R flag to run this recursively:

$ sudo chgrp -R developers .
$ ls -l
# drwxrwsr-x 2 manager developers 4096 2011-01-19 13:38 branches
# -rw-rw-r-- 1 manager developers  126 2011-01-19 13:38 config
# (text omitted)

Okay, so now all your team mates have read and write access to your repository since they’re all in the developers group. Let’s proceed with setting up symbolic links and cloning the repository to the crew to finally start working.

Step 3: Accessing the Shared Git Repository

As mentioned earlier, everybody in the developers group has read and write access to the project.git repository, and yes, they can go ahead and clone it from where it is right now, i.e. repositories/project.git in the manager’s home directory. Now to make it more convenient, let’s set up symbolic links for all our developers to point to the repository, and later see how they can easily access it from their local machines.

$ sudo ln -s /home/manager/repositories/project.git/ /home/john/
$ sudo ln -s /home/manager/repositories/project.git/ /home/andrew/
$ sudo ln -s /home/manager/repositories/project.git/ /home/robert/

Done, so now John, Andrew and Robert can access the repository without having to move away from their home directories. Now let’s get back to John’s (local) computer and try to clone the project into John’s work directory:

$ mkdir -p ~/work/project/
$ cd ~/work/project/
$ git clone .
# Initialized empty Git repository in ~/work/project/.git/

Let’s go ahead and add a readme file to the list, commit and push it to our server:

$ echo "Hello" > readme.txt
$ git add readme.txt
$ git commit -m "Adding a readme file"
$ git push origin master
# Commit messages ...

So if you’ve reached this step and successfully pushed your first commit to your remote Git server, you have done everything right, congratulations! You can now go ahead and clone the project for Andrew and Robert, I’m pretty sure they can’t wait to start pushing and pulling ;)

One more tip, suppose your username is john, you’re cloning a git repository from, and your username on is john as well, you can omit typing john@ when cloning, so it’s simply:

$ git clone .

This can save you some time if you’re working on several projects and have new ones every day. If your usernames don’t match, you have to prefix the server host with your username followed by the @ symbol. This is more of an SSH trick and not really related to Git, but it’s a good practice to work with Git projects over SSH.


I know there are quite a lot of Git tutorials out there, but what I really wanted to show here is the fact that you can actually save some money. That’s right, save money.

I’ve been working with freelancers and small tech companies all over the world, and yes, everybody simply loves Github. In fact I love it too, but public repositories are not always a solution for some of us. We sometimes work on commercial projects, secret and NDA’yed ones. We sometimes have ideas of our own that we wouldn’t like to share with the rest.

There are private repositories on Github, but they start from $7/mo and you’ll have to get the $12 plan in order to have more than one collaborator, which gives you 10 projects. Yes, hosted is good, you get security and everything, an awesome control panel, issue tracking and much more. But! Sometimes you just don’t care!

Sometimes you’re already running a $30/mo VPS with some hosting company, so why pay more for Git hosting? Right, it may not be too easy running the steps above at first, but once you get used to them, you’ll be init’ing, cloning, pulling and pushing Git repos like crazy ;)

Thanks so much for reading, and of course sharing. Feel free to bug me with questions via the comments section. Cheers!

Installing Python 2.5 on Ubuntu Linux 10.10

If you’ve been working on App Engine and you’ve noticed that some stuff works on your development server but not on your production, it may be related to the different versions of Python. Latest linux builds including Ubuntu 10.04 and 10.10 come with Python 2.6 pre-installed, but Google App Engine still runs Python 2.5 (an issue has been created to add Python 2.6 support, make sure you vote that up).

Their roadmap mentions nothing about upgrading. So in order to make your development server look more like your production servers, you’ll have to get Python 2.5, which is not that trivial at first.

So, Felix Krull has published an archive of new and old Python packages, so let’s use that source to get Python 2.5 running on a new Ubuntu box:

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.5

Yup, that was easy! Let’s now see if both Python 2.5 and Python 2.6 are available:

$ python2.5
Python 2.5.5 (r255:77872, Sep 14 2010, 15:51:01)

$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)

All done! Oh and don’t forget to launch your App Engine development server using python2.5 (installing it is not enough):

$ python2.5 .

As a bonus to this post, I’d like to share with you my way of working with App Engine, not in terms of code, but in terms of libraries organization. If you’re writing code for App Engine you’re probably working on more than one project at a time, hence you’ll need to use the SDK more than once.

So instead of copying it, replacing Python packages, etc, simply move the google_appengine folder to /usr/share and in every App Engine project create a symbolic link called .gae that points to that location. The SDK will automatically locate all the Google libraries and the development server is easy to launch:

$ ln -s /usr/share/google_appengine/ .gae
$ python2.5 .gae/ .

Don’t forget the dot at the end, since it tells the SDK which project to launch. And make sure you don’t push the .gae directory to your source control ;) Happy coding!

Upgrading Django on Ubuntu Linux

As I wrote on Twitter a couple of times, I’ve been exploring the world of Django during the latest few weeks. I’m quite impressed with the framework, although there are some issues I’m not yet used to. This post is a short snippet for the Ubuntu users that are struggling with upgrading to the latest Django package. I’m not sure about other Linux distros, but the latest Ubuntu installs django 1.1 which is quite old nowadays. So if you’ve installed Django the following way on Ubuntu:

sudo apt-get install python-django

You’re probably running an outdated version too. Now, to fix this you’ll have to get something newer as a tarball package from the Django Download section and follow the install instructions, which basically run the python setup tools to install the package. After everything’s done, there’s just one minor issue. You have to remove your old django installation as it has a higher priority for python. Use the following code to remove your old version:

sudo apt-get remove python-django

Also note that django may be left somewhere around /usr/local/lib/python2.6/dist-packages/ so make sure you remove the outdated versions from there too. Then run the python interpreter and print out the current version of Django. Make sure that you see something similar:

import django
# Outputs: (1, 2, 3, 'final', 0), hurray!