Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to cause a kernel panic with a single command line?

What would be the most straightforward such command for a sudoing user and what would it be for a regular user, if any?

Scenarios that suggest downloading something as a part of the command do not count.

share|improve this question
Write a buggy driver. – Kevin Feb 26 '13 at 19:39
:(){ :|:& };: maybe? – Carl Feb 26 '13 at 21:27
@carleeto Ok, could you explain that one to rest of us? – hydroparadise Feb 26 '13 at 22:30
@hydroparadise It's called a "forkbomb". :() defines a function called : with the body of :|:&, meaning "run : and also run : in the background". ; ends the function definition, and : calls your new function, which endlessly spawns new versions of itself until you either hit process limits or the system grinds to a halt. It's a command that effectively freezes any system without good process limits set. Don't try this at home. – Phoshi Feb 26 '13 at 22:37
@Kevin You mean writing a C program, compiling it, and installing it as a driver, all in a single command line? A working example would be great. – Desmond Hume Feb 26 '13 at 23:13
up vote 40 down vote accepted


sysctl debug.kdb.panic=1

Linux (more info here):

echo c > /proc/sysrq-trigger
share|improve this answer
echo c > /proc/sysrq-trigger sure does a good job in freezing a Linux system. But personally, an ol' good black screen of death narrating about a dramatic development of the call stack would feel like a more "canonical" kernel panic. – Desmond Hume Feb 27 '13 at 0:01
On Linux, you might have to echo 1 > /proc/sys/kernel/sysrq before you are able to echo c > /proc/sysrq-trigger. – Christian Mar 19 '14 at 8:16
how in OpenBSD? – mykhal Apr 24 '14 at 13:35
When one needs to prove how flawed an innocent piece of hw is, this might come in handy... – nemesisfixx Jul 18 '15 at 8:51

The kernel is meant to keep running no matter what. So any way to cause a kernel panic by user interaction (other than deliberate vandalism by all-powerful root, like Bruce Ediger jokinkly proposes, and most kernels today are built so most of those pranks won't work in the first place) is an extremely serious bug, that would get fixed fast.

share|improve this answer
Well, there is no much use of the kernel when the system has been completely frozen by a non-sudoing user who issued a command in the likeness of :(){ :|:& };:. – Desmond Hume Feb 26 '13 at 23:27
@DesmondHume A good setup doesn't crash due to too many processes. Look in to the /etc/security/limits.conf file. – Vreality Feb 27 '13 at 1:43

compile the following code into a module and insmod it, sure you should get a panic:

static int crash_module_init(void)

     printf("crash module starting\n");
     int *p = 0;

     printk("%d\n", *p);

     return 0;

static void crash_module_exit(void)
    printf("crash module exiting\n");

share|improve this answer
This will cause an oops, but not a panic. – SkyDan Nov 7 '13 at 13:27
mkdir /tmp/kpanic && cd /tmp/kpanic && printf '#include <linux/kernel.h>\n#include <linux/module.h>\nMODULE_LICENSE("GPL");static int8_t* message = "buffer overrun at 0x4ba4c73e73acce54";int init_module(void){panic(message);return 0;}' > kpanic.c && printf 'obj-m += kpanic.o\nall:\n\tmake -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules' > Makefile && make && insmod kpanic.ko

Compiles a module that crashes the kernel by calling the panic function, needs root, requires make and gcc

Replace the "buffer overrun at 0x4ba4c73e73acce54" in the command with something interesting for more drama.

share|improve this answer
This source code looks harmless enough. – Mark Lakata Feb 23 at 21:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.