title: How to execute commands as root using fabric
body: <p>I am trying to use Fabric to execute some basic commands in a remote server. I haven't used Fabric before and I face some difficulties in executing some commands as.</p>
  
  <p>What I need to do is to connect to the remote server, make a file in a specific directory and then restart the uwsgi server.</p>
  
  <p>Although I am able to do the first two tasks, I can not restart the service as I don't ssh to the server as root user. </p>
  
  <p>This is what I do:</p>
  
  <pre><code>def staging():
     env.hosts = ['user@my_host']
  
  def update_app(app_name):
    with cd(git_folder):
      with settings(warn_only=True):
        sudo('mkdir -p /home/new_folder/test')
        #sudo('sudo su -') # also tried this
        sudo('service uwsgi restart')
  </code></pre>
  
  <p>When I include the <strong>sudo su -</strong> command, the fab script is never finished. I just get to be logged in as a root (in the terminal).</p>