How to Fix Missing Tab Completion and Up-Arrow History in Ubuntu 10.04 SSH Sessions


2 views

When you SSH into a preconfigured Ubuntu 10.04 account, everything works fine:

  • Proper shell prompt: user@hostname:~$
  • Tab completion works
  • Up/down arrows navigate command history

But with newly created accounts:

  • Minimal prompt: just $
  • Up arrow prints ^[[A instead of navigating history
  • Tab completion fails

This happens because:

  1. The new account isn't loading ~/.bashrc properly
  2. Readline (which handles input) isn't configured
  3. Terminal settings may be incorrect

1. First, check your current shell

echo $SHELL
# Should be /bin/bash
# If not, run:
chsh -s /bin/bash

2. Force reload .bashrc

source ~/.bashrc
# Or more thoroughly:
exec bash

3. Verify key settings in .bashrc

Ensure these lines are uncommented:

# ~/.bashrc
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

4. Check terminal settings

echo $TERM
# Should be xterm or similar
# If not, set it:
export TERM=xterm

5. Create proper startup files

Copy the skeleton files:

cp /etc/skel/.bashrc ~/
cp /etc/skel/.profile ~/

Add this to your ~/.bash_profile or ~/.profile:

# Ensure .bashrc is loaded
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# Set proper terminal
export TERM=xterm

# Enable history search
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'

If issues persist:

  • Check file permissions: ls -la ~/
  • Test with bash --norc to isolate the problem
  • Compare env output between working/non-working sessions

When working with Ubuntu 10.04 via SSH, you might notice significant differences in shell behavior between a preconfigured account and a newly created one. The preconfigured account shows proper:

  • Command history navigation (up/down arrows)
  • Tab completion for files/commands
  • Full PS1 prompt (user@host:~$)

While the new account exhibits:

  • Broken arrow keys (showing ^[[A control codes)
  • Minimal $ prompt
  • Missing tab completion

This occurs because the new account lacks proper shell initialization files. Ubuntu typically sources these files in this order:

/etc/profile
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc (if interactive shell)

The missing functionality stems from either:

  1. Absent .bashrc file in home directory
  2. No sourcing of .bashrc in profile files
  3. Incorrect terminal type settings

Solution 1: Copy Default Configuration

cp /etc/skel/.bashrc ~/
cp /etc/skel/.profile ~/
source ~/.bashrc

Solution 2: Manual .bashrc Configuration

# Enable arrow keys
test -s ~/.bashrc && . ~/.bashrc || true

# Set proper prompt
PS1='\u@\h:\w\$ '

# Enable tab completion
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

If issues persist after fixing .bashrc, check your terminal type:

echo $TERM
# Should return xterm or similar
# If not, set it properly:
export TERM=xterm

For permanent changes, edit your .bash_profile:

# ~/.bash_profile
if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

After making changes:

  1. Log out completely (exit SSH session)
  2. Reconnect via SSH
  3. Run: echo $PS1 (should show full prompt)
  4. Press up arrow (should show previous command)
  5. Try tab completion (should work)

For power users wanting enhanced behavior:

# In ~/.bashrc
shopt -s histappend
HISTCONTROL=ignoreboth
HISTSIZE=1000
HISTFILESIZE=2000

# Better tab completion
bind 'set show-all-if-ambiguous on'
bind 'TAB:menu-complete'

Remember that Ubuntu 10.04 is quite old (released April 2010). Consider upgrading to a supported LTS version for better security and compatibility.