3

This question already has an answer here:

I created a user in terminal by

useradd xyz

I'm able to log in from the terminal but not in the GUI.

What is wrong?

marked as duplicate by karel, muru command-line Nov 6 '17 at 8:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • How do you log in from the terminal? Have you created user's password? – pa4080 Nov 6 '17 at 7:51
  • @Melebius this is not a duplicate of the question you linked in my opinion since the OP doesn't know that no home directory was created and didn't use the -d option but rather no options at all. – derHugo Nov 6 '17 at 8:02
  • @derHugo AFAIK it does not work that way. A duplicate question means that the answers to another question can be applied to it, so the community can maintain just one list of answers for such a situation. – Melebius Nov 6 '17 at 8:12
5

This might be because useradd didn't create a home directory for your new user. You should use

adduser xyz

instead and avoid using useradd since it is a backend command needing more input.

See also this answer, man useradd and man adduser.


Or if you still want to use useradd use at least

useradd -m xyz

to create a home directory. But this still might be insufficient.


Before starting now you might want to remove the user you created wrong by

userdel xyz

so you can create it again correctly without problems.


Anyway:
If you have a GUI it might be easier to just use the GUI for adding the new user (usually somewhere in System-settings -> Accounts). This might also solve some problems with usergroups which might appear as @Videonauth pointed out.

  • you should add that this new user should be added to some groups too, like usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare <username>. Leave suo out if you not want this user to have sudo rights and in case of sambashare not a group leave this out as well. – Videonauth Nov 6 '17 at 6:17
  • Or do it all in one command useradd -U -m -G adm,cdrom,dip,plugdev,lpadmin <username> – Videonauth Nov 6 '17 at 6:21
  • Thanks @Videonauth I never needed those groups but well .. I'm not using GUIs ^^ And when I do I always added those users within the GUI so I don't now which groups really are necessary to be added manually. adduser actually should already do a lot of that automatically.. – derHugo Nov 6 '17 at 6:23
  • When in terminal with your main user, type groups to see in which groups he is in. :) For me it returns the above mentioned ones on 17.10 and it was no different on 16.04 and all in between. – Videonauth Nov 6 '17 at 6:24
  • 1
    @Videonauth thanks for your afforts but I may repeat: adduser (which is and works different from useradd) should do that automatically using the systems /etc/adduser.conf (man /etc/adduser.conf -> EXTRA_GROUPS This is the list of groups that new non-system users will be added to. By default, this list is 'dialout cdrom floppy audio video plugdev users games'). Basic usergoups should be added by default unless you changed it in this configuration. – derHugo Nov 6 '17 at 7:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.