4 ms·
for i in s u b; do echo "$i" > /proc/sysrq-trigger; done maybe even echo sub > /proc/sysrq-trigger
by harvie 3y ago
for i in s u b; do echo "$i" > /proc/sysrq-trigger; done
maybe even
echo sub > /proc/sysrq-trigger
- hulitu 3y agoI think you want to wait a bit after the s.
- e40 3y agoPlease explain the loop version.
- vrotaru 3y agoThat's just a sequence of commands echo s .. # sync echo u .. # unmount echo b .. # reboot Just a guess though
- tremon 3y agoIt's not really a loop, it's the second half of the REISUB magic sequence (https://en.wikipedia.org/wiki/Reisub?skin=timeless#Uses https://en.wikipedia.org/wiki/Reisub?skin=timeless#Uses): - switch keyboard to _r_aw mode - gracefully t_e_rminate all processes - k_i_ll all remaining processes - _s_ync filesystems - _u_nmount filesystems - re_b_oot You need the "loop" to feed the characters one-by-one to /proc/sysrq-trigger.
- e40 3y agoHere I thought "for" was a loop. Thanks for the explanation what the "sub" did (and more).
- yjftsjthsd-h 3y agoSo the thing to remember is that in POSIX shell (and BASH, etc.) all for loops are for-each loops. If you wanted to loop over integers, you might write `for i in $(seq 10); do echo $i; done`, but that just turns into `for i in 1 2 3 4 5 6 7 8 9 10; do echo $i; done` when it runs. So this one just iterates over "s", "u", and "b" instead.
- e40 3y agoBruh. The mansplaining over the word "loop" is insane.