title: What is the best way for checking if the user of a script has root-like privileges?
body: <p>I have a Python script that will be doing a lot of things that would require root-level privileges, such as moving files in /etc, installing with apt-get, and so on. I currently have:</p>
  
  <pre><code>if os.geteuid() != 0:
      exit("You need to have root privileges to run this script.\nPlease try again, this time using 'sudo'. Exiting.")
  </code></pre>
  
  <p>Is this the best way to do the check? Are there other best practices?</p>