Archive for the ‘tutorial’ Category

How to install and configure Postfix on Ubuntu?

I’m trying to configure an incoming email service for receiving issues via email in a Redmine server for a company.

The company uses Lotus Notes and for security reasons, I cannot read email using POP3 or IMAP, only with notes client or notes iWeb. I need an account ( but the company does not generate generic accounts. I neither can use a Gmail account, because they use an authenticated proxy and it’s not possible to check the gmail account (neither I can check another user’s account in the same company). Crazy!

I don’t need to send mails from this account. At least I can use their SMTP server to send the redmine’s mails.

The solution is to create a local mail transfer agent (I’ll use Postfix) in the server where redmine is installed, create a local mail account (, and then redirect all the mail from the user account that administers the redmine to this local account. A bit convoluted, I know, but I have no other choice.

Hands on!

Postfix is a well known Mail Transfer Agent (MTA), and it’s an alternative to the also widely used Sendmail MTA. We’ll use also Courier IMAP and Courier POP3 to retrieve emails. If you want a more detailed explanation, have a look at this Ubuntu HowTo:

In this post I will focus only on the installation and configuration process. This is a schema of our final result (taken from the Ubuntu HowTo):


Postfix schema

Postfix schema


Install Postfix

The first step is to install postfix:

$ sudo apt-get install postfix

You’ll be prompted for your server type. Choose “Internet site”:

Postfix - Internet site

And then enter your domain name (, or in my case

Postfix - Domain name

Once installed, edit the /etc/postfix/ file and add this lines at the end of the file:

inet_protocols = ipv4
home_mailbox = Maildir/

We are telling postfix to use IPv4 protocol, and that the folder where the mail will be saved (home/username/Maildir). Extract from the Ubuntu HowTo:

Maildir is a format for an e-mail spool that does not require file locking to maintain message integrity because the messages are kept in separate files with unique names. A Maildir is a directory (often named Maildir) with three subdirectories named tmp, new, and cur. The subdirectories should all reside on the same filesystem.

Another reason to use Maildir format is that Courier IMAP/POP3 servers only work with Maildir format of mailboxes.

Restart postfix to get the new configuration:

 $ sudo service postfix restart 
* Stopping Postfix Mail Transport Agent postfix [ OK ] 
* Starting Postfix Mail Transport Agent postfix [ OK ]

Install Courer POP3 and Courier IMAP

To retrieve the emails from our MailBox, we’ll to install Courier POP3 and Courier IMAP:

$ sudo apt-get install courier-pop

When prompted for creating web-based administration directories, answer No:


courier-pop administration directories

Then install Courier IMAP:

$ sudo apt-get install courier-imap 

Install bsd-mailx

To make some tests sending emails, we need a mail client. Bsd-mailx is a simple command-line mail client:

$ sudo apt-get install bsd-mailx 

Install Mozilla Thunderbird

Finally, to make the final tests, we’ll install Mozilla Thunderbird. If you haven’t already installed, just type:

$ sudo apt-get install thunderbird

Testing the installation

First of all, test your mail server:

$ telnet localhost 25
Connected to localhost.
Escape character is '^]'.
220 l3-ubuntu-12 ESMTP Postfix (Ubuntu)
221 2.0.0 Bye
Connection closed by foreign host.

Lets create some users to test our mail server. Answer the questions to create the users:

$ sudo adduser user1
$ sudo adduser user2

Now change to user1 and send an email to user2:

  • To send a mail to user2, type mail user2
  • Write the subject of the email and press [Enter]
  • Write the body of the email and press [Enter]
  • To send the mail, write a dot (.) and press [Enter]
$ su user1
user1@l3-ubuntu-12:/home/user1$ mail user2
Subject: test mail from user1
This is a test mail from user1

Now check if the email has arrived to user2. To avoid the “Cannot open display” message:

$ su user2
user2@l3-ubuntu-12:/home/user2$ thunderbird 
No protocol specified
No protocol specified
No protocol specified
No protocol specified
Error: cannot open display: :0

switch to user2 with sux. Sux is a wrapper around su to transfer your X credentials, thus you can open Thunderbird with user2 (install with sudo apt-get install sux):

$ sux user2
xauth: file /home/user2/.Xauthority does not exist
user2@l3-ubuntu-12:/home/user2$ thunderbird

Open Thunderbird and create a new account:

Press Skip this and use my existing email:

Thunderbird-New account

Enter the user2 account settings:

Thunderbird - user2 account settings

Press Continue. If you get this error:

Thunderbird failed to find the settings for your email account

Thunderbird - Error


Then restart postfix and try again:

$ sudo service postfix restart

Now the configuration must be retrieved. I choose the POP3 configuration for my email account:

Thunderbird - correct settings
And press Done. You get this warning screen because we are not using encryption (maybe in a later post, for the purpose of testing the email it’s enough with this). Check I understand the risks and press Done.

Thunderbird - warning screen

And now you can retrieve the email for user2.

Thunderbird - Inbox

If you try to send a message you’ll get this error:


Thunderbird - Error sending mail


You have to get the local certificate and confirm the security exception to send mails:

Thunderbird - Confirm ecurity exception


And now just pray for this to work in the foo company!

Do you liked this HowTo? PLease leave your comments below.

How to install TrueType Fonts on Ubuntu

March 13, 2012 2 comments

To install a TrueType Font on Ubuntu is as easy as this:

  1. Download the TTF
  2. Double click in the downloaded TTF to open the font viewer window.
  3. Click “Install Font” in the lower right-hand corner to install the font.
  4. Enjoy the font

If you don’t see the TTF in your application (for instance, LibreOffice), ensure to close all the windows of that application, and then, in a terminal, type this:

$ sudo fc-cache

Categories: linux, tutorial, ubuntu Tags: , ,

How to resize a disk in VirtualBox 4.1 (ubuntu host/windows XP guest)

October 3, 2011 7 comments

In my previous post ( I discussed about resizing a virtual hard disk in VirtualBox 3.2.

Now, in the newer version of VirtualBox we have no “Create new virtual disk” option in the virtual device manager.

To resize a disk in VirtualBox is now much more easier… although you’ll have to use the command line.

First, list all of the virtual disks installed:

$ VBoxManage list hdds
UUID:        b8f8a160-d751-4a98-af16-5b6bd7174099
Parent UUID: base
Format:      VDI
Location:    /var/VirtualBox/HardDisks/WindowsXP.vdi
State:       created
Type:        normal
Usage:       WindowsXP (UUID: 6e027563-4bea-47e3-966e-067e3b563048)

That’s my 20GB hard disk drive.To resize it to 30GB:

$ VBoxManage modifyhd /var/VirtualBox/HardDisks/WindowsXP.vdi --resize 30720

And now, choose your application to extend the old partition to the new size.

It’s very easy with a LiveCD and GParted. Just choose Resize/Move and apply the changes.

An applause for VirtualBox, because in previous versions this was a little bit frustrating.

And don’t forget to read the documentation:

Install oracle database 10g on ubuntu 10.10 64 bits

May 24, 2011 2 comments

Some time ago, I installed Oracle 10g on my Ubuntu box. The client worked perfect, as I was able to connect to other databases in remote machines. But I can’t create a local database, getting diferent errors.

These past days I’ve tried to reinstall on Ubuntu 10.10 64 bits and I found this post, and all it’s working.

I’ve installed the Patchset and I’ve created a local database, all perfect.

Categories: oracle, tutorial, ubuntu Tags: , ,

Install redmine with MySQL in ubuntu 10.10

March 22, 2011 3 comments

Again with Redmine ;-D

As you can read in my older post about installing redmine with PostgreSQL (, now at home I’ll give it a try with MySQL, as I’m developing a web page with PHP/MySql.

The steps are basically the same, followed the indications of this link:

I only have had to install and enable the passenger mod for Apache:

$ sudo apt-get install libapache2-mod-passenger

Then, I can access to localhost/redmine, and don’t forget the admin/admin user/password!

Monitoring DML statements in Oracle

February 3, 2011 Leave a comment

During the last months we are upgrading the databases to oracle 10gR2.

I want to know if an application is being used in order to avoid migrating it and thus saving resources (and working time).

We have a lot of applications (more than 400) and sometimes is difficult to know if an application is being used (please, dont ask me why, I neither understand it!).

Our applications are mainly on JBoss, so we are using connection pools to access the database. So I cannot monitor access of users to the database, because they are always connected.

I decided to monitor the DML modifications of all the tables of an application. Maybe it’s not the best approah, but it’s easy. We gather schema stats weekly, so we can consider that if we don’t have DML operations during a couple of weeks, we can reach the conclussion that the application is not being used.

To monitor the DML statements, first we have to enable monitoring on that particular schema (connected as the user we want to monitor):

SQL> select 'alter table ' || table_name || ' monitoring;' from user_tables;
SQL> exec dbms_stats.gather_schema_stats(ownname=>'<owner>', cascade=>true,estimate_percent=>100,method_opt=>'for all columns size repeat');

Now I’m able to monitor DML statements:

SQL> select * from user_tab_modifications;

The information is not reflected immediately. To populate the table, connect as system to flush the information gathered. Then you can query the dba_tab_modifications or user_tab_modifications:

SQL> conn system@<database>
SQL> exec dbms_stats.flush_database_monitoring_info;
SQL> select * from dba_tab_modifications;
SQL> conn owner@<database>
SQL> select * from user_tab_modifications;
Categories: oracle, tutorial Tags: , ,

Partition an existing table using DBMS_REDEFINITION

January 14, 2011 Leave a comment

Here you can find a great post about DBMS_REDEFINITION