Friday, December 31, 2010

Tether Android Phone to Ubuntu for Internet Connectivity

I take no credit for this. This article is a reproduction of Shannon VanWagner's in case his ever goes down or is inaccessible

Important note for 64-bit Linux users: adb needs 32-bit libraries to function, so simply do a:
sudo aptitude install ia32-libs
before all this.

(Update 09-03-10 - Get the python script for setting this up automatically via this link [ sha1sum: bee940daef16aaa0439a0fb04d4043abb6b08bed ]). Based on reader comments, I've added the functionality for the script to use either yum or apt-get (Fedora or Ubuntu). I've also changed the script so that it will add udev rules to allow HTC, Motorola, and Samsung Android-based phones. READ the install instructions here (e.g., PLUG YOUR DROID INTO THE USB FIRST!)) Let me know how it works for you in the comments.)
Based on reader comments, I've added the functionality for the script to use either yum or apt-get (Fedora or Ubuntu). I've also changed the script so that it will add udev rules to allow HTC, Motorola, and Samsung Android-based phones. READ the install instructions here (e.g., PLUG YOUR DROID INTO THE USB FIRST!)) Let me know how it works for you in the comments.)

I wanted the capability to tether my Droid as an Internet modem to my Ubuntu GNU/Linux machine using the USB cable.

In my search for a solution, the first place I checked for a tethering application was in the Android Market. And while there are many other applications, the only app I was able to find for tethering, required for my phone to be "rooted" and a purchase price. Though my phone is rooted, I'm a cheap... errr... frugal guy and wanted to find a free way.

What I found are some easy tethering instructions by the masterful Shwan.c (link at ubuntuforums.org) using James Perry's azilink from Google Project Hosting, GNU+Linux, and the FOSS program openvpn. So now there was only one problem: I'm using the Verizon Droid, not the HTC Magic. The good news is that the process is generally the same, except for a difference in hardware id information for the udev rules settings in Ubuntu.

So after some minor changes, I've now successfully tethered my Verizon Droid via USB as a modem for my Ubuntu GNU/Linux machine (Works with 9.10 & 10.04 so far - only difference is that you may have to uncheck "Work Offline" in Firefox after connecting (Thanks to Gene for mentioning this)). Update:06-04-10 - these instructions have been tested and they work successfully with both the Motorola Droid and the HTC Incredible Android phones.

So here are the easy steps to get you up and running with using your Droid as a USB tethered modem (and a big Thanks to Shwan.c for posting the original idea):
(instead of steps 1-3 you can alternatively find the adb tool in various places on the web without having to jump through all the hoops of getting and installing the rest of the Android SDK)
1.) Download the current Android SDK (for Linux (i386)) from: http://developer.android.com/sdk/index.html

Update(thanks for comments!): 12-13-10 adb does not come with the new SDK by default so you have to add it via the Android SDK and AVD Manager.
2.) Extract the SDK, run the "Android SDK and AVD Manager", then to get the adb tool, install "Android SDK Platform-tools, revision 1":

tar xvf android-sdk_r07-linux_x86.tgz
cd android-sdk-linux_86
tools/android


In the Android SDK and AVD Manager, expand "Available Packages", put a checkmark by "Android SDK Platform-tools, revision 1", click "Install Selected" and follow the prompts to complete the download/installation of adb into your SDK folder (screenshot below).


3.) Change Directory into the "platform-tools" directory, then copy the "adb" application to your Ubuntu /usr/bin directory (sudo privs needed) note: I chose instead to put the adb executable in the azilink folder within my /home. It doesn't really matter where it is as long as you call it properly when executing it.)
#From the extracted "android-sdk-linux_86" directory:
cd platform-tools
sudo cp adb /usr/bin/adb

4.) Create/edit/save a rules file for udev to allow your machine to see your device
sudo vi /etc/udev/rules.d/91-android.rules

Put the text below into the file(using "i" to enter "insert" mode and hitting the escape key to return to "select" mode before saving.. C'mon, what fun would Linux be without using vi? If you really don't like vi, you can substitute with something like gedit, or nano, or kate, or etc.), replace USERNAME with your Linux username, then type ZZ to save the file from vi.

SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", SYMLINK+="android_adb", MODE="0666", OWNER="USERNAME"
If you have an HTC Android phone - use this rule instead of the one above:
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", SYMLINK+="android_adb", MODE="0666", OWNER="USERNAME"
If you have the Samsung Galaxy Android phone, use this rule instead of the one above:
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", SYMLINK+="android_adb", MODE="0666", OWNER="USERNAME"
If you have the Sony Ericsson X11 Android phone, use this rule instead of the one above (Thanks to Steven from the comments):
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", SYMLINK+="android_adb", MODE="0666", OWNER="USERNAME"

5.) Set the appropriate permissions to the rules file you just created.
sudo chmod a+r /etc/udev/rules.d/91-android.rules

6.) Restart udev to load the new rule.
sudo restart udev

7.) Enable "USB debugging" on your Verizon Droid via Settings | Applications | Development

8.) Connect your Droid to the computer with the USB cable and then use the following adb command to check for your device.
adb devices

example:
$ adb devices
List of devices attached
040364FA0901E011

9.) Install openvpn on your computer so you can connect to your device with it.
sudo apt-get install openvpn
sudo /etc/init.d/networking restart
sudo /etc/init.d/network-manager restart



*For Fedora and Yum, replace the commands above with this:
sudo yum install openvpn
sudo /etc/init.d/networking restart



Note for those without Internet: If you need to install the openvpn package (and dependencies) separately, these packages are what you will need: (liblzo2-2 libpkcs11-helper1 openssl-blacklist openvpn-blacklist openvpn). It's best to use the package manager to install openvpn because it will automatically install the dependencies, but if you can't get your Ubuntu machine onto to the Internet, then you can download the above packages (in .deb format) to a separate medium (i.e., USB drive, CDR, etc.)separately and then install them in the order listed to achieve the same result as installing from the package manager.

10.) Install openvpn on your Verizon Droid. Note: the line "adb install" actually installs the azilink application on your Droid device. After azilink is installed, an icon that looks like a flying insect will appear on your Droid in th applications area.
cd /home/yourusername/Downloads/
mkdir azilink
cd azilink
wget http://azilink.googlecode.com/files/azilink-2.0.2.apk
adb install -r azilink-2.0.2.apk
wget http://azilink.googlecode.com/files/azilink.ovpn

