Using Mastodon from the command line
Command Line – Mastodon CLI Client
If you are looking for a Twitter alternative, toot lets you interact with Mastodon from the command line.
An open source, decentralized version of Twitter, Mastodon has been in development since 2016. With Elon Musk's erratic decisions since purchasing Twitter in late 2022, many users predicting Twitter's doom have been searching desperately for alternatives. The result has been a new surge in interest in Mastodon – even if many newcomers remain puzzled by its open source organization. The interest is so great that Mastodon's founder Eugen Rochko reports that he has received offers of "hundreds of thousands of dollars" from five investors – offers he refused so as not to endanger Mastodon's nonprofit status [1]. As I write, the exodus from Twitter appears to have slowed, but along with the renewed interest in Mastodon has come a renewed interest among Linux users in toot [2], an open source command-line client for Mastodon.
Toot takes its name from Mastodon's equivalent of Twitter's tweets, the microblog messages posted by users. Officially, the term is obsolete, with Mastodon's latest release replacing toot with a simple Publish button [3], but the term remains widely used. Toot compares favorably with Twitter clients for Linux such as Twidge, Oyster, and Rainbow Stream, many of which are not up-to-date, and have an alarming tendency to come and go without warning. By contrast, although current users must still use the web interface to create a Mastodon account for everyday use, toot is a complete replacement for the web version of Mastodon (Figure 1), providing functionality that is both thoroughly documented and up-to-date with Mastodon through a series of commands and options that keeps users' hands firmly on the keyboard.
Getting Started
You will find toot in the package repositories of many distributions and you can also install toot using Homebrew, although some sources are more current than others. However you choose to install, to use toot, you must create an account in a Mastodon instance from a web browser before logging in with the command toot login_cli
(Figure 2). Upon launching, toot creates a configuration file in your home directory at .config/toot/config.json
. You must then specify a Mastodon instance to log in to – but note that its name must be entered in lowercase characters with periods rather than spaces between the words, regardless of how the instance name is presented in the web interface. After toot locates the instance, enter your email and password to log in. For later access, toot stores your email and a temporary access token in the configuration file so that your password is never stored unencrypted. Once you are connected to an instance, you can enter user whoami
to display user details and toot whois
to display account details. To switch accounts, use toot activate
. To see a list of active accounts, enter toot auth
.
Posting Toots
You can post a toot in several ways. The simplest (as shown in Figure 3) is:
toot post 'MESSAGE'
Alternatively, you can compose a toot in a text editor of your choice (Figure 4) – Vim in this example – with the following command:
toot post --editor vim
Save and exit the toot as you normally would in the editor, and the toot is also posted. If you prefer to always use a text editor, define your preferred editor as an environmental variable (for instance, export EDITOR=vim
), and then you can simply use the following command:
toot post --editor
With all these variations of the command, you can add up to four attachments. For the first attachment, use the option
-media path/to/image1.png --description "TEXT" \
and then change the image number for the subsequent attachments. If necessary, you can flag attachments with:
--media nsfw.png --sensitive
Once a toot is posted, you can see any replies using toot notifications
.
Viewing the Timeline
When viewing toots in your timeline, the basic command toot timeline
displays the most recent toot. It then gives you the option of either displaying the last dozen toots or else exiting the client altogether. You can also use the options listed in Table 1 to modify which toots are displayed.
Table 1
Viewing Options
|
Public timeline, only this Mastodon instance |
|
Posts tagged with |
|
Fetch up to 20 toots |
|
Don't prompt to fetch more toots |
At the bottom of each toot, you will find its ID and whether it has been reblogged. You can pin one of your own toots to the top of your timeline with toot pin ID
or delete it with toot delete ID
(Figure 5).
You can locate other people on Mastodon with
toot search "NAME"
or by their Mastodon instance address with
toot search NAME@INSTANCE
With an instance address, you can also use the self-explanatory commands follow
, mute
, block
, or unfollow
. To like a toot, used the command
toot favourite ID
(note the UK English spelling). To reblog toot use toot reblog ID
.
Should you decide to undo any of these actions, you can run the same commands prefaced by un
. For example, if you decide on second thought not to favor a toot, use the command:
toot unfavourite ID
The rest you can probably figure out for yourself. If necessary, though, for detailed summaries, run
toot COMMAND --help
You can perform all these basic functions from the command line or start the curses user interface with toot tui
(Figure 6). The curses interface is navigated by the keyboard commands shown in Table 2.
Table 2
Curses Interface Navigation
|
Move up the list of toots |
|
Move down the list of toots |
|
Show a help screen |
|
View status thread |
|
View the current toot in a browser |
|
Boost or unboost a status |
|
Favorite or unfavorite a status |
|
Quit the curses interface and return to the command line |
|
Show sensitive content |
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.