[HowTo] Configure msmtp to work with gmail on linux

Msmtp is a small but powerful and highly customizable smtp client. You can access gmail smtp using msmtp, which is exactly what I’ll teach in this tutorial.

Step by step instructions:

  1. Install msmtp and ca-certificates for use with SSL:
    sudo apt-get install msmtp ca-certificates
  2. We’ll create and edit the configuration file using Gedit:
    sudo gedit /etc/msmtprc

    Now copy and paste the following code in the text editor:

    defaults
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
     
    account default
    host smtp.gmail.com
    port 587
    auth on
    user [email protected]
    password mypass
    from [email protected]
    logfile /var/log/msmtp.log

    Needless to say, you have to replace [email protected] with your email and mypass with your password

  3. It should be readable by anyone. However, we’ll still execute the following command to be sure.
    sudo chmod 0644 /etc/msmtprc
  4. Your msmtp configuration is ready. Lets send a test email to yourself to see if everything’s working properly:
    echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t [email protected]

    Again replace [email protected] with your own email address and execute it. You should receive an email.

These are the exact commands to be used with Ubuntu.
You can replicate the steps for another distibution by using equivalent commands (For eg; yum install in place of apt-get install for centos, redhat, fedora.)
Cheers!

[HOW-TO] Back up all MySQL databases

To backup all or some of your MySQL databases, you’ll need mysqldump which comes bundled with mysql. If you have MySQL installed, you probably have mysqldump installed already.

To backup all databases use the following command:

In linux:

mysqldump -uroot -ppassword --all-databases | gzip > /media/disk-2/db.sql.gz

In Windows:

mysqldump -uroot -ppassword --all-databases > db.sql

This will backup all your databases from a single command.

To backup just a selected few use the following command:

In linux:

mysqldump -uroot -ppassword --databases db1 db2 | gzip > db1db2.sql.gz

In windows:

mysqldump -uroot -ppassword --databases db1 db2 > db1db2.sql

Replace db1 and db2 with your database names. You can add more databases separated by a space.

Replace ‘root’ and ‘password’ with your own mysql username and password.

Note that there is no space between ‘u’ and ‘root’ in -uroot, and between ‘p’ and ‘password’ in -ppassword

For more options please check out its man page if you are on linux or mysqldump --help which is available both in linux and windows.

It can’t get any simpler than that.

Cheers!

[How-To] Changing directory permissions from cPanel

This is not a difficult task but people often don’t know what directory permissions are. While we need not go into depth, just know 0755 is the recommended setting for all directories.

For changing a directories permission from cPanel, follow the following steps:

  • Login to your cPanel.
  • Find File Manager and click on it.
  • Select web root and click on Go.
  • Now place a check in the checkbox next to the directory you want to change the permission of.
  • Click on Change Permissions.
  • And select 755 in the box.
  • Finally, click on Change Permissions.

You’re done.

This would change the permission of selected directory to 755.

Cheers!

[How-To] Use facebook chat with pidgin

Now that facebook supports XMPP protocol for its chat, any messenger which supports XMPP would be able to use facebook chat without much effort.

Follow these steps to add your facebook chat to pidgin:

  • Start the pidgin and press Ctrl+A to bring the Accounts dialog box.
  • Click on Add.
  • Select XMPP as protocol from the drop-down menu.
  • Type in your username or your alias (the name you chose to to keep in url for your profile).
  • In ‘Domain’, type chat.facebook.com
  • In ‘Password’, type your facebook password.
  • Click on Advanced Tab, and uncheck ‘Require SSL/TLS’.
  • In ‘Connect Port’ type 5222.
  • In ‘Connect server’, type chat.facebook.com
  • Finally, click on Add.

This will add your facebook chat to pidgin.
Cheers!

[Solved] “Error saving media attachment.” error in WordPress

WordPress might give this error on uploading an image from media library. It means that wordpress isn’t able to save your file.

It is really easy to fix. However, this may not work for all:

Go to Settings->Media. Change the path in ‘Store uploads in this folder’ option to ‘wp-content/uploads’ (without the quotes).

If this doesn’t work you may have to change the permission of your wp-content/uploads directory to 0755. Read this to learn how to change directory permissions.

Cheers!

[HOW-TO] Restore recovery partition on Asus 1005HA

A friend of mine who has Asus 1005HA deleted his recovery partition to free up disk-space. He didn’t knew what the consequences could be. He felt the need of recovery just few days after it and he realised that he couldn’t use the recovery mode anymore. He gave me his netbook. It took me a while to figure out how to restore the partition.

What you require:

Another computer with DVD drive
USB flash drive (minimum 1GB) and another USB flash/hard drive(minimum 4.5GB)
PEtoUSB
ISO extraction software (winrar/7zip)
Any linux distro

Once you are setup with the requirements, follow these steps to restore:

    • Extract WINPE.iso to any folder on harddrive on second computer. Suppose this folder is D:\WINPE
    • Edit D:\WINPE\I386\SYSTEM32\WINPESHL.INI:

Change:
AppPath=x:\EPCRecover.exe
To:
AppPath=x:\GHOST32.EXE

    • Insert pendrive in the computer, and use PEtoUSB to make pendrive bootable. In Vista and Win7 please use admin mode.

Check ‘USB Removable’, and select the pen-drive.
Check ‘Enable Disk Format’.
Source Path To Built BartPE/WinPE Files: D:\WINPE
Check ‘Enable File Copy’ and select ‘Overwrite Always

    • Copy \Recovery\envir.GHO and \RECOVERY\envir.cmd from DVD to the root of your pen drive.
    • Convert your Pen-drive filesystem from FAT32 to NTFS by executing the following command in command-line:

convert x: /fs:ntfs
//change x to your pen-drive letter.

    • Disable the boot-booster on your 1005HA by pressing F2 two times as soon as you switch it on and disable it in BIOS.
    • Insert the pen-drive on 1005HA and press Esc repeatedly on bootup and select the flash drive to boot from. You’ll get into WINPE environment and Norton Ghost will start. Select to disk, from image and select envir.gho. This will repartition your complete hard-drive as it was when you purchased. Please note that this will destroy any data on your hard-drive. Make sure you back-up your data before doing this.
    • Download a linux distribution which recognises NTFS partitions. Use unetbootin to make the distribution USB bootable. Boot into live mode. I recommend Uubntu NBR for the purpose. Mount the partition labeled ‘PE’, this is your recovery partition.
    • On second computer copy \Recovery from the DVD to a larger pen-drive/hard-drive. Connect this drive to 1005HA and copy all the contents in \Recovery from your pen-drive to root of PE.
    • You can also edit the WINPESHL.INI to look like this:

AppPath = x:\minint\system32\recover.exe

This is it. Restart your computer.

Cheers!!