Pin Me

Linux Command Line: adduser

written by: jlwallen•edited by: J. F. Amprimoz•updated: 7/4/2011

For Linux administrators, the ability to add new users is key. Without the adduser command, the ability to add a new user to a gui-less server would be impossible. In this entry to the Bright Hub Linux Command Line series, you will discover how to make use of this must-have admin tool.

  • slide 1 of 3

    Is it "useradd" or "adduser"?

    In the beginning the UNIX command was useradd. Somewhere along the line the command changed to adduser. In some flavors of Linux the useradd command has been dropped in favor of adduser. In some flavors of Linux however, both commands remain. In fact, if you are using certain Linux distributions (such as Mandriva) you can issue either man useradd or man adduser - both commands come up with the useradd man page. Thus useradd and adduser are essentially the same command.

    So depending upon your distribution, you will either use adduser or useradd. If you try to use one and you receive "command not found", just use the other. Simple.

  • slide 2 of 3

    Basic usage

    First and foremost, adduser can only be used by the root user. What this command does is add a new user to a system. It's fairly straight-forward and simple. Once you have root privileges (which can be either through su or sudo) at a bash prompt (using a terminal such as aterm, gnome-terminal, or konsole) the adduser command looks like this:

    adduser [options] USERNAME

    Where USERNAME is the actual name the user will log in with.

    There are a number of options to be used with this command. The more important options are:

    • d - This argument creates the home directory for the new user. You should define the new users home directory as their log in name. So if you use maryjane as your user login, the home directory will be /home/maryjane and the command would look like useradd maryjane -d /home/maryjane.
    • m - If you have already created a user but failed to add a home directory, you can issue this argument with useradd (followed by the username) to create a home directory for the user.
    • p - This will allow you to define the users password. The p argument is always followed by the actual password for the user. So, to add on to the above command, adding the user maryjane with a home directory of /home/maryjane and a password of 1mary2jane3, you would issue the command useradd maryjane -d /home/maryjane -p 1mary2jane3.

  • slide 3 of 3

    Final Thoughts

    To any Linux administrator, having the adduser command available is an absolute necessity for so many tasks (adding users for mail servers, log ins, etc. The useradd command is simple to use but is often overlooked. If you have a gui-less server you will have to know how to add users via the command line.