LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-06-2010, 12:00 AM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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-06-2010 at 12:03 AM.
 
Old 01-06-2010, 12:10 AM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,318

Rep: Reputation: 126Reputation: 126
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-06-2010, 12:12 AM   #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-06-2010, 12:22 AM   #4
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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 05:48 AM.
 
Old 01-06-2010, 12:37 AM   #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-06-2010, 12:42 AM   #6
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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, 11:05 AM   #7
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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, 11:10 AM   #8
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / 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, 11:15 AM   #9
the trooper
Senior Member
 
Registered: Jun 2006
Location: England
Distribution: Debian Stretch Amd64
Posts: 1,477

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, 11:44 AM   #10
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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, 11:53 AM   #11
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / 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, 12:02 PM   #12
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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 12:10 PM.
 
Old 01-13-2010, 01:07 PM   #13
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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 01:08 PM.
 
1 members found this post helpful.
Old 01-13-2010, 01:55 PM   #14
MBybee
Member
 
Registered: Jan 2009
Location: wherever I can make a living
Distribution: PC-BSD / FreeBSD / 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, 04:37 PM   #15
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

All times are GMT -5. The time now is 10:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration