lkubuntu

A listing of random software, tips, tweaks, hacks, and tutorials I made for Ubuntu

How to root an Android device under Ubuntu

I have found a lot of tutorials on this subject, but none really supported Android x86 devices, so I decided to write my own here which will support both ARM and x86. If you have an android phone or tablet, you have an ARM CPU, and if you have a virtual android device (or have android installed on your computer), you have an x86 CPU. Notice that you are on your own with rooting. I can try to help, but I cannot guarantee that it will work 100% (it might even break your device). Good luck!

Prerequisites:

First, open up your android device and navigate to Settings -> Applications -> Development, and make sure USB Debugging is on. Next, connect your android device to your computer (if it isn’t already), but make sure you do NOT mount it. If it’s a virtual device, you don’t have to worry about it. Connect your android device with ADB, and type these commands in the terminal (of your computer, not the android device, replacing “path/to/directory/X/is/located” with the actual directory where X is located):

cd path/to/directory/psneuter/is/located
adb push ./psneuter /data/local/tmp/
cd path/to/directory/superuser/is/located
mkdir superuser
cd superuser
unzip ../Superuser-*.zip
adb push ./system/app/Superuser.apk /data/local/tmp/Superuser.apk
adb push ./system/bin/su /data/local/tmp/su

We just uploaded everything we need to the android device (under a temporary directory). Now it’s time to root it! If you are using Android x86, press ALT+F1 and type the commands there instead of on the host machine. If you are not using it, first type this in the host machine’s terminal (it will simply engage a shell with your phone/tablet):
adb shell
Enter these commands:
cd /data/local/tmp
chmod 755 psneuter
./psneuter

On the host machine (yes, this is both for x86 and non-x86), connect to the android device using ADB, and type these commands:
adb shell
busybox ash
mount -o remount,rw /dev/block/mtdblock0 /system
cp /data/local/tmp/su /system/bin/su
chmod 6755 /system/bin/su
cp /data/local/tmp/Superuser.apk /system/app/Superuser.apk
chmod 777 /system/app/Superuser.apk
reboot

Your android device should now be rooted!

