How to root Moto G (3rd gen) running Android 5.1.1? I recently bought a Moto G (3rd gen) and I want to root it. It runs Lollipop 5.1.1.  

My previous phone ran Android Jelly Bean and rooting was easy with the Framaroot app. But it does not work on Lollipop.

So, how do I root my device?
Caution: Unocking Bootloader will void your warranty and format your device. Proceed at your own risk.


Download ADB and install it- google it
Turn off your phone and press vol- and power button. Release power button after 4-5 sec, youll see the bootloader menu. Now release the vol- too. To enter into the fastboot you may have to press the vol up key while fastboot is selected(use vol down to navigate).
Connect your phone and open command prompt on pc(press windows key + R and type cmd). 
Type this- "fastboot devices" and see if it displays the device id. If yes, proceed to next step. If no, make sure fastboot drivers are properly installed.
Then type this in the cmd "fastboot oem get_unlock_data". You'll get a string copy it to a notepad and save it. Then type "fastboot reboot" to reboot your phone. 
Go to motorola's website review the risks and click on next. You'll be asked to sign in, use the google account connected to your phone. Follow the instructions to format the string and paste it on the webpage click the agree radio button and click on "can my device be unlocked?".
On the next page click"request unlock key"
Check your email for the unlock code. Now type "fastboot oem unlock KEY" where KEY= the key you received in the mail.
Download TWRP Extract the .img file to ADB folder.
Connect your phone is fastboot mode. Type "fastboot flash recovery filename.img"
Now download SuperSU.zip (google it because I can't post more than 2 links) from the link and place the zip file in your phone's sd card or internal memory.
Now flash the update from TWRP recovery which you installed.
ASK if you're unsure about any steps. Don't risk bricking your phone.