Usually, all your personal files are inside your $HOME
. So, you should create a second admin user. From this one, copy over everything you want to keep or better create a backup from your old $HOME
, so you can recreate important things later and you don't miss anything.
Check in other locations like /tmp
or /var
if there are any personal files or logs. It should be safe to remove /var/logs/*
.
You could use find
to find files that belong to the old user in locations outside of $HOME
:
sudo find / -xdev -path "/home/old_user" -prune -o -user old_user
Then remove your old user and your complete $HOME
directory.
sudo deluser --remove-home old_user_name
When you are done with that, you need to wipe all empty space.
You can use sfill
from secure-delete
to wipe all empty space on your hard drive.
sudo apt-get install secure-delete
sfill
will default to run multiple passes with /dev/random
, which is super-paranoid. If your enemy is not the NSA, one-time filling with zeros is enough:
sfill -l -l -z /home/new_user/
... or overwrite the space yourself by creating a big empty file and when all space is filled, delete it:
cat /dev/zero > zero.file
sync
rm zero.file
If for some reason, your user should be kept, you need to remove your personal files manually before wiping empty space. Be aware that you have config, keyring files, temp files, logs, thumbails in various locations and you will likely miss some of them. You can use bleachbit
to help you with this, but I would still always prefer creating a new user and deleting the old one.
If you want to make sure, run photorec
on your hard drive to check if there is anything that a new user could possibly see:
sudo apt install testdisk
sudo photorec /dev/sda1
(replace /dev/sda1
with your actual hard drive location).
Depending on the size of your disk, this will take a while.