LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2005, 06:16 PM   #1
ppcthug
Member
 
Registered: Jan 2005
Location: california
Posts: 35

Rep: Reputation: 22
can I shut down my comp without logging into root?


I can't seem to use the shutdown command without switching to root login, is there a way to allow other users to shutdown the computer?
 
Old 02-11-2005, 06:31 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Yes. Do you use a graphical login manager (do you log in using a graphical tool). Which one is it? KDM or GDM?
 
Old 02-11-2005, 06:41 PM   #3
ppcthug
Member
 
Registered: Jan 2005
Location: california
Posts: 35

Original Poster
Rep: Reputation: 22
I'm useing gnome.

Last edited by ppcthug; 02-11-2005 at 08:52 PM.
 
Old 02-12-2005, 01:59 AM   #4
ppcthug
Member
 
Registered: Jan 2005
Location: california
Posts: 35

Original Poster
Rep: Reputation: 22
and gnome = gdm right?
 
Old 02-12-2005, 02:47 AM   #5
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 849

Rep: Reputation: 33
Use sudo. It's a program used to give underprivilaged users rights to use root's commands. It's probably installed on your box already, so just "man sudo".
 
Old 02-12-2005, 03:17 PM   #6
ppcthug
Member
 
Registered: Jan 2005
Location: california
Posts: 35

Original Poster
Rep: Reputation: 22
no manual entry for sudo, nutbunnies.
 
Old 02-12-2005, 03:42 PM   #7
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 849

Rep: Reputation: 33
http://www.aplawrence.com/Basics/sudo.html
 
Old 02-12-2005, 09:39 PM   #8
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
Here's one way.

1) Created a new group named "pwroff"
Code:
	root@corvette:~# groupadd pwroff
2) Then find what groups you belong too & add yourself to the group:
Code:
	root@corvette:~# groups hammer
	hammer : users
	root@corvette:~# usermod users,pwroff hammer
3) Then edit /etc/sudoers, using visudo, to add the commands for the pwroff group.
Code:
root@corvette:~# visudo
Then add these 2 lines at the bottom:
NOTE: If you don't want to have to enter root's password to shutdown then set the NOPASSWD flag.
Code:
%pwroff corvette = NOPASSWD: /sbin/poweroff
%pwroff corvette = NOPASSWD: /sbin/reboot
4) Then add a couple 1 line scripts to your $PATH so you can just invoke the command "poweroff" & "reboot", without having to enter the whole thing. I choose /usr/bin for these scripts because it comes after /sbin in root's $PATH, meaning the actual reboot & poweroff commands would still be invoked by root instead of these 2 scripts. Anyway, make sure you don't overwrite the real poweroff & reboot programs, wherever they are.
Code:

cat > /usr/bin/reboot << "EOF"
#!/bin/sh

sudo /sbin/reboot
EOF
Code:

cat > /usr/bin/poweroff << "EOF"
#!/bin/sh

sudo /sbin/poweroff
EOF
5) Now change the group and permissions on these 2 scripts:
Code:
chgrp pwroff /usr/bin/poweroff
chgrp pwroff /usr/bin/reboot
chmod ug+x /usr/bin/poweroff
chmod ug+x /usr/bin/reboot
That's it, now anyone that is a member of the pwroff group can reboot & poweroff the PC without a password or without being root.

Last edited by DaHammer; 02-13-2005 at 12:22 AM.
 
Old 02-12-2005, 09:49 PM   #9
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
In some distros, you can also create afile called /etc/shutdown.allow containing a list of users allowed to shut down the system.
 
Old 02-13-2005, 06:19 AM   #10
nixcraft
Member
 
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379

Rep: Reputation: 30
Quote:
Originally posted by DaHammer
Here's one way.

1) Created a new group named "pwroff"
Code:
	root@corvette:~# groupadd pwroff
2) Then find what groups you belong too & add yourself to the group:
Code:
	root@corvette:~# groups hammer
	hammer : users
	root@corvette:~# usermod users,pwroff hammer
3) Then edit /etc/sudoers, using visudo, to add the commands for the pwroff group.
Code:
root@corvette:~# visudo
Then add these 2 lines at the bottom:
NOTE: If you don't want to have to enter root's password to shutdown then set the NOPASSWD flag.
Code:
%pwroff corvette = NOPASSWD: /sbin/poweroff
%pwroff corvette = NOPASSWD: /sbin/reboot
4) Then add a couple 1 line scripts to your $PATH so you can just invoke the command "poweroff" & "reboot", without having to enter the whole thing. I choose /usr/bin for these scripts because it comes after /sbin in root's $PATH, meaning the actual reboot & poweroff commands would still be invoked by root instead of these 2 scripts. Anyway, make sure you don't overwrite the real poweroff & reboot programs, wherever they are.
Code:

cat > /usr/bin/reboot << "EOF"
#!/bin/sh

sudo /sbin/reboot
EOF
Code:

cat > /usr/bin/poweroff << "EOF"
#!/bin/sh

sudo /sbin/poweroff
EOF
5) Now change the group and permissions on these 2 scripts:
Code:
chgrp pwroff /usr/bin/poweroff
chgrp pwroff /usr/bin/reboot
chmod ug+x /usr/bin/poweroff
chmod ug+x /usr/bin/reboot
That's it, now anyone that is a member of the pwroff group can reboot & poweroff the PC without a password or without being root.
No need to setup group permission or other stuff on RH you can use shutdown account to do this http://www.cyberciti.biz/nixcraft/vi...own-linux.html
 
Old 02-13-2005, 07:40 AM   #11
johntramp
Member
 
Registered: Sep 2003
Location: Christchurch, New Zealand
Distribution: Gentoo / Slackware
Posts: 72

Rep: Reputation: 15
thanks alot for that DaHammer, even if nobody else appreciates it I will definately use it.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
My comp does not shut down caezar Mandriva 2 09-25-2005 03:25 AM
how to do: using a linux comp to act as router for a windows comp grimhammer Linux - Networking 8 02-10-2005 10:56 PM
couldn't ping a WinXp comp from Fedora Comp tanbetien Fedora 5 12-04-2003 07:03 AM
Telnetting to comp does not allow Root login ksoma Linux - Networking 9 06-22-2003 07:45 AM
using red-carpet without logging out and logging as root. packman Linux - Software 1 12-09-2002 03:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:33 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