Solved

How to start a service without using the root account in linux

Posted on 2006-07-22
6
302 Views
Last Modified: 2013-12-16
Hi Friends

How can i assign a user  to start | stop | restart a service?
I tried one method ... :).

"chown user.user /etc/init.d/nagios".

 But didn't work . . :(

Would you help me out to find an answer.?

Regards

0
Comment
Question by:dinkon4u
6 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 125 total points
ID: 17159778
use sudo and configure /etc/sudoers
eg. in /etc/sudoers
username   ALL=/etc/init.d/nagios *

then as username
sudo /etc/init.d/nagios start
0
 
LVL 22

Assisted Solution

by:pjedmond
pjedmond earned 125 total points
ID: 17159782
The problem is that the service needs to initially run as root in many cases. In order to do this, you need you use:

1.    Setuid - Not recommended, unless you trust the individuals that have access to the system 100%:

http://www.samag.com/documents/s=1149/sam0106a/0106a.htm

gives a number of good reasons not to use this approach.

2.   Use sudo - This allows commands to be executed as root based on permissions in the /etc/sudoers file:

http://www.chinalinuxpub.com/doc/www.siliconvalleyccie.com/linux-hn/sudo.htm

Due to the nature of this command if a 'flaw' is found in it, then the implications are potentially serious, so you need to keep an eye on advisories.

(   (()
(`-' _\
 ''  ''
0
 
LVL 3

Expert Comment

by:bryanlloydharris
ID: 17171104
Raven and pj are right, sudo is a good choice.

sudo service nagios start
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17175180
probably you vcan configure your service to use ports > 1023, then their might start it as ordinary user
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can't See Site After DNS Resolved 7 55
nagios 4 php error after installation 6 94
Hacked File Timestamps 4 62
Reset Root Password on CentOS 6 4 54
This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question