HOW TO: Root the Samsung Galaxy S2 from Linux

  • Posted on: 20 November 2012
  • By: teknikqa

The easiest way to root an Android phone on linux is to use Heimdall. Heimdall is an open source program to flash Android on Samsung Galaxy devices.

Heimdall is available as a binary executable for many platforms, including Debian. Unfortunately, since I use Fedora, I had to compile the code from scratch.
First install all the needed tools.

# Install packages such as autoconf, make, gcc necessary for compiling the code
yum groupinstall "Development Tools"
yum install libusb1-devel qt-devel

Then download the source code and compile it

git clone git://
cd Heimdall/libpit
cd ../heimdall
su -c 'make install'
cd ../heimdall-frontend/
su -c 'make install'

You might get a message like “RCC: Warning: No resources in ‘mainwindow.qrc’” during qmake. You can safely ignore it as it is not an actual error and Heimdall will work just fine.

Now that we have installed Heimdall, we need to find out which kernel our phone is running. So on the Android phone, select Settings -> About Phone.

Look for  the Kernel Version. It will say something like "3.0.15-I9100XWLP7-CL340913". Note the text that is in bold (LP7). Find the kernel image that matches your phone from the xda-developers forum based on this string.

Once you've downloaded the image, we need to push it to the phone. Extract the contents of this file. Assuming you downloaded

tar xvf CF-Root-SGS2_XW_XEN_LP7-v5.4-CWM5.tar

This should leave you with the file zImage.

Now, put your phone into Download mode.

Power Off
Hold Volume Down+Home Key+Power key until you see the intro key
Press Volume Up to continue (the screen will prompt you to do so)
Connect the phone to your PC with USB and check whether it's been detected

heimdall detect
# Should return Device Detected
su -c 'heimdall flash --kernel zImage'

A large amount of output will appear, which should end with

Uploading KERNEL
KERNEL upload successful
Ending Session....
Rebooting Device....
Re-attaching kernel driver....

And your phone should reboot into the newly rooted system. Now's a good time to look at backing up your efs folder though, to avoid needing to pay Samsung to repair things should anything go wrong.

So, install a terminal emulator on your phone, and after opening run the following

# Accept when asked if you want to grant permissions
mkdir /sdcard/efs
busybox tar zcvf /sdcard/efs/efs-backup.tar.gz /efs

This will create a backup of the /efs folder on your SDCard, so should you ever break anything in this folder you have half a chance of restoring it!

Other guides to rooting Andoid phones:

What to do after rooting your phone? These links should help:


Setting default directory for screenshots in GNOME

  • Posted on: 12 November 2012
  • By: teknikqa

There is no easy way to configure the location where screenshots get saved using gnome-screenshot.

In order to set this option, install dconf-editor package:

yum install dconf-editor

Run dconf-editor, navigate to org/gnome/gnome-screenshot, and specify any directory in the auto-save-directory value where all screen shots should be saved automatically, for example, file:///home/user/Screenshots.

Remember to change the value of last-save-directory too, so that any screenshot taken by running gnome-screenshot in interactive mmode will save it to this location too.

While this sets the directory where screenshots get saved, there is no option to set the name of the screenshots. This isn't a problem by itself, but if you share the image with Windows users, it is impossible for them to open such files.

There is a simple hack to rename these screenshots immediately after their creation.

First install inotify-tools

yum install inotify-tools

Then run this command:

while true; do inotifywait -e CREATE ~/Screenshots && rename 's/\:/\_/' Screenshot/Screenshot*.png; done;

When this command is run, everytime you save a new screenshot in ~/Screenshot/ directory, the script will rename every file containing :, substituting : with _.

Learning philosophy with the New York Times

  • Posted on: 4 April 2011
  • By: teknikqa

From David Brooks' summary of a symposium organized by on "What scientific concept would improve everybody’s cognitive toolkit?"

Path Dependence
Decisions for any circumstance is limited by decisions taken in the past, even though past circumstances may not be relevant anymore.
“something that seems normal or inevitable today began with a choice that made sense at a particular time in the past, but survived despite the eclipse of the justification for that choice.”

Einstellung Effect
Predisposition to solve problems based on past experiences rather than approaching each problem individually.
the idea that we often try to solve problems by using solutions that worked in the past instead of looking at each situation on its own terms. This effect is especially powerful in foreign affairs, where each new conflict is viewed through the prism of Vietnam or Munich or the cold war or Iraq.

Focusing Illusion
Bias that occurs when one aspect of an event is given too much importance, thereby affecting the accuracy of the predicted future outcome.
“nothing in life is as important as you think it is while you are thinking about it.”

