Follow Me: Tweeting from the Linux Command Line

Updating Twitter via the command line on Linux is rather easy. But before I'll show you how, let me tell you a short story.

I joined Twitter almost a year ago and only managed to update my status a few times. A very small number of friends followed me and I followed some people as well. I don't really intend to have thousands of followers on Twitter that's why I didn't advertise or mention it here before that I'm tweeting. However, as I noticed that Tech Source from Bohol now has a good number of loyal readers/subscribers, I realize that I should inform everyone that I'm tweeting HERE.

I'm doing this because instead of posting short personal updates on this site, I'm going to do it on Twitter, and I intend to do it more often. Also, I think it will give me the opportunity to get to know some our regular readers (Twitter users) since I often follow those who follow me. So, to everyone who always want to know what I'm doing (or what I’m not doing), follow me.

Now, here’s how to update Twitter from the Linux command line:

1. Install curl with this command (Ubuntu/Debian):

sudo apt-get install curl

2. Create a new file named ‘twitter’ at '/usr/bin' with your favorite text editor:

sudo gedit /usr/bin/twitter

Then, paste this code:

curl --basic --user "yourusername:yourpasswd" --data-ascii "status=`echo $@|tr ' ' '+'`" "" -o /dev/null; echo Message Sent!

*Make sure you replace "yourusername" and "yourpasswd" with your own Twitter username and password. Save and Exit.

3. Give the file executable privileges with this command:

sudo chmod +x /usr/bin/twitter

4. Start tweeting using the command line by typing ‘twitter’ [space] [your message]. See example below:


5. You have just posted a Twitter update via the Linux command line!


  1. I got the following:

    $ twitter Hello from the Linux Command Line
    % Total % Received % Xferd

    Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    110 776 105 736 0 40 1177 63 --:--:-- --:--:-- --:--:-- 2115
    curl: (6) Couldn't resolve host 'echo'
    curl: (6) Couldn't resolve host 'Message'
    curl: (6) Couldn't resolve host 'Sent!'

    It posted on Twitter though with no problems. Thanks.

  2. [1] maybe you should add ";" before "echo"

  3. Worked a treat , but got shed loads of errors through the works proxy. I will have a look at the curl command and see if a proxy is defined that will help.
    Excellent find though.

    cheers Nick

  4. I also get the same error as above but it posts without issues.... hmmm

  5. I am binnyva and I have added you on twitter.

    I created a post on command line twitter a while ago - its almost exactly the same as your version. By the way, I think your are missing a semi-colon...

    -o /dev/null; echo Message Sent!

  6. Fixed the problem. Put ";" before "echo". Thanks for the correction guys.

  7. Do you know this?

  8. Works a treat! Many thanks! I was about to embark on a massive BeautifulSoup and Python project to do just this

  9. Wonderful: simple and functional. Thanks!

  10. it works! thanks a lot!