Add Users From The Command Line In Ubuntu 11.04 Natty Narwhal

Let’s say you want to add a new local user to your Ubuntu 11.04 Maverick Meerkat. You can of course use the graphical tools to do this, but in Linux it’s always best to do know how to do things from the command line.

So here’s how to add a new user to a Ubuntu system from the command line. Let’s assume you want to add a user with a full name of Caina Amalas. Use the useradd command at the prompt (note that to add users, you need root-level permissions, so use this command with sudo):

sudo useradd -c “Caina Amalas” -m -s “/bin/bash” camalas

What do all those switches do, exactly?

First, the -c “Caina Amalas” switch lets you specify the user’s full name.

The -m switch creates a home directory for the new user in the /home folder.

The -s “/bin/bash” command specifies that the new user receive a default shell of bash. Otherwise, Ubuntu defaults to the sh shell.

Finally, the command specifies a new username of “camalas” for Caina Amalas.

One last thing, though. Caina will not be able to log into the system until you create a password for her. Which you can do with this command:

sudo passwd camalas

Select a password. Once you have a password, Caina can log into the system using the username camalas and the password you created.

-JM

This entry was posted in Ubuntu 11.04. Bookmark the permalink.

2 Responses to Add Users From The Command Line In Ubuntu 11.04 Natty Narwhal

  1. Joan Piedra says:

    Jonathan, thank you so much!

    I’ve been trying to figure out for a while why would my command line act so weird whenever I logged in with a new user.

    -s “/bin/bash” solved everything! I can’t believe I didn’t see this anywhere else..

    You are a lifesaver, thanks!!

  2. Mikhail says:

    Great post, thanks.