4

I have created a new user

useradd -d / -G www-data dsweb
sudo passwd dsweb
usermod -aG sudo dsweb

I logged in as this user successfully but when I tried pressing up key it shows me something like ^[[A rather than the commands I typed just few moments ago. If log in as root user everything works fine.

How do I make it work?

2 Answers2

8

The git developers talk of plumbing (low level) and porcelain (high level) commands. useradd is plumbing. You should have used adduser (=porcelain) instead.

From useradd's manpage:

useradd is a low level utility for adding users. On Debian, administrators should usually use adduser(8) instead.

When using useradd you need to specify literally everything, like a home directory and a login shell. adduser on the other hand has reasonable defaults for them. The experience you made is either due to having / as the home directory (no write permissions there) and/or a wrong no login shell, as @steeldriver noted in a comment. adduser handles all this. Thus:

adduser dsweb           # create user with default settings (like $HOME, $SHELL)
adduser dsweb www-data  # add him to group www-data
adduser dsweb sudo      # ... and sudo

And yes, it's a real mess that we have two commands adduser and useradd. I myself always have to look up which is which.

To remove your previously created dsweb user, use deluser dsweb. Do not supply the --remove-home switch because you created him with / as $HOME and you don't want that removed.

PerlDuck
  • 13,885
1

Issuing this command from the user account helped me: chsh -s /bin/bash.

You need to re-login after issuing the command.

Thanks to this answer here.

sariDon
  • 111