Want to identify and remove un-used application data in your Ubuntu, Fedora, Debian, Arch, etc Linux? This free open-source script can help!
Linux applications store your personal cache and config data in user’s home directory. They are hidden folders, which, will NOT be automatically deleted while removing applications.
The app cache and data file left in your home directory can be useful! When you install the applications again, they take use of the cache & config to restore to their previous status.
By default, the app cache is saved in
.cache folder, while config data stored in
.config. For the universal Flatpak apps, the personal app data is available in
.var/app. And, Snap apps store them in ‘snap‘ folder in user home.
You can manually go into above folders to manually remove un-used app data. But, for be using for long period of time, you may have quite a lot of folders there. So, here’s the script to help to find them out!
XDG Unused Data
The script I’m going to introduced is called ‘XDG Unused Data’. It’s a new project so far works for apps installed as
.rpm, and other native packages.
It can detect all the app data left on your home directory, while apps themselves have been removed!
1. Install the ‘jq’ dependency library.
The script depends on ‘jq’, which is available in the most Linux repositories. For Debian / Ubuntu, just open terminal and run command to install it:
sudo apt install jq
For Fedora/RHEL, replace
dnf. For Arch & Manjaro, use
sudo pacman -S jq instead.
2. Download the script.
You can download the source by going to its project page by visiting the page below:
Or, just open terminal and run command to clone the source:
git clone https://github.com/pawel-0/xdg-unused-data
sudo apt install git if command not found. After that, there should be a ‘xdg-unused-data’ folder.
3. Use the script to detect unused app data
Once you clone the source, navigate to that folder in terminal:
Then, add executable permission:
chmod +x xdg-unused-data.sh
Finally, you can run the script to tell all the un-used data.
As new project, it so far may have issues! The big one at the moment is the xdg-basedir environment variables issue. As a workaround, you may run the 4 commands below one by one to manually set the variables, which works only in current terminal:
Finally, re-run the script to detect.
You can alternatively edit .bashrc file and add 4 commands above into the end.
4. Delete unused app data
After running the script, you can manually delete the data folders via your system file manager.
Or, run the script with following flag to delete all detected data folders:
./xdg-unused-data.sh | xargs rm -rf
NOTE: The script may have bug that work incorrectly! Do the command above with your own risk!
To remove a specific app data, such as audacious, use command:
./xdg-unused-data.sh | grep audacious | xargs rm -rf
In the end
The script so far is a new project! At the moment of writing, it supports 324 applications. To help making it better, you can report bugs and/or submit more applications by visiting the github page.