added heredocs and user sanity check for root or sudo