LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-11-2007, 06:10 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
Let users to shutdown via sudoedit ?


Let users to shutdown via sudoedit ?

I just would like that users can shutdown the PC.
How to let users have this right ?

Code:
# ls -la /sbin/shutdown 
-rwxr-xr-x 1 root root 18152 2006-07-25 19:51 /sbin/shutdown
Quote:
~$ /sbin/shutdown
shutdown: you must be root to do that!
How to play with /etc/sudoers maybe for that ?
 
Old 02-11-2007, 08:27 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Maybe create a new group called 'shutdown' or something, add the users you want to be able to shut down to that group, then add this line to /etc/sudoers:
Code:
%shutdown ALL = /sbin/shutdown
Or for specific users (and not group) leave the %-mark off the beginning of the line and instead of group name type user name. It's of course more handy to use a group. You can make this several different ways, though; refer to
Code:
man sudoers
on what you can actually do.
 
Old 02-11-2007, 08:48 AM   #3
sn68
Member
 
Registered: Oct 2005
Distribution: FC5
Posts: 338

Rep: Reputation: 30
/etc/sudoers can be edited with visudo
After you run visudo you need to press "i" (w/o quotes) to start typing, and hit Esc to exit insert mode. After you've finished your addition, type :wq.

ZZ to close
 
Old 02-11-2007, 10:27 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Weird ... not working ... :-(

Code:
# whereis shutdown
shutdown: /sbin/shutdown /usr/share/man/man8/shutdown.8.gz

I followed :
Quote:
adduser shutdwn
blabla ok
Quote:
adduser xeratul shutdwn
blabla ok

then:
visudo

Code:
Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
%shutdwn   ALL = /sbin/shutdown
then,
I rebooted the box ...

and not possible to shutdown with xeratul account ...
why actually ?

thank you
 
Old 02-11-2007, 10:49 AM   #5
sn68
Member
 
Registered: Oct 2005
Distribution: FC5
Posts: 338

Rep: Reputation: 30
Change
Code:
%shutdwn   ALL = /sbin/shutdown
to
Code:
shutdwn ALL = (ALL) ALL
This will allow user "shutdwn" root priviledges needed to run shutdown script so
>sudo /sbin/shutdown

else

>su
pwd
>/sbin/shutdown

Last edited by sn68; 02-11-2007 at 10:50 AM.
 
Old 02-11-2007, 10:56 AM   #6
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Rep: Reputation: 35
For a start you created a user called shutdwn, you wanted to create a group called shutdwn, and add your user to that group
Also if you did have a user called shutdwn then they would have complete control for your system!

Keep what you did first and when you want to shutdown do (with out qoutes) 'sudo shutdown'


Last edited by snowtigger; 02-11-2007 at 10:59 AM.
 
Old 02-11-2007, 11:19 AM   #7
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by snowtigger
For a start you created a user called shutdwn, you wanted to create a group called shutdwn, and add your user to that group
Also if you did have a user called shutdwn then they would have complete control for your system!

Keep what you did first and when you want to shutdown do (with out qoutes) 'sudo shutdown'

pffff
it's getting more difficult now ..;

soo, how can I make this working for the xeratul user only:
Code:
$ shutdown -r now
(without sudo inbetween addition)

( If I change to ALL ALL , then the user can do all he wants like roots ? :-( )
 
Old 02-11-2007, 11:37 AM   #8
snowtigger
Member
 
Registered: Mar 2005
Location: england
Distribution: slackware, win2k
Posts: 364

Rep: Reputation: 35
Always use visudo to edit the sudoers file. As when you use this and save the file it will check that you have used the correct syntax.

To set it up for one user without asking for a password, add this to your sudoers. replace USER with your users name.

USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Then to shutdonw type 'sudo shutdown'

If you want to use sudo to do this then you will have to type sudo.

If you want to allow the group users to do this put this in your suduers.

$users ALL=(ALL) NOPASSWD: /sbin/shutdown

If you want to prompt users for there password to shut the system down remove the NOPASSWD.

One thing to point out is thatthe two above examples will let a user shutdown the system from anywhere, ie via ssh, telnet etc. To stop thatyou could use something like,

%users localhost=/sbin/shutdown

This will let everybody in the group users to only shutdown the system from the localhost.

I hope this helps and has not confused things any more for you.

 
Old 02-11-2007, 11:49 AM   #9
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by snowtigger
Always use visudo to edit the sudoers file. As when you use this and save the file it will check that you have used the correct syntax.

To set it up for one user without asking for a password, add this to your sudoers. replace USER with your users name.

USER ALL=(ALL) NOPASSWD: /sbin/shutdown

Then to shutdonw type 'sudo shutdown'

If you want to use sudo to do this then you will have to type sudo.

If you want to allow the group users to do this put this in your suduers.

$users ALL=(ALL) NOPASSWD: /sbin/shutdown

If you want to prompt users for there password to shut the system down remove the NOPASSWD.

One thing to point out is thatthe two above examples will let a user shutdown the system from anywhere, ie via ssh, telnet etc. To stop thatyou could use something like,

%users localhost=/sbin/shutdown

This will let everybody in the group users to only shutdown the system from the localhost.

I hope this helps and has not confused things any more for you.

You rock !
I work with :
Code:
sudo shutdown -r now
I can create in /usr/bin/myshutdown
containing sudo shutdown -r now

thank you
 
  


Reply

Tags
sudo, sudoers, visudo



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to stop a shutdown with multiple users dannyk1 Linux - General 3 04-22-2006 09:15 AM
Users can't shutdown in KDE duffmckagan Debian 1 10-20-2005 10:45 PM
Users unable to use shutdown Jskill007 Slackware 3 09-15-2004 02:54 AM
Allowing all users to use 'shutdown' command mrde50garfield Mandriva 5 01-08-2004 09:58 AM
allow users to shutdown plisken Linux - General 1 02-06-2002 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration