Creating labels for disks in ubuntu

March 31, 2008

The ability to create or change the disk label of fat/fat32/vfat file systems/partitions doesn’t come with Parted; yet is quite simple to achieve with Ubuntu Debian GNU/Linux :).

This comes in very handy when you have a number of fat devices (like USB, SD, etc) and want something more meaningful than just “disk” as its name.

Get mtools if you haven’t it already
sudo apt-get install mtools

Create a configuration file to avoid some error reporting
echo “mtools_skip_check=1″ > ~/.mtoolsrc

Check where your disk is in the linux devices
mount

Label your disk
mlabel -i /dev/sdb1 -s ::my_disc

…and there you have it.

Disconnect the device and reconnect it and the label will show when it is auto mounted.


Undelete files on a vfat partition in Ubuntu

March 31, 2008

I have recently used the ‘photorec’ component of the ‘testdisk’ application for recovering files from FAT32 file systems.

I had used it before to recover files from general USB devices and others like Compact Flash/MMC/Secure Digital media with great success.

Then, I was focusing on recovery of photos and movies.

This time I was looking for various non-image files. Again I was suitably impressed by its coverage, and its simplicity in terms of use and speed.

They name may suggest only photos, but this is a great piece of software, regardless of what kind of file you are trying to recover.


Spoofing your Browser

March 31, 2008

Web servers sometimes behave differently for different browsers, for compatibility reasons usually, but not neccessarily.

If you want to test how a system or site behaves for different browsers, plugins for firefox such as the ‘User Agent Switcher‘ can help. With it you can enter any data for the User Agent string.

The User Agent String is essentially a text string that your browser sends with each request to tell the server what browser, operating system, extensions/plugins, etc you are using.

I didn’t initially find the format or usage of this plugin to be very intuitive, but thankfully there are importable files online with settings for many of the more common combinations of browser/os etc. One such list I have used is at http://qainsight.net. Check for updates to the version of the script. Right now the site is offline, but the latest (March 2008, from internet caches) appears to be here.

Last I read it does not properly cater for the different User Agent String formats of other browsers, for instance the IE and Firefox string are quite different in both content and organisation. So while it will usually work, it may sometimes fail, and will probably not hide the fact of what browser you are actually using from those who might really want to know…


Address Book with Mutt on Ubuntu

March 28, 2008

I have been using Mutt MUA for a little while now and it is apparent that I need some kind of address book. The solution outlined here saves address automatically when you send email.

This solution is better for me than saving received addresses. Think spam etc.

The addressbook used os lbdb, little brother database.

My lbdb is installed and setup with the following in ~/.lbdbrc


# my lbdb config file

# methods to search [www.spinnaker.de/lbdb/]
METHODS=”m_inmail”
#m_muttalias m_palm m_gpg m_ldap

To save addresses when sending, I replace the mutt sendmail option which was using esmtp to now point to a custom script.
The script uses the tee command to send a copy of the mail to lbdb for address harvesting, and another copy to esmtp as before. I also added an option to tell mutt to use lbdb for address queries.

The changed and new options in ~/.muttrc are


set sendmail=”~/esmtp-lbdb.sh”
set envelope_from=yes

# use lbdb for email address querying
set query_command=”/usr/bin/lbdbq ‘%s’”

The script esmtp-lbdb.sh is as follows


#!/bin/bash
#
# Script must run with Bash so keep above
# send mail with esmtp but send a copy to lbdb-fecthaddr to harvest address
#
echo -e \\n \\n MARK \\n \\n >> /tmp/test.log
echo “$@” >> /tmp/test.log

# harvest mail (stdin) and major to address
# tee the stdin,
# tee splits input into two copies, one to named file, one to stdout
# instead of named file, we redirect to command, and the other copy to stdout is piped to a second command
#
# the first command harvests email addresses from the input email
# the second command sends the input e-mail, and takes the parameters via “$@” which are the from and to/cc/etc addresses
tee >(lbdb-fetchaddr -a) | /usr/bin/esmtp -v -X /tmp/esmtp.log “$@”

When sending an email in mutt, I can press CTRL-T to get the list of addresses from lbdb and choose one for inclusion.


Setting up Email with Mutt on Ubuntu

March 28, 2008

I have been using the Mutt email client for a short while now. By no means an expert, but have found a few little gems.

Firstly, I am using external POP and SMTP for sending and collecting email, with no local email server.

I use the following basic mutt settings in ~/.muttrc


set mbox_type=Maildir
set folder=”~/email/mailbox”
set mask=”!^\\.[^.]”
set mbox=”~/email/mailbox/kept
set record=”+.Sent”
set postponed=”+.Drafts”
set spoolfile=”~/email/mailbox/in-default
set realname=”me”
set from=”me@domain.tld”
set use_from=yes

As you can see, the mailbox are all in a folder in my home directory, no use of spool etc as I am not running an email server.

For sending email I use esmtp with this option in .muttrc


set sendmail=”/usr/bin/esmtp -v -X /tmp/esmtp.log”
set envelope_from=yes

For receiving email, I use getmail via cron every 15 mins.
The cron is :


crontab -l
# m h dom mon dow command
*/15 * * * * getmail –getmaildir /home/me/email/getmail/ –rcfile getmail.me.rc

The retriever in the getmail config is SimplePOP3SSLRetriever, and the destination is to procmail, which then does filtering based on rules and filters i set up and drops the email into the various maildir folders in ~/email/mailbox/


Viewing images with Mutt on Ubuntu, via mailcap configuration

March 27, 2008

When viewing various mime attachments, Mutt uses mailcap [/etc/mailcap] to decide which applications to use.

I was suprised to find that gif and other images are not supported ‘out of the box’.

However, creating a file called ~/.mailcap with the following text solved it quickly.


###############################################################################
#
# MIME types and programs that process those types
#
###############################################################################
image/*; /usr/bin/gthumb ‘%s’; test=test -n “$DISPLAY”

/usr/bin/gthumb‘ refers to the application I want images to be opened with from Mutt, when I get image attachments in my email.

Thats pretty much it!