A Ghost is Typing! It’s randtype

📅 April 7, 2015
randtypeIt’s possessed!

(…Or your terminal seems like it.)

The program randtype will take text from standard input or from a file and simulate typing. The effect is mysterious and impressive for those new to randtype, and it is certain to put a smile on your face and make you think, “Neat!”

While randtype might not appear to be a super useful program, the novelty factor alone is worth a look.


randtype is available from the repository, so install it using Synaptic or the command line.

sudo apt-get update
sudo apt-get install randtype


In a terminal, pipe some text to randtype.

echo 'I am watching you from the.........other side.' | randtype

Be amazed as the text seems to appear at a semi-natural typing speed without your involvement. It seems as if the terminal is possessed by an unknown, mysterious…being.

Why not type out the man page for randtype?

man randtype | randtype

Be aware that this will take a long time to complete, but it illustrates the point. Ctrl+C is your friend.
How about a file?

randtype lorem_ipsum.txt


randtype < lorem_ipsum.txt

This types out the contents of a text file. In this case, I made a text file containing Lorem Ipsum text from http://lipsum.com/.


These are simple examples. man randtype reveals many adjustments. How about we speed up the typing with the -t option?

randtype -t 5,16000 dummy_text.txt

The -t option takes two values separated by a comma. The first value, 5, is a microsecond, and the second value, 16000, is a random multiplier of the microsecond from 0 to 16000 (this value). This specifies a random delay between each character.

(dummy_text.txt is a plain text file that I created containing real sentences, not Latin filler text.)

Specifying -t 5,100 causes text to appear much faster:

randtype -t 5,500 dummy_text.txt

This speed emulates a slightly faster terminal output:

randtype -t 25,500 dummy_text.txt

However, the faster speed emulates a slow computer terminal rather than a human typist.

At the extreme, we can simulate a perfect beginner:

randtype -t 0,1000000 dummy_text.txt


Add Typing Mistakes

Is the typing too perfect? Let’s add some typing mistakes with the -m option.

randtype -m 100 dummy_text.txt

Ah! That’s better. Every now and then, our phantom typist makes a typing mistake and goes back to correct it. The value after -m specifies how many times to match and compare nearby and random characters until the correct character appears.

The lower the value, the fewer the mistakes and the quicker they are resolved. The higher the value, the more noticeable the mistakes. High values emulate beginning typists better. Try this example:

randtype -m 1000 dummy_text.txt

Poor thing. Watching the output gives the impression that the ghost is looking at his fingers while he types.

I have found that this value needs to be at least 100 to produce a convincing effect. The value 1000 is very amateurish in the results, but this might be what you want. For example, suppose you wish to highjack someone else’s terminal, but you have the reputation as an accurate typist. randtype (with mistakes) can help you out.

echo 'sudo shutdown -P now' | randtype -m 500 > /dev/pts/7

Ooooooh! That’s just creepy…and cruel. Bwa, hah, hah! Imagine the look on the target’s face as he watches what appears to be someone who is logged into his machine trying to shut it down while he is in the middle of something important.

Ctrl+C in his terminal does not stop the typing, and any attempt will cause the typing to continue across multiple prompts. Of course, the computer will not shutdown because we are simply redirecting text, not entering an actual command. But imagine the panic this joke can cause on the right person at the right time!

(To find a terminal, use the tty command. In Linux Mint or Ubuntu, you should see something like /dev/pts/7 to represent a terminal. Try it on yourself for fun!)

Adding mistakes is effective at simulating human typing, which is rarely perfect. I have found that values need to be above 100 for the best effect when combined with a faster typing speed. The following command is more convincing to give the illusion of an intermediate typist:

randtype -m 200 -t 13,16000 dummy_text.txt

Will randtype work with espeak for audio output? Yes, it works, but there is a delay before we hear any speech.

espeak $(echo 'hello' | randtype)

espeak will say, “Hello,” but we must wait for randtype to complete the word. Why not speed up the text for less delay?

espeak $(echo 'hello' | randtype -t 13,16000)

That works, but we do not see any typing in the terminal, so why bother with randtype and espeak? espeak needs a complete word, not a character at a time.

Other Languages

We are not limited to English. If your terminal supports Unicode, which Linux supports well, then you can use randtype to type text in other languages. For example,

echo '話していたことは全部わかりました。'  |  randtype -t 13,16000

randtype offers a number of options, such as quitting the program after a number of seconds (-q), replacing strings (-r), and line output (-l), so consult man randtype for more details.

Have fun!


, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: