Step 1 : Enable USB debugging
On your Nexus device, go to Settings> About Phone. Then tap on "Build Number" repeatedly until a dialog says "You're now a Developer".
Now go back to Settings and you will see a new "Developer Options" near the bottom of the menu. Go to "Developer Options". Then scroll down and select on "USB debugging".
Step 2 : Download Factory Image for your Nexus Device
Open the link below and download the correct the correct build for your device.
Step 3 : Download Custom Recovery for your Nexus Device
Open the link below and download the newest recovery image for your device.
Step 4 : Connect your device to the computer via micro-USB cable.
Step 5 : Install Android Developer Tools
To install Android Developer Tool adb and fastboot on your computer, open the Terminal and enter the commands below.
sudo apt-get install android-tools-adb
sudo apt-get install android-tools-fastboot
Step 6 : Check if adb recognizes your device
To check if the adb recognizes your device type the following in Terminal.
It can ask you to allow connection to computer in your phone, select always allow. It should show something like the screenshot below with some numbers and device connected information. Otherwise your device is not recognized and you cannot continue any further.
Step 7 : Reboot your device to Bootloader Menu
adb reboot bootloader
If the command is successful, your device will boot into bootloader like the picture below.
Step 8 : Flash the Factory Image
Extract the factory image file you downloaded. Then go inside the directory and right click and Open in Terminal. Now you will run the flash-all.sh file in the directory using following command in terminal.
You can skip Step 9 and 10 if you don't want to mess with the bootloader.
Step 9 : Unlock the bootloader
Unlocking bootloader will wipe everything in your device and void your warranty so make sure you want to do this before using the following command. But you can always relock the bootloader any time in the future.
sudo fastboot oem unlock
Skip Step 10 if your want the bootloader to remain unlocked.
Step 10 : Lock the bootloader
sudo fastboot oem lock
Step 11 : Flash Custom Recovery
Go to the directory where you downloaded the custom recovery. Right click and Open Terminal. Then enter the following command.
fastboot flash recovery (the file name of the recovery image).img
For example it can be like :
fastboot flash recovery openrecovery-twrp-18.104.22.168-grouper.img
To root your Nexus Device
Download the CF-Auto-Root zip file for your device from the link below :
Then extract the zip file. Navigate to that folder and open Terminal there. Enter following command first.
chmod +x root-linux.sh
Then enter following
It may ask you to press Enter once. Do that and let it do the rest.
I hope this post helped you. If have any questions you can write then in the comment section below.
Stay High on Android. Peace!!!