I am creating a new user for a Linux Debian distribution.

I did use the command to create a new user via terminal, while I was logged in as root; tehn assigned the user to the sudo group, so I can install and run commands as superuser when needed (without swap with su).

Is there a sequence of commands to perform, to create a user, create the home folder, assign it to sudo group and such?

This is the sequence of commands that I performed:

<login as root>
useradd myuser
passwd myuser
adduser myuser sudo
usermod myuser -s /bin/bash
<logout and login as myuser>

At this point, I had no home folder set up; created one via sudo but obviously it has Root as owner, so I can't do anything inside it.

I had to use chown to change the home permission, although this doesn't seems right.

What else do I need to do, to have a proper user created?

  • 1
    You're using adduser anyway. Why not just run adduser myuser, and skip the passwd and usermod commands?
    – muru
    Dec 17, 2015 at 7:03
  • Right, I could set the password in the adduser command; although neither the standard console nor the group parameter were accepted, so I ended up calling each command separately. Maybe I was doing something wrong
    – rataplan
    Dec 17, 2015 at 7:22
  • What do you mean? adduser has a --shell <SHELL> option, but /bin/bash would be the default. It doesn't have an option for extra groups, unlike useradd, yes.
    – muru
    Dec 17, 2015 at 7:28
  • I did use the -s option while using useradd, to use bash instead of sh, and it was failing. I was not aware of adduser being a replacement for useradd.
    – rataplan
    Dec 17, 2015 at 23:52

1 Answer 1


As muru says, you should just use adduser:

adduser myuser

will prompt for myuser's GECOS information and password, and create myuser's home directory with the appropriate permissions. The default shell should be /bin/bash. adduser will also populate the new home directory with the contents of /etc/skel (default shell initialisation scripts etc.).

All that's needed then is to add myuser to the sudo group, as you're doing already, so the whole sequence becomes

adduser myuser
adduser myuser sudo
  • Thanks a lot; I was not aware that adduser can be used as whole replacedment for useradd
    – rataplan
    Dec 17, 2015 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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