The method that we are going to use in this post is the CF-Auto-Root file thanks to recognized xda-developers member - Chainfire.
Disclaimer:Not following such procedures carefully and failing to complete it might brick your device. AndroidJunkie will not be responsible for your actions.
- Be sure to have the USB Drivers installed for the Nexus 5 in order to be able to transfer files between the phone and computer.
- Make sure your Nexus 5's bootloader is unlocked. To unlock the bootloader you may read this post.
- Create a backup of all your valuable saved messages, app data, contacts and everything else you want to keep
- Enable USB debugging on the phone by going to Settings -> Developer options. If you don't have Developer options enabled, head into Settings -> About phone - now begin tapping continuously on where it says Build number and it should say "You are now a developer".
- Make sure you have some battery juice because if the device shuts off before the procedure is completed, you may corrupt your rom and end up with a bricked device.
How to Root Nexus 5 running Android 4.4.2 KitKat (KOT49H):
- It's finally time to begin the procedure. So download the Android SDK and set it up with downloading platform-tools in SDK. If you're not sure how, you can check out this guide by TeamAndroid - Click here.
- Download Fastboot and extract it in the directory android-sdk/platform-tools.
- Download the CF-Auto-Root-hammerhead-hammerhead-nexus5.zip file to your computer.
- Once the file is on your phone, power it off. Now hold the Volume up + Volume down + Power buttons simultaneously to boot into Fastboot/Bootloader Mode until you see it appear on your phone.
- Connect your Nexus 5 to your computer with your USB cable.
- Extract the CF-Auto-Root files into the same directory where you extracted Fastboot and head into that directory.
- Now run the file run-windows.bat
- Now wait and watch as the process begins and follow the on-screen instructions.
- Once the process is done, the phone should reboot. Please note that the boot may take some time, be patient before coming to conclusions!
Source: Team Android