43 responses to “How to root an Android device under Ubuntu

  1. Pingback: Today’s Links | PICwebs

  2. Charles Faulkner December 27, 2012 at 12:52 am

    Gotta be careful, some tablets, notably CnM 7″ and 9″ touchpad DON’T have a cp command, so for safety, in the shell, type busybox cp (rest of the line here) whenever you need a cp command

  3. android phones December 30, 2012 at 1:14 am

    do this way does not have a risk?

    • Anonymous Meerkat December 30, 2012 at 1:16 am

      Any rooting is risky, this way just makes you (almost) totally in control of the rooting, so if something went wrong, you can figure out what happened and maybe fix it. So no, this one is still risky.

  4. Aplikasi Android Terbaru December 31, 2012 at 4:22 pm

    I’ll try it later.
    thanks for the article

  5. DamiaN January 5, 2013 at 7:45 pm

    Hi. I tried rooting an Android x86 (4.0 RC2) VM (VirtualBox) on a Win7 host machine. I got stuck at the step that involves executing ./psneuter, The console throws this message:

    “Failed to set prot mask (Inappropriate ioctl for device)”
    Plus all other permission modifications failed (Permission Denied).

    Android x86 also includes busybox and su by default. Also tried several rooting tools and none work. Any ideas?

  6. Hafeez shaikh (@Bais01) January 30, 2013 at 5:21 am

    is this metod dependant on installing firs the adb+fastboot etc? i use ubuntu distro on usb live iso.
    any ideas ?

  7. Hafeez shaikh (@Bais01) February 2, 2013 at 7:22 am

    i have downloaded android sdk and adb etc., but dont know how to install these things while booting the ubuntu thru live usb disk ? plz help

    • Anonymous Meerkat February 2, 2013 at 7:18 pm

      Okay, you don’t need to install them. Simply go to the directory of the android sdk, and adb should be under platform-tools. Once you are there, just replace any “adb” to “./adb” (that will run adb from the current directory)

      • Hafeez shaikh (@Bais01) February 4, 2013 at 4:37 pm

        Sir do u mean to rename saying replace. Means do I rename file name adb to ./adb ?

      • Hafeez shaikh (@Bais01) February 4, 2013 at 4:42 pm

        And do I need to have androi sdk installed beforehand? And PLZ guide me way to install sdk and adb when I only try running Ubuntu thru live USB distro from startup of my pc I have not installed Ubuntu in my pc. PLZ help

      • Anonymous Meerkat February 4, 2013 at 6:24 pm

        No, you don’t need to rename, I was saying replace as in the instructions (so when you see adb ..., run ./adb ... instead).

        And no, you don’t need to install it if you do what I said above (I actually have no idea how to install it if you aren’t using a package manager, sorry). :)

      • Hafeez shaikh (@Bais01) February 7, 2013 at 7:26 am

        ok now everything needed is installed (SDK, NDK etc. etc.), all things set. when i start the process i have following errors :
        after i use ./psneuter, there is some error like … inappropriate…. device….
        and after i keep continue the rest of the process, like tpe adb shell and then busybox ash, there is again some error. thereafter almost every step brings errors.
        sir do i have to connect my device booted normally or do i have to boot my device in bootloader mode etc.? because i can’t boot my device in bootloader mode because i don’t know th exact method to do that. i have tried several (all possible) key-combinations to boot my device (samsung galaxy music duos GT-S6012) but not worked any keys to boot it in the bootloader/fastboot mode.
        plz help !

      • Anonymous Meerkat February 7, 2013 at 4:32 pm

        Hmm, you are sure that you downloaded the ARM version of psneuter? I’ll check the links to make sure that they are pointing to the correct file if not.

  8. Dan February 6, 2013 at 10:15 am

    Unable to download the x86 version of psneuter using the link provided. It seems only registered users can download?

  9. NotTheDroidYoureLookingFor February 11, 2013 at 1:49 pm

    The ARM version of psneuter, was successfully copied to a Samsung Galaxy SII (i777, which is the AT&T version). Here’s the conversation with the device via adb:

    shell@android:/ $ cd /data/local/tmp
    cd /data/local/tmp
    shell@android:/data/local/tmp $ chmod 755 psneuter
    chmod 755 psneuter
    shell@android:/data/local/tmp $ ./psneuter
    ./psneuter
    Failed to set prot mask (Inappropriate ioctl for device)
    1|shell@android:/data/local/tmp $ ls -la
    -rw-rw-rw- shell shell 1468798 2008-02-29 02:33 Superuser.apk
    -rw——- shell shell 0 2011-01-01 00:01 immvibed.lck
    -rwxr-xr-x shell shell 557962 2013-02-11 06:16 psneuter
    -rw-rw-rw- shell shell 380532 2008-02-29 02:33 su

    Seems right, so far, but psneuter does not appear to run.

    Android 4.04 3.0.15 UCLK3 blah blah

    Ideas?

    Thanks!

  10. poretga99 February 20, 2013 at 10:12 pm

    “ok now everything needed is installed (SDK, NDK etc. etc.), all things set. when i start the process i have following errors :
    after i use ./psneuter, there is some error like … inappropriate…. device….
    and after i keep continue the rest of the process, like tpe adb shell and then busybox ash, there is again some error. thereafter almost every step brings errors.
    sir do i have to connect my device booted normally or do i have to boot my device in bootloader mode etc.? because i can’t boot my device in bootloader mode because i don’t know th exact method to do that. i have tried several (all possible) key-combinations to boot my device (samsung galaxy music duos GT-S6012) but not worked any keys to boot it in the bootloader/fastboot mode.
    plz help !”

    Same here…
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation. Vse pravice pridrzane.

    C:\Users\Martin>cd C:\Users\Martin\Downloads

    C:\Users\Martin\Downloads>adb push ./psneuter /data/local/tmp/
    2657 KB/s (557962 bytes in 0.205s)

    C:\Users\Martin\Downloads>cd superuser

    C:\Users\Martin\Downloads\superuser>adb push ./system/app/Superuser.apk /data/local/tmp/Superuser.apk
    2774 KB/s (1468798 bytes in 0.517s)

    C:\Users\Martin\Downloads\superuser>adb push ./system/bin/su /data/local/tmp/su
    3210 KB/s (973198 bytes in 0.296s)

    C:\Users\Martin\Downloads\superuser>adb shell
    shell@android:/ $ cd /data/local/tmp
    cd /data/local/tmp
    shell@android:/data/local/tmp $ chmod 755 psneuter
    chmod 755 psneuter
    shell@android:/data/local/tmp $ ./psneuter
    ./psneuter
    Failed to set prot mask (Inappropriate ioctl for device)
    1|shell@android:/data/local/tmp $ ./psneuter

    any idea what is wrong?

  11. -X-Modder-X-Android-X-Modder-X- May 12, 2013 at 1:39 am

    hmmm…… Sounds like some of these peeps should not be ROOTing there own phones, considering the posts I’ve read …. No offense to those who have posted :-). There is also a GINGERBREAK file that is an x-ecutable in the .Zip they downloaded…. Always read Instructions that are so abundant across the entire world of /////WEB/////…. Learn before you do anything. There is no sure-fire method , or non-risky method to Root your phone. The above method may not work on every device so here is a little bit of help. No offense intended :-)

    cd /path-to-your-adb/platform-tools
    adb start-server
    adb devices
    adb push ./GingerBreak /system/data/local/GingerBreak
    (or ./psneuter) or both :-)
    adb push ./Superuser.apk /system/data/local/Superuser.apk
    adb push ./su /system/data/local/su

    someone@someone-GT5252:~$ adb shell
    root@android:/ # cd /system/data/local
    root@android:/system/data/local # ls
    GingerBreak
    Superuser.apk
    psneuter
    su
    tmp
    root@android:/system/data/local # ls GingerBreak
    GingerBreak
    root@android:/system/data/local # ./GingerBreak

    [**] Gingerbreak/Honeybomb — android 2.[2,3], 3.0 softbreak
    [**] Exploit may take a while!
    [+] Plain Gingerbread mode!
    [+] Found system: 0x4002511c strcmp: 0x4000e270
    [+] Found PT_DYNAMIC of size 264 (38entries)
    [+] Found GOT: 0x0001b445
    [+] Using device /devices/platform/goldfish_mmx.0
    [*] vold: 0094 GOT start: 0x0001b470 GOT end: 0x0001b4b0

    I hope this helps a little………. And thanks to the Original Post for helping others and I am in no way responsible if you damage or “BRICK” your device. Root at your own Positiveness or your Decadence….. Happy Rooting and dont forget to say thanks to the original Post(e)

    • Anonymous Meerkat August 10, 2013 at 6:06 am

      Thanks for sharing this method!!

      But I’m wondering, what does GingerBreak do? It seems to do some rather more complex things than what my post suggests to do, so I’m wondering, why does it do this? Is it so that it will make sure everything works fine?

  12. Damon Mobley May 13, 2013 at 4:08 pm

    Even though I got the ioctl error, it still rooted my phone. :) and is rooted PROPERLY.
    I had taken my phone to a shoppe, and had them root it. the phone said “Your phone is not properly rooted.”

  13. mik3 th3 b3st June 15, 2013 at 11:40 am

    is that working with ANY android device??i mean it can work with chineese brand??

  14. John Rose August 15, 2013 at 10:13 pm

    ARM version of psneuter no longer available from http://ompldr.org/iaGRpOQ as that webiste doesn’t connect. Please advise where it may be obtained.

  15. John Rose August 16, 2013 at 5:54 am

    Thanks for the new links for psneuter. When I try to go to the piratebay link that you supplied, I get “Error – site blocked”. As I’ve never used piratebay, I don’t know how to get round this error. Please advise. So I used the other new link (i.e. 2shared.com).

    Re “Next, connect your android device to your computer (if it isn’t already), but make sure you do NOT mount it¨. I don’t think all Ubuntu users will understand this. On my Android tablet, Ubuntu automatically mounts & syncs to the “internal sdcard”. On my Android phone (ZTE V790), I have to use mtpfs in order to mount it – so I haven’t used mtpfs. Is that correct?

    I copied to /data/local/tmp the 3 files you supplied, as shown below:
    shell@android:/data/local/tmp $ ls -l
    -rw-rw-rw- shell shell 1468798 2008-02-29 02:33 Superuser.apk
    -rwxrwxrwx shell shell 557962 2013-08-16 06:32 psneuter
    -rw-rw-rw- shell shell 380532 2008-02-29 02:33 su
    However, when I key “busybox ash”, I get:
    shell@android:/data/local/tmp $ busybox ash
    ash: precmd: Permission denied
    Please tell me what I should do.

  16. John Rose August 16, 2013 at 8:41 am

    I forgot to mention that running psneuter gave:
    shell@android:/data/local/tmp $ ./psneuter
    Failed to set prot mask (Inappropriate ioctl for device)

    PS I’m trying to root my ZTE V790 phone (not my tablet).

  17. Juan September 4, 2013 at 1:14 am

    Algunos articulos me agradaron mas… ;)

  18. Luis November 21, 2013 at 2:00 am

    No creia ver un articulo asi en este blog sin embargo he
    quedado grafamente agradecido esta vez

  19. Pingback: Rooten mit Linux (S7582) - Android-Hilfe.de

  20. Fikri Syahfalaq February 27, 2014 at 2:18 am

    hi! Thanks this is work in my devices

  21. iua June 12, 2014 at 3:06 am

    adb push ./psneuter /data/local/tmp/ seems to be hangs, when I execute this line it doesn’t show me the command prompt in next line, but cursor keeps blinking. Please help

  22. Frodo Baggins April 24, 2015 at 10:53 pm

    When I run psneuter on my x86 Dell Venue 3730, I get the error:
    “nmap() failed: invailed argument”

    I run ubuntu 15.05 on my pc and my droid runs 4.4.2

  23. The Linux Machine June 22, 2016 at 10:20 pm

    ./psneuter does not work, how can this be fixed?, I am receiving any error message (after I executed the command adb shell, then cd into the /data/local/tmp) which is mmap() failed. Invalid argument (once I executed the command ./psneuter).

Leave a reply to Dan Cancel reply