jump to navigation

Clean Up Old Thumbnails February 15, 2006

Posted by Carthik in administration, commands, maintenance, snippets, ubuntu.

The nautilus file manager shows you thumbnails of images, pdf files etc when you are browsing your directories. But you already know that. Nautilus also saves a copy of the thumbnails for later, to speed things up. The thumbnails are stored in your ~/.thumbnails directory. Over time, thumbnails keep accumulating, since, even if you delete a file (an image, say), the thumbnail remains. Cleaning this up might save you some space. It saved me about 650MB!

I found this neat command that you can execute to find and delete thumbnails that have not been accessed in the last 7 days. Deleting a thumbnail should not affect anything much, since if Nautilus cannot find a thumbnail, it will just create one anew.

$find ~/.thumbnails -type f -atime +7 -exec rm {} \;

You can put that code in your cron if you like, to have it run every month or so.


1. Eiriks forfatterblogg - February 15, 2006

Fjern gamle ikoner

Man kan si mye pent om filviseren Nautilus, men neppe at den er gjerrig med plassbruken. I den skjulte mappen…

2. Erez Schatz - February 15, 2006

I disabled all thumbnailing options, apart from the small image files, and those too are only available as a small icon… But I’m still curious how large that folder got…

3. Limulus - February 15, 2006

I’m surprised that there doesn’t seem to be a setting to limit the size of the thumbnail cache… I just ran the command line you suggested and it erased over 300 MB of thumbnails.

4. Pascal Klein - February 16, 2006

My dad wrote a tiny little bash script for this and stuck it into ~/bin. Here’s what we use:

#! /usr/bin/bash

# clear local data cache

# rm ~/.thumbnails/{large,normal}/*
# Error:
# bash: /bin/ls: Argument list too long

find ~/.thumbnails/ -name ‘*.png’ | xargs rm

Of course you can just use the command as it is as apposed to making a bash script. ­čÖé

Smaller too. =)

5. Pascal Klein - February 16, 2006

Actually, now that I use Ubuntu, the script needs to be altered slightly. In order to allow this script to be used by anyone on your system, do this:

$ touch clearthb
$ nano clearthb

Paste the following into the file:


# clear local data cache

# rm ~/.thumbnails/{large,normal}/*
# Error:
# bash: /bin/ls: Argument list too long

Write out the file (Ctrl + O, Enter), exit (Ctrl + X).

$ sudo chmod +x clearthb
$ sudo mv clearthb /usr/bin/

Done, now whenever you wish to clear your thumbnail cache, execute:

$ clearthb


6. anon - February 17, 2006

It would be cool if you could parse this line as english, like:

$find ~/.thumbnails -type f -atime +7 -exec rm {} \;

find inside the hidden directory .thumbnails in your home dir for files who’ve last been acessed 7 or more days ago, and execute a remove command on them.

What’s the final \; for?

sharpzq - September 9, 2012

