Added proper root/sudo permission handling