Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Commands & Shells, Featured

Installing t CLI power tool for Twitter

Submitted by on January 21, 2019 – 4:41 pm

The ‘t’ is an excellent Ruby-based CLI utility for interacting with the Twitter API written by Erik Berlin. This is certainly not the only such tool available, but, in my estimation, it is the most full-featured and expertly-written. No amateur-hour coding here.

Here I am showing how to install and use t on CentOS 6. I am a professional Unix sysadmin and so getting me to upgrade anything takes a lot of incentive. Having said that, installing t on a more recent version of Linux is, obviously, a lot easier.

Installing Things

First, we’ll need to install some prerequisites. Mostly Ruby-related stuff for obvious reasons:

At this point I realized that I need Ruby 2.2+ and that’s not on tap for my OS version. So I had to get it the hard way:

And now to install t itself:

Twitter Authorization

Since July 2018 Twitter tightened up requirements for a developer’s account. Now you need to submit an application and get approved before you can authorize your app. The authorization mechanism supplied with t does not function any longer, unfortunately.

So we have to jump through some hoops here. Apply for the dev account; create the application; and use twurl ( to handle authorization.

For a complete overview of the available t commands, just hop over to it’s developer’s GitHub page.

Installing Optional Tools

When dealing with Twitter API, you’re likely to run into lots of CSV files. Dealing with CSV can be a pain, especially when the data is complex and multi-lingual. The csvfix tool will help you to fix your CSV files and massage them in various ways.

The script I forked from some dude’s coursework repo and modified it somewhat. What this script does now is it grabs the last whatever number of your tweets ad a list of common English words. And then it shows you most common hashtags (minus the most common words), likes, retweets, etc.

And just in case you’re wondering, here’s what the output of this script looks like for me:

[su_spoiler title=”Sample output” icon=”arrow-circle-1″]


Some Examples

The function below will search the latest tweets for keywords picked at random from your keyword list. And then it will follow a few authors of those tweets. Some of the variables here:

max_keywords – the number of words to pick at random from the keyword array

max_count – the maximum number of people to follow

logfile – the log file used to store script output and make sure you don’t try to follow people you already following

Here’s another function that will retweet a certain number of tweets based on keyword. The variables here are some of the same from the previous example. The one extra touch here is the favorite_exclude variable that is set by scanning the logfile for users you have unfollowed in the past.

The function below will delete your tweets that contain specified keywords. This can be useful if you’re using a bot to post some of your tweets and sometime undesired material sneaks in.

Similar to the previous example, the function below will delete your tweets that tell you can buy something for a price. Very simple but surprisingly effective.

Here’s another function – and, I promise, the last one – it will unfollow people who haven’t tweeted in a long time. The threshold is specified in months.

So there you go: Twitter is pretty much a bunch of cron jobs conversing with each other.


Print Friendly, PDF & Email

Leave a Reply