> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# useradd Command Examples
- URL: https://linuxhandbook.com/useradd-command/
- Published: 2020-01-15T18:04:14.000Z
- Updated: 2024-04-25T04:00:07.000Z
- Description: The useradd command lets a superuser create a new user account on Linux. Here's how to use the useradd command with various options.
- Author: Abhishek Prakash
- Tags: User Account Management, Commands, #docs-col, #user-commands

The useradd command lets a superuser create a new user account in Linux.

It is a low level utility that doesn’t do a lot of things by default but provides several options to create users with various configuration.

Here’s the syntax of useradd command:

```
useradd [options] username
```

Let’s see how to use useradd command.

✋

Keep in mind that you need to be root or a sudo user in order to use this command.

## Add a new user in Linux with useradd command

You can use the useradd command without any options like this:

```
useradd new_username
```

It will create the user account but:

- the user’s home directory won’t be created
- the password has to be set separately
- the default shell for the user will be sh

You can [set a password for this new user account using the passwd command](https://linuxhandbook.com/passwd-command/):

```
passwd new_username
```

You can also create home directory while creating the user.

## Add a user with home directory with useradd command

The -m option of useradd command allows to copy all files from your system [skeleton directory](http://www.linfo.org/etc%5Fskel.html?ref=linuxhandbook.com) (/etc/skel) to the newly created home directory.

In other words, you can create a user with home directory using the -m option as well.

```
useradd -m new_username
```

You can also specify an existing directory as the home directory of the newly created user with option -d.

```
useradd -d Path_to_Existing_Directory new_username
```

## Add a new user with a different shell

The [default shell for a user](https://linuxhandbook.com/shell-using/) created with useradd command is sh. These days sh shell is hardly used when there is bash and [zsh](https://linuxhandbook.com/why-zsh/).

A [user can change his/er default shell](https://linuxhandbook.com/change-shell-linux/) but you can also create the user with a different default shell with the option -s.

For example, if you want the new user to use bash as the default shell, here’s what you can do:

```
useradd -s /bin/bash new_username
```

## Add a new user with different group

Usually, when you create a new user, a group with the same name as the user is created. The new user is added as the member of this group.

With the option -g, you can add a new user to an already existing group as its default group.

```
useradd -g Existing_Group_Name_or_ID new_username
```

Suppose you are creating an account for a developer. Adding all the developers to a ‘dev group’ could be a strategy.

You can also add the user to additional (existing) groups with option -G.

```
useradd -G group_1 group_2 new_username
```

So if you are [creating a sudo user](https://linuxhandbook.com/create-sudo-user/), you can simply add the user to the sudo group while creating it.

## Add a new user with specific user ID (UID)

You may also create a new user with a specific user ID with the option -u of useradd command:

```
useradd -u uid new_username
```

Please [read this article to know more about UID in Linux](https://linuxhandbook.com/uid-linux/).

[What is UID in Linux? How to Find UID of a User?This Linux Basics guide teaches you everything important associated with UID in Linux.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2020/06/uid-in-linux.png)](https://linuxhandbook.com/uid-linux/)

## Bonus Tip: Combine multiple options to create a new user with different parameters

You can combine multiple options together to create a new user in Linux with a predefined configuration.

```
useradd -d /home/abhishek -s /bin/bash -g my_group 
```

As you can see, the useradd command by default doesn’t add much. This is why some people prefer to use the adduser command. You can [read about difference between useradd and adduser](https://linuxhandbook.com/useradd-vs-adduser/), if interested.

I hope you found the useradd command examples useful. You may also want to learn to [delete users with userdel command](https://linuxhandbook.com/userdel-command/). Questions and suggestions are welcome.