11.) Create a replacement resolv.conf file to be copied over to your /etc directory at run-time: (note: I backed up my original /etc/resolv.conf beforehand just to be safe.)
vi resolv.conf

#Type in the text below(hit "i" for insert first, then ESC after the insert, before saving) and then hit ZZ to save
domain lan
search lan
nameserver 192.168.56.1

12.) Now create a very small script to start the modem
vi start_modem

#Type in the text below, then hit ZZ to save
adb forward tcp:41927 tcp:41927
sudo cp resolv.conf /etc/
sudo openvpn --config azilink.ovpn

13.) Set your new script to be executable.
chmod 755 start_modem

14.) On your Verizon Droid, launch the azilink app and place a checkmark by "Service active" so it can receive the connection from your Ubuntu machine.

15.) With your wireless connection in Ubuntu "unchecked"(via right-click of the Network manager applet), launch the the connection script you just made in the Terminal:
/home/Downloads/azilink/start_modem

You should now be able to surf the Internet, using your Verizon Droid as a tethered modem. When you're finished - hit ctrl+c at the Terminal from which you started the connection script. Then uncheck "Service active" in Azilink on your Droid.

(Update 09-03-10 - Get the python script for setting this up automatically via this link. Based on reader comments, I've added the functionality for the script to use either yum or apt-get (Fedora or Ubuntu). I've also changed the script so that it will add udev rules to allow HTC, Motorola, and Samsung Android-based phones. READ the install instructions here (e.g., PLUG YOUR DROID INTO THE USB FIRST!)) Let me know how it works for you in the comments.)

If you're trying to set this up on CentOS and it's not working, checkout hughesjr's post on droidforums.net

(08-14-2010) For Gentoo GNU/Linux users, checkout "Tether your Motorola Droid on Gentoo Linux (USB Version)" on the Faction Clash blog

For those looking for similar instructions for Mac OSX, checkout the article "Tethering Your Android Phone to OS X via USB" on droidie.com.

Haven't replaced your iphone with the Android yet? Checkout Ashton Mills' article at apcmag.net to tether your iphone to Ubuntu GNU+Linux.

Update: 08-31-10 - Just received the Android 2.2 (froyo) update for my Verizon Droid Incredible. Tethering works perfectly for me after the update.

Shannon VanWagner
Updated 12-13-10

PS3 Media Server on 64-bit Linux

I was having the darnedest time getting MKV files to play from PS3 Media Server from fresh Ubuntu 10.04 Lucid Lynx. They worked fine from Windows and from an old 32-bit 9.04 Jaunty Jackalope system. Turns out Warriorcookie found the problem. 64-bit Linux systems need to install 32-bit libraries (ia32-libs for Ubuntu) for some packages, including Tsmuxer, apparently. So I simply:

sudo aptitude install ia32-libs

Then I rebooted and all was well. WOOHOO!!

Wednesday, December 29, 2010

The "Find" Command

The find command is not only useful for finding files by name, size, owner, etc, but it is also very powerful in limiting files to which you apply other commands either by using the pipe or arguments to find. For example, to change permissions on files only you can use:


find -maxdepth 1 -type f -exec chmod 644 {} \;


This command will change permissions in the present working directory (-maxdepth 1) to 644 on files only.


To change permissions on directories only use:


find -maxdepth 1 -type d -exec chmod 755 {} \;


This command will also be limited to the present working directory. It will change permissions to 755 on directories only. If you want to control recursion, you can use a different number with the -maxdepth option or leave it out altogether to recurse into all lower directories. Be careful, though, the find command is very powerful and can lead to unexpected and disastrous results if not used properly.

Sunday, December 19, 2010

Change Files on Droid 2

After rooting the Droid 2, there are sometimes files you want to change. You can pay for the Root Explorer app or use the free Android Terminal Emulator with linux commands on your phone. To change the system folder and below from read-only to read-write, do the following:


su
mount -o remount,rw -t yaffs2 /dev/block/mtdblk3 /system
rm /system/app/Gmail.apk
reboot

Saturday, December 18, 2010

Root The Droid 2

This is from other people: (there are other ways, like using adb from the Android SDK)

