su command question

Smoot Carl-Mitchell smoot at tic.com
Sat Jul 5 16:26:49 UTC 2008


On Sat, 2008-07-05 at 10:31 -0500, Robert Dailey wrote:

> Basically, I'm trying to run a Ventrilo server, but the documentation
> for Ventrilo suggests that you run the server as a user named
> "ventrilo". That way, I can use chmod and chown to give the server
> access rights to the files that the Ventrilo server will be
> needing/accessing. The exact line of script I posted in my original
> post was the suggested script to be run. However, I was surprised to
> find (mainly due to my lack of experience) that I had to enter a
> password prompt each time I ran my script to start the server.
> 
> I plan to make this script "hands-free", because later on I'm going to
> be adding this to my /etc/rc.d/rc.local so that the server starts by
> itself every time I reboot the server. "hands-free" here means
> basically that the script does not require any user interaction, such
> as requesting passwords.

If you are going to do this in a startup script at boot time then using
"su" will work, since the rc scripts are run with root privileges.  So
your original "su" command will work in rc.local since root does not
require a password prompt.   You could do the equivalent with sudo
using:

sudo -u ventrilo <command> 

in the startup script.

Normal Unix/Linux practice is to use "su" to switch privileges in the
rc.* startup scripts.  Some systems do not allow "root" to run sudo, so
using "su" is preferred.
-- 
Smoot Carl-Mitchell
System/Network Architect
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005




More information about the ubuntu-users mailing list