|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Execute a command as root from normal user
Hi , I am trying to stop and start a process using the below code. I have sudo access on my machine Code:
## PID = process id echo "$PASSWD" | sudo -S kill -9 <PID> echo "$PASSWD" | sudo -S /opt/abc/startserver /opt/abc/startserver: error while loading shared libraries: librts.so: cannot open shared object file: No such file or directory But its working if i follow the below procedure Code:
$ sudo -i # opt/abc/startserver Server Started How do i execute a process with sudo access in my case , i have tried -p <promt option > but no use any help is much appreciated |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
You are running the upper code in a crontab? In any case it looks like the environment in the first example is missing LD_LIBRARY_PATH variable.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
First code is a script file not in cron. The former are the series of commands executed in shell one after the other (not through scripting) Code:
The below commands are working fine <<command 1>> $sudo -i <<command 2>> # opt/abc/startserver Server Started i tried $sudo /opt/abc/startserver , it throws the same error |
|
#4
|
||||
|
||||
|
What, as the concerned user, is the output of Code:
sudo -l |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
output of sudo -l
User <xyz> may run the following commands on this host: (ALL) ALL (ALL) ALL |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Ok its OT but, I feel a bit concerned by your security with what I see above... Cant you get your user to have: Code:
n12:/home/vbe $ sudo -l
User vbe may run the following commands on this host:
(ALL) NOPASSWD: ALLWhat I mean is execution without password... since he has all rights... or you all know the passwd and could not care... Your issue now, it look like suggests Jim, to do with the environment...To see if its that source root's .profile before executing you commands: Code:
. ~root/.profile |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Thanks vbe and jim Finally the below code worked Code:
## startserver is already included in the Current environment through /etc/profile echo "PASSWD" | sudo -S -E startserver Code:
I dont want to try the below trick because this is just adhoc not a regular task. (ALL) NOPASSWD: ALL |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| java version mismatch for normal user and root user | frintocf | Solaris | 3 | 08-19-2011 06:02 AM |
| Execute Root command as Normal user | abhishek1979 | Shell Programming and Scripting | 3 | 03-22-2010 01:53 PM |
| root user command in shell script execute as normal user | mnmonu | Shell Programming and Scripting | 3 | 10-19-2009 07:42 AM |
| login into root from user and execute command through script | pradeepreddy | Shell Programming and Scripting | 6 | 08-29-2008 02:49 AM |
| Other than root user .Normal user is unable to create files | mallesh | UNIX for Advanced & Expert Users | 1 | 06-22-2005 12:18 PM |
|
|