Cannot user create

cannot create user, see below.
I don’t know why the system say there is no command.

bin/mattermost user create --email user@example.test --username user --password Password
Error: unknown command “user” for “mattermost”

Hi @H.Furukawa and welcome to the Mattermost forums!

This command as an argument to the Mattermost binary is deprecated - please use the mmctl binary to create users on the command line.

Where can I install the mmctl from ?

mmctl is part of the default installation and the binary is also installed in the bin folder, so you should be able to execute it with bin/mmctl. You need to set up authentication to your Mattermost server first using this tool, otherwise you won’t be able to run the commands. One way of doing that if you’re running mmctl directly on the server where Mattermost is hosted, is to use the --local mode of the mmctl application. To do that, you will have to change the configuration option EnableLocalMode in your server’s config.json to true and restart the server, afterwards, you can use mmctl --local user [...] to manipulate users without further authentication.

bin/mmctl is found. But the command errored “mmctl : command not found”.

$ cd /opt/mattermost/bin
$ ls
mattermost mmctl
$ mmctl --local user create ....
-bash: mmctl: command not found

Of course, before that, I set “EnableLocalMode=True” and rebooted.

If you’re directly in the bin folder, you need to run ./mmctl or you cd to /opt/mattermost and run bin/mmctl (like you did with the mattermost command earlier).

From the mmctl to the . /mmctl, I got the following

$ ./mmctl --local [user ....] 
Error: owner of the file "/var/tmp/mattermost_local.socket" must be the same user running mmctl
$ ls -l /var/tmp/mattermost_local.socket
srw-------. 1 mattermost mattermost 0 Jun  6 13:24 /var/tmp/mattermost_local.socket

You can either change the permissions of the socket to include your linux user or group, or run mmctl either as root user or as the mattermost user.
I suggest running it as user mattermost:

# interactive shell as mattermost user
su - mattermost
# (if this does not work, you can try the following command)
sudo -u mattermost -s

# run the mmctl binary as this user
/opt/mattermost/bin/mmctl --local ...

Alternatively, you can also use one-shot commands like:

su - mattermost -c /opt/mattermost/bin/mmctl ...
sudo -u mattermost /opt/mattermost/bin/mmctl ...
1 Like

Thanks.

Your advice helped me do it.

sudo -u mattermost -s
/opt/mattermost/bin/mmctl --local [user...]

Awesome, thanks for the feedback!