By just typing some commands, how can Ubuntu be uninstalled? I don't want to install Windows or anything, leaving my PC without an OS.

Would this command work?

sudo rm -rf /
  • 1
    Never do this. It won't uninstall Linux completely – Motte001 Jul 1 '16 at 21:29
  • 3
    I'd note that, apart from the practical reasons why you should never do rm -rf /, it's also conceptually the wrong thing. / in a Unix system is not just the local drive or something, it's in a sense the universe. Anything you've mounted, any remote you're connected to, any virtual file the OS uses, it's all reachable from this point. Deleting root is nuking your hometown, full with the side-effects of a nuclear war. – leftaroundabout Jul 2 '16 at 14:44
  • rm -rf / doesn't do anything with most modern implementations of rm, because they protect from accidental deletion of the root directory. You can force the action with --no-preserve-root, but that may also brick your EFI firmware and other operating systems (if you have their file systems mounted). – David Foerster Jul 4 '16 at 19:18

DO NOT RUN sudo rm -rf / --no-preserve-root on systems with systemd

When running the command on a UEFI computer (2012 or newer) you are deleting all the UEFI firmware variables which can cause your PC to be bricked and cannot be repaired without a motherboard replacement on some devices.

Here is what happened to one Linux user : An Ubuntu command bricked my system?

So don't try what the other answers talking about rm -rf / say since it only works on legacy BIOS machines. I am typing this from a UEFI laptop which can also be bricked by the command.

Proper Method for UEFI devices.

Boot an Ubuntu Live USB / CD and open GParted. Then delete all the partitions and click apply.

Please note that after this, most of your data can still be recovered easily using professional tools.

Proper Method for UEFI devices if you have private data

