Rocky 9.6 keeps re-creating /root/.bash_profile on reboot, what is doing that?

Post the upgrade to 9.6, on reboot, something keeps re-creating ~root/.bash_profile, ~root/.cshrc and ~root/.tcshrc.

Not that big of a deal, but since bash will only read .profile if .bash_profile is absent, which in my case completely replaces .bash_profile, this requires an extra step to get rid of it.

I can’t find anything in etc (systemd included) that would be triggering this.

Does anyone have a hint on where to look so I can get this to stop?

It’s part of the rootfiles package. You will need to create an override tmpfiles or remove the rootfiles package completely (I don’t recommend this, create an override tmpfiles instead. If doing this doesn’t work then remove the package).

[root@router ~]# rpm -ql rootfiles
/root/.bash_logout
/root/.bash_profile
/root/.bashrc
/root/.cshrc
/root/.tcshrc
/usr/lib/tmpfiles.d/rootfiles.conf
/usr/share/rootfiles
/usr/share/rootfiles/.bash_logout
/usr/share/rootfiles/.bash_profile
/usr/share/rootfiles/.bashrc
/usr/share/rootfiles/.cshrc
/usr/share/rootfiles/.tcshrc
1 Like

Aha. Yes, that’s it. Timestamps and all.

Thank you. :joy:

It should not overwrite existing files, the manual of tmpfiles.d says:
copy a file or directory, if the destination files or directories do not exist yet

In my case, the absence of the .bash_profile causes bash to read ~/.profile, which is my desired behavior. With the rootfiles recreating the /root/.bash_profile, this causes the default .bash_profile to be read, which negates my use of .profile as the main rc file.

The rootfiles will always recreate the file if missing, and I want the .bash_profile to be missing. Whatever inspired the rootfiles changes just occurred in 9.6; I have been running like this for years without having the file recreated, so this was new, unexpected behavior.

You could create a .bash_profile which just sources .profile.

The /root/.bash_profile is rather minimal, it merely sources . ~/.bashrc
You could add . /root/.profile to the .profile
Then bash would read your .profile


One can always consider whether to force the system operate “your way”, or adapt your way to match what the system does.