Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Shutdown from Command Line
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
spadearcher
Tux's lil' helper
Tux's lil' helper


Joined: 18 Nov 2006
Posts: 131
Location: Seattle

PostPosted: Sun Jan 21, 2007 1:01 am    Post subject: Shutdown from Command Line Reply with quote

What is the command, if any, that can be executed from the console command line that totally shuts down the system?
Back to top
View user's profile Send private message
414C485649
n00b
n00b


Joined: 02 Feb 2006
Posts: 26
Location: Guatemala

PostPosted: Sun Jan 21, 2007 1:23 am    Post subject: Reply with quote

Any of the following:

Code:
shutdown -h now

Code:
halt

Code:
poweroff
Back to top
View user's profile Send private message
spadearcher
Tux's lil' helper
Tux's lil' helper


Joined: 18 Nov 2006
Posts: 131
Location: Seattle

PostPosted: Sun Jan 21, 2007 1:36 am    Post subject: Reply with quote

Very strange. When trying to execute any of those from my "jim@localhost ~ $" prompt, none work! I appreciate your quick response on this. Any idea what might be happening? It should be a simple matter, shouldn't it? Thanks again, Jim
Back to top
View user's profile Send private message
noice
Guru
Guru


Joined: 05 Dec 2005
Posts: 473
Location: italia, Ischia

PostPosted: Sun Jan 21, 2007 1:43 am    Post subject: Reply with quote

there is an How-to but it's in italian language:
https://forums.gentoo.org/viewtopic-t-206349-highlight-spegnere+utente.html
_________________
Noice

when you post remove comments
Code:
grep -vh '^[[:space:]]*\(#\|$\)' "$@"
Back to top
View user's profile Send private message
414C485649
n00b
n00b


Joined: 02 Feb 2006
Posts: 26
Location: Guatemala

PostPosted: Sun Jan 21, 2007 1:43 am    Post subject: Reply with quote

Try to run the commands as root. It's because those are located in /usr/sbin I think (not sure, not in my gentoo box right now) and this directory is not in the path of common users.

You're welcome. :wink:

EDIT: Is in /sbin


Last edited by 414C485649 on Sun Jan 21, 2007 2:12 am; edited 1 time in total
Back to top
View user's profile Send private message
spadearcher
Tux's lil' helper
Tux's lil' helper


Joined: 18 Nov 2006
Posts: 131
Location: Seattle

PostPosted: Sun Jan 21, 2007 1:55 am    Post subject: Reply with quote

You're right. They work fine from root. But that doesn't really help me, because I want to be able to have one of those commands executed from my config file via a window button, and I don't want to always be operating from root. This has been helpful, but Is there something more I need to do to accomplish what I'm after? Many thanks. Jim
Back to top
View user's profile Send private message
414C485649
n00b
n00b


Joined: 02 Feb 2006
Posts: 26
Location: Guatemala

PostPosted: Sun Jan 21, 2007 2:11 am    Post subject: Reply with quote

Maybe if you create a symlink to any of the commands, for example shutdown, in your home/bin ... if you have one. But if you want any user to be capable of execute shutdown, you may create the symlink in /bin (but be careful with that)

As root do:

Code:
 ln -s /sbin/shutdown /bin/shutdown


This should work for you.
Back to top
View user's profile Send private message
noice
Guru
Guru


Joined: 05 Dec 2005
Posts: 473
Location: italia, Ischia

PostPosted: Sun Jan 21, 2007 2:29 am    Post subject: Reply with quote

414C485649 wrote:

Code:
 ln -s /sbin/shutdown /bin/shutdown


i think that it not works..
you can tried in this way:
Code:
#emerge sudo
#visudo

in visudo add
Code:
%shutdown ALL=(root) NOPASSWD: /sbin/reboot.sh
%shutdown ALL=(root) NOPASSWD: /sbin/halt.sh

create /usr/bin/reboot
Code:
#touch /usr/bin/reboot

and /usr/bin/halt
Code:
#touch /usr/bin/halt

in /usr/bin/reboot put
Code:
#! /bin/sh
sudo /sbin/reboot.sh $*

in /usr/bin/halt put
Code:
#! /bin/sh
sudo /sbin/halt.sh $*

after
Code:
# cd /usr/bin/
# groupadd shutdown
# chgrp shutdown reboot halt
# chmod 755 reboot halt

create /sbin/reboot.sh
Code:
#touch /sbin/reboot.sh

and /sbin/halt.sh
Code:
#touch /sbin/halt.sh

in /sbin/reboot.sh put
Code:
#! /bin/sh
/sbin/shutdown -r 0

and in /sbin/halt.sh put
Code:
#! /bin/sh
/sbin/shutdown -h 0

after
Code:
# cd /sbin/
# chmod 744 reboot.sh halt.sh

edit /etc/group and add to it
Code:
...
shutdown:x:407:<user1>,<user2>,...,<userN>...

now you can use as user "reboot" and "halt" :wink:

edit:for info here
how-to by fctk
_________________
Noice

when you post remove comments
Code:
grep -vh '^[[:space:]]*\(#\|$\)' "$@"


Last edited by noice on Sun Jan 21, 2007 2:50 am; edited 1 time in total
Back to top
View user's profile Send private message
414C485649
n00b
n00b


Joined: 02 Feb 2006
Posts: 26
Location: Guatemala

PostPosted: Sun Jan 21, 2007 2:46 am    Post subject: Reply with quote

noice wrote:
414C485649 wrote:

Code:
 ln -s /sbin/shutdown /bin/shutdown


i think that it not works..


Yep, that does not work. Sorry I wasn't at my gentoo box so I was unable to try before posting. :oops:
You should try what noice says.
Back to top
View user's profile Send private message
spadearcher
Tux's lil' helper
Tux's lil' helper


Joined: 18 Nov 2006
Posts: 131
Location: Seattle

PostPosted: Sun Jan 21, 2007 7:04 am    Post subject: Reply with quote

Noice: Your instructions worked fine, with some minor modification. Your "%shutdown..." additions to visudo apparently didn't quite do the trick, and I had to uncomment the command lines in general allowing users to execute them. But now all functions well. Many many thanks (to the two of you) for your efforts in guding me to a successful outcome. Regards to you both, Jim
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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