Paul Labis: This is a personal blog where everyone can read my experiences, ideas and thoughts about programming, latest gadgets and other information technology related topics, lifestyle and many other stuff I would like to share to the public.

Encrypt and decrypt files in Ubuntu with ccrypt

ccrypt is a utility for encrypting and decrypting files and streams. It was based on Rijndael cipher, which was chosen candidate by U.S. government's for Advance Encryption Standard. This cipher is believed to provide a very strong security.


1. Install CCrypt from repo


sudo apt-get install ccrypt


2. To encrypt a file, use one of the following command,


ccrypt -e file_name or ccencrypt file_name


3. It will prompt you for Encryption Phrase aka Password, enter it. for example,


ccrypt -e sample.text 
Enter encryption key: your_key 
Enter encryption key: (repeat) your_key 


Note: Don't forget the encryption phrase, there is no way to get back the original file without it.

How to Backup and Restore PostgreSQL Database

There is an easy way to create backup file and restore your current PostgreSQL database using the Linux terminal. I am not sure though if this is the easiest way.

As of the moment I am writing this article, I used the following command to backup and restore my database. 

Using pg_dump and psql will make your life easier. Below are the terminal command I use to backup and restore my database.
  • Backup : pg_dump -U {user_name} {database_name} -f {backup_file_name}
  • Restore : psql -U {user_name} -d {database_name} -f {backup_file_name}
If you are getting an error:

Recover Ubuntu Grub2 After Windows Installation

A month ago I decided to dual-boot my laptop with windows 7 and Ubuntu 10.04 version as my main operating system. So I first installed Ubuntu 10.04 then Windows 7 afterwards. After installing Windows 7, ubuntu distribution isn't accessible. I am not sure but I think Windows installation might have wiped out Ubuntu grub.

To be able to recover Grub2 menu along with the option to select either which operating system you want to use, I did the following recovery steps below.
  1. Boot from Ubuntu Live CD - any Ubuntu distribution is okay to use for as long as you get access to linux terminal or bash shell.

Install NVIDIA driver manually for Asus K43 SV with Ubuntu Lucid 10.04

I just bought a new laptop Asus K43 SV and installed Ubuntu Lucid 10.04 LTS stable release. It has an i5 2nd generation processor with 4Gb of memory and 1 Gb of VRam. So far, I think this is the most affordable laptop I can look for in Philippine market offered free delivery through LBC by www.pccorner.com or www.laptopking.com from your online purchase.
Some of you might have difficulties in installing NVIDIA driver on your new bought Asus K43 SV laptop. I started researching online and found that there is a default yet not installed NVIDIA driver on synaptics. However, I had been screwing my desktop and as a result, I had to reformat my laptop again and again. I always backed-up my xorg.conf file but had difficulties on restoring it. Anyway, thats the end of story and in this article, I'm gonna share how to easily install NVIDIA driver manually on your k43SV. 

Commons Email - Examples

I found another good apache tool for sending emails.
Its easy to use and has good documentation.
Below is an example of an easy way to sending an email.
It is explained properly on apache user guide page which is embedded on the bottom part of this article.


import org.apache.commons.mail.*;
...

// Create the attachment
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("mypictures/john.jpg");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
attachment.setName("John");

// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("The picture");
email.setMsg("Here is the picture you wanted");

// add the attachment
email.attach(attachment);

// send the email
email.send();


Sending Mail with SMTP

I was was having problem on sending emails through Java.
I researched and found this apache API SMTP for sending email.
I just want to share this simple tutorial article on Discursive blog to everyone who needs it.

10.16. Sending Mail with SMTP | Discursive

Check Ubuntu laptop temperature

I noticed my laptop temperature is getting hotter. I was a bit worried so I made a little research on how to check the temperature via the internal chip sensors and Ubuntu terminal/command line. The quickest way so far is through below:

1. Make sure you lm-sensors are already installed. (In latest version as of 2010 - this was already configured) To know more about it goto http://packages.ubuntu.com/lucid/lm-sensors

2. Open you terminal/command line and enter the command "sudo sensors-detect". You will be asked which hardware sensors to scan. Answer it yes or no.

3. Get the temperature by running command "sensors" on your terminal.

There we have it! Thats how I check my laptop temperature. There other ways to check and are probably better and accurate. Have fun and enjoy.

April Blogging Comeback

Oh yeah! Techieboy is back in sharing his experiences!

Its been a while since I created an article on my experiences with technology. It was around October last year since I stopped due to busy schedules and work. I was also sent to Chicago, Illinois to assist our company client.

It had a wonderful experience though. I was able to see and experience what politics was in software industry. I was exposed to high-end technologies such as Spring Roo and JQuery. Learn a lot on how to deal with management stuff particularly on strategies of motivating employees to make them productive. I had been quite on most of the time, but, I am very observant of thing happening around me.

Anyway, I will cut this article for now. There will be a lot of articles coming up in few days. Have fun and keep in-touch.