Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOW TO] halt, reboot, shutdown as ordinary user
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
m@o
Apprentice
Apprentice


Joined: 25 Nov 2003
Posts: 184
Location: /eu/at/grz

PostPosted: Sun Jan 25, 2004 2:01 pm    Post subject: [HOW TO] halt, reboot, shutdown as ordinary user Reply with quote

i searched the web for a while to get this done and i
found 4 methods:

the first and best method is as follows:
Code:
# emerge sudo
# visudo
or
# nano -w /etc/sudoers

add these lines to this file:
Code:
yourusername ALL=(root)NOPASSWD:/sbin/halt
yourusername ALL=(root)NOPASSWD:/sbin/reboot
yourusername ALL=(root)NOPASSWD:/sbin/shutdown

or if you want to give a whole group the permission
to halt the computer:
Code:
%groupname ALL=(root)NOPASSWD:/sbin/halt
%groupname ALL=(root)NOPASSWD:/sbin/reboot
%groupname ALL=(root)NOPASSWD:/sbin/shutdown

after that you should add a little bash script to your
/usr/local/bin/ folder:
Code:
#!/bin/bash
sudo /sbin/halt

name it 'halt' and don't forget to make it executable
Code:
# chmod 755 /usr/local/bin/halt

do the same for reboot and shutdown too.

the second method is the following:

!!! this method is NOT increasing the security of your system !!!

add a sticky bit to /sbin/halt
Code:
# chmod a+s /sbin/halt

to halt as user just do:
Code:
$ /sbin/halt

do scripts as described above. but of course without sudo!

the third method is to solve it over groups:

Code:
# groupadd shutdown
# usermod -G shutdown,users $USER
# chgrp shutdown /sbin/halt
# chmod 750 /sbin/halt
# chgrp shutdown /sbin/reboot
# chmod 750 /sbin/reboot
# chgrp shutdown /sbin/shutdown
# chmod 750 /sbin/shutdown


the fourth method is the weakest:

change the following line in /etc/initab:
Code:
ca:12345:ctrlaltdel:/sbin/shutdown -r now

take away the -r and replace it with an -h
Code:
ca:12345:ctrlaltdel:/sbin/shutdown -h now

then the Ctrl+Alt+del key shortcut should halt your machine.



i'm using the first version, because i think its the most secure one.
and it really works fine for me.

have fun :D
m@o


references and other posts to this target:
https://forums.gentoo.org/viewtopic.php?t=19791
https://forums.gentoo.org/viewtopic.php?t=28143
https://forums.gentoo.org/viewtopic.php?t=28510
https://forums.gentoo.org/viewtopic.php?t=6253
https://forums.gentoo.org/viewtopic.php?t=1401


Last edited by m@o on Wed Feb 15, 2006 2:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
ank
Apprentice
Apprentice


Joined: 06 Aug 2003
Posts: 185
Location: Maribor, Slovenia

PostPosted: Sat Jan 31, 2004 8:43 pm    Post subject: Reply with quote

Mayby is a dumb question and i shuld already know the answer: What to do if you wish that ctrl+ald+del do nothing?

Now it close all program except X-windows and xfce and i dont like that.

Is it enough if i just edit the line to:

ca:12345:ctrlaltdel:


Sorry!
Me bad 8O
I shuld use google first next time, before asking dumb question:

http://www.dslreports.com/faq/4033
Back to top
View user's profile Send private message
ett_gramse_nap
Apprentice
Apprentice


Joined: 01 Oct 2003
Posts: 252
Location: Göteborg, Sweden

PostPosted: Sun Feb 01, 2004 8:11 pm    Post subject: Reply with quote

Thanks a lot!
_________________
Don't bother!
Back to top
View user's profile Send private message
SaFrOuT
Apprentice
Apprentice


Joined: 08 Jul 2003
Posts: 256
Location: Egypt

PostPosted: Sun Feb 01, 2004 10:54 pm    Post subject: Reply with quote

thanx alot

i really needed this Tip very much
Back to top
View user's profile Send private message
aamonten
n00b
n00b


Joined: 27 Aug 2003
Posts: 72
Location: Chile

PostPosted: Thu Feb 05, 2004 3:05 am    Post subject: Reply with quote

I prefer the third method
Back to top
View user's profile Send private message
v912485
n00b
n00b


Joined: 05 Feb 2004
Posts: 26
Location: London, UK

PostPosted: Thu Feb 05, 2004 9:50 pm    Post subject: Reply with quote

How about adding a pam solution?
Back to top
View user's profile Send private message
ezman
n00b
n00b


Joined: 22 Jan 2004
Posts: 9
Location: NorthWestern U.S.

PostPosted: Sun Mar 07, 2004 7:07 pm    Post subject: Reply with quote

I made my users able to use poweroff and reboot by issuing the following

Code:
#ln -s /sbin/poweroff /bin/poweroff
#ln -s /sbin/reboot /bin/reboot


its a quick and dirty method but works for now.

I will however try the first method mentioned using sudo.
_________________
Happy Gentoo Convert :)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum