Cleaning up my Home Directory
I have the following problem, I’ve installed a bunch of Ubuntu packages ever since I used Ubuntu, now I’ve removed these packages using the Synaptic Package Manager but somehow it still left hidden folders in my home directory for the specific applications I uninstalled, taking up unnessesary diskspace. eg. .Netbeans and .amarok etc
Is there a way to detect these folders that are no longer in use automatically and delete them?
There’s no way how to detect these unused folders reliable. A program can choose any folder name to save the user information. There’s not necessarily a relation between folder name and program name.
In most cases it’s not worthwhile delete this folders because most of them occupy very little space. And if you ever reinstall the program all your data is still there.
You can however manually delete folders which occupy very much space. You have to guess if the folders aren’t used anymore. You may want to backup these folders first.
The space occupied by each folder can be listed with a graphical file manager or on a console with a command like this:
cd "$HOME" du -h --max-depth 1
Take a look into the folders that bother you, to see if there is anything of value in there, and – if you’re happy with losing the data – just delete them (just in case, you might choose to leave them in the trash for a few weeks).
In the future, you can instruct your package manager to remove the application as well as associated system-wide configuration files by doing a purge.
- In synaptic,
right click the package and select
Mark for complete removal.
- On the command line, if you prefer,
sudo apt-get purge.
This will delete any configuration and application data that the application has created system-wide, it will – of course – leave intact all the data that you have saved from within the application (i.e. NetBeans’ project directory), this includes all the user-specific configuration that is saved in your home directory. Manual deletion is the only way to get rid of those.
If you want to find out what folders take up much space, there’s the Disk Usage Analyser (Applications → Accessories → Disk Usage Analyser), select the “scan home” option to get a listing of everything in home, including hidden files.
Also, use the Computer Janitor (System → Administration → Computer Janitor) to clean up any rubbish that has been left behind by the package manager. In terms of the command line, this would be equivalent to doing
sudo apt-get autoremove && sudo apt-get autoclean.
Some applications, like NetBeans and AmaroK, may leave behind quite a bit of data. But there is no way for the system to automatically delete them without the risk of deleting something somebody actually wanted to keep. For the users’ sake, there’s no such feature; a good job considering you might have used netbeans for a few years before removing it – i’d be really annoying if apt deleted all your work to free 500 kilobytes. 🙂
Well, I had the same problem once, and I just opened nautilus, pressed Ctrl+h to view hidden files, and sorted them by date. I found lots of folders that werent modified beyond a certain date. Take note though, I had installed a new fresh version of Ubuntu, and hence some applications had newer modified dates, which helped me to sort.
I am not sure about this: Some applications might change files inside the folder, but the folder date wont be modified. You have to check for that too.
The Mundus project is building some software designed to make it easier to clean up unused files in a home directory. See: https://sebikul.github.io/mundus/