Dangerous commands on Linux

  • Post author:
  • Post category:General
Dangerous commands on Linux

AtomicLinux

As Linux servers are handled using commands, the following points should be taken note of while executing certain commands that could be potentially destructive. These commands should be used only after careful analysis. Test the performance of these commands on a test environment, so that you could understand how it would affect the server performance and its consequences.

1. rm -rf

The rm -rf command helps in deleting a folder and its contents at a faster pace. But a little typo or ignorance may result in unrecoverable system damage. Some of its usages are specified below:

rm command in Linux is used to delete files.

rm -r command deletes the folder recursively, even the empty folder.

rm -f command removes ‘Read only File’ without asking.

rm -rf / : Force deletion of everything in root directory.

rm -rf * : Force deletion of everything in current directory/working directory.

rm -rf . : Force deletion of current folder and sub folders.

So be careful when you are executing rm -rf command. To prevent accidental deletion of files by ‘rm‘ command, create an alternative ‘rm‘ command as ‘rm -i‘ in “.bashrc” file. Now a question will be asked, before confirming every deletion.

2. :(){ :|:& };: – Fork Bomb

The above command is known as fork bomb. It operates by defining a function called ‘:‘,. You need to call it twice, once in the foreground and once in the background. The process continually replicates itself, and its copies continually replicate themselves, quickly consuming all your CPU time and memory. This can cause your computer to freeze. It’s basically a denial-of-service attack.

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

This command writes junk data to the hard drive. The dd if=/dev/random of=/dev/sda line will also obliterate data from one of your hard drives.

dd – Perform low-level copying from one location to another.

if=/dev/random – Use /dev/random (random data) as the input – you may also see locations such as /dev/zero (zeros).

of=/dev/sda – Output to the first hard disk. This will replace the file system with random garbage data.

4. mv ~ /dev/null

/dev/null command moves your Home Directory to a Black Hole. Moving something to /dev/null is akin to destroying the same. Think of /dev/null as nothing but a black hole.

mv – Moves the following file or directory to another location.

– Represents your entire home folder.

/dev/null – Moves your home folder to /dev/null. As said earlier, this will destroy all your files and delete even the original copies.

5. mkfs.ext4 /dev/sda1

This command formats a Hard Drive and is very simple to understand.

mkfs.ext4 – Creates a new ext4 file system on the following device.

/dev/sda1 – Specifies the first partition on the first hard drive, which is probably in use.

Together, these commands are akin to running format c: on Windows – it will wipe the files on your first partition and replace them with a new file system.

These commands can come in other forms as well like mkfs.ext3 /dev/sdb2. This will format the second partition on the second hard drive with the ext3 file system.

So take care while executing each and every command when you are on a linux server environment. A small mistake can result in destructing data residing in the server, which cannot be recovered later.

 

This Post Has 2 Comments

  1. ElishaXMaggs

    What’s up, its fastidious article concerning media print, we all know media is a impressive source of data.

  2. Ronny

    I wanted to thank you for this excellent read!! I absolutely loved every little bit of it. I have you book marked to look at new things you post…|

Leave a Reply