How To: Restore Your 2013 Nexus 7 Back To Stock Using A Full Factory Image And Root I
In order to complete the steps below, you need to have the Android SDK installed. The SDK contains the latest version of adb and fastboot, which you will need for flashing files and issuing commands. You will also need a MicroUSB cable to execute adb sideload, fastboot flash, and other commands. You also need to unlock your bootloader - a process that wipes your data.
Enable Developer options by going to the Settings -> About screen and tapping Build number until the OS unlocks the hidden Developer options menu. Now go to Developer options and make sure you have USB debugging turned on. For security purposes, you can turn it off after we're done.
To unlock the bootloader, if you haven't already done so:
Reboot into the bootloader by issuing an adb reboot bootloader command on your computer or holding VolDn+Power while booting (power off, hold VolDn, then hold Power).
Warning: This will wipe your data. Type in fastboot oem unlock on your computer. Agree to the unlock by selecting Yes on your tablet (VolUp, then Power).
You have now unlocked your bootloader (and the data partition was wiped clean). Verify by rebooting to the bootloader again and looking at Lock State.
Download the full factory image corresponding to your exact model (for example, 2013 Nexus 7 Wi-Fi is razor), which includes the full system, bootloader, recovery, kernel (boot.img), and radio (radio not included for Wi-Fi-only variants). It's a clean slate for these components - they'll flash cleanly over anything you have now.
Unpack the tgz (tar/gz) archive into its own directory. I use Total Commander, but you can use any tool that reads gz and tar, like 7-Zip:
Proceed with this step if you want to keep your data intact. If you skip this step, your data will be wiped. With your favorite text editor, edit (be careful not to run it by accident instead of editing) flash-all.bat (if you're on Windows) or flash-all.sh (Mac, Linux) and remove "-w" from the fastboot update command. For example, if the line reads fastboot -w update image-razor-jss15j.zip, it should now read fastboot update image-razor-jss15j.zip. The -w option instructs fastboot to wipe data.
Reboot into the bootloader and run the appropriate flash-all script:
8-9-2013 5-20-09 PM
That's it, you're done. In my case, the Nexus 7 is now running stock Android 4.3:
Note: The above procedure restored the factory recovery, so if you want a custom one, you can flash one now (see below).
For better security, you can relock the bootloader by issuing fastboot oem lock while booted to the bootloader. This will, however, mean that if you ever want to do anything that requires an unlocked bootloader, you will lose your data in the unlock process.
Rooting a Nexus 7 is very easy. It requires an unlocked bootloader and a custom recovery. I recommend using TWRP.
Flash TWRP from here (Reboot into the bootloader as before and then fastboot flash recovery FILENAME.img).
Reboot into recovery (adb reboot recovery or hold VolUp and Power while booting).
Flash SuperSU from this post. To do that, download the zip, then put the recovery into adb sideload mode (in TWRP, it's under Advanced), and then do adb sideload FILENAME.zip. I've seen some people complain that doing so via CWM doesn't work, but flashing through TWRP and selecting Fix Superuser Permissions at the end does the trick.
You should be rooted.
Reboot, head to the Play Store, and update SuperSU.
To see full article with pictures go to source : cloudandro.com//revu_2_en.html