unistalling software on ubuntu server 18.04

The reverse of

sudo mv mattermost /opt

is

sudo rm -rf /opt/mattermost

Mind though that a source install tends to have a document in the directory explaining how to uninstall (so check for a readme or uninstall document in /opt/mattermost/) as that should take precedence over the rm command.

Also make sure if there is a service you stop it first.

Remove the service with:

rm /lib/systemd/system/mattermost.service

systemctl daemon-reload