I just finished setting up my Mastodon instance and one of the first things I wanted to get my hands on what the Mastodon CLI. I mean, why not use a simple command line interface when you can, right?
Turns out, it’s a little less straight-forward compared to WordPress’ WP CLI. In the spirit of “I hope someone spends less time figuring out how this works than me” here’s how to actually use it.
Time needed: 2 minutes.
The Mastodon CLI is already installed, but you have to know from where on the command line you can use it, and more importantly how.
- Install Mastodon
Obviously, you should have finished installing Mastodon on your server and have completed all steps. This means you’ll need to see something of a Mastodon interface here:
If that’s the case, you can move back to the command line.
- Log into your server
Use your default root enabled user to log into your server.
- Switch to the mastodon user
With the following command you can switch to the
mastodonuser you’ve created during the installation process:
You’ll have confirmation when that’s been successful when the prompt changes in your command line interface to something like this:
- Make sure you in the /live/ folder
As you can see in the above screenshot, we’re in the
/livefolder. If you find yourself anywhere else, make sure to navigate to that folder first
- Find the command you need
In the Mastodon CLI documentation you can find a whole array of commands to use. Make sure you construct the command best you know based on that documentation.
- Example command
This is the command I needed to execute:
tootctl accounts modify remkus --role Owner --confirm
This will convert the specified
remkusaccount to the role of owner without needing a confirmation email.
This is what it looked like on the command line:
RAILS_ENV=production ./bin/tootctl accounts modify remkus --role Owner --confirm
Without including that
RAILS_ENVpart, you’ll get reports saying the
tootctlcommand is not found:
Command 'tootctl' not found.
P.s. Make note of the lack of the actual
- Hit Enter
This is all there’s left to do. Enter and your command will be processed. The prompt should return with a simple
Let me know if that works for you as it did for me!