As @ByteCommander says, download DBAN (Darik's Boot And Nuke), burn the ISO to a disc / USB and tell it to erase the disk

After performing this, all data is irreversibly gone!

  • 5
    No, it is because it deletes things in /sys/.The UEFI Variables are mounted in a folder in /sys – Suici Doga Jul 1 '16 at 8:50
  • 8
    This is scary - malware could destroy my motherboard (?) ... – JonasCz - Reinstate Monica Jul 1 '16 at 12:13
  • 5
    There's an old saying: "rm -rf: a moment of convenience, a lifetime of regret" – Mark Plotnick Jul 1 '16 at 21:58
  • 5
    @AnmolSinghJaggi No , I did it in a VM on my UEFI laptop and nothing happened other than Ubuntu breaking.The UEFI specification says that the system must be boot able if there are no variables , but manufacturers didn't listen so it is the manufacturers and not a problem with UEFI – Suici Doga Jul 2 '16 at 1:14
  • 2
    Note that this doesn't happen on all UEFI systems. The ideal UEFI can regenerate deleted stuff from the mountmoint in /sys. The problem is that some vendors thought a cheap implementation is more important than a proper implementation according to the specs etc. ... – deviantfan Jul 2 '16 at 9:27

I guess you want to sell your computer. In that case it would be the best to securely wipe the entire disk to prevent that anybody can recover any of your personal files later.

The best tool for this is DBAN (Darik's Boot And Nuke).

Download the .iso image and burn it to a CD or flash drive. Then boot your computer from it and let it erase the whole hard disk.

Depending on the option you chose, the erasure will be more or less secure, but take longer. Unless you have really private data on that disk, a quick pass should be enough.

Please note that erasing a hard disk this way will irreversibly destroy all data on it, there's no way it can be recovered. Use with caution!

  • 1
    I just discovered that you can still buy blank CDs, and that it's not even cheaper than it was 10 years ago. – njzk2 Jul 1 '16 at 2:33
  • 8
    @njzk2 Maybe some day there will come a retro trend to boot from vynil ... – Hagen von Eitzen Jul 1 '16 at 6:36
  • @njzk2 You can still buy 3.5" floppies, and they're the same/similar dollar value they were in the 90s. Probably even worse quality though, so that trend continues (downward). – Criggie Jul 1 '16 at 22:06

Yes, running sudo rm -rf / --no-preserve-root will destroy your installation and your motherboard if you have UEFI, leaving only an expensive paperweight , the bootloader (GRUB) and an empty partition.

Note that this will not securely erase data ! Files deleted in this way can still be recovered using data recovery tools.

To securely erase the contents of the disk, leaving your computer without any trace of Ubuntu or your files, boot from a Linux / Ubuntu live DVD / USB, and run

sudo dd if=/dev/zero of=/dev/sda bs=4M

which will securely erase data. Make sure that /dev/sda is the main hard drive in the computer - you can check with lsblk. You can also use DBAN, which might be easier to use - see Byte Commander's answer.

  • 7
    Be awared that second command will erase everything or your disk - Windows or anything as well – kubahaha Jun 30 '16 at 22:31
  • 3
    ... and that the first command will erase also any mounted disk - be it USB drives, a secondary hard drive that you mounted for some reason, a network share, the UEFI partition, ... generally, it's definitely not a good idea. – Matteo Italia Jul 1 '16 at 9:32
  • 1
    @Suici Thanks for the edits regarding the fact that this will destroy UEFI motherboards - I didn't know that ! I'm glad I don't have a computer with UEFI. – JonasCz - Reinstate Monica Jul 1 '16 at 12:07
  • @JonasCz I once ran rm -rf / on a BIOS laptop running Ubuntu from a USB with no partitions mounted and nothing happened other than Ubuntu crashing.I have UEFI on my newer laptop so that will brick it if i tried.UEFI is not as solid as BIOS – Suici Doga Jul 1 '16 at 12:42

Boot into a livecd. take note of the device names of your old system install, and unmount the drives if automounted. I'd use lsblk to check, and umount to unmount.

Run the shred command on each device. This basically overwrites each partition with zeros, much like dban does. You can then delete the partitions with a suitable tool.

dd should work, but I prefer shred since its a more precise tool designed to clear data.

If its an SSD, you might want to use hdparm to run a sata secure erase command instead.

rm -rf / is a terrible way to wipe a disk. It risks bricking your system as Suici Doga has suggested. If it dosen't, the data is likely recoverable, and your system may be at a point where you've deleted enough that more cannot be deleted. Its a little like using a hammer to turn a nut. It might work, or you may end up hitting yourself in the head.


If you're on a single drive system attempting to wipe the root drive you should boot from a live media as mentioned by @JourneymanGeek.

My preferred method for wiping a drive uses dc3dd.

If you don't have it you can install it from the universe repository on a terminal with sudo apt-get install dc3dd.

You'll want to determine exactly what drive you are trying to wipe (this is especially important in a multi-drive system).

You can find the correct drive using the output of sudo fdisk -l.

After determining that the drive is /dev/sdX or whatever you can issue the command sudo dc3dd wipe=/dev/sdX which will overwrite the entire drive with zeros.

A more secure approach might be to overwrite using a pattern such as sudo dc3dd wipe=/dev/sdX pat=FFEEDD which will overwrite the drive using a hexadecimal pattern (in this case FFEEDD)

You can also use a text pattern to overwrite such as sudo dc3dd wipe=/dev/sdX tpat=iloveubuntu which will overwrite the drive using the text string iloveubuntu.

Sources: Experience and Linhost.info (article).

Another method of wiping a whole drive consists of using the ATA Secure Erase feature implemented on many newer drives. This will erase all data on the selected device. Be aware that depending on circumstances (buggy kernel, firmware, or BIOS or using a USB interface) it appears that it's possible to brick the device at least temporarily by locking your self out of it.

If I haven't managed to convince you to use the easier solution above continue from here.

1st insure the drive isn't frozen and secure erase is supported:

Example from a Samsung HD103SJ I found on my shelf:

$ sudo hdparm -I /dev/sdd | grep -A9 Security:

    Master password revision code = 65534
    not enabled
    not locked
    not expired: security count
        supported: enhanced erase
Logical Unit WWN Device Identifier: 50024e92033cfe47

This drive is frozen and need to be unfrozen in order to continue After trying everything from putting the drive to sleep via Disks unplugging and replugging the data cable I ws finally successful in getting the drive into a not frozen state by unplugging the power to it, waiting for it to spin down and plugging the power back into the drive resulting in :

    Master password revision code = 65534
    not enabled
    not locked
    not frozen
    not expired: security count
        supported: enhanced erase
Logical Unit WWN Device Identifier: 50024e92033cfe47

Now we proceed to set a security password so that we can perform the secure erase.

sudo hdparm --user-master u --security-set-pass Pass /dev/sdd

 Issuing SECURITY_SET_PASS command, password="Pass", user=user, mode=high

Since the time for a secure erase of this drive is in excess of 2 hours we had best verify our hdparm version.

 hdparm -V
hdparm v9.43

We do this because hdparm versions prior to 9.31 do not pass-through the long command time-outs required for the erase commands to the SCSI-ATA Command Translation ("SAT") layer which such devices use. Mine is version 9.43 so I will proceed.

First I'll confirm that the security mode was properly set:

sudo hdparm -I /dev/sdd |grep -A9 Security

       *    Security Mode feature set
       *    Power Management feature set
       *    Write cache
       *    Look-ahead
       *    Host Protected Area feature set
       *    WRITE_BUFFER command
       *    READ_BUFFER command
       *    NOP cmd
       *    Advanced Power Management feature set
    Master password revision code = 65534
    not locked
    not frozen
    not expired: security count
        supported: enhanced erase
    Security level high

Yes it is as we can see above. Now I will begin to secure erase the drive and go away for the 2 1/2 hours it will take on this one.

sudo hdparm --user-master u --security-erase Pass /dev/sdd

 Issuing SECURITY_ERASE command, password="Pass", user=user

When the process is complete your prompt will simply return.

A final alternative:

If you just want to insure that no data on the drive is retrievable and wish to retire the drive permanently. You can pound it flat with a big hammer (wear eye protection and do this at your own risk)

Secure Erase Sources:


man hdparm




  1. Run a live CD/USB with GParted.
  2. Search for your hard drive in GParted (usually sda/sdb).
  3. Mark all Ubuntu partitions (I always have / and /home) for deletion. Include swap.
  4. Apply the changes.
  5. You will have a clean hard disk.

Or... You can drill your hard disk.

  • 1
    Welcome to Ask Ubuntu community! – EKons Jul 2 '16 at 18:34
  • Thank you! I'm Debian user, but I have a lot of experience with Ubuntu – Juanjo Salvador Jul 3 '16 at 19:22
  • 1
    Here's how I assumed you were new: 200 > rep > 100 -> assoc = 100, 1 + assoc + up * 10 - down * 2 = 1 + 100 + 10 - 0 = 111, you had 111 rep. I've suggested an edit fixing some grammar and spelling errors. – EKons Jul 4 '16 at 7:57
  • Remember: you search for the hard drive, but, in fact, you clean the disk. The drive is where you put the disk, the disk is a container of data. – EKons Jul 4 '16 at 8:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.