> For the complete documentation index, see [llms.txt](https://alicenab.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alicenab.gitbook.io/linux/redhat/tasks/user-account-operations.md).

# user account operations

## Task 1:

Create user named alex, and the user id shoud be 1234, and the password should be alex111.

Solution:

```
useradd -u 1234 alex
passwd --stdin alex
```

## Task 2:

Add user user1, set uid=601. Password: redhat, The user's login shell should be non-interactive.

Solution:

```
useradd -u 601 -s /sbin/nologin user1
passwd --stdin redhat
```

## Task 3:

According to the following requirements to create user, user group and the group members:

* A group named admin
* A user named mary, and belong to admin as the secondary group
* A user named alice, and belong to admin as secondary group
* A user named bobby, bobby's login shell should be non-interactive. Bobby not belong admin as the secondary group.

Mary, alice, bobby users must be set `password`as the user's password.

Solution:

```
groupadd admin
useradd -G admin mary
useradd -G admin alice
useradd -s /sbin/nologin bobby
passwd --stdin mary
passwd --stdin alice
passwd --stdin bobby
```

## Task 4:

Create the following users, groups and group memberships:

* A group named adminuser
* A user natasha who belongs to adminuser as a secondary group
* A user harry who also belongs to adminuser as secondary group
* A user sarahat who does not have accessto an interactive shell on the system, and who i not a member of adminuser, natasha harry, and sarah sll have the password or redhat.

Solution:

```
groupadd adminuser
useradd -G adminuser natasha
useradd -G adminuser harry
useradd -s /sbin/nologin sarah
passwd --stdin natasha
passwd --stdin harry
passwd --stdin sarah
```

## Task 5:

Add admin group and set gid=600

Solution:

```
groupadd -g 600 admin
cat tail /etc/group
```

## Task 6:

Create the user named eric and deny to interactive login.

Solution:

```
useradd -s /sbin/nologin eric
passwd --stdin eric
```
