[sf-lug] shutdown, wall, ... (was: sudo abuse, suspend/shutdown, and polkit)

Rick Moen rick at linuxmafia.com
Wed Feb 20 20:18:52 PST 2019


Quoting Michael Paoli (Michael.Paoli at cal.berkeley.edu):

> So, shutdown(8) has been around since nearly forever ... certainly
> from relatively early days of Unix.  Though, even long before Linux,
> the particular syntax of shutdown(8) varied greatly among differing
> flavors of Unix....

Traditionally on Linux flavours that used SysVInit, /sbin/shutdown has
been some sort of little binary tool that, by default, when invoked with
root privilege, called the SysVInit /sbin/telinit binary (a second hard
link to /sbin/init) to do 'telinit 0', i.e., change to runlevel zero and
thereby run the scripts in /etc/rc0.d/ to shut down daemons, did other
housekeeping including notifying users using 'wall', unmounting remote
filesystems, unmounting non-root local filesystems, shutting down MD RAID if
any, unmounting the root filesystem, and last running a script
(/etc/init.d/halt) that tells the UPS (if there's a UPS) that this is a
deliberate shutdown, and finally running binary executable /sbin/halt with
flags saying 'shut down network interfaces, put any hard drives in
standby mode, and then shut off the power.'

I would guess that Slackware, which back when I ran it used a variant of
the BSD init, did these tasks in some BSDish but roughly similar way.
(Looks like Slackware eventually moved to SysVInit.)  The point is
that any init system's shutdown tasklist, or any root-run shutdown tool,
would be best off doing just about exactly that -- in order to do an
orderly shutdown.  (I mean, it's possible to shut down a system by
sending the CPU a signal to just stop, in a variety of ways including
particular modes of /sbin/halt, but you wouldn't like what that does to
filesystems, etc., and you wouldn't want to do it unless there were no
better way available.)




More information about the sf-lug mailing list