1

I created a new WSL2 container of Ubuntu-24.04. Also, I made a new default user there that has a different name than my Windows user, and moved the container file to another location. In general, the distributive works, apps could be operated using a console.

But bash does not work as it used to. There are no colors in the console, no file or command autocomplete on Tab, no back/forward history navigation.

Adding custom inputrc binds does not look good. There should be a bigger issue.

Please, help me fix the issue.

Thank you.

The ~/.bash_profile, ~/.bashrc, and ~/.profile files are present. An attempt to reload .bashrc fails because the source command does not exist in this context.

PIoneer_2
  • 121

1 Answers1

1

I got it! The shell is not bash! It is sh! That's why all the bash features were not in use. By default, a full Ubuntu distributive should use sh as a default shell. But my previous WSL2 Ubuntu distro had bash. All I was needed is to change the default shell for the user.

First, we need to check what shell is the default for a mynewuser user:

cat /etc/passwd

The original output should be like this:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
dhcpcd:x:100:65534:DHCP Client Daemon,,,:/usr/lib/dhcpcd:/bin/false
mynewuser:x:1000:1000::/home/mynewuser:/bin/sh

Second, we should find the user in the list. There are "home path for the user" and "user's shell" in the end of it's line. The mynewuser has /bin/sh as the shell.

Third, we need to carefully update the shell.

NB! The /etc/passwd file is public but its structure break can harm your sistem! Pleae, edit it carefully!

Updating the shell carefully (with no manual file edit):

sudo usermod -s "/bin/bash" mynewuser

To double-check the change - read the /etc/passwd content again:

cat /etc/passwd

The new output should be like this:

root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
dhcpcd:x:100:65534:DHCP Client Daemon,,,:/usr/lib/dhcpcd:/bin/false
mynewuser:x:1000:1000::/home/mynewuser:/bin/bash

More about the "user shell types" could be found at unix.stackexchange.com - here.

Fourth, re-login with the user, and the "bash magic" will return!

That's it!

Hope it will help.

PIoneer_2
  • 121