0

I have a little project server sandbox running CentOS.

Setting up a new server package, I realized I needed to add new directory to the path and I found $HOME has a trailing slash for the main user.

I can't find where this has been set. It's not in,

~/.bashrc
~/.bash_profile
/etc/bashrc
/etc/profile.d

Any other suggestions?

xtian
  • 321
  • 3
  • 15

1 Answers1

7

The value of $HOME originates from the /etc/passwd file. You can use usermod --home /home/user user as root to change the home directory of user to be /home/user. The advantage of using usermod rather than editing /etc/passwd directly is that usermod will do a bit of validation and guard against race conditions if multiple changes to /etc/passwd are applied in parallel.

The trailing slash in $HOME is unusual but should be harmless. Even if it results in scripts producing path entries with double slashes in them, those will work exactly the same as single slashes.

kasperd
  • 30,455
  • 17
  • 76
  • 124
  • "The trailing slash in $HOME is unusual but should be harmless." the side effect is `$PWD` never match `$HOME`, while [bash interpret `\w` in `PS1`](https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html), `\w` won't show as `~` even if current dir is `$HOME`. – georgexsh Aug 28 '23 at 07:37