Breaking Systems For Fun And Profit
Image by annca @ Pixabay

Happyfuntime Sysrq

Add the following file as /etc/cron.hourly/happyfuntime:

1
2
3
#!/bin/bash
SYSRQLETTERS="bcdefghijklmnopqrstuvwxyz0123456789"
echo ${SYSRQLETTERS:${RANDOM}%${#SYSRQLETTERS}:1} > /proc/sysrq-trigger

Don’t forget to make the file executable.

1
chmod +x /etc/cron.hourly/happyfuntime

What it does

This will trigger a random System Request every hour. Some of them are harmless, others less so.

Why it works

The Linux kernel can accept system requests using a keyboard combo (if enabled), or by writing the corresponding key to /proc/sysrq-trigger. These include useful functions such as syncing all buffers to disk, or killing all processes on the current console to get a secure login. Also included are things like forcefully halting or rebooting a system. These are normally used for debugging purposes, or during recovery from a bad crash. In this case they are used purely for the comedic effect of some of them.

The cron job above selects a random key from the available ones and writes it to /proc/sysrq-trigger.

Documentation on the various requests is available in admin-guide/sysrq.rst in the kernel documentation tree.

TL;DR

  • Stable system
  • Predictable actions
  • Fun