Don't Paste Text Into Your Terminal!

Here's a brief demonstration of why you should not copy things like terminal commands from a website and paste them into your terminal.

Go ahead and copy this console command.

console.log("I'm completely safe!");

Now paste it below:

Oh no! Here's what happened:

This little bit of JavaScript code detected your copy command and replaced your clipboard contents with my own code. While it was safe THIS time, the code you pasted could have been malicious.

              
document.addEventListener("copy", (event) => {
    event.clipboardData.setData(
      "text/plain",
      `Hmmm this isn't right.`
    );
    event.preventDefault();
  });
              
          

It's harmless here, but if you copied a command that was hijacked and pasted it into your computer's terminal, all sorts of nasty things could happen.

It's much safer to type the commands by hand. Plus you'll retain the information better that way!