Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do I halt the system?
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
HungGarTiger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2014
Posts: 127
Location: /nz/auckland

PostPosted: Sun Aug 27, 2017 9:54 am    Post subject: How do I halt the system? Reply with quote

[Moderator edit: Changed title to try to attract relevant answers. -Hu]

Ok, this might rate as one of the dubest questions I've every asked but, how the hell do I turn off my box?

Apparently
Code:
shutdown, poweroff, halt
all these commands don't exsit in openrc anymore? I even searched around and found that
Code:
openrc-shutdown
is the new way to turn the box off but that doesn't work either...

Am I missing something here? :oops:
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1462

PostPosted: Sun Aug 27, 2017 10:00 am    Post subject: Reply with quote

Wait, what?
What version is it?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 38871
Location: 56N 3W

PostPosted: Sun Aug 27, 2017 10:01 am    Post subject: Reply with quote

HungGarTiger,

Those are all privileged commands. You need to be root to run them, or you need an agent to run them as root for you.

Code:
 $ equery b shutdown
 * Searching for shutdown ...
media-libs/libcanberra-0.30-r5 (/usr/share/gnome/shutdown)
sys-apps/openrc-0.17 (/usr/share/openrc/runlevels/shutdown)
sys-apps/sysvinit-2.88-r9 (/sbin/shutdown)

shutdown itself is provided by sys-apps/sysvinit.

See also
Code:
man shutdown

_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
HungGarTiger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2014
Posts: 127
Location: /nz/auckland

PostPosted: Sun Aug 27, 2017 10:02 am    Post subject: Reply with quote

szatox wrote:
Wait, what?
What version is it?


The newst one? I only installed today. Apparently
Code:
openrc-shutdown
registers as a command as superuser but doesn't actually do anything.
Code:
reboot
works fine
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 5043
Location: Removed by Neddy

PostPosted: Sun Aug 27, 2017 10:21 am    Post subject: Reply with quote

Those commands never existed in openrc, they are part of sysvinit & are root commands (need sudo if you want a regular user to use them)

Code:

grep "shutdown$\|poweroff$\|reboot$\|halt$\|init$" <(equery f sysvinit)
/sbin/halt
/sbin/init
/sbin/poweroff
/sbin/reboot
/sbin/shutdown
/sbin/telinit


The kernel will by default attempt to launch /sbin/init once it has finished booting. Traditionally this has been provided by sysvinit & openRC still depends on this package for this precise reason.


Not to long ago OpenRC included its own init command & to ensure no clashes called then openrc-init, openrc-shutdown.
HOWEVER, you must go out of your way to include init=/sbin/openrc-init as a bootoption -> you have already chosen to use openrc init. Once you have made that decision you need to use openrc shutdown command.

Code:
grep "shutdown$\|poweroff$\|reboot$\|halt$\|init$" <(equery f openrc)
/sbin/openrc-init
/sbin/openrc-shutdown




So the real question is ...
do you set your kernel boot option to init=/sbin/openrc-init as per https://wiki.gentoo.org/wiki/OpenRC#openrc-init. If you did then you need to adhere to the pre-req of the command. If you didn't and are still booting via /sbin/init and thus you must have sysvinit installed... where are your other init commands...

unless you did something unconventional and have /sbin/openrc-init -> /sbin/init
_________________
The best argument against democracy is a five-minute conversation with the average voter
Great Britain is a republic, with a hereditary president, while the United States is a monarchy with an elective king
Back to top
View user's profile Send private message
HungGarTiger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2014
Posts: 127
Location: /nz/auckland

PostPosted: Sun Aug 27, 2017 10:58 am    Post subject: Reply with quote

Naib wrote:
So the real question is ...
do you set your kernel boot option to init=/sbin/openrc-init as per https://wiki.gentoo.org/wiki/OpenRC#openrc-init. If you did then you need to adhere to the pre-req of the command. If you didn't and are still booting via /sbin/init and thus you must have sysvinit installed... where are your other init commands...

