LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-05-2010, 11:00 PM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
Ubuntu/debian: Is there a way to give permissions for users to use SHUTDOWN command?


Hello,

Shutdown is for root only. But I would like to set a ubuntu box to give permissions for users to use SHUTDOWN command.

What is the modern way to do such operation?


I read that there is :
Quote:
adduser power yourusername
but actually I would like only the command : halt or shutdown now (if possible)
and
Quote:
adduser power yourusername
let certainly too much permissions for users that they can break the machine.

Last edited by frenchn00b; 01-05-2010 at 11:03 PM.
 
Old 01-05-2010, 11:10 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Rep: Reputation: 141Reputation: 141
It shouldn't be hard to add a rule to /etc/sudoers to allow all users to shut your system down. "man sudoers"
 
1 members found this post helpful.
Old 01-05-2010, 11:12 PM   #3
~sHyLoCk~
Senior Member
 
Registered: Jul 2008
Location: /dev/null
Posts: 1,173
Blog Entries: 12

Rep: Reputation: 129Reputation: 129
Well I usually add to my sudoers:
Quote:
shy ALL=(ALL) NOPASSWD: /sbin/shutdown
shy ALL=(ALL) NOPASSWD:/sbin/reboot
This helps me since I use WMs.
 
Old 01-05-2010, 11:22 PM   #4
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by ~sHyLoCk~ View Post
Well I usually add to my sudoers:


This helps me since I use WMs.
Thank you !! I am gonna try the modern trick, and let you know. Sounds very good.

# cat sudoers

Code:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults	env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL

shy ALL=(ALL) NOPASSWD:/sbin/shutdown
shy ALL=(ALL) NOPASSWD:/sbin/reboot

Last edited by frenchn00b; 02-11-2010 at 04:48 AM.
 
Old 01-05-2010, 11:37 PM   #5
~sHyLoCk~
Senior Member
 
Registered: Jul 2008
Location: /dev/null
Posts: 1,173
Blog Entries: 12

Rep: Reputation: 129Reputation: 129
Err... don't put shy that's my username, replace it with your username. :P
 
Old 01-05-2010, 11:42 PM   #6
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by ~sHyLoCk~ View Post
Err... don't put shy that's my username, replace it with your username. :P
I changed to correct user. thank you it was importnat to mention.

I wish you a pleasant day
 
Old 01-13-2010, 10:05 AM   #7
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Code:
apt-get install sudo
Code:
frenchnoob ALL=(ALL) NOPASSWD: /sbin/shutdown
Code:
~$ /sbin/shutdown now
shutdown: you must be root to do that!
well I have to look what it is ...
 
Old 01-13-2010, 10:10 AM   #8
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
Quote:
Originally Posted by frenchn00b View Post
Code:
apt-get install sudo
Code:
frenchnoob ALL=(ALL) NOPASSWD: /sbin/shutdown
Code:
~$ /sbin/shutdown now
shutdown: you must be root to do that!
well I have to look what it is ...
You need to invoke sudo to use sudo, so try this:
Code:
sudo shutdown now
See if that works. You can also use a wrapper script, setuid, alias, etc.

Alias might be the fastest and easiest.
http://webtools.live2support.com/linux/alias.php

Basically just set up an alias in your login script like so:
Code:
alias shutdown 'sudo shutdown -h now'
Then whenever you type 'shutdown', you'll get the desired reaction.
 
Old 01-13-2010, 10:15 AM   #9
the trooper
Senior Member
 
Registered: Jun 2006
Location: England
Distribution: Debian Bullseye
Posts: 1,508

Rep: Reputation: Disabled
As MBybee said you need to use sudo.
What window manager are you using?.
The reason i ask is because i do something very similar to shutdown/restart Fluxbox from a menu entry.
 
Old 01-13-2010, 10:44 AM   #10
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by the trooper View Post
As MBybee said you need to use sudo.
What window manager are you using?.
The reason i ask is because i do something very similar to shutdown/restart Fluxbox from a menu entry.
found at the same time: http://linux.byexamples.com/archives...sudo-password/

I added sudo before : and it works
above I placed a link how to make it without sudo :
Code:
chmod +s /sbin/shutdown
thank you !!

Cool for my mythtv box with lirc remote control!!
 
Old 01-13-2010, 10:53 AM   #11
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
Quote:
Originally Posted by frenchn00b View Post
found at the same time: http://linux.byexamples.com/archives...sudo-password/

I added sudo before : and it works
above I placed a link how to make it without sudo :
Code:
chmod +s /sbin/shutdown
thank you !!

Cool for my mythtv box with lirc remote control!!
That's actually setuid - basically you're saying that any user who executes the command does so as the owner of the command (root).
Quick, but it is a bit dangerous as a fix-all.
 
Old 01-13-2010, 11:02 AM   #12
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by MBybee View Post
That's actually setuid - basically you're saying that any user who executes the command does so as the owner of the command (root).
Quick, but it is a bit dangerous as a fix-all.
oh really? thank you for hte infromation..
I didnt do chmod +s /sbin/shutdown

Well, ... the testing was as follows:

visudo
Code:
frenchnoob ALL=(ALL) NOPASSWD: /sbin/shutdown
frenchnoob ALL=(ALL) NOPASSWD: /sbin/reboot
DONE

I added to .lircrc the command to do :
Code:
sudo shutdown now
when press on power
DONE, it works, ... but not well ...

The X stops (tinywm) and the pc goes to console, and no shutdown
the pc (console mode tty ) askes me for the root password
not working Any ideas?


edit:
I start X like this : http://tldp.org/LDP/LG/issue72/chung.html

Last edited by frenchn00b; 01-13-2010 at 11:10 AM.
 
Old 01-13-2010, 12:07 PM   #13
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
OK , I found

I had certainly to use " for "shutdown now"

So I did like this: (working way):
no chmod +s

visudo and I add:
Code:
frenchnoob ALL=(ALL) NOPASSWD: /sbin/halt
frenchnoob ALL=(ALL) NOPASSWD: /sbin/reboot
then into .lircrc, I use:


Code:
begin
    prog = irexec
    button = Power
    config = sudo halt &
end

Thank you ! It can work now.

mythtv or Freevo linux home tv recommended.

Last edited by frenchn00b; 01-13-2010 at 12:08 PM.
 
1 members found this post helpful.
Old 01-13-2010, 12:55 PM   #14
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
Excellent to see! You might want to mark the thread as solved for anyone who comes looking. I know I wasn't able to find any instructions for tinywm in the first couple searches I did.
 
Old 01-13-2010, 03:37 PM   #15
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by the trooper View Post
As MBybee said you need to use sudo.
What window manager are you using?.
The reason i ask is because i do something very similar to shutdown/restart Fluxbox from a menu entry.
tinywm for mythtv .. it is nice
all goes via nut's n bolt and .xinitrc
 
  


Reply



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
Like plugdev, how to give permissions to users for GPHOTO2? frenchn00b Linux - General 0 08-19-2009 03:45 PM
how to give the permissions to gphoto2 for users? frenchn00b Linux - General 0 07-27-2009 06:44 AM
I need a way to give several users permissions to run a single program Thaidog Linux - Desktop 1 01-04-2009 02:06 AM
How to give permissions for users....... manikantha Linux - General 1 03-17-2005 04:27 AM
give users permissions to write dragosp Linux - Security 2 09-12-2004 06:53 AM

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

All times are GMT -5. The time now is 02:51 AM.

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