Send & Receive mails to & from localhost

Mails don't work when locally but sometimes it might prove to be very useful in development if one can send & receive mails to & from localhost. It can be setup pretty easily too. Basic idea is to configure postfix for localhost & then use mutt to read local mails. Here is how it is done (should work fine for any UNIX based OS):

Install postfix

sudo apt-get install postfix

Install mutt

sudo apt-get install mutt

To configure postfix for localhost, specify the following in its config file at /etc/postfix/

myorigin = localhost
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks = [::ffff:]/104 [::1]/128
relayhost =

Restart postfix

sudo /etc/init.d/postfix restart

Now you can read localhost mails using mutt


It will read emails from /var/mail/USERNAME

Ubuntu controlling network adapters through terminal

We all know that Ubuntu's network management is quite good but not there yet. One big issue with it is that, on some machines, disabling one type of network adapter, disables the other one too.

Like I use wifi to connect to the internet but my bluetooth is switched on by default all the time. And if I try to disable bluetooth it disables wifi too.

To control them via terminal or command line, you can do this (Atleast from Ubuntu 10.10 onwards):

ashfame@ashfame-xps:~$ rfkill list all
0: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no
4: hci0: Bluetooth
Soft blocked: yes
Hard blocked: no

You see how it says soft blocked & hard blocked. Soft block is a switch in OS & hard block is a hardware switch in your machine.

You can disable the ones you don't want by:

rfkill block bluetooth

and enable the ones you want by:

rfkill unblock wifi

Disabling the ones you don't want will save you some battery if you are on a laptop/notebook/ultrabook.

Pomodoro Timer in Ubuntu

I finally decided to try Pomodoro technique to see how well it can improve my productivity as I am a lot disorganised, lazy sorta geek (well who isn't?). So I built up a small script which acts as a Pomodoro timer for me using Ubuntu notification system (Do read it if you haven't, you need to install lib-notify package for this script to work).

I have created a launcher in my top panel, with which I start a new pomodori (name for a new period of time, lets call it a Pomodoro anyway). It calls up the script which alerts me that a new Pomodoro (time period) has started and then alert me again when the timer ends and I should take a small break.

Here is the script:

DISPLAY=:0 notify-send -t 1000 -i /home/ashfame/Dropbox/Ubuntu/icons/pomodoro.png "New Pomodoro starts" "You have 25 minutes to work."
# 25 minutes timer
sleep 1500
DISPLAY=:0 notify-send -t 1000 -i /home/ashfame/Dropbox/Ubuntu/icons/pomodoro.png "Pomodoro ends" "Take a break!"

As soon as I click the launcher, the first notification appears telling me that a new Pomodoro has started.

pomodoro starts

Then it sleeps for 1500 secs = 25 minutes. And after that the second notification appears telling me that the Pomodoro has ended.

pomodoro ends

I just take a 3-5 minutes break or even longer (I am the boss!), and then I again click on the launcher starting another Pomodoro and I work for another 25 minutes. You can use the same tomato icon, if you want.


Enjoy the awesomeness of Ubuntu and ditch Windows, yes I am an Ubuntu advocate and will push you to switch all the time ๐Ÿ˜›

Have your say in the comments!

Using Ubuntu Notification System – NotifyOSD

Ubuntu features a notification system, where you can see a message notifying you about some particular event. Rhythmbox uses it to show the next track when a track ends, Filezilla shows a notification that file transfers are completed when its window is not in focus (Very handy!) and so on several applications can use it to notify users in the same way (keeping the UI consistent, which is a good design principle).

Rhythmbox Song Notification

rhythmbox notify

Filezilla Transfer Complete Notification

filezilla notify

We too can use this easily in our shell scripts. It supports more functionality if you are working in Python or C (Read Ubuntu NotifyOSD) but for shell scripts it does the pretty fine job too, if you just want to make Ubuntu work for you.

Using NotifyOSD in shell scripts

Make sure you have libnotify-bin installed, if not, just install it by typing the following command in a terminal:

sudo apt-get install libnotify-bin

notify-send - Program to send desktop notifications

With notify-send you can sends desktop notifications to the user via a notification daemon from the command line. These notifications can be used to inform the user about an event or display some form of information without getting in the userโ€™s way.

Check out the man page for it, to see the options it has to offer - man notify-send

Enter this in a terminal, notify-send "Hello" "this is just a test" and you will see the notification appearing up on your desktop.I usually collect icons that I would like to use and then use them in notification bubbles in the following manner:

In terminal, you can use it like

notify-send -t 2000 -i /home/ashfame/Dropbox/Ubuntu/icons/console.png "Hello Ashfame" "This is your computer, lets start with work"

In a shell script, use it like (take care of the screen where you want to display the message - I am on a dual screen setup)

DISPLAY=:0 notify-send -t 2000 -i /home/ashfame/Dropbox/Ubuntu/icons/console.png "Hello Ashfame" "This is your computer, lets start with work"

