I changed my user name (Ubuntu 22.04.1) from something to user by following the the exact steps in this AskUbuntu answer. Everything seems to be fine as if the user name were created from scratch, except that the user prompt for bash does not use tilde (~).

When I initially launch a terminal (in GUI or without X server), the bash prompt is using ~ as before. But as soon as I cd some directory, it changes to the raw value, as shown below:

user@mybox:~$ cd 

How can I fix the prompt to use tilde as it used to?

FYI, the ~ still refers to the changed home folder correctly. I didn't change the prompt in .bashrc or elsewhere. Below are the relevant info of the system:

$ getent passwd "$LOGNAME"

$ echo "${HOME}"

$ echo "$PS1" 
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
  • Is this possibly fixed by simply removing the trailing / on the home directory in the passwd file?
    – Kusalananda
    Sep 7, 2022 at 18:52
  • @Kusalananda Thanks. Indeed, that fixes the problem.
    – tinlyx
    Sep 7, 2022 at 19:11

1 Answer 1


I think it's the slash at the end of the home directory name that confuses Bash.

If I add one manually to my $HOME, Bash shows the full path of the home directory. Removing it again fixes it.

~$ pwd
~$ HOME=/home/ilkkachu/
/home/ilkkachu$ cd 
/home/ilkkachu$ HOME=/home/ilkkachu

Try and remove the trailing slash from the path in the passwd entry.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .