View previous topic :: View next topic |
Author |
Message |
spadearcher Tux's lil' helper
Joined: 18 Nov 2006 Posts: 131 Location: Seattle
|
Posted: Sun Jan 21, 2007 1:01 am Post subject: Shutdown from Command Line |
|
|
What is the command, if any, that can be executed from the console command line that totally shuts down the system? |
|
Back to top |
|
|
414C485649 n00b
Joined: 02 Feb 2006 Posts: 26 Location: Guatemala
|
Posted: Sun Jan 21, 2007 1:23 am Post subject: |
|
|
Any of the following:
|
|
Back to top |
|
|
spadearcher Tux's lil' helper
Joined: 18 Nov 2006 Posts: 131 Location: Seattle
|
Posted: Sun Jan 21, 2007 1:36 am Post subject: |
|
|
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 |
|
|
noice Guru
Joined: 05 Dec 2005 Posts: 473 Location: italia, Ischia
|
|
Back to top |
|
|
414C485649 n00b
Joined: 02 Feb 2006 Posts: 26 Location: Guatemala
|
Posted: Sun Jan 21, 2007 1:43 am Post subject: |
|
|
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.
EDIT: Is in /sbin
Last edited by 414C485649 on Sun Jan 21, 2007 2:12 am; edited 1 time in total |
|
Back to top |
|
|
spadearcher Tux's lil' helper
Joined: 18 Nov 2006 Posts: 131 Location: Seattle
|
Posted: Sun Jan 21, 2007 1:55 am Post subject: |
|
|
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 |
|
|
414C485649 n00b
Joined: 02 Feb 2006 Posts: 26 Location: Guatemala
|
Posted: Sun Jan 21, 2007 2:11 am Post subject: |
|
|
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 |
|
|
noice Guru
Joined: 05 Dec 2005 Posts: 473 Location: italia, Ischia
|
Posted: Sun Jan 21, 2007 2:29 am Post subject: |
|
|
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"
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 |
|
|
414C485649 n00b
Joined: 02 Feb 2006 Posts: 26 Location: Guatemala
|
Posted: Sun Jan 21, 2007 2:46 am Post subject: |
|
|
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.
You should try what noice says. |
|
Back to top |
|
|
spadearcher Tux's lil' helper
Joined: 18 Nov 2006 Posts: 131 Location: Seattle
|
Posted: Sun Jan 21, 2007 7:04 am Post subject: |
|
|
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 |
|
|
|