Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
in my /etc/rc.d/rc.local file, i am adding a command to start my teamspeak server on the boot of my webserver....everything ok, right?
BUT, i dont want to run it as root, ive configured this user "tss" to be able to run the teamspeak server with the command:
sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript start
which is in the file which has:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
sh /home/httpd/vhosts/bfserver.com/games/tss2_rc2/teamspeak2-server_startscript start
SO.....
how can i run this at startup as my user tss instead of root?
for doing stuff as other users without logging in, I think the command is "su user -c command". For shutting down the server, put something in the equavalent of /etc/rc.d/rc.0 on FC.
Originally posted by tuxdev for doing stuff as other users without logging in, I think the command is "su user -c command". For shutting down the server, put something in the equavalent of /etc/rc.d/rc.0 on FC.
Root can run "su <someuser>" without having to enter a password. If you just want to execute one command su'd instead of starting a shell logged in as that user, you use the -c option. So it'd be 'su -c "<command to run>" <user>'.
As for shutdown, most distributions have scripts that are used when you change runlevels (shutdown is changing to runlevel 0, reboot is changing to runlevel 6). So you need to find where Red Hat stores scripts for these runlevels, and add the command to stop the server there. I'm not 100% sure, but I think if you create /etc/rc.d/rc0.d/K??teamspeak, and /etc/rc.d/rc6.d/K??teamspeak (replace ?? with numbers... the scripts in the directory will execute in the order they're numbered), and put the commands in there (make sure that the files are executable), that might do it.
Originally posted by oot Root can run "su <someuser>" without having to enter a password. If you just want to execute one command su'd instead of starting a shell logged in as that user, you use the -c option. So it'd be 'su -c "<command to run>" <user>'.
As for shutdown, most distributions have scripts that are used when you change runlevels (shutdown is changing to runlevel 0, reboot is changing to runlevel 6). So you need to find where Red Hat stores scripts for these runlevels, and add the command to stop the server there. I'm not 100% sure, but I think if you create /etc/rc.d/rc0.d/K??teamspeak, and /etc/rc.d/rc6.d/K??teamspeak (replace ?? with numbers... the scripts in the directory will execute in the order they're numbered), and put the commands in there (make sure that the files are executable), that might do it.
so if i just make the file and insert the command it will run, awesome......
and i understant if im asking from root to run as tss i shouldent need a password...but read the last post I made, and see that it requireds a 2nd command after the first..hmmmm
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.