This is one of the harder ones. Supervene literally means to take place or occur as something additional or extraneous.
In essence it means, to be dependent on a set of facts or properties in such a way that change can occur only after change has occurred in those facts or properties.
Imagine a picture on a computer screen of a dog sitting in a rowboat. It can be described as a picture of a dog, but at a different level it can be described as an arrangement of pixels and colors. The relationship between the two levels is asymmetric. The same image can be displayed at different sizes with different pixels. The high-level properties (dogness) supervene the low-level properties (pixels).

Fundamental Attribution Error
Wikipedia explains it as the 'tendency to over-value dispositional or personality-based explanations for the observed behaviors of others while under-valuing situational explanations for those behaviors.'
Don’t try to explain by character traits behavior that is better explained by context.

Emergence (Concept)
Ah! The easiest way to understand emergence is through fractals. It is basically, the way how complex systems arise from simple interactions.

One Bad Apple Spoils the Bunch

  • Posted on: 27 March 2011
  • By: teknikqa

This is interesting: One Bad Apple Spoils the Bunch: Exploiting P2P Applications to Trace and Profile Tor Users

Assume that a source wants to leak top secret documents anonymously. It is considered secure to do so through Tor using a privacy-enhancing browser plugin such as TorButton. However, assume that, at the same time, this source uses another insecure application on Tor. Is it then possible to associate the top secret documents with the IP address of the anonymous source? The answer to this question is yes!

Abstract: Tor is a popular low-latency anonymity network. However, Tor does not protect against the exploitation of an insecure application to reveal the IP address of, or trace, a TCP stream. In addition, because of the linkability of Tor streams sent together over a single circuit, tracing one stream sent over a circuit traces them all. Surprisingly, it is unknown whether this linkability allows in practice to trace a significant number of streams originating from secure (i.e., proxied) applications.

In this paper, we show that linkability allows us to trace 193% of additional streams, including 27% of HTTP streams possibly originating from “secure” browsers. In particular, we traced 9% of all Tor streams carried by our instrumented exit nodes. Using BitTorrent as the insecure application, we design two attacks tracing BitTorrent users on Tor. We run these attacks in the wild for 23 days and reveal 10,000 IP addresses of Tor users. Using these IP addresses, we then profile not only the BitTorrent downloads but also the websites visited per country of origin of Tor users. We show that BitTorrent users on Tor are over-represented in some countries as compared to BitTorrent users outside of Tor. By analyzing the type of content downloaded, we then explain the observed behaviors by the higher concentration of pornographic content downloaded at the scale of a country. Finally, we present results suggesting the existence of an underground BitTorrent ecosystem on Tor.

Yum remove Enlightenment

  • Posted on: 18 March 2011
  • By: teknikqa

Here's a one-liner that will save some time. Uses sed, uniq, sort and of course regular expressions.

yum remove `yum search enlightenment | awk '{print $1}' | sed -e 's/.\(x86_64\|i686\|noarch\)//' -e '/^[:=]/d' -e 's/\(Loaded\|font-manager\)//' | uniq | sort`

What does it do?

It uses yum to remove all packages that are related to the Enlightenment Window Manager.

It does this by searching the package lists for the word enlightenment, prints just the first word, filters out unnecessary stuff, lists only the unique ones and finally sorts the result. This resulting list of packages is then passed on to yum to remove.

The 15 min exercise system

  • Posted on: 24 January 2011
  • By: teknikqa

In a world of Arnold Schwarzenegger's and Sylvester Stallone's, people like Franz Kafka or J.P. Müller stand out.

My take: Müller's system combined with yoga and meditation might be the perfect exercise system.

From the article:
The exercise guide, which promised that just "15 minutes a day" of prescribed* exercise would make "weaklings" into strong men (and women)
Müller wasn't interested in building muscle mass through dumbbells.

Source: Franz Kafka, J.P. Müller: The exercise system that swept Europe in the early 1900s. (Sarah Wildman - Slate Magazine)

The future is now!

  • Posted on: 18 January 2011
  • By: teknikqa
I've seen the future. It's in my browser!

Today the W3C released an official HTML5 logo. Its a call to rally forward the advancement of the HTML5 spec.

Just as quickly, the awesome designer Jen Simmons branded the HTML5 Logo for Drupal.

Those are the shiny new logo's you see on top.

I'm using the Sky Theme, which uses HTML5 and CSS3. It still gives you some ugly code, but it is more or less HTML5 compliant. I've made some modifications here and there, mostly to the CSS, but I want to do a complete rewrite that gives pure HTML5. I'll be working on that shortly. After all this is the future!

Btw, both these logo's are licensed Creative Commons Attribution 3.0

Drupal 7

  • Posted on: 16 January 2011
  • By: teknikqa

I upgraded the site to Drupal 7. The upgrade was smooth. I had to disable some modules that I used on the old site. I didn't have much use of them, so might as well keep things simple.

Some things still need to be fixed. Like the error reporting and logging. I'll get around to that eventually.

But for now, go Drupal!!