22

I added a new linux user by doing a

useradd -d /var/www/mywebsite.com -m newuser
passwd newuser

I tested the account by logging into the server with the following command

ssh [email protected]

After login, the shell doesn't let me do tab autocomplete. For example, I would type /var/www/myweb{tab}, but the tab button only enters a space into the shell. Also, pressing the up and down arrow keys does not give me the most recent shell commands entered.

Everything works perfectly when I ssh login as root. But it doesn't work when I ssh login as newuser.

Did I miss something?

Thanks

5 Answers 5

49

Check what shell 'newuser' is using. Make sure it's one that actually supports tab completion (like bash or zsh).

You can determine what shell the user is using using the following command

# getent passwd rodjek
rodjek:x:1001:1001:x:/home/rodjek:/bin/zsh

You can change the users shell using the chsh command

# chsh -s /bin/bash rodjek
1
  • 1
    great, that worked! Jan 5, 2010 at 21:38
5

When you add a user with useradd there is no special shell added.
You can see this with the command:cat /etc/passwd

test1:x:1004:1005:,,,:/home/test1:/bin/bash
test3:x:1007:1008::/home/test3:

You can see that the user test1 has a shell of /bin/bash but the user test3 has no shell added.

To fix this you can change the shell of user test3 with this command:

chsh -s /bin/bash test3

Or when you create a new user you can use the s option:

useradd -s /bin/bash test4
3

On my system tab autocompletion is added by:

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

in .bashrc. Bashrc doesn't get created for new users since it doesn't exist in /etc/skel. Create .bashrc in /etc/skel with the above code in and it will work for new users. Then copy the file to the new user you just created so it works for them too.

1

have you checked your new user has the same shell as your root user? Its seems that your root user has bash your something like it and your new user has a ksh or something similar. Take a look at the /etc/passwd file or the SHELL environment variable.

0

Did the folder /var/www/mywebsite.com exist before you created the account?

Can you check that contents of /etc/skel get copied over to the home directory /var/www/mywebsite.com?

Did the new account get a different shell which doesn't support auto-complete?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .