I have an old laptop that is running Ubuntu. Now I want to give away this laptop, but I want to remove all private data. So what should I remove? I don't want to format the whole system, because the OS will be still in use by the new owner.

  • 5
    Several answerers have pointed out that a complete (and clean) reinstall might be the safer solution. Do you have something specific to keep in this current configuration for the new user ? Do you worry about driver problems, install disc ? You do not tell us what the current distribution is on this laptop.
    – ogerard
    Apr 12, 2011 at 13:55
  • Termites could be useful in this case..
    – landroni
    Apr 26, 2014 at 19:15

9 Answers 9


You normally have all your private data in /home, especially browser cache and so on.

You might have private internet-settings in /etc/Network-Manager. Visit /etc, and look into the directories. Reconfigure your things, delete private data (WLAN key), see if everything is vanished. If not, remove by hand. mc (midnight commander) is a useful tool to iterate through directories, to view and delete files. (shred, see bottom).

Another directory with private Data might be /var/spool or /var/cache. For example the cups-printer-spooler produces summaries of printjobs, and document name, date of job can be reconstructed. Maybe you wish to clean them too.

Those files in /tmp get automatically deleted on every startup. So if you didn't reorganized things, which only you may know,

  • create a fresh new account without password for the new user, (who is prompted for a password on the first login) and give this user the right to become superuser. Issue a groups command at your own profile, to copy useful privileges like lpadmin, plugdev, scanner, ... before deletion.
  • login with the recover-option to get root access, and
  • cd /home/roflcoptr
  • find . -delete # or, instead of -delete, you might consider shred:
  • find . -execdir shred -n 1 {} +
  • control with ls
  • delete your normal account (see: /etc/passwd, /etc/shadow) (suggested from the comments, thanks @intuited, give him a star)

If you consider cleaning empty space (@intuiteds second advice, maybe we should donate a star?), It would be more easy to use a live-cd to shred the whole system (which can continue unattended) and then install a new one (needs about 25 minutes with few interactions, mostly in the beginning). This could be in general the faster solution. More than one shred iteration is nonsense.

  • 7
    Seems like you would also want to overwrite empty space on the drive in order to prevent recovery of previously deleted confidential files.
    – intuited
    Apr 11, 2011 at 17:41
  • 9
    You should also change your password and/or delete your account, especially if there's any chance that you are using that password elsewhere.
    – intuited
    Apr 11, 2011 at 17:43
  • Why do you say more than one shred iteration is nonsense? Everything I have read about secure wiping indicates otherwise.
    – Tanath
    Apr 11, 2011 at 19:22
  • 5
    a) The whole idea of reading wiped data goes back to Peter Gutman, who reconstructed single Bytes on old hard drives in the mid 90ies. Today, the probability to reconstruct a single bit is only 56%, so to reconstruct a whole byte is nearly impossible. Links [heise.de (LANG=DE)] (heise.de/newsticker/meldung/…) and [the great wiping controversy] (springerlink.com/content/408263ql11460147) Apr 11, 2011 at 20:24
  • Thanks a lot for the links. Good to have myths cleared up with actual evidence. BTW, there was a link to the english version of the first article at the bottom of the page: h-online.com/newsticker/news/item/…
    – Tanath
    Apr 12, 2011 at 20:31

Your safest option is to use something like DBAN to securely wipe the disk and then reinstall from scratch.

If you want to provide the same application profile to the recipient, you can use dpkg --get-selections to dump the system package state before wiping, and then use dpkg --set-selections after reinstallation to tell the new system that you want those packages installed. This will allow you to conveniently reinstall all the apps that you had set up.

The tool aptitude-create-state-bundle can also be used for this purpose, and is likely preferable, since it works at a higher level and can remember what packages were explicitly installed by you.

  • 1
    Yes, DBAN is the best way to go. Definitely do this. Re-installing Ubuntu isn't hard, and only takes 10-20 minutes, so the whole process shouldn't take more than about 2 hours, depending on your hard-drive read/write speed.
    – bntser
    Apr 11, 2011 at 23:01

In my opinion, doing a complete disk wipe and reinstall of the OS is easier, less time-consuming, and more likely to erase everything that you wanted to erase. True, wiping the whole disk will take a long time, but you can go do something else while you wait. Removing specific packages and files from the existing OS is an involved process that requires lots of thinking and leaves lots of room for error. A complete reinstall accomplishes the same thing, only more effectively and with less work on your part.


In complement to very good advice already given:

If you have been running local servers for development purposes, such as apache2, mysql, etc. I would advise to remove them using the "purge" option (it destroys conf files), be sure to remove the data and log directories and files (such as found in /var/log/ and /var/www/ or /var/lib/xxxx/ by default but in other places of your choice in you made a custom config) and then reinstall them with their default settings if needed by the new user.

Another advice for paranoid/clean people is to regenerate a new ssh server host key for the machine.

rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server

so that it is no more considered as a known host by others.


Run Bleachbit. http://bleachbit.sourceforge.net/

This way you may choose exactly what you want to remove without using some complicated command lines.


I personally use any method methods to wipe the drive

# from a live CD
dd if=/dev/zero of=/dev/sda bs=iM

Or DBAN or scrub (again from a live CD)

sudo apt-get install scrub
sudo scrub -p dod -f  /dev/sda


You can the do an OEM install

How do I pre-install Ubuntu for someone (OEM install)?

  • +1 for mentioning the OEM install, it's the perfect thing to do when gifting someone a computer. Jan 28, 2012 at 17:53

If the data is not very important, you can create a new user and delete the old one.


There are varying levels of security. Personally, I play it a little more paranoid. I wouldn't give away a hard drive if I've stored sensitive info on it. It might be worth it to you to just buy a new hard drive and install Ubuntu on it for whoever you're giving this to.

If you aren't this paranoid, or your data isn't that sensitive, see user unknown's post.

  • 3
    Hard drives from the mid-nighties and from the nullies are very, very tight packed. Shred a hdd just once, and ask a service company for a price to restore it. You can't pay it. In former times, single bytes where reconstructed (with some uncertainty). It will take years and years to analyze a recent drive, and nobody will do it to find some porn, some banking informations or shared mp3s. If you are Mubarak or Ghaddafi, yes, I would melt it. Apr 11, 2011 at 18:07

Very old question i know. Most of us have spare disks knocking about from old systems and even if you don't they are cheap enough now that you could easily just buy a new one and replace the existing disk in the laptop/computer.

All you need to do then is install the operating system via OEM install option and the new owner sets up their own account on first login, plenty of answers on that right here on askubuntu so I won't rehash that.

Simply put, you keep/destroy your disk that might contain sensitive information and put another disk in.

You must log in to answer this question.

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