Visit the market and get the free Android Terminal Emulator installed.
Visit the market and make sure you have Astro installed.
Grab rageagainsthecage.zip with your phone
Use Astro to navigate to the /sdcard/download folder
Long press on the rageagainstthecage.zip file and "extract to this directory"
The 4 files, from the zip file should now be in the /sdcard/download folder (rageagainstthecage-arm5.bin, su, superuser.apk and busybox.
What are we going to do?
Steps 1- 5: Change to the /tmp folder on your phone, copy the file to the tmp directory, change its permissions. run it, and wait.

Step 6: make sure we can proceed

Steps 7 - 14: make system read-writable, copy the superuser. su and busybox files to where they need to go, use chmod to change their permissions, then make the system folder read-only, and exit Terminal Emulator.

If you want to know more about the commands being used here: cd, cp, chmod, mount, and exit are all Linux commands you can look up on your favorite search engine.

Okay, let's do it - type the blue parts in Terminal Emulator

cd /tmp
cp /sdcard/download/rage*.bin /tmp/
chmod 777 rage*.bin
./rage*.bin

This will take some time, just wait for the $ to show up so you know it is done.
Go to Settings > Applications > Manage Applications > Terminal Emulator > and Force Stop the application
Sanity check - Go into Terminal Emulator again and make sure you have a # symbol as a prompt. If so you are ready to proceed.

mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system
cp /sdcard/download/Superuser.apk /system/app/Superuser.apk
cp /sdcard/download/su /system/bin/su
cp /sdcard/download/busybox /system/bin/busybox
chmod 4755 /system/bin/su
chmod 4755 /system/bin/busybox
mount -o ro,remount -t ext3 /dev/block/mmcblk1p21 /system
exit

Thursday, December 2, 2010

Setting Up a Separate Data Partition

Now that I went through the process of learning how to move /home to a separate partition, I learn that it isn't always the best practice. Actually, if one is running multiple versions of Linux, it can cause problems because configuration files are stored for each user in the /home folder and they will rarely be compatible from one installation to the next.

Still, I learned a lot and can apply what I learned to an even better alternative—keeping /home on the root partition but having a common, separate /data partition. This way, you can easily backup the configuration files in your small /home folder if you want (although this data won't typically be as important as user documents, etc.)—even back it up to the /data partition—and keep them separate to each installation (if you have multiple on one machine), while storing all of your documents, photos, videos, audio, etc. on the one, separate /data partition. Pretty smart idea I got from the Ubuntu Forums.

I plan to implement this soon, and many of the same principles and steps from moving /home to a separate partition will apply to setting up a separate /data partition.

Wednesday, December 1, 2010

Move Home Folder to Separate Partition

*NOTE* See "Setting Up a Separate Data Partition" before deciding to put your home folder on a separate partition.

There are several benefits to having the home folder (the one in which all user data is kept) stored on a separate partition, not the least of which is making re-installs or new installs cleaner and separate from user data. As with most things on this blog, I learned this from other sources and am consolidating the steps here for documentation's sake and to include small things that were left out of other tutorials.

First, boot from an Ubuntu CD so you are not booted from the drive you need to change. When in the Live CD environment, use GParted to repartition your hard disk drive and create an empty partition to be your home partition, formatted with the same filesystem (i.e. ext3 or ext4) as your root linux installation. I won't cover the details of this process.

Now, for this example, we'll assume your linux root partition is on the hard disk drive /dev/sda and found at /dev/sda5. We'll also assume the new, empty home partition is at /dev/sda7 and both are formatted with the ext4 fielsystem.

Since we booted from Live CD, we must mount the original linux partition and the new one where home will be. We do this by executing the following commands in a terminal:

sudo mkdir /original
sudo mount -t ext4 /dev/sda5 /original
sudo mkdir /new
sudo mount -t ext4 /dev/sda7 /new


Next, we copy the original home to the new home partition, move the original home to home_backup just in case we need a backup, then make a fresh and empty home folder on the root partition into which the new home partition will be mounted:

cd /original/home
find . -depth -print0 | sudo cpio –null –sparse -pvd /new/
sudo mv /original/home /original/home_backup
sudo mkdir /original/home


The above "find" command is one place I ran into problems. The guides I found did not have "sudo" after the pipe, which caused the copy operation to fail due to "permission denied" errors.

Now we need to backup the fstab file, then open it with an editor. (The following uses GEdit graphical editor. You may use your favorite editor as long as you have root privileges. For example, to use a terminal editor, replace the whole gedit line below with "sudo nano -w /original/etc/fstab"):

sudo cp /original/etc/fstab /original/etc/fstab_backup
gksudo gedit /original/etc/fstab


Now add a line to fstab that mounts the home partition into the /home folder on the root partition at boot time:

/dev/sda7 /home ext4 nodev,nosuid 0 2

Another problem I had related to file and folder ownership. I had two users in my home folder, one with user id (uid) 1000 (we'll call him bob). Some of the copied folders and files showed ownership of user "root" instead of uid 1000. To fix this, still booted from the Live CD, I used the following command after ensuring the new home partition was mounted and changing to the proper folder (i.e. "cd /new/bob":

find -user root -print0 | sudo xargs -0 chown 1000:1000

The "find" portion of the above searches the present working directory and below for files and folders owned by "root". The xargs feeds each line produced by the "find" command to chown (change ownership), which then changes the ownership to the uid 1000.

Now you can reboot normally.

Monday, November 22, 2010

Extract Files to Other Folder Using Tar

To extract files from a tarball to a folder other than the current one, simply add -C /path/you/desire/ to the end of the normal syntax. Examples follow.

Extract a zipped tarball:
tar -xvzf ./filename.tgz -C /home/user/jackrabbit/

Extract a bz2 tarball:
tar -xvjf ./filename.bz2 -C /my/desired/path/

Saturday, November 20, 2010

SSH Host Key Error

When trying to ssh into a server you may get the following error:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
5b:9c:15:52:a1:ce:19:80:3b:ad:4b:b2:31:ad:d5:4c.
Please contact your system administrator.
Add correct host key in /home/user/.ssh/known_hosts to get rid of this message.
Offending key in /home/user/.ssh/known_hosts:1
RSA host key for ras.mydomain.com has changed and you have requested strict checking.
Host key verification failed.

If you have reinstalled Linux with OpenSSH, you will get the above error. To confirm the fingerprint of the server, login to it directly if possible and execute

ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub

(To confirm fingerprint of other host keys use:

ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
ssh-keygen -l -f /etc/ssh/ssh_host_key.pub


To get rid of this problem (if you are certain it it NOT due to an actual security breach):

Remove The Offending Key

Use the -R option to removes all keys belonging to hostname from a known_hosts file. This option is useful to delete hashed hosts. If your remote hostname is server.example.com, enter:

$ ssh-keygen -R {server.name.com}

$ ssh-keygen -R {ssh.server.ip.address}

$ ssh-keygen -R server.example.com


Sample output:
/home/robert/.ssh/known_hosts updated.
Original contents retained as /home/vivek/.ssh/known_hosts.old
Now, you can connect to the host without a problem.

Saturday, October 30, 2010

Loosing Rogue IRC Nick

Sometimes—I don't know how—my IRC nick gets hung, which fouls me up trying to login to another IRC network right away as that nick. To release the "hung" nick, do:

/msg nickserv ghost nick password

Wednesday, August 25, 2010

Install Bluefish 2.0.1

Here's the quick guide to installing Bluefish Editor 2.0.1.

sudo apt-get install build-essential checkinstall libart-2.0-dev libaspell-dev libbonobo2-dev libbonoboui2-dev libgail-dev libgnome-keyring-dev libgnome2-dev libgnomecanvas2-dev libgnomeui-dev libpcre3-dev libpcrecpp0 libpopt-dev libgvfscommon-dev libgucharmap2-dev libenchant-dev intltool

$ sudo mkdir /usr/local/src
$ sudo chown $USER /usr/local/src
$ sudo chmod u+rwx /usr/local/src
$ cd /usr/local/src
$ wget http://bluefish.mrball.net/stable/source/bluefish-2.0.1.tar.bz2
$ tar xjvf bluefish-2.0.1.tar.bz2
$ cd bluefish-2.0.1
$ ./configure
$ make
$ sudo checkinstall --pakdir "/usr/local/bin" --backup=no --deldoc=yes --deldesc=yes --delspec=yes --default --pkgversion "2.0.1"
$ make distclean

Friday, August 20, 2010

GPG (or PGP) Encryption

I did a lot of searching and experimenting before I learned this one (thanks to rww on IRC). I used to use PGP in Windows for email and file encryption. Ubuntu is open-source and so is GPG (GnuPG), so I thought Ubuntu would have great support for GPG. Well, it appeared to at first. It comes with a password management application called Seahorse, which has some things in it about GPG keys. However, I could never get it to work with my old PGP keys, and I couldn't figure out how to encrypt and decrypt files from the GUI. I really wanted the ability to easily encrypt or decrypt the clipboard, but I finally decided that was just asking too much.

It turns out there is a package called seahorse-plugins that for some reason is not installed by default but is required for all this GPG stuff to work. I think it used to be called gedit-plugins several distributions ago, but that package no longer exists.

So, install it with:

sudo aptitude install seahorse-plugins

Then, to add the clipboard capabilities, right click on a panel, choose "Add to Panel," and choose "Clipboard Text Encryption" applet.

Sunday, August 15, 2010

United States English as Default Language

I chose English as my default language when installing Ubuntu, but still in some applications, especially in Firefox, the spell-checking would use Great Britain English (insisting that there is a "u" in "color" "favorite" and "behavior"). To change it to US English, simply navigate to a page in Firefox that has a text box (i.e. a web form to send an email or something), right click, choose Languages, and choose "English / United States."

Thursday, August 12, 2010

Cleanup Filenames With Detox

An easy way to cleanup filenames is a handy little utility called detox. It's so easy to use. After installation, from a command line, simply type:

detox /path/to/files/*.mp3

to cleanup filenames of all MP3 files in the given directory, for example. It removes spaces and replaces special characters with plain ones (i.e. replaces u with accent with plain "u"). It has options, but if you just want the basics all you have to do is something like the above.

Tuesday, August 10, 2010

FreeNAS FTP

If you have trouble with FTP working (I did with version .7), it may be have something to do with having DHCP set instead of a static IP. Try either changing DHCP to static or going into Network/Hosts and adding a host. Enter the name of the freenas server (in my case "freenas") and the IP that belongs to it. Now try to FTP.

Monday, August 9, 2010

K3B To The Rescue

It turns out K3B is a great piece of software for writing optical discs. Brasero and others work for basic stuff, but K3B has saved the day when I could find no other native Linux software to do what needed to be done... namely write a traditional audio CD from a CUE sheet file and one large MP3. This requires the MP3 to be decoded and converted back into WAV format, then the CUE sheet must be used to parse the audio into various tracks of certain length for the audio CD. All other software I tried choked, even command line stuff. K3B JUST WORKED! I didn't want to have to run KDE / QT -based software on my Gnome / GTK -based Ubuntu system because of the extra libraries and resource cost, but considering the time and trouble involved in trying to accomplish something that just won't happen, it's worth it... at least for now. I'll still keep my eyes out for a Gnome / GTK -based application that can use CUE sheets and MP3 files, even though I rarely need to do that.

Fixing GPG Errors That Show Up After Aptitude Update

When you get GPG errors after doing a sudo aptitude update here is the fix:

W: GPG error: http://archive.canonical.com jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 40976EAF437D05B5
W: GPG error: http://download.virtualbox.org jaunty Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY DCF9F87B6DFBCBAE
W: Failed to fetch http://ppa.launchpad.net/chromium-da...jaunty/Release

W: Some index files failed to download, they have been ignored, or old ones used instead.

The fix for this is to re-download the keys using the hexidecimal numbers given in the error (I bolded them above).

NOTE: Your hexadecimal numbers may be different then mine, so make sure to use the hexadecimals numbers in your error, not mine.

Type this command into the terminal (Applications > Accessories > Terminal)

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys #don't actually run this line yet

And then add the hexadecimal numbers to the command (again, these are my keys from my error. Make sure to use your own):

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 DCF9F87B6DFBCBAE 2EBC26B60C5A2783 A8A515F046D7E7CF 6E871C4A881574DE 28A8205077558DD0 D739676F7613768D 8C851674F96FD737 C0B56813051D8B58 4874D3686E80C6B7 60D11217247D1CFF 5A9A06AEF9CB8DB0 6D975C4791E7EE5E 5A9BF3BB4E5E17B5 7FB8BEE0A1F196A8

Wednesday, August 4, 2010

Network Security Software

Nmap (Network Mapper) is a helpful ip scanner and network security utility. It uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. Once installed, simply use:

sudo nmap 192.168.1.*

for example to release its hounds to search out interesting IPs on that subnet. There are many other ways to use it, but this is a basic start. For full documentation type man nmap or search for nmap documentation on the web.

Thursday, July 29, 2010

Install NFS Client and Mount NFS Share

A quick and simple reminder for how to install the components necessary for NFS on the client:

sudo aptitude install portmap nfs-common

Then to mount, simply:

sudo mount -t nfs IP:/mnt/path /local/path

That's it.

abcde Ripper and Encoder





  1. Andrew's Corner :

  2. This entire post is from the following URL at Andrews-Corner:http://www.andrews-corner.org/abcde.html. He gets all the credit. The only reason I'm duplicating it here is in case he decides to take it down sometime and/or to make it easier for me to find when I need it.


abcde: Command Line Music CD Ripping for Linux


I have tried a variety of programs to rip my personal collection of music from CD to computer. I found significant shortcomings with many of the GUI programs and throughout I was also a little nonplussed at the complexities of whole process. Fortunately I came across the script known as abcde which eliminates the needless froth of the GUI as well as seamlessly takes care of much of the complexity of the process. This small guide aims to demonstrate to Linux users how to harness this amazing script for their own purposes. I will describe on this page how to rip and encode music cds to five different music formats: MP3, Ogg Vorbis, FLAC, Musepack and AAC and to top it all off show how with a single command a music cd can be encoded to all five at the same time. I will also for the sake of completion demonstrate the syntax required to convert CDs that contain the spoken word to Speex. But first for some preliminary setup:



Setting it all up ...


abcde is actually a long shell script that manipulates a handful of programs. I am using version 2.3.99.6 for this guide and this version is the slightly patched one available for Slackware 13.1. I note that 2.4.2 is now available but a quick look at this shows that there are still some issues with aac tagging, so I personally am sticking with the older version until some of the existing patches to address this problem are applied. To get yourself started you will need to download abcde itself as well as a selection of the other programs to match your encoding needs. Details of these programs are:



abcde

"A Better CD Encoder" = abcde! Ordinarily, the process of grabbing the data off a CD and encoding it, then tagging or commenting it, is very involved. The abcde script is designed to automate this.

cd-discid


cd-discid is a backend utility for getting CDDB discid information for a CD. It was originally designed by Robert Woodcock for cdgrab (now abcde), but can be used for any purpose requiring CDDB data.

cdparanoia

cdparanoia retrieves audio tracks from CDROM drives. The data can be saved to a file or directed to standard output in WAV, AIFF, AIFF-C or raw format. For the purposes of conversion abcde directs cdparanoia to produce WAV files.

EasyTAG

I will admit to using this excellent tagging program to sometimes "clean up" after abcde. id3v2, vorbiscomment and metaflac will do the same but EasyTAG does it so much quicker!

FAAC


FAAC is an open source MPEG-4 and MPEG-2 AAC encoder. It does not claim to be the best AAC encoder but it is the only one that currently works with abcde. Patches are available to enable NeroAacEnc to work with abcde as well.

FLAC Tools

FLAC (Free Lossless Audio Codec) is an audio format similar to MP#, but lossless, meaning that audio is compressed in FLAC without any loss in quality. flac is a command-line tool for encoding, decoding, testing and analysing FLAC streams. metaflac is used by abcde to add metadata to the FLAC files.

id3

An ID3 tag is a data container within an MP3 audio file stored in a prescribed format. This data commonly contains the Artist name, Song title, Year and Genre of the current audio file.

LAME

LAME is an open source application used to encode audio into the MP3 file format. A truly great program that is arguably the best tool for this particular job.

mkcue

mkcue generates CUE sheets from a CD TOC (Table Of Contents). It is a perfect companion for abcde to generate backups of your audio CDs using the FLAC codec and the single track option.


Musepack

Musepack is an audio compression format with a strong emphasis on high quality. It's not lossless, but it is designed for transparency, so that you won't be able to hear differences between the original wave file and the much smaller MPC file.

Vorbis Tools

Ogg Vorbis is a completely open, patent-free, professional audio encoding and streaming technology with all the benefits of Open Source. oggenc is the encoder for Ogg Vorbis files that will also write the comments at encoding time.

Speex

Speex is an Open Source/Free Software patent-free audio compression format designed for speech.


That is it for definitions. There is a wealth of details in the man pages for all these programs which I encourage you to consult. But now on to the nuts and bolts of the program:


Menus for abcde



abcde can be operated purely from the commandline but it is much easier to run the program from a configuration file. abcde looks for two of these files at startup: /etc/abcde.conf and $HOME/.abcde.conf. The file /etc/abcde.conf is a fully commented configuration file that is well worth looking at if only to copy to your home directory as $HOME/.abcde.conf (as is most usually done). But my gift to you, Gentle Reader, is a set of $HOME/.abcde.conf files that will achieve great results "straight out of the box" and will simply require the command abcde or abcde -1 to run the whole process:




  1. ~/.abcde.conf for MP3

  2. ~/.abcde.conf for Ogg Vorbis

  3. ~/.abcde.conf for FLAC

  4. ~/.abcde.conf for MPP/MP+(Musepack)

  5. ~/.abcde.conf for M4A/AAC

  6. ~/.abcde.conf for MP3 + Ogg Vorbis + FLAC + MPP/MP+(Musepack) + M4A/AAC


  7. ~/.abcde.conf for Speex


Feel free to use these and call them your own although I would encourage you to work on them a little and tweak them to match your own needs.



~/.abcde.conf for MP3


Who can escape MP3? I have placed this menu at the top of the list as I realise most people have MP3 players these days and many equate encoding with MP3. Bear in mind however that MP3 is a proprietary format and there are equally good formats that are totally free.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# MP3 format using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for MP3. In this case
# the alternatives are gogo, bladeenc, l3enc, xingmp3enc, mp3enc.
MP3ENCODERSYNTAX=lame

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/lame
LAME=lame

# Specify your required encoding options here. Multiple options can
# be selected as '--preset standard --another-option' etc.
LAMEOPTS='--preset extreme'

# Output type for MP3.
OUTPUTTYPE="mp3"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

The most obvious area to change is the MP3 encoding options but you will find that the example above will deliver perfectly acceptable sound on most systems. If you wish you can put your favourite MP3 recipe in place or go with the highest quality preset: --preset insane. For fuller information about these wonderful presets type in lame --preset help at your shell prompt.




~/.abcde.conf for Ogg Vorbis


This is the format that I use myself and I bought an iRiver X20 player specifically for its native support of the amazing Ogg Vorbis format. Arguably produces better sound than MP3 at a smaller file size and it is completely free.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# Ogg Vorbis using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for Ogg Vorbis. In this case
# vorbize is the other choice.
OGGENCODERSYNTAX=oggenc

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/oggenc
OGGENC=oggenc

# Specify your required encoding options here. Multiple options can
# be selected as '-q 6 --another-option' etc.
OGGENCOPTS='-q 6'

# Output type for Ogg Vorbis
OUTPUTTYPE="ogg"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

Again the first are for change would be the -q 6 setting but I believe that most will be happy with the sound produced at this level. Options are from -1 to 10 or of course you can place your own custom ogg encoding options here.



~/.abcde.conf for FLAC



FLAC stands for Free Lossless Audio Codec and it is the only codec used here that does not remove material from the audio stream. I have not used it extensively myself as the trade off is large file size, but the sound quality cannot be matched by MP3 or ogg regardless of quality settings.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# FLAC using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for FLAC. In this case
# flac is the only choice.
FLACENCODERSYNTAX=flac

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/flac
FLAC=flac

# Specify your required encoding options here. Multiple options can
# be selected as '--best --another-option' etc.
FLACOPTS='--verify --best'

# Output type for FLAC.
OUTPUTTYPE="flac"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

The warning remains: FLAC files sound very good but they are big. If you also wish to generate a cue sheet with a single-track encode you will need to have the program mkcue available to abcde and then run the following from the commandline: "abcde -1 -a default,cue", without the quotation marks of course. This certainly worked well enough on my own system.



~/.abcde.conf for MPP/MP+(Musepack)


I will admit that I am only just starting to experiment with Musepack but it produces great sound and fits in well with abcde. So here is an $HOME/.abcde.conf file to start your own exploration of this quality format:



# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# MPP/MP+(Musepack) format using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for MPP/MP+ (Musepack). In this case
# there is no other choice.
MPPENCODERSYNTAX=mppenc

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/mppenc
MPPENC=mppenc

# Specify your required encoding options here. Multiple options can
# be selected as '--standard --fade 5' etc.
MPPENCOPTS='--extreme'

# Output type for MPP/MP+ (Musepack).
OUTPUTTYPE="mpc"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

For those who wish to explore the Musepack encoding options a little more the command mppenc --longhelp will show the details. The first thing to manipulate might be the encoding options although this produces a perfectly adequate output file with a bitrate of about 210 kbps.



~/.abcde.conf for M4A/AAC


I have held off including an AAC section for some time as automatic tagging of these files was broken in the script. I noted however that Ubuntu had a patch which addressed this issue and once applied tagging worked beautifully.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# m4a/aac using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for m4a/aac. In this case
# faac is the only choice.
AACENCODERSYNTAX=faac

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/faac
AACENC=faac

# Specify your required encoding options here. Multiple options can
# be selected as '--best --another-option' etc.
AACENCOPTS='-q 250 -w -s'

# Output type for m4a/aac.
OUTPUTTYPE="m4a"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

This produces a bitrate of about 220kb/s which is more than adequate for the average system. Note that the -s option I use in AACENCOPTS requires the most recent version of faac.




~/.abcde.conf for MP3 + Ogg Vorbis + FLAC + MPP/MP+(Musepack) + M4A/AAC


This one is the grandaddy of the all and is demonstration of the power of abcde. With this $HOME/.abcde.conf file a music cd is ripped and encoded to all five formats at the same time and the resulting albums are then sorted into five different subdirectories.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# MP3, Ogg Vorbis, FLAC, Musepack & AAC
# using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

OGGENCODERSYNTAX=oggenc # Specify encoder for Ogg Vorbis
MP3ENCODERSYNTAX=lame # Specify encoder for MP3
FLACENCODERSYNTAX=flac # Specify encoder for FLAC
MPPENCODERSYNTAX=mppenc # Specify encoder for Musepack
AACENCODERSYNTAX=faac # Specify encoder for AAC

OGGENC=oggenc # Path to Ogg Vorbis encoder
LAME=lame # Path to MP3 encoder
FLAC=flac # Path to FLAC encoder
MPPENC=mppenc # Path to Musepack encoder
AACENC=faac # Path to AAC encoder

OGGENCOPTS='-q 6' # Options for Ogg Vorbis
LAMEOPTS='--preset extreme' # Options for MP3
FLACOPTS='--verify --best' # Options for FLAC
MPPENCOPTS='--extreme' # Options for Musepack
AACENCOPTS='-q 250 -w -s' # Options for AAC

OUTPUTTYPE="ogg,mp3,flac,mpc,m4a" # Encode to all 5 formats!

CDROMREADERSYNTAX=cdparanoia
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

OUTPUTDIR="$HOME/music/"
ACTIONS=cddb,playlist,read,encode,tag,move,clean
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

The part of the script that steers this is the simple ${OUTPUT} part. Run the script and have a listen to all five formats: a fascinating exercise that invites some interesting comparisons! And perhaps I might suggest if you wish to use the "5 codecs" method that you both beef up the MAXPROCS option in your ~/.abcde.conf and also buy yourself a bigger HDD?




~/.abcde.conf for Speex


Speex is down the bottom here as it is designed for the spoken word, not music, but can I say that it does a fantastic job on such things as audio books and the like.


# -----------------$HOME/.abcde.conf----------------- #
#
# A sample configuration file to convert music cds to
# Speex using abcde version 2.3.99.6
#
# http://andrews-corner.org/abcde.html
# -------------------------------------------------- #

# Specify the encoder to use for Speex. In this case
# speexenc is the only choice.
SPEEXENCODERSYNTAX=speexenc

# Specify the path to the selected encoder. In most cases the encoder
# should be in your $PATH as I illustrate below, otherwise you will
# need to specify the full path. For example: /usr/bin/speexenc
SPEEXENC=speexenc

# Specify your required encoding options here. Multiple options can
# be selected as '-q 6 --another-option' etc.
SPEEXENCOPTS='--denoise --quality 8 --vad --comp 5'

# Output type for Speex
OUTPUTTYPE="spx"

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac.
CDROMREADERSYNTAX=cdparanoia

# Give the location of the ripping program and pass any extra options:
CDPARANOIA=cdparanoia
CDPARANOIAOPTS="--never-skip=40"

# Give the location of the CD identification program:
CDDISCID=cd-discid

# Give the base location here for the encoded music files.
OUTPUTDIR="$HOME/music/"

# The default actions that abcde will take.
ACTIONS=cddb,playlist,read,encode,tag,move,clean

# Decide here how you want the tracks labelled for a standard 'single-artist',
# multi-track encode and also for a multi-track, 'various-artist' encode:
OUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${TRACKNUM}.${TRACKFILE}'
VAOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${TRACKNUM}.${ARTISTFILE}-${TRACKFILE}'

# Decide here how you want the tracks labelled for a standard 'single-artist',
# single-track encode and also for a single-track 'various-artist' encode.
# (Create a single-track encode with 'abcde -1' from the commandline.)
ONETRACKOUTPUTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}'
VAONETRACKOUTPUTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}'

# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.
PLAYLISTFORMAT='${OUTPUT}/${ARTISTFILE}-${ALBUMFILE}/${ALBUMFILE}.m3u'
VAPLAYLISTFORMAT='${OUTPUT}/Various-${ALBUMFILE}/${ALBUMFILE}.m3u'

# Put spaces in the filenames instead of the more correct underscores:
mungefilename ()
{
echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\]
}

# What extra options?
COMMENT="Encoded for Speex Playback" # Comment meta tag
MAXPROCS=2 # Run a few encoders simultaneously
PADTRACKS=y # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=y # Useful for debugging
EJECTCD=y # Please eject cd when finished :-)

Speex implementation needs a little polishing in the bare source although patches exist o fix a few small problems. Hopefully some of these patches will be rolled into a new version of abcde one day?


And in conclusion...


Of all the pages that I have written for Linux this one has been the most fun. I guess because abcde is such a beautifully written script that invites you to explore programs that are all gems in their own right. Please feel free to use the email address at the base of this page to pass on your thoughts about this page, any corrections, praise or condemnation. And remember: Have fun!



Monday, July 26, 2010

Lucid Lynx (Ubuntu 10.04 LTS 64-bit) Suspend/Resume Solution

Lucid Lynx would lock up when resuming from a suspend on my Dell Studio 1555 notebook computer. Finally it seems to be solved in AMD's Catalyst version 10.6 driver set.

But then I discovered I couldn't eject an optical disc, so I had to add nomodeset to my Grub line.

sudo nano -w /etc/default/grub

Find the line that reads:

GRUB_CMDLINE_LINUX=""

and put nomodeset between the quotes. Then save it, exit, and run:

sudo update-grub

Sunday, July 25, 2010

Manually Configure Network

Just a reminder of how to manually configure a network in Linux. Let's say you have a desktop that will never leave the house or the confines of your home, wired network, so you don't want to fool with network manager. Your /etc/network/interfaces file should look something like:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.255.255.0

auto eth0
iface eth0 inet dhcp

If you're using dhcp, this should do it. Then you can disable network-manager applet on startup or remove it altogether (sudo aptitude remove network-manager).

Of course this isn't an exhaustive guide and doesn't cover many situations, but this particular situation is one I found myself in and I believe fairly common.

Sunday, May 16, 2010

Adjust Synaptics Touchpad in Lucid Lynx

Until Lucid Lynx, HAL was used to control certain settings. For example, to adjust the Synaptics Touchpad on a laptop, settings could be put into /etc/hal/fdi/policy/11-x11-synaptics.fdi (see my previous post). However, HAL was removed in Lucid. How, then, does one make these adjustments to a Synaptics Touchpad? ... by using xinput.

I created a folder named .synaptics in my home directory (/home/myuser/). Then I made a text file named touchpad_adjustments.sh (filename doesn't really matter) which contained the following (the xinput lines beginning with # are adjustments I left in that I may want to easily enable later): (SEE UPDATE AT END OF THIS POST TO VIEW MOST RECENT ADJUSTMENT FILE I USE.)

#!/bin/bash
#
# list of synaptics device properties http://www.x.org/archive/X11R7.5/doc/man/man4/synaptics.4.html#sect4
# list current synaptics device properties: xinput list-props '"SynPS/2 Synaptics TouchPad"'
#
sleep 5 #added delay...
# xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 1
# xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4
# xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 9 # Below width 1 finger touch, above width simulate 2 finger touch. - value=pad-pixels
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Area" 0, 0, 0, 4800 # set sensitive area of touchpad - value=left, top, right, bottom
xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling" 1 0 0 # vertical, horizontal, corner - values: 0=disable 1=enable
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Jumpy Cursor Threshold" 300 # stabilize 2 finger actions - value=pad-pixels
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Tap Action" 0 0 0 0 1 2 3 # pad corners rt rb lt lb tap fingers 1 2 3 (can't simulate more then 2 tap fingers AFAIK) - values: 0=disable 1=left 2=middle 3=right etc. (in FF 8=back 9=forward)
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0 # vertical scrolling, horizontal scrolling - values: 0=disable 1=enable
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Circular Scrolling" 1
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Circular Scrolling Trigger" 3

exit


Then I made sure it had execute permissions by running:

chmod ug+x /home/myuser/.synaptics/touchpad_adjustments.sh

After that, to make sure it ran every time I started a session, I went to System > Preferences > Startup Applications and chose "Add," then gave it this filename for the command.

Update: The most current version of touchpad adjustment file I use is:

#!/bin/bash
#
# list of synaptics device properties http://www.x.org/archive/X11R7.5/doc/man/man4/synaptics.4.html#sect4
# list current synaptics device properties: xinput list-props "SynPS/2 Synaptics TouchPad"
# To get list of devices and IDs, do xinput list
#
sleep 5 #added delay...
# xinput set-int-prop "SynPS/2 Synaptics TouchPad" "Device Enabled" 8 1
# xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Pressure" 4
# xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Width" 9 # Below width 1 finger touch, above width simulate 2 finger touch. - value=pad-pixels
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Area" 0, 0, 0, 4800 # set sensitive area of touchpad - value=left, top, right, bottom
xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling" 1 0 0 # vertical, horizontal, corner - values: 0=disable 1=enable
xinput --set-prop --type=int --format=32 "SynPS/2 Synaptics TouchPad" "Synaptics Jumpy Cursor Threshold" 300 # stabilize 2 finger actions - value=pad-pixels
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Tap Action" 0 0 0 0 1 2 3 # pad corners rt rb lt lb tap fingers 1 2 3 (can't simulate more then 2 tap fingers AFAIK) - values: 0=disable 1=left 2=middle 3=right etc. (in FF 8=back 9=forward)
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Two-Finger Scrolling" 1 0 # vertical scrolling, horizontal scrolling - values: 0=disable 1=enable
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Circular Scrolling" 1
# xinput --set-prop --type=int --format=8 "SynPS/2 Synaptics TouchPad" "Synaptics Circular Scrolling Trigger" 3

exit

Thursday, May 13, 2010

Remove Unwanted Kernels From Grub Menu

To remove unwanted kernel choices from the Grub menu simply go to System > Administration > Synaptic Package Manager. In search box type the kernel version you want to remove (i.e. 2.6.32). Mark for removal the installed ones that you want to remove. Then apply changes.

Grub 2 Splash Image

To add a background image to the Grub 2 boot menu and increase resolution...

From terminal:

sudo nano -w /etc/default/grub

To uncomment a line, remove the #. So uncomment the GRUB_GFXMODE line and you can change the graphics modes as follows if you like:

GRUB_GFXMODE=1280x720,1024x768,800x600

CTRL-X to exit, answer Y, then enter.

sudo nano -w /etc/grub.d/05_debian_theme

Change value after WALLPAPER to name of background image you want to use. Be sure to get the image and put in this directory. Mine shows:

WALLPAPER="/usr/share/images/desktop-base/BlueGlowTux_1280x720.png"

If you want to change the color of the menu text, change the first color in either of the color pairs:

COLOR_NORMAL="blue/black"
COLOR_HIGHLIGHT="yellow/black"

CTRL-X to exit, answer Y, then enter.

Now in terminal type

sudo update-grub

...and you're done.

Wednesday, May 12, 2010

Change Position of Window Controls in Lucid Lynx Ubuntu 10.04

The default position of window controls changed in Lucid Lynx. Many people, like me, do not like the new default. To change back to the way things were is easy.

Alt-F2
gconf-editor
apps > metacity > general
change button_layout value to:
"menu:minimize,maximize,close"

Install Adobe Flash in Lucid Lynx Ubuntu 10.04

For some reason I couldn't get Adobe Flash installed in a fresh install of Lucid Lynx the way I have in Karmic and Jaunty. I found the following tip from EllyBilateralCl on the Ubuntu Forums:

sudo add-apt-repository ppa:sevenmachines/flash && sudo apt-get update && sudo apt-get install flashplugin64-installer


It worked.

Saturday, February 13, 2010

Adjust Sensitive Area of Synaptics Touchpad - Karmic Koala Ubuntu 9.10

Sometimes you may want to adjust the sensitive area (or other settings) of your touchpad. To do so type "synclient -l" in a terminal and you will get a list of options. At the bottom you should see AreaLeftEdge AreaRightEdge AreaTopEdge AreaBottomEdge which are probably set to 0. If you change these to a nonzero value the you it will define the edge of the touchpad. Use your LeftEdge RightEdge TopEdge BottomEdge values as references because they are close to the edge of your touchpad.
After you determine the values you need then you can put them in your HAL configuration file:
/etc/hal/fdi/policy$ cat 11-x11-synaptics.fdi

<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.touchpad">
<merge key="input.x11_driver" type="string">synaptics</merge>
<merge key="input.x11_options.SHMConfig" type="string">On</merge>

<merge key="input.x11_options.EmulateTwoFingerMinZ" type="string">40</merge>

<merge key="input.x11_options.VertTwoFingerScroll" type="string">true</merge>
<merge key="input.x11_options.HorizTwoFingerScroll" type="string">false</merge>
<merge key="input.x11_options.JumpyCursorThreshold" type="string">300</merge>
<merge key="input.x11_options.AreaBottomEdge" type="string">5000</merge>
<merge key="input.x11_options.TapButton1" type="string">1</merge>
<merge key="input.x11_options.TapButton2" type="string">3</merge> <!--two finger tap -> middle click(3) -->
<merge key="input.x11_options.TapButton3" type="string">2</merge> <!--three finger tap -> right click(2). almost impossible to click -->
</match>
</device>
</deviceinfo>

Getting Fn Buttons Working in Karmic Koala Ubuntu 9.10

Sometimes things like Fn buttons don't work properly in Linux. This can be fixed sometimes by adding "noapic" to the end of the linux line in Grub. Do not confuse this with "noacpi"... they are very different things.

Friday, February 12, 2010

USB Flash Drive Read-Only in GNU/Linux

One reason your USB Flash Drive may be showing up as read-only in GNU/Linux is it may have been removed from a Windows PC without first choosing "Safely Remove Hardware." If this is the cause, simply put it into a Windows PC, then choose "Safely Remove Hardware," then remove and use in GNU/Linux.

It may also work to run a filesystem check in Linux using something like fsck or Gparted.

Boot with Bluetooth Turned Off - GNU/Linux

To boot with bluetooth turned off in GNU/Linux (specifically Ubuntu 9.10 Karmic Koala) add the following to /etc/rc.local :

rfkill block bluetooth

Validate an E-Mail Address with PHP, the Right Way

Jun 01, 2007 By Douglas Lovell

Listing 9. A Complete E-mail Validation Function


Spread the word! There is some danger that common usage and widespread sloppy coding will establish a de facto standard for e-mail addresses that is more restrictive than the recorded formal standard. If you want to fool the spambots, adopt an e-mail address like, {^c\@**Dog^}@cartoon.com. Unfortunately, you might fool some legitimate e-commerce sites as well. Which do you suppose will adapt more quickly?

Douglas Lovell is a software engineer with IBM Research, author of The XSL Formatting Objects Developer's Handbook published by Sams, and Web site editor for iac52.org.

Login to FreeNAS via Passwordless SSH - GNU/Linux

I found this solution on the FreeNAS forums. It's not very straightforward, in my opinion, to setup SSH passwordless login on FreeNAS.

Taken from FreeNAS forums:

What you need to do to customize your server for passwordless authentication:
  1. From WebGUI|Advanced|Execute command or shell
    1. protect the /mnt directory by setting the mode to 755(we don't want users to write on /mnt, that can fill up the RAM disk and crash the system.

      You must change the mod as startup command, after each reboot.

      Code:

      chmod 755 /mnt
    2. For your safety change the mode for each mount, or at least one "mount".

      Code:

      chmod 755 /mnt/mount
    3. Create the user(A) home directory /mnt/mount/userA

      Code:

      mkdir /mnt/mount/userAdir
    4. Make userA the owner of his home directory

      Code:

      chown userA /mnt/mount/userAdir
    5. Secure userA home directory

      Code:

      chmod 700 /mnt/mount/userAdir
  2. Set userA home directory on WebGUI|Access|Users|Edit|Home directory to point to /mnt/mount/userAdir

  3. From your remote client(ssh/PuTTy)
    1. Check if home directory is set corectly for userA. The output should be /mnt/mount/userAdir

      Code:

      ssh -p 22 userA@FreeNASip 'pwd'
    2. Create the .ssh directory

      Code:

      ssh -p 22 userA@FreeNASip 'mkdir .ssh'
    3. Upload your id_rsa.pub or id_dsa.pub to remote .ssh directory.

      Code:

      cat id_rsa.pub | ssh -p 22 userA@FreeNASip 'cat >> .ssh/authorized_keys'
    4. Change the .ssh dir mode

      Code:

      ssh -p 22 userA@FreeNASip 'chmod -R 700 ~/.ssh'
  4. Now try to login passwordless.

Replace Spaces with Underscores - GNU/Linux

rename -v 's/\ /\_/g' *