Nexus 5. Needs factory reset, no access to AndroidOS., can't unlock or grant permission I have a Nexus 5 updated to Android 5.1.1 just some days ago. 

Today I have installed this app: https://play.google.com/store/apps/details?id=com.vanillasys.mikechang&amp;hl=en

(I always only install really trusted app from well known developers or companies, but today I have done it, and I am already regretting it. So far I have lost everything in the phone -luckily I always have full backup enabled-)

I could not log in into the app as it even does not advise how to register, when I tried to exit the app, the Android OS entered a never ending loop of crashing the interface - displaying a message about the interface crash - crash again - message -crash - message .......

A) I rebooted thinking about not launching the app again and deleting it from the Google Play Store, and then even before getting to the PIN screen to unlock the phone, the loop crash - message - crash - appears again, not even displaying the on-screen numkey to dial the PIN. (the rest of the OS seems to work as I could hear the email warnings) 

B) I booted in Safe mode, and again not even displaying the numkey screen, error loop again.  

C) I can manually go into Recovery Mode and reboot bootloader (I don't know what this is for)

I booted in recovery mode and 

1) wipe data/factory reset   -> reboot and same result as in A)

2) wipe cache partition -> reboot and same result as in A)

So I am desperate. 

I am using XUbuntu Linux 14.04 LTS fully updated. 

Then I am using this guide: https://www.youtube.com/watch?v=m7fhPYQSMQ4
I remember some moths ago about having done the clicking 7 times in the build number to enable developer mode. I also possibly enabled (very likely) the "USB debugging" ... 

BUT as I have no access to the Android OS anymore I am not able to use the  abd devices command and get the phone to display the box asking for permision "Allow USB debugging?" (2:54 in the video), so I never get permission, and I can't either perform the command abd reboot bootloader (3:23) and even worse fastboot oem unlock (4:21)

I also try going into recovery mode and then to use the option "apply update from ADB" but as I do not have permission to access the phone from the computer I cannot do anything. I try abd sideload image-hammerhead-lmy48b.zip just to get notified of lack of permission. 

What can I do? I can use windows, Linux or Mac. How can I unlock the phone's recovery mode and get permission to access it form the computer?

I would prefer not to use windows as It seems a pain to configure everything to get it to work with Windows, and also I have not used it for some years.

Info from my phone's recovery state screen:

Fastboot mode:
Product name: hammerhead
Variant: hammerhead D821(H) 32GB 
hardware version: rev_11
Signing: production
Secureboot: enabled
Lock state: locked


Thanks in advance.

Alex
First, I want to clarify:  when you hold the volume button while turning on the phone, and get the screen with the big "Start" arrow at the top, that's not recovery mode.  That's the bootloader, also known as fastboot mode.  When you choose "recovery mode" from the fastboot screen and get a screen with a little droid and a red exclamation mark, that's recovery mode.  adb commands work only in the regular OS or in recovery mode; fastboot commands work only in fastboot mode.

You don't need to worry about enabling USB debugging from the settings menu; that's only for enabling it within the regular Android OS.  It's always enabled in fastboot and recovery mode.  Also, adb reboot bootloader is the same as just turning the phone off and then holding the volume button when turning it back on again.

The factory reset that you already did should have fixed the problem.  That erases all installed apps, files, etc. and leaves you with just the OS, which is in a read-only partition and shouldn't have been affected by any apps you installed.  If the problem persists after a factory reset, either the app somehow managed to gain root and modify the system partition (unlikely if you were running 5.1, assuming you hadn't rooted it), or it's a problem with the phone itself and the timing (after you installed that app) was just coincidental.  Maybe something went wrong while installing the 5.1.1 update.

Anyway, the best course of action now is to reinstall the factory image.  This is more thorough than a factory reset because it actually reinstalls the OS itself, rather than just erasing all the user data.  If the system partition is corrupted somehow, a factory image will put it right.

Go to Google's Nexus factory image page and download the 5.1.1 image for the Nexus 5.  At the top of that page, you'll find directions for how to install it.  In a nutshell:  put the phone into fastboot mode, then run fastboot oem unlock, then run the flash-all script included in the factory image package.

The fastboot program on your computer may require administrative privileges, so you should run it as root when doing fastboot oem unlock.  You should also run the flash-all script as root, since the script just runs several other fastboot commands for you.

Just to be clear:  installing a factory image will erase all user data stored on the phone.  Don't do it if you have any important data on the phone that you don't want to lose.  (But if you already did a factory reset, you probably don't have any data left on the phone anyway.)