# Users & Permissions

### Users and groups

List all groups and users in groups

```bash
getent group
```

Add a user to a group

```bash
sudo adduser username groupname
```

which is the same as

```bash
sudo usermod -aG groupname username
```

Create a new user

```bash
sudo useradd -options_here username
```

**Options available**:

- m = create home directory

### Permissions

To see if a particular user can run a command

```bash
sudo -u USER COMMAND
```

To change a folders permission

```bash
sudo chmod -R u+rwx,g+rwx,o-rwx /path/to_folder
```

or change ownership

```bash
sudo chown -R NEW_USER:NEW_GROUP FOLDER_NAME
```

-R = recursive

 **Note**: user or group can be left blank

### Passwords

To change the curretly logged in user's password `passwd`

To change a different users password `sudo passwd USERNAME`