This is a short tutorial explaining how to post to Twitter using command-line in Linux, without needing to even open up your web browser.

  1. First, install the curl package:
  2. sudo apt-get install curl
  3. Next, create a script anywhere in your $PATH, for example twitter.sh inside ~/bin, where ~ is your home directory (make sure ~/bin is included in your $PATH variable, in case echo $PATH doesn’t return it, edit ~/.bashrc and add a line like this: export PATH=/home/USER/bin/:$PATH).The script twitter.sh should contain the following:
    #!/bin/bash
    curl -u USER:PASS -d status="$*" http://twitter.com/statuses/update.xml > /dev/null
    echo "Message sent!"
  4. Replace USER and PASS with your Twitter username and password, and then make the script executable:
  5. chmod 755 ~/bin/twitter.sh
  6. And now test it:
  7. twitter.sh Hello, world! This is a test.
  8. So just use it as:
  9. twitter.sh YOUR MESSAGE

This should be all. Have a look at the screenshots below:

Running the twitter.sh script

Tags: