sudo -H -u otheruser bash -c 'echo "I am $USER, with uid $UID"'
Source: Run a shell script as another user that has no password
sudo -H -u otheruser bash -c 'echo "I am $USER, with uid $UID"'
Source: Run a shell script as another user that has no password