5

WARNING!!!: The question asks for temporarily breaking Ubuntu. There shall be no safe answers. If you have important services running, important documents/files being edited, please note that you might not be able to recover/save your work. Please note that trying these answers is not recommended unless you know what and why you're doing it, and it is not answerer's (or asker's, FWIW) fault if you break something.

I need a way to make my Ubuntu become unresponsive. No running shutdown scripts, no recovery from hanging state. Just a quick and dirty way for the system to go into derp mode. Recovery should be only via powering off and on again.

Assume three things:

  • I am root
  • Non-bash solution ( so no fork bombs please, but command-line solution ok)
  • filesystem must remain intact

To address dobey's comment:

  • derp mode basically means "computer runs, but that's it"
  • "What you're actually trying to achieve". I think the title explains it pretty clearly. I want to make the OS unresponsive at will, where it won't be able to do anything. That's exactly what I'm trying to achieve. There's no debugging involved, there's no XY problem. I just need a way for system to lock up/crash/hang up where I can't do anything except hold the power down button.

3 Answers3

5

One definite way to make your system unusable is to crash it using:

sudo sh -c 'echo c > /proc/sysrq-trigger'

Or (if your /proc/sys/kernel/sysrq setting is set to something not so restrictive, like 1), press Alt + SysRq + C for the same effect.

These files are documented in the proc(5) manual:

/proc/sys/kernel/sysrq

This file controls the functions allowed to be invoked by the SysRq key. [..]

/proc/sysrq-trigger (since Linux 2.4.21)

Writing a character to this file triggers the same SysRq function as typing ALT-SysRq-<character> (see the description of /proc/sys/kernel/sysrq). This file is normally writable only by root. For further details see the Linux kernel source file Documentation/admin-guide/sysrq.rst (or Documentation/sysrq.txt before Linux 4.10).

For more information about this "sysrq" feature, see https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html

Lekensteyn
  • 178,446
4

Please don't try unless you know exactly what you're doing!

  • changing /proc/sys/kernel settings related to kernel panic

    echo 1 >/proc/sys/kernel/hung_task_panic
    echo 1 >/proc/sys/kernel/panic_on_io_nmi
    echo 1 >/proc/sys/kernel/panic_on_oops
    echo 1 >/proc/sys/kernel/panic_on_stackoverflow
    

    This will set the kernel to panic immediately in case of a hung task(!), an NMI caused by an IO error, an oops or BUG and overflows of kernel, IRQ and exception stacks. While not causing a panic immediately, this should make it much easier to get to the point.

  • output the system's I/O ports

    cat /dev/port
    
  • overwrite the memory device with zeroes

    cp /dev/zero /dev/mem
    
  • flood system I/O ports with random numbers

    dd if=/dev/random of=/dev/port
    
  • using SysRq, perform a system crash by a NULL pointer dereference:

    echo 1 >/proc/sys/kernel/sysrq # make sure SysRQ is fully enabled
    echo c >/proc/sysrq-trigger    # pull the trigger
    

I didn't try any of these. (source 01, source 02, How to cause kernel panic with a single command?, source 04)

dessert
  • 40,956
0

Trying:

cd /proc

Followed by:

sudo kill *

Should do the trick

saltq
  • 11