Arrow keys, Home, End, tab-complete keys not working in shell

I have installed ubuntu minimal(mini.iso) on my vm. I then used recovery mode to login as root and create an account with useradd -m admin and then set a password with passwd admin.

When I login on the new account, instead of the normal prompt I only see a $ sign. If I try to tab-complete a command or file name it prints a normal tab. If I try to use the arrow keys it prints ^[[A, ^[[B, ^[[C or ^[[D. Also, ls no longer adds colors.

None of these problems were in recovery mode. How can I fix this?


Solution 1:

That probably means that the new user account was created with /bin/sh as its login shell (which symlinks to the dash shell by default) instead of /bin/bash - you can change a user's login shell with the 'chsh' command

chsh -s /bin/bash

or to change another user's login shell (need to be root to do this obviously)

sudo chsh -s /bin/bash <username>

(you will need to start a new login session for the change to take effect). You may also need to copy the default .bashrc from /etc/skel to get the color prompt.

In future you might want to use the 'adduser' command instead of 'useradd' - it sets up a more complete user environment including things like a default .profile and .bashrc - as well as setting the login shell to 'bash'

Solution 2:

I was unable to use tab completion when connecting via VNC to a headless XFCE4. The answer listed here did not work but this did:

Edit Keyboard Shortcuts in xml file:

sudo nano ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

Find:

<property name="&lt;Super&gt;Tab" type="string" value="switch_window_key"/>

Change it to:

<property name="&lt;Super&gt;Tab" type="empty"/>

Logout/reboot and should be good to go

Solution 3:

I just installed Vim and everything was solved. At first, I thought that it was installed on the original version of Ubuntu since I was able to use Vi command, but it was not the case.

sudo apt-get install vim 

solved the problem.

Solution 4:

sudo sh -c "if [ -e $(which bash) ]; then rm $(which sh) && ln -s $(which bash) /bin/bash; fi"

My problem was that /bin/sh was symlinked to /bin/dash.