Run compile command make as another user


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Run compile command make as another user
# 1  
Old 03-07-2017
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.
# 2  
Old 03-07-2017
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
# 3  
Old 03-07-2017
Quote:
Originally Posted by go4bash
Hello


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)

Code:
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.
You should be using code tags to separate the code fragments from the rest of your post.

The problem is you are doing:
Code:
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
Code:
sudo -u lool /bin/bash -c "id -u"

instead.

Andrew
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

tuxedo command run from another user

Hi , I would like to know, whether if it is possible or not. I am runing one tuxedo command script. This script should run on another userID and stored the data on another UserID. For Example: UserA : The Script is available in this userID location. . If i run that script then it... (3 Replies)
Discussion started by: Mani_apr08
3 Replies

2. Shell Programming and Scripting

how to run a command as soon as user exits from session

I need to write a script, where I have to get names of files that are to be deleted from a user and have to delete those files when he exits session. How to set a particular command to be run as soon as user exits from a session? Can somebody help? I have to write a script on linux system.... (3 Replies)
Discussion started by: yashashri
3 Replies

3. UNIX for Dummies Questions & Answers

Compiling gcc to compile make to compile yaboot

I have just installed OpenBSD on a 333MHz PPC iMac G3. It has a 6GB HDD that has been partitioned as 1GB MacOS 8.5.1, 3GB MacOS X 10.3.9, 2GB OpenBSD 4.8. I now need to install a bootloader so that my computer can recognize the OpenBSD partition at startup. I have been trying to install... (0 Replies)
Discussion started by: t04st3r
0 Replies

4. HP-UX

Make command performs badly and refuses to compile on 200000 files

I am trying to run make command on 200000 files in HP UX but it refuses to compile giving a message that " command line is too long .stop" I checked and found out that there is a limit imposed by the operating system on the command line .for Eg refer following link : The maximum length of... (6 Replies)
Discussion started by: madhur.tripathi
6 Replies

5. UNIX for Advanced & Expert Users

How can I run command with super user privledge

Hello All, I am working on UNIX like environment. This environment is ported from UNIX. Here when we need to build product set, we need to run some script with super user privledge (which we normal user dont have) Is there any way (some C program or some script) through which any normal... (2 Replies)
Discussion started by: joshi123
2 Replies

6. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

7. AIX

run which command to check the actual user

hi gurus, i have a question: when run which javac under a user account I got the following results: PROD DB Server: /usr/java14/bin/javac DR DB Server: /usr/java14/bin/javac DEV DB Server: /usr/java5_64/bin/javac The .profile in all environments are same. so how do know who is the... (1 Reply)
Discussion started by: lweegp
1 Replies

8. UNIX for Dummies Questions & Answers

how can i make sar command run forever ?

Hello all i found out about the sar command but when looking in the man pages there is no way to make sar working for ever .. only with some kind of interval . like sar 2 30 . my question is can i just run sar for ever ? (5 Replies)
Discussion started by: umen
5 Replies

9. Shell Programming and Scripting

who to compile needed libs with Make

Hello all my project is contains 2 directories, 2 directories are building library and one for the executable that using the libes from the other 2 Now what im doing is compiling first the 2 libs directories and then the main directory. But I will like to automate the process and to be able ... (0 Replies)
Discussion started by: umen
0 Replies

10. Shell Programming and Scripting

How to run a command with some other user id

Hi Say I am running a script using my user id csaha. How can I run any specific command in the same sctipr using any other user id (say root). Definitely I have the password of root. Any idea how the same can be achieved ??? Example: I need to run a script using my id (csaha) only on... (4 Replies)
Discussion started by: csaha
4 Replies
Login or Register to Ask a Question