Linux – Why does `cat /dev/urandom` break your terminal

devlinuxrandom number generatorterminal-emulator

In reference to this question: https://serverfault.com/questions/534449

How does cat /dev/urandom make some terminal emulators go wonky?

Best Answer

While there are your normal, printable ASCII characters that are sent back and forth on a terminal, there are also many unprintable characters that are used for the system to communicate with the terminal. For example, if a program sends the character 0x07 ("ASCII Bell character"), your terminal should beep.

Other special sequences can be used to change the color of text being displayed, which direction it's displayed, the title of the window, the size of the window, etc., among many other things.

When you

cat /dev/urandom

A bunch of random characters are dumped to your terminal, and the terminal can't tell that it's not real control codes.

Because the program is effectively sending random commands to the terminal, the terminal ends up in a random, often unusable state.

Related Question