title: How to make my environment variables available for sudo commands?
body: <p>Currently, I have a script that loads my environment variables. And I'm sourcing it like this:</p>
  
  <pre><code>#!/bin/bash
  
  set -x
  
  # sourcing my env variables
  . /etc/profile.d/company_env.sh &gt; /dev/null 2&gt;&amp;1
  
  clear_known_hosts(){
    local known_hosts="${NAGIOS_HOME}/.ssh/known_hosts"
    # clear
    su - nagios -c "echo '' &gt; ${known_hosts}"
  
  }
  </code></pre>
  
  <p>But, removing the sourcing part, because I don't want to add it in every script that may create, my <code>sudo</code> command can't find my environment variables, like <code>NAGIOS_HOME</code> for example, which is empty. </p>
  
  <p>Any suggestions ? </p>