[sf-lug] What purpose is served by the first two parts? (cd / && umask 022 ...
Rick Moen
rick at linuxmafia.com
Sun Jan 1 14:37:10 PST 2017
Quoting Michael Paoli (Michael.Paoli at cal.berkeley.edu):
> cd /
> at least many versions of shutdown will typically umount non-root
> filesystems (at least before eventually dealing with root filesystem)
> in order to umount those filesystems, they can't have any processes on
> them with open files or current directories there - that's generally
> dealt with by shutdown using fuser or the like to terminate/kill such
> offending processes ... and if your shutdown itself didn't chdir(2) to
> avoid that, then it may terminate itself.
You _could_ just reboot this way:
# echo b > /proc/sysrq-trigger
That doesn't even try to umount or sync any filesystems, let alone warn
those pesky users. The strong will survive. ;->
(More seriously, above works even if /sbin/reboot & /sbin/shutdown
cannot function for reasons that might include disk media problems.
And it supports not just an unconditional reboot command but also a
sync command 's' and a umount command 'u' -- among others. So, sending
s, then u, then b is a safe forced reboot.)
For above to work, the kernel's magic SysRq option must be enabled,
which I think ought to be routinely for reasons entirely aside from
being able to terrorise users. This sets that:
# echo "kernel.sysrq = 1" >> /etc/sysctl.conf
To enable it only for the current runtime:
# echo 1 > /proc/sys/kernel/sysrq
For more about System Request Key coolness:
https://kernel.org/doc/html/latest/admin-guide/sysrq.html
More information about the sf-lug
mailing list