On 25/09/2025 19:26, Jeffrey Walton wrote:
On Thu, Sep 25, 2025 at 1:40 PM <debian-user@howorth.org.uk> wrote:Andy Smith <andy@strugglers.net> wrote:On Thu, Sep 25, 2025 at 09:29:32PM +0530, Avinash Sonawane wrote:I noticed that there is a directory named ".cache" at root level. It seems to be created at the time of installation. What is it?It's one of the XDG standard directories. https://specifications.freedesktop.org/basedir-spec/latest/Who has created it?Probably put there as part of user creation but all apps that need to use it will also (re-)create it if you delete it.I'm confused. It's part of a user's directories, and defaults to $HOME/.cache so surely it should be under /root not under / ? The OP could test it by setting an explict value for $XDG_CACHE_HOME in root's environment and seeing if that makes any difference.I was thinking something similar... Sudo or another program scrubbed the environment. $HOME became empty, so "$HOME/.cache" became "/.cache".
It's probably worth noting, too, that the `login` program (from util-linux) will use / as a home directory if it _can't_ change to $HOME. It will, however, print a message letting the user know this is the case: https://sources.debian.org/src/util-linux/2.41.2-1/login-utils/login.c#L1549
So there's a few possibilities here: * $HOME wasn't set * $HOME was set, but was either blank or resolved to /* $HOME was set, but the path didn't exist (e.g. some service accounts use "/nonexistent" as a fake home directory)
* $HOME was set, but login couldn't chdir into it (e.g. it wasn't mounted, or the permissions were wrong)
And now the question comes of "is this a bug, or is this actually just a complicated set of assumptions"? Because I don't think you can call what login is doing a bug; it looks like a deliberate decision that - if the user has permission to login but their home directory isn't mounted, let's give them at least *somewhere* to launch recovery tools from! So then the next question is "who created $HOME/.cache"? As several people have pointed out, that's normal behaviour. Is it a bug that every such application didn't test whether "$HOME==/" before creating the cache directory? Not really.
So how do you - as the administrator of a system - tell applications that you think "$HOME==/" is an error? Probably your best bet is to ensure that / is only writeable by root (other users can use sub-directories, but only root can create directories in /). If it happens again, then there's only one user to blame.
Seems to be a bug in some package which has created it..."Everything I don't understand is a bug"Words of wisdom. Jeff
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature