I'm trying to compile LibreOffice core from github.com. But this can - as far as I know - not be done as root user. So I compiled it as login user (the user as I log in) and compilation works.
Now I try to compile LibreOffice core as a user I created using useradd:
Then I try to run the compile commands using sudo -u. And it fails.
I'm not an experienced bash user. But I realized that some environment variables doesn't come from anotheruser but from the login user that starts the command sudo -u. So when I run (as login user)
sudo -u lool /bin/bash -c "echo `id -u`"
the id of the login user is returned and not the id of anotheruser. Why?
You should be using code tags to separate the code fragments from the rest of your post.
The problem is you are doing:
echo `id -u`
which is a completely superfluous use of echo in this case. It looks to me as though the part in back-ticks ( `id -u` ) is being processed by the parent shell before being sent to the sudo sub-process. Try