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?

  • Yes I wanted to create a non-root user but still have sudo access e.g. making changes to apache config as well as changing /var/www files etc. However, I can delete this user account and setup another correct way if you have any suggestions? – TigerTiger May 31 '18 at 13:18
  • 2
    Likely because you didn't set the login shell as /bin/bash - see Arrow keys, Home, End, tab-complete keys not working in shell – steeldriver May 31 '18 at 13:18
  • @steeldriver yes perfect that's exactly what I needed. if you can post your comment as answer, I'll accept that the answer or maybe mark this as duplicate question or I can close it? – TigerTiger May 31 '18 at 13:25
  • @TigerTiger - Step by Step do this as described here: https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart - there is a difference between commands useradd and adduser. This is explained in man pages. When you want to go step by step. You have to remove created user first and reboot before to proceed. – dschinn1001 May 31 '18 at 14:25

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,335
0

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
  • 101