205

What is the ~/.local folder good for and is it safe to remove the content within this folder?

Elitmiar
  • 2,645

3 Answers3

213

This is a recent innovation, followed by Gnome and thus by Ubuntu, to store user-specific data in fixed directories. According to XDG Base Directory Specification, there is

  • a single directory where user data is stored, defaulting to ~/.local/share;
  • a single directory where configuration is stored, defaulting to ~/.config;
  • a single directory which holds non-essential data files, defaulting to ~/.cache.

Historically, Unix programs were free to spread their data all over the $HOME directory, putting their data in dot-files (files starting with ".") or subdirectories such as ~/.vimrc and ~/.vim. The new specification is intended to make this behavior more predictable. I suspect this makes backups of application data easier, in addition to giving your home directory a tidier appearance. Not all applications adhere to this standard yet.

In the .local hierarchy, programs put user information such as emails and calendar events. You could manually remove this data, but then the program would lose its state; unless this is what you intend (e.g. when there is a problem with your configuration), you shouldn't remove or change files in that directory. With .cache you can be more careless as the program should be able to recover - redownload or recompute - all the files if you remove them.

loevborg
  • 7,282
  • 18
    .local is for storing user program data (like locally installed programs), not user data (like photos, calendars etc) – Martin Owens -doctormo- Nov 23 '10 at 13:55
  • 1
    I don't think you're right. Two interpretations of the specification are possible: (1) .local/share is supposed to be used in a way analogous to /usr/share, e.g. to override icons; and (2) applications are permitted to write state to subdirectories of .local/share. The existence of ~/.local/share/trash/ implies that at least some applications favor the second interpretation. Granted that .local is used to install local versions of software from source. But it is apparently also used to store data similar to ~/.firefox. – loevborg Nov 23 '10 at 14:11
  • 14
    It seems like .config and .cache should be inside .local for consistency, shouldn't they? – Piotr Dobrogost Jul 24 '13 at 21:45
  • 5
    I'm wondering if it's a good idea to backup my ~/.local or parts of it for the purpose of easier recovering when my computer is broken. Or would it be mostly not applicable on a different/new computer? Any suggestion? – lumeng.dev Sep 04 '15 at 19:58
  • 2
    What other things can appear in ~/.local other than ~/.local/share and ~/.local/bin (which I know pip uses for user installations)? – CMCDragonkai Jan 06 '17 at 08:23
  • 2
    @CMCDragonkai, I've personally used ~/.local as a canonical alternative to /usr/ for local installations. Since it already has a ./share, and a ./bin, it may as well have whatever you want to put there. Since PATH seems to search ~/.local/bin already (at least for CentOS), I think it's relatively safe to assume this was at least one intended use case of the directory. – Alex Eftimiades May 17 '18 at 12:33
  • @AlexEftimiades It seems to me that $HOME/.local is clearly the place to do installs that concern the one user, so you don't pollute the "all-user's" /usr dir. In hindsight, maybe /usr wasn't such a great name, but something was/is needed to separate the code needed by users from the code needed by the system. So having a .local/bin, .local/lib, and even a .local/include for installing SDKs (that you could even edit) seems very useful. – Cosmo Nov 04 '21 at 02:06
  • Just another thing to look for, Steam installs a lot in ~/.local/share/Steam - 43Gb on my system, and I'd only installed steam to see what was available :-( – DorianFM Sep 25 '22 at 12:04
25

Let me share one of my experiences about the .local directory. I also found my disk partition(root partition) which store home directory has no enough space, and after I check those directories' content, I found the .local directory stores above 70G space, then I want to delete it, but fear the deletion could cause my ubuntu system crash. So I searched this question in google, and it directs me here. But the previous answers could not solve my problems, I only want two results on my system:

  1. Remove some content in the .local directory, then I could have enough disk space to store my new files;

  2. I don't want my system crash, it means I don't want to directly delete the content from my home .local directory, it's too dangerous!

Finally, I found the biggest content under the .local directory is here:

/home/myAccount/.local/share/Trash

It occupies 69G Bytes. I feel it relates to the Trash, so I go to trash, and empty the trash.

Then I found the 69G bytes disk space was freed!!

So my conclusions:

  1. It's highly risky to delete .local directory directly

  2. We could safely delete content under /home/myAccount/.local/share/Trash by "Empty" trash.

richbl
  • 2,303
  • 2
    Thanks for this answer. The first answer might be the best for the question that got asked, but it's kind of dishonest in a way. It says .local contains "user information such as emails and calendar events", but the vast majority of what's in .local isn't user info at all: it's trash can files. Your answer explained what actually takes up the vast majority of .local, making it the better answer IMHO. – machineghost Dec 19 '18 at 23:31
  • 3
    well, how much is in your trash depends on you - I clean it out regularly, so my .local is mostly user data – xeruf Apr 06 '20 at 11:56
  • 1
    You don't have to delete the whole directory. In your instance it sounds like there's an application that's probably dumping a lot of cache into your .local folder. Investigate using du ~/.local and/or use something like find ~/.local -type f -size +100k to find offenders. Then run find ~/.local -type f -size +1M -exec gio trash {} \; to move those files to trash – CervEd Apr 24 '21 at 06:47
4

The .local/ directory is used by some software to keep your preferences (as pointed by @loevborg). This directory is part of the effort to standardize the mess that is the $HOME user. But unfortunately many software has not yet joined this effort, even some gnome software still are spreading your preferences in others directory (see .gnome2, .gconf, .evolution, etc).

It is not safe to remove the directory. Some apps store important information/config files inside this directory.

waltinator
  • 36,399
crncosta
  • 2,839
  • 3
    .config is there "to keep your preferences", not .local - the directory is meant for user/application data – xeruf Apr 06 '20 at 11:57