/usr/share vs. $HOME/.local/share : a very basic question

Playing around with Lubuntu 20.04 LTS, (mostly as admin user), I’m getting a good feel of the directory landscape.

But I also have a couple of “normal users” set up, and I find that some of their configuration files reside in $Home/.local/share, whereas the admin user configuration files reside in /usr/share.

Am I right in thinking that both directories have the same functionality, but just different user types?
And that $HOME/.local/share is the right place for non-admin-user files, equivalent to /usr/share?

My confusion arises from the fact, that /etc does not have a “normal-user” equivalent. And that /usr/local exists, which some people use.

Think of /usr, /etc… as a place holder for system-wide defaults. Users change them with their own provided they are allowed to.

1 Like

As @arsivci so correctly points out, it tends to be true that there are always two levels of configuration: system-wide and user-specific, where the latter always overrides the former.

As far as where these folders are and what they’re for, you should consult the XDG specification as well as our wiki regarding our own implementation.

1 Like

This landed like a bomb by me. I’ve not seen this stated so clearly anywhere else. But it makes sense.

Thank You, Thank You.

2 Likes

I’ve slept on this issue, and it doesn’t really rest.

The “normal User” issue is fine, no problem there.

The question remains: what do I do with my Admin User?

Should I copy the files from /usr/share to $HOME/.local/share ?

I see upsides and downsides. My /home resides on a separate partition, so updates and new installations will let /home survive.
On the other hand, a new installation/update will perhaps bring new things to /usr/share ?

I’m looking for a bit of guidance here, I’m certain that there are perspectives I’ve overlooked.

Thank You in advance.

Your admin user (which should be the initial user created; at least that’s the one that has sudo access) should be like any other user: when it’s created, system-wide files are copied to the user’s home.

If you want to change something for the admin user, you change the files in the admin user’s home.

If you want to change something for another user, you change the files in that user’s home.

If you want to change something for everyone, you would change the system wide files.

If there are updates to a configuration file, you will be warned about it and given choices of what to do. I wouldn’t worry about that too much.

@wxl:
Thank You.
Yes, I’m talking about the user that has “sudo access/rights” and, like you say, the first user created on my machine.
However, on every installation I’ve done (18.10, 19.04, 19.10, 20.04), the “first user” never had any files in $HOME/.local/share. Subsequent/other users did.
And on my running 20.04, there’s nothing in $HOME/.local/share for the first/sudo user.

Thus my question.

Thanks.

I just did an installation, admittedly in what will become 21.04, with a separate /home, and the first user had two folders in $HOME/.local/share, one of which was notable as it’s for the login manager, sddm. That said, I can’t replicate your experience.

However, that’s not really the source of most config files and if that’s what you were looking for, that might have been the confusion. That would be $HOME/.config.

If you look at the environment variables, you will see that the former is XDG_DATA_HOME whereas the latter is XDG_CONFIG_HOME. They’re pretty self explanatory but according to the aforementioned XDG spec:

  • There is a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME.
  • There is a single base directory relative to which user-specific configuration files should be written. This directory is defined by the environment variable $XDG_CONFIG_HOME.

Another way to think about this whole thing is that there are really three levels of configuration:

  1. In the program itself. Many times defaults are already given and overriden only in the case that a config file exists.
  2. In a system-wide config file, again existing somewhere in XDG_CONFIG_DIRS. These override the above.
  3. In a user-specific config file, again existing in XDG_CONFIG_HOME. These override the above.

The point being that you might see no files and there still might be a configuration.

Also there is our own implementation. Read it and you’ll understand why /usr/share, which should be in XDG_DATA_DIRS is also in XDG_CONFIG_DIRS.

Hopefully that’s enough for ya’ll to make sense of things.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.