A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Joined: Feb 23, 2009
Feb 23, 2009 02:46:05
I logined as a root in linux . I am using Runtime.getRuntime().exec(somecommand) to execute some command . The command is executed as root(As I logined as root) . How can I execute some command as a particular user(not as a root) ?
Thanks and Regards
Joined: Mar 22, 2005
Feb 23, 2009 03:00:04
You can use the "su" and "sudo" commands to achieve this.
As a general hint, I wouldn't routinely log into a Unix system as root. Use a regular account, and then execute anything that requires higher privileges using "sudo".
Ping & DNS, my free Android app for network diagnostics
subject: Runtime.getRuntime().exec(somecommand) -help
How to Run a command
Retrieving classes of a package
Executing Unix command from java
Where is the InputStream stored...?
Runtime getRuntime() exec(String command) - How does this work?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013