How To Use Mastodon CLI

Home » Notes » How To Use Mastodon CLI

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.

  1. 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: mastodon.example.com/admin/
    If that’s the case, you can move back to the command line.

  2. Log into your server

    Use your default root enabled user to log into your server.

  3. Switch to the mastodon user

    With the following command you can switch to the mastodon user you’ve created during the installation process:
    su mastodon
    You’ll have confirmation when that’s been successful when the prompt changes in your command line interface to something like this:

  4. Make sure you in the /live/ folder

    As you can see in the above screenshot, we’re in the /live folder. If you find yourself anywhere else, make sure to navigate to that folder first

  5. 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.

  6. Example command

    This is the command I needed to execute:
    tootctl accounts modify remkus --role Owner --confirm
    This will convert the specified remkus account 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_ENV part, you’ll get reports saying the tootctl command is not found: Command 'tootctl' not found.

    P.s. Make note of the lack of the actual tootctl part.

  7. Hit Enter

    This is all there’s left to do. Enter and your command will be processed. The prompt should return with a simple OK confirmation.

Let me know if that works for you as it did for me!

First name
This field is for validation purposes and should be left unchanged.

Automatically sent to your inbox, just like 🪄 

2 responses to “How To Use Mastodon CLI”

  1. Marcelo Avatar

    Hellow! Thx for your article.

    The system tells me authentication error and I’m sure it’s the correct password. What could I do?
    Please help me!

    1. Remkus Avatar

      Have you made sure you are doing it from the right account? So either the Mastodon account, or the Sudo account

Leave a Reply

Your email address will not be published. Required fields are marked *