title: Bash: executing commands from within a chroot and switch user
body: <p>Im writing a script that should do this...</p>
  
  <pre><code>chroot /chroot_dir/ su -
  ./startup.sh (This should run within the su environment)
  </code></pre>
  
  <p>I have tried this approach:</p>
  
  <pre><code>chroot /chroot_dir /bin/bash -c " su -; ./startup.sh"
  </code></pre>
  
  <p>This tries to execute the user switching and the script as a string command to bash...however what it does, is it "stops" after
      <strong>"su -"</strong> and doesnt execute the script.
  However, once I leave the "su -" environment, it does try to run startup.sh but of course, it cant find it.</p>
  
  <p>Basically I need to nest the "startup.sh" to be run inside the "su -" environment...</p>