2

The $HOME variable is incorrectly set to "/root" for all users on login on my Raspberry Pi 3B+ board running Ubuntu Server 22.04.

In an SSH session I have to manually $ export HOME=/home/ubuntu and $ source .bashrc (for the default ubuntu user, it's the same for every user I create).

However this annoyance becomes a problem with VS Code remote for example, as it can't read the profile:

stderr> -bash: /root/.bash_profile: Permission denied.

How can I load my user profiles correctly?


I've tried running usermod -d /home/ubuntu ubuntu as suggested in this answer, but everything is apparently ok (usermod: no changes).

Since I'm running the Pi headless I have no xsession as was OPs problem in the linked thread, so I'm a bit at a loss.

glaux
  • 123
  • 5
  • Should we assume you have checked systemwide login shell initialization files (/etc/profile, /etc/profile.d/*.sh) for offending lines like `HOME=/root`? Does the behavior change if you temporarily set your user's login shell to something different than bash? – steeldriver May 22 '22 at 13:29
  • I hadn't, but I have now to no avail. I have grep'ed /home, /etc and /root with `grep -R "\$HOME" .` but not found anything useful. I'm not sure where to look. Changing login shell to /bin/sh have no effect, the output of `cd` is still `-sh: 1: cd: can't cd to /root` – glaux May 22 '22 at 20:04
  • `file /bin/sh` please. – nobody May 22 '22 at 21:02
  • `$ file /bin/sh` `/bin/sh: symbolic link to dash` – glaux Jun 02 '22 at 19:43
  • searching in the fog `env` please. Never seen this error. – nobody Jun 02 '22 at 19:51
  • It's really strange. I just realised that I can work around it by placing a script in /etc/profile.d with `export HOME=/home/ubuntu`. That seems to work, but I would like to understand why it happened (and if anything else is broken, doesn't seem like it though) – glaux Jun 02 '22 at 20:05
  • Output of env, slightly redacted: https://gist.github.com/nicolajknudsen/59980a6fe79829166b5ef669a928ff67 – glaux Jun 02 '22 at 20:14
  • Maybe stupid question you are not login as root over ssh? – nobody Jun 02 '22 at 20:47
  • Not stupid, that would be the obvious, but I'm ssh'ing as the user 'ubuntu', and gets logged in as that user. – glaux Jun 03 '22 at 06:47
  • I'm sorry. What is the system you log over ssh to your raspi? How did you add new user (which tool/which options)? – nobody Jun 03 '22 at 10:00

0 Answers0