notify example

Time parameter (-t) lets you specify the time in miliseconds after which the notification will fade away. Its affected with a bug right now (will work on the default timeout even if you set it, but will be fixed in upcoming releases anyway, so better use it).

Icon parameter (-i) is used to specify the icon which is to be used in the notification.

You can also use it to notify you when a certain command has completed in the terminal, like when you were compiling some code or anything which takes a good amount of time so that you can get to know the moment it is ready. As an example, you can use it like

make && notify-send "DONE"

Making practical use of NotifyOSD using notify-send

You can create shell scripts for additional functionality you want, right? Just use notify-send where you want you to be informed or alerted.

Here are the examples, where I use them:

  1. WordPress new version alert
  2. Alert if my site is down
  3. Health check - Tells me to take breaks, sleep at night and if I resist, lock the screen
  4. Pomodoro technique for quantizing time for increasing productivity
  5. Random fun facts from

You can build a lot more useful stuff as per your needs. Share your ideas in the comments and we can discuss ๐Ÿ™‚

Quickly setup a localhost environment in Ubuntu

Although, I use Ubuntu, this should apply to a large number of linux distros. Every developer uses a local environment to develop locally before testing it live. I kinda avoid that root by mounting my FTP webspace in Ubuntu and directly working on live files (there is no need of download and upload as you might think), but I wanted to do some CPU intensive job for a client for which I needed to setup a localhost environment, so I thought I would share this with everyone on my blog.

Install LAMP stack

Fire up a terminal (Applications > Accessories > Terminal) and enter this command:

sudo apt-get install lamp-server^


Enter y for yes when it asks to continue after estimation of how much data will be downloaded and how much will be used on disk.

It will install quickly and can take a few minutes depending on your internet speed, and then it will ask you to setup the password for MySQL user root. It is usually left blank on localhost machines as they are used only for development purposes but last time I left it blank, I had to deal with the issues that it didn't change the password to blank but has something else and I had to turn off the password prompt for root access. Avoid doing all that by just selecting "root" or anything you want as the password of the root user of MySQL.


Confirm it once (Type the password and press Tab key).


and you are done.

Test Apache Webserver

Just open http://localhost/ in your browser and it will show up a message "It works!" which means Apache is working fine.

Test PHP

Create a file named phpinfo.php in /var/www/ to check if PHP is working fine.

sudo nano /var/www/phpinfo.php

Enter the content as <?php phpinfo(); ?> and save the file by hitting Ctrl + X and then y (for yes) and return key (enter).

Restart Apache webserver by the following command - sudo /etc/init.d/apache2 restart

Now open http://localhost/phpinfo.php and it will show up a page with lots of php related information, if you can see it, PHP is working fine.

Install phpMyAdmin

Enter this command in terminal - sudo apt-get install libapache2-mod-auth-mysql phpmyadmin


Select Apache as the web server by pressing Space and then Tab key and press enter key.


Press Yes to configure database for phpmyadmin.


Provide password which we set as "root" earlier.


Again, enter "root".


Confirm it, and then you are done.


Test phpMyAdmin

Now open http://localhost/phpmyadmin/ in your brower to access phpmyadmin and you can login with username and password both as root.

Pretty quick & easy!

Everything is done, you have your web root at /var/www/ where you will need super user permissions to write files, I will do a follow up post on how you can make this easier by keeping your files in your Home directory instead and a bit of extra which will make it totally complete.

Subscribe so that you don't miss updates! RSS/Email options are in the sidebar.

Connect to a FTP server in Ubuntu without any FTP client

You don't need a FTP client to connect to a FTP server in Ubuntu, in fact this seems a lot better than traditional FTP download and upload method, though it is still the same but we don't have to do it manually. We mount the FTP space of a server on our system and can work on it locally just like other files. The moment you make any changes, they are uploaded to the server without you doing anything manually. Moreover this way is very efficient for handling multiple files and folder. You can even use it to live edit a site as it works really fast.

The screenshots are that of Ubuntu 10.10 & it should be close to other versions.

Steps to connect to a FTP server in Ubuntu

Select Places > Connect to Server.


Select FTP (with login) as Service type, enter server name and user name. You can even add it as a bookmark so that next you will only need to click it once to quickly connect to the server again.


Enter the password and chose to save it if its your personal computer.


That's it. You can now browse your FTP content just like how you browse local files.


Have fun with powerful Ubuntu!

Compiz Fusion – Unmatched 3D Environment in Linux

compiz fusion logo

Compiz Fusion : Unmatched 3D Environment in Linux

Think Aqua interface in Mac OSX and 3D Flip in Windows Vista was the best looking Operating system? Ever thought that the 3D effects on hacker's desktop shown in movies are not for real? No need to think again, just read on because the freedom and flexibility Compiz Fusion provides is beyond imagination.

Continue reading Compiz Fusion – Unmatched 3D Environment in Linux