I created a fresh WSL2 container of Ubuntu-24.04. Also, I created a new default user there that has different name than my Win user, moved the container file to another location. In general, the distributive works, apps could be operated using console.
But bash
looks not as it used to. There is no colors in the console, no file or command autocomplete on Tab, no back/forward history navigation.
Adding custom inputrc
binds looks not good. There should be a bigger issue.
Please, help me fix the issue.
Thank you.
The ~/.bash_profile
, ~/.bashrc
, ~/.profile
files are present. An attempt to re-load .bashrc
fails because the source
command does not exist in this context.
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):
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
Fourth, re-login with the user and it the "bash magic" will return!
That's it!
Hope, it will help.