unless you did something unconventional and have /sbin/openrc-init -> /sbin/init


I only installed this system today, so I haven't done this. I've just followed the guide and it wasn't in there, unless it's an option that's run in genkernel (I did my kernel manually)
Back to top
View user's profile Send private message
Hund
n00b
n00b


Joined: 18 Jul 2016
Posts: 13
Location: Sweden

PostPosted: Sun Aug 27, 2017 12:44 pm    Post subject: Reply with quote

Code:
# shutdown -h 0

Works out of the box.
_________________
Screenshots | dotfiles | Keyboards
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 5043
Location: Removed by Neddy

PostPosted: Sun Aug 27, 2017 1:19 pm    Post subject: Reply with quote

HungGarTiger wrote:
Naib wrote:
So the real question is ...
do you set your kernel boot option to init=/sbin/openrc-init as per https://wiki.gentoo.org/wiki/OpenRC#openrc-init. If you did then you need to adhere to the pre-req of the command. If you didn't and are still booting via /sbin/init and thus you must have sysvinit installed... where are your other init commands...

unless you did something unconventional and have /sbin/openrc-init -> /sbin/init


I only installed this system today, so I haven't done this. I've just followed the guide and it wasn't in there, unless it's an option that's run in genkernel (I did my kernel manually)
using openrc-init is still "experimental"

so now I am confused with your opening statement because you will have the needed commands via sysvinit which is an install-time dependancy of openrc (for now...)

as mentioned these are root-only commands; what makes you think they are not present? what exactly did you do?
_________________
The best argument against democracy is a five-minute conversation with the average voter
Great Britain is a republic, with a hereditary president, while the United States is a monarchy with an elective king


Last edited by Naib on Sun Aug 27, 2017 4:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 38871
Location: 56N 3W

PostPosted: Sun Aug 27, 2017 1:26 pm    Post subject: Reply with quote

Hund,

Your # shows you are root.
It won't work for a normal user.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hund
n00b
n00b


Joined: 18 Jul 2016
Posts: 13
Location: Sweden

PostPosted: Sun Aug 27, 2017 2:54 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Hund,

Your # shows you are root.
It won't work for a normal user.


Yes. But I assume he has access to sudo or the root user. :)
_________________
Screenshots | dotfiles | Keyboards
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 5043
Location: Removed by Neddy

PostPosted: Sun Aug 27, 2017 2:59 pm    Post subject: Reply with quote

Hund wrote:
NeddySeagoon wrote:
Hund,

Your # shows you are root.
It won't work for a normal user.


Yes. But I assume he has access to sudo or the root user. :)
assume makes an ASS out of U and ME
_________________
The best argument against democracy is a five-minute conversation with the average voter
Great Britain is a republic, with a hereditary president, while the United States is a monarchy with an elective king
Back to top
View user's profile Send private message
Cyker
Veteran
Veteran


Joined: 15 Jun 2006
Posts: 1703

PostPosted: Sun Aug 27, 2017 3:30 pm    Post subject: Reply with quote

You should be able to poweroff in X, assuming you're using a DE or WM that has a shutdown command in its menu.

You should also be able to just hit the power button on your box to make it shut down?
Back to top
View user's profile Send private message
Tony0945
Veteran
Veteran


Joined: 25 Jul 2006
Posts: 1948
Location: Illinois, USA

PostPosted: Sun Aug 27, 2017 3:57 pm    Post subject: Reply with quote

Did you install open rc or systemd? Which version?

Please post the result of "emerge -pv openrc sysvinit" DON'T forget the "p".
EXAMPLE:
Code:
X3 ~ # emerge -pv openrc sysvinit

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-apps/sysvinit-2.88-r9::gentoo  USE="(-ibm) (-selinux) -static" 0 KiB
[ebuild   R    ] sys-apps/openrc-0.17::local  USE="ncurses netifrc pam -audit -debug -newnet (-prefix) (-selinux) -static-libs -tools -unicode" 0 KiB

