Run compile command make as another user

Hello

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:

useradd -r -U -m -d /var/lib/anotheruser -s /bin/false anotheruser

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?

Any hints are welcome. Kind regards.

Hi,

I would suspect that if you wanted to run a compile, you'd need to have a shell set such as /bin/bash.

From memory /bin/false will just run an "exit" command and log you out.

Regards

Gull04

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

sudo -u lool /bin/bash -c "id -u"

instead.

Andrew