How to root Google Pixel and Pixel XL

How to root Google Pixel and Pixel XL

Step 1: To begin with, you will have to unlock the bootloader of you smartphone. Turn off your smartphone and then press the — volume down and power button simultaneously for a few seconds. This will boot the smartphone in fastboot / bootloader mode.
Step 2: Connect your smartphone to the PC using the USB cable. Now, open the Minimal ADB and Fastboot folder that you created on the desktop, press and hold Shift key on your keyboard, right click on the mouse or touchpad and select — open command window here. Now type adb devices and press enter, which will show your connected device.
Step 3: Once your device is recognized, type the following command – fastboot devices and press enter. Then type fastboot oem unlock and press enter. Once it shows success, then type fastboot reboot and press enter.
Step 4: Now that the bootloader on your Pixel / Pixel XL is unlocked, you can go ahead to download the boot image of your device. Click here for Pixel and here for Pixel XL. Once the .ZIP file is downloaded, extract it and copy the boot-to-root.img file onto the Minimal ADB and Fastboot folder on the desktop. (Do note – unlike other smartphones where you have to flash the images, in case of Pixel smartphones, you need to write them via fastboot command)
Step 5: Once again, press and hold Shift key on your keyboard, right click on the mouse or touchpad and select — open command window here inside the Minimal ADB and Fastboot folder. Now, type fastboot devices and press enter. Once your device shows up, type – fastboot boot boot-to-root.img and press enter. This process will write the modified boot image on to your Pixel or Pixel XLsmartphone. Your device will reboot a couple of times (have patience) and then Android OS should boot successfully. 
Thanks for your comment