Apply a complete firmware image
First install the following tools:
sudo apt-get install android-tools-adb android-tools-fastboot
Activate the USB debugging on the phone settings.
Then to apply an official Google factory image for Nexus phones, type:
adb reboot bootloader
If the phone is not unlocked:
fastboot oem unlock
Or remove from the zip file "userdata.img", and change the script file by removing the "-w" parameter in order to avoir the loss of your personal data.
Then launch:
fastboot erase cache
Execute the installation script
./flash-all.sh