Total: 2 packages (2 reinstalls), Size of downloads: 0 KiB

Don't be alarmed if your version is higher. I deliberately use an old version of openrc for reasons unrelated to your problem.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 11183

PostPosted: Sun Aug 27, 2017 4:00 pm    Post subject: Reply with quote

This should work. Please stop summarizing your problem and instead show us exactly what you did and exactly how it did not work. Don't refer to "the guide"; refer to a specific URL or other reasonably unique identifier we can use to go read the same material you read. Don't rephrase error messages. Paste them inline, preferably in a code tag.
Back to top
View user's profile Send private message
HungGarTiger
Tux's lil' helper
Tux's lil' helper


Joined: 04 Feb 2014
Posts: 127
Location: /nz/auckland

PostPosted: Sun Aug 27, 2017 10:19 pm    Post subject: Reply with quote

Hi guys,

Came back to this after a sleep, last night it was a big "I can't deal with this crazy nonsense" moment so Hu you're right I should've given more details. I'm setting up a headless home server, which I just finished installing yesterday so at the time of writing this I didn't even have sudo installed - I always forget that doesn't come as standard with Gentoo. Though the problems I was having was logged in as root.

Quote:
Did you install open rc or systemd? Which version?


I'm using openrc-0.28 and sysvinit-2.88

Quote:

You should also be able to just hit the power button on your box to make it shut down?

I'm not using X, nor do I just want to hit the power button.

So, when I typed
Code:
shutdown
as root user it gave me the message I needed to add more options. I would add those options "-h now" it would accept the command then do nothing.

Today, I log on and emerge sudo. Then test the commands again and the worked.

So, I'm not sure what was going on last night - or if it was a case of me being too tired and making a few simple errors that I simply wasn't aware of. But it all works fine with the only apparent change of me installing sudo. I have to say I'm slightly embarrassed but maybe this is a good lesson to go to sleep and take a break from the computer when you're tired before you do something you can undo. :oops:

Thanks for taking the time to reply to my (what was probably) a silly question :roll:
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 11183

PostPosted: Sun Aug 27, 2017 11:04 pm    Post subject: Reply with quote

With the right configuration, an ACPI-enabled machine can respond to a power button short press (not the 8 second hold!) by running a command, most commonly an immediate orderly shutdown. This can be convenient to allow a clean powerdown without needing to log in first. This would not have been available to you when you first installed it, but could be useful to set up when you have time. This is especially helpful if you have family members who can be told to go tap the power button, but you don't or can't give them root (or you can give them root, but don't care to train them how to use it).

This is most commonly done using acpid to monitor ACPI events.
Back to top
View user's profile Send private message
Tony0945
Veteran
Veteran


Joined: 25 Jul 2006
Posts: 1948
Location: Illinois, USA

PostPosted: Mon Aug 28, 2017 1:11 pm    Post subject: Reply with quote

HungGarTiger wrote:
So, when I typed
Code:
shutdown
as root user it gave me the message I needed to add more options. I would add those options "-h now" it would accept the command then do nothing.


I type "halt" from a virtual terminal if the Desktop screen is messed up. Sometimes it gives a problem if X11/Mate is running. Very reliable is "/etc/init.d/xdm stop" followed by "halt'.
Back to top
View user's profile Send private message
Ant P.
Advocate
Advocate


Joined: 18 Apr 2009
Posts: 4380

PostPosted: Mon Aug 28, 2017 4:36 pm    Post subject: Reply with quote

HungGarTiger wrote:
So, when I typed
Code:
shutdown
as root user it gave me the message I needed to add more options. I would add those options "-h now" it would accept the command then do nothing.

sysvinit also provides /sbin/poweroff which is a shortcut for shutdown -h now and /sbin/reboot that passes some other flag to shutdown. If none of those commands work, make sure /dev/initctl exists, sysvinit depends on that to do anything.
_________________
Your PID1 sucks // runit-scripts
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