Check sudo access in a proper way

Thanks to KenMacD