Solved

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

Posted on 2006-07-22
6
301 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now