LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-06-2019, 07:10 AM   #1
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Rep: Reputation: 43
systemd init 0 vs poweroff


Hi everyone,
before systemd I used to use "init 0" to gracefully shutdown the the system.
Although recently I have heard that in systemd I should not use "init commands" anymore and to shutdown the system gracefully use "poweroff" command.

That is a surprise to me as up to now "poweroff" ment to me cut-off power immediately.
Any comments on that/your opinions & experience ?
 
Old 02-06-2019, 07:27 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,757

Rep: Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930
Since systemd does not have runlevels init 0 if it works at all would be a shortcut to systemctl command.

poweroff, shutdown and halt are all shortcuts to systemctl and I think that in the old days poweroff actually called shutdown which would be the preferred way.
 
Old 02-06-2019, 07:48 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
I know I just push my power button (laptop here) and it shuts down gracefully, with systemd and systemV, runit (void linux). I do remember seeing/reading in one of them ("scripts") how this was tied to the 'shutdown now' command.
 
Old 02-06-2019, 09:07 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,910

Rep: Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026
Quote:
Originally Posted by BW-userx View Post
I know I just push my power button (laptop here) and it shuts down gracefully, with systemd and systemV, runit (void linux).
That's how I've always done it too.
 
Old 02-06-2019, 10:20 AM   #5
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,628
Blog Entries: 19

Rep: Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464Reputation: 4464
In sysvinit, Poweroff always meant "Shutdown, then switch off via ACPI (soft off)", whereas Halt meant "Shutdown and wait for instructions". I assume systemd uses the same conventions.

If you can get a graceful shutdown by pressing the power button, this must work via ACPI. If you look in /etc/acpi, you should find a script for handling the power button press event. Because it's an ACPI thing, it shouldn't be affected by what kind of init system you have, as long as that system recognises the shutdown command which the script uses.

Last edited by hazel; 02-06-2019 at 10:22 AM.
 
Old 02-06-2019, 11:03 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,141

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Things are rarely that cut-and-dried - more true with systemd. FWIW I have always used "poweroff" command; never had an issue.
First place to look for power control options might be "man logind.conf"
 
1 members found this post helpful.
Old 02-06-2019, 11:06 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,910

Rep: Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026Reputation: 5026
@hazel, I don't know for certain as I avoid it like the plague, but I wouldn't be surprised to hear that acpid is one of the daemons that systemd has "assimilated".
 
Old 02-07-2019, 06:11 AM   #8
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Original Poster
Rep: Reputation: 43
So I understand that nowadays (under systemd based OS) the right way to gracefully shutdown system is:
Code:
# systemctl poweroff
 
Old 02-07-2019, 11:05 AM   #9
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by czezz View Post
That is a surprise to me as up to now "poweroff" ment to me cut-off power immediately.
In my system (Slackware) halt, reboot and poweroff are all the same executable and do a "gracefull" shutdown, optionally followed by a poweroff or reboot
Code:
-rwxr-xr-x 1 root root   12312 2013-08-17 05:24:42 halt
lrwxrwxrwx 1 root root       4 2015-10-05 09:09:44 poweroff -> halt
lrwxrwxrwx 1 root root       4 2015-10-05 09:09:44 reboot -> halt
PS: Slackware is still systemd free!
 
Old 02-07-2019, 03:20 PM   #10
czezz
Member
 
Registered: Nov 2004
Distribution: Slackware/Solaris
Posts: 924

Original Poster
Rep: Reputation: 43
Quote:
PS: Slackware is still systemd free!
And hope it will stay this way forever

Under Slack I would keep useing: init 0
However, in systemd OS'es - I understand I must not use init 0 anymore and use: systemctl poweroff

Can anyone confirm that?

Last edited by czezz; 02-07-2019 at 03:22 PM.
 
Old 02-07-2019, 03:53 PM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,757

Rep: Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930
Yes, I use shutdown or poweroff which are symlinks to systemctl
 
Old 02-07-2019, 03:59 PM   #12
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,735

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
I haven't switched to the systemd commands yet...I still use init 0 or init 6...but I should. /sbin/init is a link to systemd and could go away in some future release.

BTW the commands are
Code:
shutdown 
or 
poweroff
NOT
Code:
systemctl poweroff
 
Old 02-07-2019, 04:14 PM   #13
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,757

Rep: Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930Reputation: 5930
Again since /sbin/shutdown and /sbin/poweroff commands are symlinks to systemctl and both work fine (i.e. poweroff or systemctl poweroff). I use poweroff since its easier to type.

I have not used init 0 command in a very long time and it is symlinked to /lib/systemctl. I just tried it on a CentOS and it still stops the system.
 
  


Reply



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
init.d script to systemd with systemd-sysv-generator tankzeu Linux - Newbie 1 09-17-2018 04:41 AM
LXer: The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linu LXer Syndicated Linux News 1 04-07-2017 11:33 PM
[SOLVED] Executing command on systemd poweroff/reboot Mr. Alex Linux - Newbie 2 07-28-2013 04:20 AM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
What is the exact diff between init 1,init S and init s challavijay Linux - Newbie 1 08-05-2010 06:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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