[sf-lug] /proc/sysrq-trigger ...

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sun Jan 1 16:52:36 PST 2017


/proc/sysrq-trigger
Good to know!  :-)
https://en.wikipedia.org/wiki/Magic_SysRq_key

Of course physical and console keyboard access needs be suitably secured,
but that's part of the physical security anyway.

Also among handy things like, when ls(1) is broken, how do you list the files?
# echo *
... but also don't forget the dot (.) files
# echo .[!.] .??*
... or printf if your shell has that.


> From: "Rick Moen" <rick at linuxmafia.com>
> Subject: Re: [sf-lug] What purpose is served by the first two parts?  
> (cd / && umask 022	...
> Date: Sun, 1 Jan 2017 14:37:10 -0800

> 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