# Mmctl: create the first user

**URL:** <https://forum.mattermost.com/t/mmctl-create-the-first-user/12385>\
**Category:** Command Line Interface\
**Created:** [October 20, 2021, 11:03am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385 "2021-10-20T11:03:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kemenaran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/kemenaran/32/5151_2.png) [@kemenaran](https://forum.mattermost.com/u/kemenaran)\
**Post date:** [October 20, 2021, 11:03am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/1 "2021-10-20T11:03:59Z")

</div>

Hello there,

I’m scripting the deployment of new Mattermost instances ([https://github.com/YunoHost-Apps/mattermost\_ynh/blob/master/scripts/install](https://github.com/YunoHost-Apps/mattermost_ynh/blob/master/scripts/install)), and I’m trying to create the first user of the server.

So I do

```auto
bin/mmctl user create --email $email --username=$admin --password '$password' --locale $language --system-admin

```

But it fails with:

> Error: cannot read user credentials, maybe you need to use login first

The thing is, I can’t authenticate, as I didn’t create any user yet.

Is it possible to create the first user of the system using mmctl?  
(And otherwise, is it wise to open an issue for this?)

---

<div class="post-metadata">

**Author:** ![agnivade](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agnivade/32/3846_2.png) [@agnivade](https://forum.mattermost.com/u/agnivade)\
**Post date:** [October 22, 2021, 6:36am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/2 "2021-10-22T06:36:45Z")

</div>

Hey @kemenaran

The first user that you sign up with in the system will always be a system admin. So you can use the UI and sign up as usual for that.

Alternatively, you can use mmctl in `--local` mode ([mmctl Command Line Tool — Mattermost documentation](https://docs.mattermost.com/manage/mmctl-command-line-tool.html#local-mode)) to perform operations without logging in.

---

<div class="post-metadata">

**Author:** ![kemenaran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/kemenaran/32/5151_2.png) [@kemenaran](https://forum.mattermost.com/u/kemenaran)\
**Post date:** [October 30, 2021, 12:35pm UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/3 "2021-10-30T12:35:21Z")

</div>

I seems the local mode is exactly what I need. I’ll try that right away. Thanks for the advice!

---

<div class="post-metadata">

**Author:** ![KoloskovaMariia](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/koloskovamariia/32/6057_2.png) [@KoloskovaMariia](https://forum.mattermost.com/u/KoloskovaMariia)\
**Post date:** [November 7, 2022, 1:45pm UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/4 "2022-11-07T13:45:36Z")

</div>

Hi! I’ve a question about local mm user creation. How can we authorize on MM with local created user? As usually?

For example:

1. I create user locally

email = “qwe@qwe”  
name = “dan”  
password = “password”  
subprocess.run([“mmctl”, “–local”, “user”, “create”, “–email”, email, “–username”, name, “–password”, password,  
“–firstname”, “firstName”, “–lastname”, “lastName”])

1. I wanna auth with this user on MM to add another users, teams and channels. Should I do like this?

url = “some-url”  
community\_name = “test”  
username = “dan”  
password = “password”  
subprocess.run(  
[“mmctl”, “auth”, “login”, url, “–name”, community\_name, “–username”, username, “–password”, password])

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [November 8, 2022, 5:14am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/5 "2022-11-08T05:14:55Z")

</div>

Hi KoloskovaMariia and welcome to the Mattermost forums!

Yes, authentication is the same as with other users, depending on your server configuration. If you support multiple authentication types (LDAP, email, etc.) you would need to specify the authentication backend upon user creation. The code snipped you posted will create a user account with email/password authentication.  
In order to add users to a Mattermost installation, the user needs to be at least get the team admin permissions so they can send invites or create invite links which others could then use to create their own unprivileged accounts.  
User creation using `mmctl` is only available for system admins AFAIK.

---

<div class="post-metadata">

**Author:** ![KoloskovaMariia](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/koloskovamariia/32/6057_2.png) [@KoloskovaMariia](https://forum.mattermost.com/u/KoloskovaMariia)\
**Post date:** [November 8, 2022, 7:51am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/6 "2022-11-08T07:51:22Z")

</div>

Thanks a lot! Now I know what to do in my work project!

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [November 9, 2022, 5:53am UTC](https://forum.mattermost.com/t/mmctl-create-the-first-user/12385/7 "2022-11-09T05:53:16Z")

</div>

Awesome, great to hear that 🙂 If you have further questions, please don’t hesitate to create a new issue here in the forums.