$ find ~/.thumbnails -type f -atime +7 -exec rm {}
find: missing argument to `-exec’

That is the error message on ubuntu 11.10 when the last \; is omitted.

7. Sionide - February 18, 2006

Pascal, you are the man! Useful stuff.. Thanks.

8. TJH - February 19, 2006

Yeah, very useful stuff!

9. Brent Roos - February 28, 2006

very cool. I feel that the best way to add this permanetly, is to add an alias to the command find ~/.thumbnails -type f -atime +7 -exec rm {} \;

e.g.alias clearth='find ~/.thumbnails -type f -atime +7 -exec rm {} \;'Then all I have to type is clearth in the teminal. Of course, clearth can be whatever name you want. I chose clearth, because it is logical and it is not already a linux command.

Aliases are very cool, and are a good way to execute commands that otherwise might have a lot of syntax to remember.

To make aliases permanent, you must edit two files:

First create .bash_aliases, if you don’t already have this file:gedit .bash_aliasesThen add you aliases inside this file, each alias having its own line. Saved the file.

Next, edit your .bashrc file:gedit .bashrcFind these lines:
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
Uncomment them, and save the file.

Close gedit.

Lastly, type bash in the terminal to restart bash.

Now when you type your aliases, you will see that the command gets executed.

Isn’t linux cool?

Hope this helps anyone out there wondering about using aliases for long commands.

10. Brent Roos’ Blog 2.0 » Blog Archive » Use An Alias For A Command - February 28, 2006

[…] I learned this command on Ubuntu Blog. The command clears out thumbnails in Nautilus, which after time, can accumulate a lot of disk space. […]

11. Ben - March 14, 2006

Fantastic hack – mind if I add it to my hack notebook wiki? I’ll add full credit on there.


12. ubuntonista - March 14, 2006

Feel free, Ben.

13. Ricardo - April 9, 2006

Sorry but i’m a newbie in the world of Linux, in wich cron file should i put that line of code ($find ~/.thumbnails -type f -atime +7 -exec rm {} \;)?

14. ubuntonista - April 12, 2006


Use the command $crontab -e

to edit your cron jobs.

15. precinto - June 6, 2006

You can also use gnome-schedule (Universe) to manage your cron jobs.

16. Find in Forums - June 9, 2006

I manage cron jobs through the cpanel interface – it’s simple and effective

17. Brent Roos » Blog Archive » Use An Alias For A Command - August 18, 2006

[…] I learned this command on Ubuntu Blog. The command clears out thumbnails in Nautilus, which after time, can accumulate a lot of disk space. […]

18. shadow - November 19, 2006

would this command be similar/same for Kubuntu?

19. Open Source Notebook - December 16, 2006

Monday cleaning tasks (Cron jobs)

Every Monday night I run a series of automated cron jobs to free up disk space and keep the system tuned. The jobs empty some temporary folders which is not really necessary, and often consumes a lot of disk space.
Access the cron job editor by typing …

20. El Demonio Negro - » Vaciar la cache de miniaturas (thumbnails) de nautilus - January 12, 2007

[…] Nautilus seg├║n la Wikipedia [GNOME.org] Proyecto Nautilus clean up old thumbnails […]

21. Henrik - April 9, 2007

Isn’t “find ~/.thumbnails -type f -atime +7 -delete” cleaner?

22. miyaka - April 12, 2007

i cant build a program… and my boss said that maybe my pc crashes… what will i do now?

23. Rotate image e thumbnail | ilPestifero - May 27, 2007

[…] faccia il suo sporco lavoro di ricreare tutte le thumbnails ora orientate correttamente. Qui un comodo scriptino per cancellare le thumbnail delle immagini che non sono state visualizzate di recente ( in questo modo si risparmia anche un po di spazio su […]

24. Zaiaku - July 7, 2007

I didn’t save as much but it did help me out with some extra space. Thx

25. franganghi - July 28, 2007

fantastic. it works perfectly!

26. sdf - October 28, 2007

4Gb over here…

27. mortenvp - November 12, 2007

“wipe -rfc .thumbnails” does the job for me. I added an icon for the command to the panel, so now it’s just one click, and the thumbnails are gone forever…..

28. nelas - December 19, 2007

thanks, 1.6gb of thumbs are gone!

29. La Consola ┬╗ Limpieza de rutina - March 8, 2008

[…] al leer im├ígenes desde Nautilus (GNOME) o Konqueror/Dolphin (KDE). El consejo lo consegu├ş en esta nota y paso a explic├írselos […]

30. Libera espacio limpiando tus miniaturas | Venraiker - April 26, 2008

[…] Ubuntu blog Escrito el 26 de Abril del 2008 a las 20:47 § RSS § Trackback § Comentar § […]

31. Planet Resquemor » Libera espacio limpiando tus miniaturas - April 26, 2008

[…] V├şa: Ubuntu blog […]

32. Joe - September 26, 2008

I just freed 5GB with this command (although I set -atime to +60).

33. zika - February 13, 2009

what about ~/.nautilus files? I know how to turn-off ~/.thumbnails from creating but how to turn off creating of these .XML files?

34. Stefano Karapetsas - March 23, 2009

I’m writing a Python GTK application to delete obsolete thumbnails:


35. Nattgew - April 11, 2009

Cool script… but how about changing the values in
with the Configuration Editor?

36. Starhawk - July 23, 2009

I had been using this method for a few years now, but recently found a program that does this and more, see http://bleachbit-project.appspot.com/

37. Yacht rental - September 13, 2009

yhanks and cool scriptÔÇŽ but how about changing the values in
with the Configuration Editor?

38. porno siki┼č - September 27, 2010

Actually, now that I use Ubuntu, the script needs to be altered slightly. In order to allow this script to be used by anyone on your system, do this:

39. sex siki┼č - September 28, 2010

Pascal, you are the man! Useful stuff.. Thanks.

40. antalya b├Âcek ila├žlama - August 7, 2011

antalya ev ila├žlama

41. dr_agon - August 14, 2012

Modification to remove files older than 30 days from .thumbnails directory for ALL USERS, to be used by root as a cron job:

find /home -regex “/home/[^/]*/\.thumbnails/.*” -type f -atime +30 -delete

42. Jonie Dimick - March 6, 2016

I greatly enjoyed this post! It seems like you are truly dedicated to your topic, which is a much needed change. I see a lot of authors just putting up quick junk, which is unfortunate. Thank you for bringing this information out, it’s much appreciated!

Leave a Reply to Find in Forums Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: