Root Your Nexus 5 Under Linux [Guide]

I am using Linux Mint for this guide, and unlike Windows, under Linux you do not have to install any additional drivers. If you are using Ubuntu or Fedora, you need to set up some things for ADB to work. You can follow my Ubuntu or my Fedora guide to set up ADB. With Linux Mint you just plug and play, that is the beauty of it 🙂

Now let’s get down to the Nuts and bolts of this guide






Getting ADB and your Phone Ready

  1. Download the latest Android SDK.
    • Scroll to the bottom of the page: DOWNLOAD FOR OTHER PLATFORMS -> SDK Tools Only -> Linux 32 & 64-bit
  2. Extract the TGZ file to your home/YOUR-USERNAME directory
  3. On your phone, click Settings > Applications > Development and make sure USB Debugging is on.
    • Tap seven times in Build Number: Settings > About Phone > Build Number
    • You will get a message saying you have enabled Developer Options or something like that, go back to Settings and you will see Developer Options in there.
  4. Once you have done the above, you need to add adb to your PATH as environmental variable.
    • Open a terminal window in your home (~) directory and type: sudo vi .bashrc
    • or sudo gedit .bashrc if you don’t like vi

    • Add the following line at the end: export PATH=${PATH}:/home/YOUR-USERNAME/android-sdk-linux/platform-tools
    • Save and close the terminal window
  5. You should be ready to go, type in a new terminal window adb devices with your phone plugged in and you should get the below message in your phone. Check Always allow from this computer and press OK
  6. screenshot_2013-08-13-20-23-53-png

  7. In your terminal you will get the following
  8. esilva@esilva-N56VJ ~ $ adb devices
    List of devices attached 
    063dcadc0ae59d9a	device
    

Unlocking the Bootloader

  1. Turn the phone off. Then boot it into the bootloader/fastboot mode by holding volume down + power
  2. Plug your Nexus 5 into your PC and open Terminal (make sure you log in as root)
  3. cd to /home/YOUR-USERNAME/android-sdk-linux/platform-tools
  4. Type ./fastboot devices
  5. esilva-N56VJ platform-tools # ./fastboot devices
    063dcadc0ae59d9a	fastboot
    
  6. If you get an output similar to the one above, proceed to typing ./fastboot oem unlock. You will get an output similar to the one below (Remember that this step will wipe EVERYTHING off the phone)
  7. On the phone a screen should pop up asking whether or not you would like to unlock the bootloader. Use the volume rockers to highlight “Yes” then press power to confirm the action.
  8. esilva-N56VJ platform-tools # ./fastboot oem unlock
    ...
    OKAY [ 23.817s]
    finished. total time: 23.818s
    
  9. After the above command has finished executing, you need to reboot your phone via ./fastboot reboot
  10. esilva-N56VJ platform-tools # ./fastboot reboot
    rebooting...
    
    finished. total time: 0.001s
    
  11. The phone will reboot. Next you will be presented with a screen containing an android logo and a progress bar (this may take up to ten minutes to complete). Wait until the phone has fully booted up into android, then proceed onto the next section of the guide

Installing a Custom Recovery

  1. Download a custom recovery image
  2. Turn the phone off. Then boot it into the bootloader/fastboot mode by holding volume down + power
  3. Still with terminal opened in /home/YOUR-USERNAME/android-sdk-linux/platform-tools
  4. (Most than likely, your custom recovery image will be under your Downloads directory). Type ./fastboot flash recovery recovery.img. You will get the below output
    • Note: recovery.img is name of your downloaded recovery
    esilva-N56VJ platform-tools # ./fastboot flash recovery "/home/esilva/Downloads/Nexus 5/Root/recovery.img" 
    sending 'recovery' (13306 KB)...
    OKAY [  0.619s]
    writing 'recovery'...
    OKAY [  1.057s]
    finished. total time: 1.676s
    
  5. On the phone, use the volume buttons to scroll onto “Restart Bootloader” and hit power to select it. After the bootloader reloads, use the volume buttons to scroll onto “Recovery Mode” and power to select it. You should then be greeted with your newly installed custom recovery
  6. Close Terminal

Rooting

  1. Download SuperSU to your Downloads directory
  2. Open a new Terminal window and plug in your phone. You do not need to be logged in a root
  3. Turn the phone off then boot into the bootloader. (volume down + power).
  4. Once in the bootloader use the volume rockers to scroll onto Recovery Mode, then press power to select it. This should bring you into your newly installed custom recovery. Leave the phone at the home page of the custom recovery
  5. Type adb push /home/YOUR-USERNAME/Downloads/UPDATE-SuperSU-vX.XX.zip /sdcard/
  6. This will copy the SuperSU zip onto your phone. Once the command has completed continue with the instructions to use TWRP or CMW

TWRP

  1. Install > browse to SuperSU zip and select the it
  2. Swipe to confirm the installation. Then reboot

CWM

  1. Install zip from sdcard > choose zip from sdcard.
  2. Next, browse to the location where you previously copied the SuperSU zip and select the it.
  3. To confirm the installation, scroll down to “Yes” and select it. The installation shouldn’t take very long, and once it has completed you may reboot

That is it, you now have rooted your Nexus 5 🙂

RootNexus5





Esau Silva
Software Engineer at Region One ESC
Microsoft Full Stack Application Developer
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed.
Share