A photo of Mitesh Shah

Mitesh Shah

Linux Expert | Automation Enthusiast | Security Consultant

Email Skype Github Twitter Resume Hire Me Keybase LinkedIn Stackoverflow


Deadly Linux Commands

Overview

  • If you are new to Linux, chances are you will meet a stupid person perhaps in a forum or chat room that can trick you into using commands that will harm your files or even your entire operating system.
  • Don’t run anything without understanding exactly what it does. Look it up (use Google or man command) if there’s any part of a command you’re not clear on.

  • Also you can use http://explainshell.com/ to explain what command is.
  • To avoid this dangerous scenario from happening, I have here a list of deadly (Most Dangerous) Linux commands that you should avoid

deadly-linux-commands

Delete Everything Recursively

  • This command will recursively and forcefully delete all the files inside the / root directory.
[mitesh@Matrix ~]$ sudo rm -rf /

Fork Bomb

  • The following weird looking command is actually function which created copies of itself endlessly.
  • This Fork Bomb quickly use all your system resources like CPU, RAM, etc and cause system crash.
  • This can often lead to corruption of data.
  • For More Detailed Information Refer https://en.wikipedia.org/wiki/Fork_bomb
[mitesh@Matrix ~]$ :(){:|:&};:

Format Hard Disk Drive

  • This will reformat or wipeout all the files of the device that is mentioned after the mkfs command.
[mitesh@Matrix ~]$ sudo mkfs.ext3 /dev/sda

Fill Hard Disk Drive with Junk Data

# Fill HDD with letter y
[mitesh@Matrix ~]$ sudo yes > /dev/sda
# Fill HDD with number zero 0
[mitesh@Matrix ~]$ sudo dd if=/dev/zero of=/dev/sda
# Fill HDD with random data
[mitesh@Matrix ~]$ sudo dd if=/dev/urandom of=/dev/sda
# Overwrite HDD Data (Multiple Times)
[mitesh@Matrix ~]$ sudo shred /dev/sda

Delete /etc Directory

  • The following command delete all the linux configuration files.
# Delete /boot Directory
[mitesh@Matrix ~]$ sudo rm -rf /etc

Delete Boot Entry

  • The following command delete Kernel, Initrd, and GRUB/LILO Files (Needed For Linux Startup)
# Delete /boot Directory
[mitesh@Matrix ~]$ sudo rm -rf /boot/

Find and Delete configuration files

[mitesh@Matrix ~]$ sudo find / -iname "*.conf" -exec rm -rf  {} \;

World Writable

  • The following command make your system world writable.
[mitesh@Matrix ~]$ sudo chmod -R 777 /

Remove Access Privilege

[mitesh@Matrix ~]$ sudo chmod -R 000 /
# Another way
[mitesh@Matrix ~]$ sudo chown -R nobody:nobody /




Post Navigation