What is the difference between following commands? Which should be used preferably?
Code: Select all
sudo init 0
sudo shutdown 0
Code: Select all
sudo init 0
sudo shutdown 0
Code: Select all
sudo shutdown -h now
Code: Select all
sudo shutdown -r now
md5sum $(which init) $(which shutdown)
apt-get source upstart
systemctl reboot
yelp man:systemctl
init 0 is old and outdated: https://askubuntu.com/questions/75427/u ... n-computerdeepakdeshp wrote: ⤴Fri Mar 16, 2018 1:38 pm Hello,
What is the difference between following commands? Which should be used preferably?Code: Select all
sudo init 0 sudo shutdown 0
The second, although not with unadorneddeepakdeshp wrote: ⤴Fri Mar 16, 2018 1:38 pm What is the difference between following commands? Which should be used preferably?Code: Select all
sudo init 0 sudo shutdown 0
0
but with either +0
or its alias now
; the fact that 0
works at all is essentially a parser bug. The sudo is not necessary either: being an administrator user (which on Mint means being root and/or a member of groups "sudo" and/or "admin") will make polkit grant permission to shutdown the system. Among the two given choices shutdown now
is the preferred command, then.init
program used to in not so olden times be the name of the actual system init, the program launched by the kernel directly so as to create process 1, the init process. The telinit
program was used to communicate with said process and specifically telinit <number>
would instruct said process to switch to runlevel <number>. telinit
moreover used to in fact simply be a link to init
with the program deciding at runtime whether to behave as init or as telinit simply by seeing if it was in fact process 1 or not.init
is itself a link to /lib/systemd/systemd
but systemd emulates the above behaviour: init 0
is still equivalent to telinit 0
and the latter you in man telinit
find to be in turn equivalent to systemctl poweroff
; like before, sudo is not in fact necessary. shutdown
is a link to systemctl
with the systemctl program at runtime deciding how to behave depending on what name it was called through. In the case of that name being "shutdown" it behaves exactly as, again, systemctl poweroff
.systemctl poweroff
. Your options are two levels of historical baggage...@renedeepakdeshp wrote: ⤴Fri Mar 16, 2018 1:38 pm Hello,
What is the difference between following commands? Which should be used preferably?Code: Select all
sudo init 0 sudo shutdown 0
In case you have disabled display of signatures: he specifically mentions to be running Mint 18.3 in it. No mention of 17 anywhere so I do believe he's asking simply in the Mint 18 context. Anyways...
init
used to be upstart
rather than systemd
but the "same" as above holds in the sense of both init 0
and shutdown -h now
being equivalent to telinit 0
; to init switching the system to runlevel 0. I do believe that leaving out -h
in that case in fact meant telinit 1
instead, single-user mode. And you do need sudo
on 17.sysvinit
days shutdown
was or could be supplied by util-linux and was at the very least conceptually different from telinit 0
in the sense of it signalling processes itself. It of course depended on a specific distribution's implementation of going to runlevel 0 whether or not that was actually all that different, and I seem to recall not all distributions using the util-linux shutdown back then. Slackware I fully trust did the most obsolete thing it could think of and used the util-linux one directly, but if I'm not mistaken RedHat for example did not; if not simply misremembering then I trust they in fact implemented it as telinit 0
.If by "under init" you specifically mean "not under systemd" then fine but note this to be untrue for Mint 18.3 which is what the poster runs. On it,kc1di wrote: ⤴Sun Mar 18, 2018 6:26 am to answer the original question. In a multi user system under init if you issue init 0 the system will go down without any notification where using shutdown -h will send a message to anyone on the system that the system is about to go down. so shutdown is delayed a bit.
shutdown -h now
goes down as fast and as quietly as init 0
(although "as quietly" might judging from the manpages in fact be unintended).that is why I Specifically said Under init - If you look at my first post you will see I told the op that 18.3 runs under systemd and that there are no run levels in that system. Cheersrene wrote: ⤴Sun Mar 18, 2018 8:06 amIf by "under init" you specifically mean "not under systemd" then fine but note this to be untrue for Mint 18.3 which is what the poster runs. On it,kc1di wrote: ⤴Sun Mar 18, 2018 6:26 am to answer the original question. In a multi user system under init if you issue init 0 the system will go down without any notification where using shutdown -h will send a message to anyone on the system that the system is about to go down. so shutdown is delayed a bit. Thshutdown -h now
goes down as fast and as quietly asinit 0
(although "as quietly" might judging from the manpages in fact be unintended).
Don't get it. Why do both you and all41 assume the question is not about Mint 18? There's no mention of anything other than Mint 18.3 and hence of systemd.
ls -l $(which init)
followed by man systemd
would for example inform you that
and the subsequentFor compatibility with SysV, if systemd is called as init and a PID that is not 1, it will execute telinit and pass all command line arguments unmodified. That means init and telinit are mostly equivalent when invoked from normal login sessions. See telinit(8) for more information.
man telinit
that init 0
is hence ...
Other than an init system systemd is much more these days; be sure to separate the two (ha! two!) when studying it.[ ... ] translated into an activation request for poweroff.target and is equivalent to systemctl poweroff.
This page is pretty good and concise.deepakdeshp wrote: ⤴Sun Mar 18, 2018 8:54 am That's an excellent discussion , thanks all. And yes I do use Mint 18.3 and the context to my question is 18.3.
I learnt many things. Systems is quite involved, I don't intend to read something voluminous. Does anybody know a link or slideshow explaining the basics of systemd?
Code: Select all
man systemd