# Users and groups

**Adding an existing user to an existing group**

```shell
usermod -a -G theExampleGroup theExampleUser
```

**Changing the primary group of an existing user**

```shell
usermod -g theExampleGroup theExampleUser
```

**See wich groups the user belongs to**

```shell
groups theExampleUser
```

**Add an existing user to the sudo group**

```shell
usermod -aG sudo username
```

 **Add a new user with name, shell and home directory**

```shell
sudo useradd -m -c "Samwise the Brave" sam  -s /bin/bash
```

[https://www.cyberciti.biz/faq/howto-linux-add-user-to-group/](https://www.cyberciti.biz/faq/howto-linux-add-user-to-group/)

[https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart](https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart)

[https://askubuntu.com/questions/643411/ubuntu-14-04-new-user-created-from-command-line-has-missing-features](https://askubuntu.com/questions/643411/ubuntu-14-04-new-user-created-from-command-line-has-missing-features)