Score:0

How to fix unconnected User?

hk flag

So I am using WSL, and I recently found the path to my Ubuntu files in Windows. I renamed my user's home folder through Windows, and now I see the following:

This message is shown once a day.
To disable it please create the 
/home/useradd/.hushlogin file.
touch: cannot touch '/home/userad/.motd_shown':
Permission denied
-bash: /home/useradd/.bash_profile: 
Permission denied   

I don't really know what to do and how to fix it.

NotTheDr01ds avatar
vn flag
Welcome to All Ubuntu! Are you saying that you changed the name of your Ubuntu user's home folder using File Explorer in Windows?
Marvin avatar
hk flag
Well i changed the name of the folder and now it's telling me i should create the /home/useradd/ .hushlogin file., aswell as touch: cannot touch '/home/useradd/.motd_shown': Permission denied -bash: /home/useradd/.bash_profile: Permission denied and i
Marvin avatar
hk flag
So i followed the path to where the files where saved and renamed the folder of my username to another one thats what i did and then those things occured.
ru flag
DO NOT alter the WSL files via Windows! You WILL break your WSL
Score:1
vn flag

I recently found the path to my Ubuntu files in Windows. I renamed my user's home folder through Windows

Let's start with, don't do that! ;-)

While the normal WSL permissions shouldn't allow you to do that in the first place, apparently you were able to somehow. I'm not sure how, but it doesn't really matter. Simply renaming a Linux user's home folder will never work, even in "normal" (non-WSL) Ubuntu. For that matter, renaming your Windows user's folder would have a similar (perhaps worse) effect.

While I can't rename my user's home directory through Windows, I can still reproduce your same error by starting Ubuntu as root with:

wsl ~ -d Ubuntu -u root

Then:

mv /home/ntd /home/xyz

After that, when I attempt to login as my ntd user, yes, I see that message.

The problem is that Ubuntu still thinks the home directory for my user is /home/ntd (and for yours, /home/useradd apparently). For instance:

# echo $HOME
/home/ntd
# cd ~
-bash: cd: /home/ntd: No such file or directory

Also, certain items in the default startup files reference $HOME. For instance, in /etc/profile.d/update-motd.sh you'll find:

if [ ! -e "$HOME/.hushlogin" ] && [ -z "$MOTD_SHOWN" ] && ! find $stamp -newermt 'today 0:00' 2> /dev/null | grep -q -m 1 '.'; then
                [ $(id -u) -eq 0 ] || SHOW="--show-only"
                update-motd $SHOW
                echo ""
                eval_gettext "This message is shown once a day. To disable it please create the"
                echo -n "$HOME/.hushlogin "
...

I don't really know what to do and how to fix it.

At this point, the easiest way to fix that particular issue is to tell Ubuntu where the user's new home directory is. You can do this by:

  • Exiting Ubuntu

  • Start PowerShell and:

    wsl ~ -u root
    
  • This starts Ubuntu as the root user. Then start the "safe editor" for the passwd file with:

    vipw
    
  • Look for the line that starts with your normal username (which sounds like it is useradd). It will probably look something like:

    useradd:x:1000:1000:,,,:/home/useradd:/bin/bash
    
  • Change the /home/useradd to the new directory name.

  • Save and exit

Exit Ubuntu and restart it as your normal user. Hopefully, the error will be fixed.


Note that the proper way to change the directory name is (as mentioned in this question) to use usermod -d. This is quite a bit easier in WSL than normal, since you can easily start as root and make sure that your normal user isn't in use.

  • Exit Ubuntu and from PowerShell:

    wsl -l -v
    # Confirm the name of the distribution being used
    # and replace "Ubuntu" below with the correct name if 
    # it is different
    
    wsl --terminate Ubuntu
    wsl ~ -u root
    
  • In Ubuntu:

    usermod -d /home/<new_directory> -m <username>
    

The -d specifies the new directory, and the -m specifies that the existing user files should be moved to that directory.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.