I'm using Ubuntu without ever (knowingly) having had any virus issues.

Recently I put a usb pen in a computer in a print shop, and their Windows machine told me that it was infected. I would like to clean up this usb pen to start using it again.

I hope, that this virus is only for Windows and I am safe. But can I even be sure about that?

Is formatting of a USB pen always enough to be sure that it is clean? Or should I "clean deeper"?

Assuming that the virus is 'dangerous' for my Linux machine (which I hope/think not) how can I safely clean it? I mean, even inserting it into my Linux machine might cause some autorun stuff to happen, right?

4 Answers 4


First of all, the antivirus should have performed the cleanup itself if it's worth its salt. Just to be sure, you can safely wipe your USB key with the following command:

sudo dd if=/dev/zero of=/dev/[device]

...[device] being your pendrive of course. You'll have to format it again afterwards. All your data will be overwritten, though. Whether the virus can be harmful to your Linux machine, I'd say "most likely not", but I don't have anything to back that up.

  • 2
    and be f***in careful with dd, you can easily wipe out your active system with it (if you choose your active drive or partition as [device]). other than that it is a great tool.
    – Baarn
    Jan 8, 2012 at 13:13

Formatting a flash drive will clean it (with the possible exception around it having an auto-load USB driver partition that is not erasable that will be installed on the victim machine...maybe)

For your Linux machine, it is very simple to prevent autorun if you want to, but in fact any antivirus worth its salt should scan and clean before anything else can happen (check out ClamAV for a good Linux antivirus solution)

Have a quick read of "How can I prevent viruses/malware from infecting my flash drive" and "Is disabling auto-run enough to protect against malicious code from removable media automatically infecting a machine" for some further background info.


Five easy steps:

  1. Shut down your computer.
  2. Remove all hard drives, and any removable media you care about, from your computer.
  3. Boot the computer from a live CD. Any OS will do, but a Linux flavor would be preferred.
  4. Insert the suspect USB drive.
  5. Nuke from orbit with your preferred tool.

You can be sure about the virus looking at it's description provided by the antivirus that detected it. You shouldn't be too concerned for linux at the moment though.

On a related note I'm disappointed by some linux desktop environments that start windows executables with wine-hq by just double-clicking them.

I don't recommend you to dd the whole drive. Many usb sticks would show 0 capacity after being dd-ed. Usually the USB stick has one partition. You can safety mkfs.vfat that partition (you can also dd it with zeroes first) and it will be clean. Also you can use testdisk to rebuild the mbr and the boot sectors. Also there is a package in debian called "mbr" that also claims to overwrite mbr. I guess it will be present in ubuntu as well.

Hope that helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .