> For the complete documentation index, see [llms.txt](https://docs.udroid.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.udroid.org/using-udroid/non-root-users.md).

# Non-root Users

here is a step by step guide to creating a non-root user in any Linux

#### prerequisite

* A working Linux with `useradd` & `openssl` installed
* a terminal to access Linux

### Creating non-root user

there are two ways to create a non-root user ( thanks to tools in Linux ) one shows a prompt that asks all the details required & sets up everything itself and the other is more like linuxy way ( we are doing the second way cause it's good for one-liners )

### <mark style="color:orange;">`useradd`</mark>

> useradd is a low level utility for adding users

* make sure to install OpenSSL with `apt install -y openssl`

for this guide let's say the username you want to create is **ubuntu** and the password for it is **foxy1.** add username and password to a variable to make the process easier

```bash
username="ubuntu"
password="foxy1"
```

then copy-paste the below command in your terminal

```bash
useradd -m \
    -p "$(openssl passwd -1 ${password})" \
    -G sudo \
    -d /home/${username} \
    -k /etc/skel \
    -s /bin/bash \
    $username
```

{% hint style="success" %}
Now you successfully created a non-root user
{% endhint %}

### Adding <mark style="color:blue;">`SUDO`</mark> rules for new user

you may observe that the traditional way for adding a user to the sudo group won't work cause sudo daemon service can't start in proot. but adding rules to `sudoers.d` will do the job as a workaround

to do this add username to variable

```bash
username="ubuntu"
```

then add sudo rules with this command

```bash
echo $username ALL=\(root\) ALL > /etc/sudoers.d/$username
chmod 0440 /etc/sudoers.d/$username
```

{% hint style="info" %}
Now you see sudo working when you login to you new non-root user
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.udroid.org/using-udroid/non-root-users.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
