How can I use Tab-Completion in PuTTY connecting to a Ubuntu Server?

11

3

I use PuTTY to connect to an Ubuntu Server (VPS). I would like to use Tab-Completion when I'm working with the command line on Ubuntu Server... How can I configure it?

Jonas

Posted 2010-03-12T13:47:37.193

Reputation: 21 007

Answers

13

Tab completion should work in PuTTY. Tab completion is provided by the shell you're running on the server, not by PuTTY itself. Please edit your question and provide more details including what shell you're using and what specifically happens when you try to use tab completion.

Josh

Posted 2010-03-12T13:47:37.193

Reputation: 7 540

OK, thanks. How can I see what shell I am using? I have a Ubuntu VPS, so I guess it is the default one. Is it Bash? – Jonas – 2010-03-12T13:52:58.900

2try echo $SHELL to see what shell you're running. – Kevin M – 2010-03-12T13:57:16.773

What do you try and type which doesn't auto-complete? Do you press tab once or twice? Have you tried using bash instead of sh? (I think on Ubuntu /bin/sh is a symlink to /bin/bash but I could be wrong) – Josh – 2010-03-12T14:11:50.930

4Even if it's a symbolic link to /bin/bash, the executable might alter functionality depending on how it's called. Since Sanoj is seeing that the login shell is /bin/sh, it's probably acting like Bourne shell (sh) and not Bourne-again shell (bash).

The best thing to do is to change your login shell. Try chsh /bin/bash – Doug Harris – 2010-03-12T14:20:15.283

In example if I am on / and type "cd b" and tab it should auto-complete to "cd bin" I guess? ..but when I type TAB I see a few spaces... It seams like /bin/sh is a symlink to dash* Any ideas? – Jonas – 2010-03-12T14:23:32.893

Dash is the lightweight shell used these days. Try {{{chsh}}} like Doug Harris mentioned. – janmoesen – 2010-03-12T14:31:35.810

With bash the Tab-Completion seams to work fine. But I can not change shell with "chsh /bin/bash" I get: "chsh: unknown user /bin/bash". – Jonas – 2010-03-12T14:48:45.983

This seams to be the same question, but I can still not change my shell. Have tried the answers in to that question. http://serverfault.com/questions/77926/tab-completion-not-working-in-ubuntu-hardy-heron

– Jonas – 2010-03-12T14:55:59.353

1

New question: http://superuser.com/questions/119179/how-can-i-change-shell-in-ubuntu

– Jonas – 2010-03-12T15:18:05.020

9

I had an interesting variation of this, where it worked for root, but not for my personal user. It's a local VM, as krowe suggested, on a VirtualBox running Debian. I used the same connection, so the issue had to be on the server side.

As it turned out, the difference was that root had /bin/bash in /etc/passwd, while the personal user had /bin/sh.

Changing the default shell to /bin/bash solved the problem for me.

Christian Friedl

Posted 2010-03-12T13:47:37.193

Reputation: 91

6

I have the same problem running Putty on Windows and sometimes, hitting Tab just takes the focus away from the Putty window and does not do the autofill that it usually does under /bin/bash. I have tried all of the solutions mentioned above and none of them seem to fix this problem for me.

This is how I fixed mine. Go to the Windows Desktop screen and press the Alt-Tab and Ctrl-Tab combination keys a few times and that seems to fix it for me. Now go back to the Putty screen and try Tab again.

kambiz

Posted 2010-03-12T13:47:37.193

Reputation: 61

1Somewhat surprisingly this actually worked – Graeme – 2014-02-19T06:31:36.100

1Same here! First time it happened to me with Putty – leonbloy – 2014-04-11T00:21:26.753

3

Type the following command:

sudo vi /etc/bash.bashrc

Look for these lines:

# enable bash completion in interactive shells
# if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
# fi

Uncomment some lines, to make it look like this:

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

Save, close putty, then reopen it.

aashish

Posted 2010-03-12T13:47:37.193

Reputation: 139

1

Your shell might be the default /bin/sh.

You can fix it by using /bin/bash instead, using the following commands:

chsh
/bin/bash

Nicolas Louis Guillemot

Posted 2010-03-12T13:47:37.193

Reputation: 323

0

I know this is an old question but I've run into this problem a few times and have found that the real solution is not server side at all but it's on the client side and this is the first thing that comes up when I searched for a solution to the problem.

OK, the OP mentions that he is using the VPS version of Ubuntu. This makes me suspect that he is running a virtual server and because he is having this particular problem I'd bet that the server is being hosted locally. When I've encountered this in the past it is due to a problem with VM tools. It is annoying because you'll need to completely restart the host OS but afterwards you should be good. You may want to just try shutting down VMware or maybe just unplugging your keyboard would also work but my desktop starts up really fast so I usually just do a full restart.

In my particular case, this problem happens every time I try to install the latest Kubuntu release using the VMware quick install feature (which also fails BTW). It even happens when the server I'm connecting to is a remote server. Hope this helps someone.

krowe

Posted 2010-03-12T13:47:37.193

Reputation: 5 031

0

In putty under keyboard select Linux. Then under Features select Disable switching to alternate window

Worked for me in ADBPutty

Don

Posted 2010-03-12T13:47:37.193

Reputation: 1