Fix Common Fedora 10 Linux Issues

I’m a big fan of Fedora Linux and have been a user since the Red Hat days. I cut my Linux teeth on Fedora Core 1 (I still have the install discs). Though I’ve tried many other distros, I tend to return to Fedora.

Fedora 10 was released a few days ago. I just installed it, and decided to address a few common issues typical users may face. A few of you may remember that I did the same thing for Fedora Core 6. Here we go.

For the purposes of this guide, I’m using GNOME on an i686 machine.

Add the RPM Fusion Repository

First and foremost, install the RPM Fusion repository to gain access to a lot more software. You can do it graphically or via the command line (please see their configuration page). Copy and paste the following code into the Terminal:

su -c 'rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'

Don’t skip this step. It makes most of the other steps much simpler. Many of the remaining steps will also utilize the command line, but if you prefer a graphical user interface (GUI), just go to System → Administration → Add/Remove Software. You will get a GUI, like this:

Get Video Working

Alright, the next step is to get video acceleration working. I only own Nvidia cards, and installing the latest Nvidia driver is as easy as:

su -c 'yum install kmod-nvidia'

For ATI cards, try this:

su -c 'yum install kmod-fglrx'

Once it installs, just logout and log back in (or reboot if you really feel like it). To see if the video driver is working, try typing glxgears in the Terminal.

If you see frame-rate numbers in the thousands, you have video acceleration.

Install the Flash player

Let’s get the Adobe Flash player working. There are a few ways to do it, but I suggest using YUM. First, go to this link:

http://get.adobe.com/flashplayer/?promoid=BUIGP

Select YUM for Linux from the drop-down list, and download the RPM.

Double-click to install the RPM. You have now set up a repository for Flash, and all that is left to do is initiate YUM to install it.

su -c 'yum install flash-plugin'

Restart Firefox to enable the Flash player.

Have a Little WINE

If you want to try your hand at running any Windows applications, go ahead and install WINE.

su -c 'yum install wine wine-tools wine-desktop'

Make MP3s Work

As discussed many times, Fedora does not include MP3 playback out of the box for legal reasons. However, enabling MP3 support is trivial. The first time you try to play an MP3, Totem will prompt you to search for the MP3 codec. Provided that you enabled the RPM Fusion repository (as described above), it will find the decoder automatically! Piece of cake!

If you prefer to enable MP3 playback manually, do it like this:

su -c 'yum install gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly'

I prefer using Rhythmbox over Totem as a music player. It is usually installed by default (look under Applications → Sound & Video), but if you do not have it, install Rhythmbox like this:

su -c 'yum install rhythmbox gstreamer'

And DVDs, too

DVDs are a little more tricky. Reading DVDs is no problem. Just do this:

su -c 'yum install lsdvd libdvdread libdvdnav'

However, the problem comes when trying to decrypt an encrypted DVD. This is a legal issue in some countries (such as the USA… sigh). In order to do this, you need the libdvdcss package, and it is currently not in the RPM Fusion repository due to legal responsibility. Maybe it will be added in the future, or maybe there will be a workaround, who knows?

In the meantime, you can install the libdvdcss package like this (from the Livna repository):

su -c 'rpm -ivh http://livna-dl.reloumirrors.net/fedora/development/i386/libdvdcss-1.2.9-5.lvn9.i386.rpm'

Install VLC

VLC is an excellent media player that will play almost anything you throw at it.

su -c 'yum install vlc'

Get Thunderbird

Fedora 10 comes with Evolution for a mail client. If you prefer Thunderbird, install it like this:

su -c 'yum install thunderbird'

To make Thunderbird the default Mail program, just go to System → Preferences → Personal → Preferred Applications. From there, select Thunderbird from the drop-down list.

Burn CDs/DVDs with GnomeBaker

As a GNOME user, my favorite tool for burning CDs and DVDs is GnomeBaker.

su -c 'yum install gnomebaker'

Make Nautilus Better

If you like the default behavior of Nautilus, skip this step. Personally, I prefer that Nautilus NOT open every folder in a new window.

To fix this, simply open any folder (such as your Home folder) and go to Edit → Preferences. Click the Behavior tab. Put a check next to Always open in browser windows.

Enable Numlock by Default

su -c 'yum install numlockx'

Now whenever you log in to GNOME, numlock should turn on automatically.

There we go. This guide is by no means comprehensive, but it should help alleviate some of the common issues that the average user faces.

If you want to share any other Fedora 10 tips, or know of a better way to accomplish anything that I have listed, please comment below.

µTorrent Mac Beta Finally Released

I just received this e-mail from the μTorrent Mac Team:

Psst…

You asked us to tell you about µTorrent Mac developments.

The beta is out. It’s Leopard and Intel only right now, but we’re working
to expand support soon.

Get it here: mac.utorrent.com/beta

Remember it’s beta software, so there may be bugs and annoyances. Please
help us make it better by contributing to the conversation in the forums
(forum.utorrent.com).

– The µTorrent Mac Team

This is great news. µTorrent is an excellent torrent client on Windows, and I’m excited to give it a try on Mac OS X. Yes, it’s still a beta, but I look forward to seeing how it compares to my reigning favorite client – Transmission.

0.9.0 is the current version.

Here’s the main screen:

And some Bandwidth preferences:

So far, I’d say it looks and acts a lot like the Windows version, just a lot more slick, glassy, and Mac-like.

Your thoughts? Will you be switching your Mac torrent client?

Keep Your Address Book in Sync with Dropbox (Mac OS X)

Disclaimer: some users have reported that this method does not work properly. Rest assured that it works, but I only recommend it for people comfortable with the Terminal. There’s a lot of room for error.

Please back up your Address Book before attempting this method. I am not responsible for lost data. Please see the comments below for further commentary.

Here is a little tip for you Mac users out there. We have written about the awesome, cross-platform Dropbox service before (here and here), and while it’s great for keeping ordinary files and folders in sync across the Internet, there are a few more clever uses for it.

With a tiny bit of command-line magic, you can easily keep your Mac OS X Address Book backed up online and synced to other Macs. Here’s how:

Preliminary Steps

First of all, download and install Dropbox on any OS X machines that you wish to sync. Finished? Excellent!

Next, go ahead and make a backup of your Address Book (optional, but strongly recommended). Just go to File → Export → Address Book Archive….

Keep that export handy in case things go wrong.

Link Address Book to Dropbox

Here’s the fun part. To make this process work, Address Book needs to be able to save data to your Dropbox folder. At present, Dropbox can only sync ONE folder (and everything in it). So, you see the problem? Address Book keeps all its data inside ~/Library/Application Support/AddressBook, and we need to trick Address Book into saving to your Dropbox folder.

Symbolic Links to the rescue! We can easily fool Address Book by creating a symlink.

Step 1 – First, we’re going to move the Address Book data files to your Dropbox folder. Make sure Address Book is closed. Launch Terminal (in your Utilities folder), and assuming your Dropbox folder is inside your Home directory, issue this command:

mv ~/Library/Application\ Support/AddressBook ~/Dropbox/

Step 2 – Now, create the symbolic link. The format is ln -s [destination] [name of file or folder]. The syntax does not change as to whether the link is to a file or a folder. Still in Terminal, type:

ln -s ~/Dropbox/AddressBook/ ~/Library/Application\ Support/AddressBook

That’s it. You’re done. Try launching Address Book and make sure your contacts are still there. Now when you add a new contact and it, you should see Dropbox update as well. Notice the tiny, green Dropbox check marks on my AddressBook linked folder:

Adding Other Macs

To add another OS X machine to the mix, just repeat these steps (except for the first mv command). In short, just install Dropbox, make sure Address Book is closed, and then:

  1. Delete the AddressBook folder from ~/Library/Application Support
  2. Create the symlink (ln -s ~/Dropbox/AddressBook/ ~/Library/Application\ Support/AddressBook)

There you go. Address Book will stay syncronized and backed up online.

ADrive – 50GB of Free Storage (Online Storage Series)

In continuing our online storage series, today we’re going to look at ADrive, which offers a whopping 50GB of free storage. So far we have taken a look at:

Note: In addition to the free plan, ADrive also offers paid plans with additional features and storage space. For this article, I’m using the free version.

For a free offering, ADrive is loaded with features. Here are a few of them:

  • 50 GB storage (per account)
  • Multiple folder upload (Nice!)
  • File-sharing capabilities
  • Remote file transfer
  • Integration with Zoho Editor
  • ADrive Backup Client (Windows only at the moment)

Upgrading to the cheapest paid version also adds SSL encryption and WebDAV access (mapping as a network drive). These two features alone are worth the upgrade price. Also, the free version is ad-supported.

Once you register for an account, you can start creating folders and uploading files. Here is what the main window looks like. I’ve already added a few folders.

Notice the buttons at the bottom of the window. They allow for file/folder manipulation (move, copy, create directory, share, and delete).

Uploading

There are several different ways to get files into ADrive, but the most common way is using the Java upload tool. If you don’t have Java installed already, you should do so. The first time you try to upload a file, Java will start to load. If you want, tell it to “Always trust….”

Once Java loads, you will have access to a Java uploader than can upload multiple files and folders simultaneously.

While loading Java can be sluggish, I absolutely LOVE the ability to upload a hierarchy of folders at once, keeping their original structure intact.

Except… there’s a big problem with using a browser-based Java uploader. Once Java comes to the forefront, it seizes control, and the rest of the browser is rendered absolutely useless. You can’t switch tabs or even minimize appropriately. The only browser I’ve found that gets around this annoying problem is Google Chrome (due to its multi-threaded approach).

If you want to avoid Java, a Basic Uploader is available, but it can only upload one file at a time.

Downloading

To download files, you can simply navigate the folder hierarchy and double-click the file you want to download. Easy enough…

Or, you can use the more advanced Java downloader. With it, you can select multiple files (control-click or shift-click), and the utility will automatically create folders on your computer, keeping the hierarchy intact. Brilliant!

Remote Transfer

Another one of my favorite features is the ability to remotely transfer a file from elsewhere on the Internet straight into ADrive. Considering that remote transfer is usually only available in paid accounts in other services, I’m glad to see that ADrive offers it for free.

Here is a remote transfer in progress:

Other Features

If you’re a Zoho user, you will be pleased to know that you can directly open and edit files from within ADrive. Just right-click on any compatible file and look for the Edit in Zoho button.

I admit, I’m disappointed that OpenOffice documents are not yet supported. This is a shame considering that Zoho can handle OpenOffice files. Hopefully ADrive will correct this soon.

On the other hand, the ADrive Backup Client is slick tool that’s available for Windows users. This small utility allows you to set up scheduled backups, restores, and synchronizations.

Though the Backup Client used to be limited to a 30-day trial, it is now free for all accounts. While I certainly applaud ADrive for making it free, I also wish to see a client for Mac/Linux.

Sharing

As with most other online storage services, ADrive allows for public sharing of files. Simply select a file and click the Share button.

You can then view a direct link to the file, and choose to download or e-mail it to a friend.

If you can’t tell, I like ADrive. I have been using it for many months, but it took a while to grow on me. The interface is functional, but not as slick as other services, and I was turned off by the 30-day trial of the Backup Client (now free).

Mainly, the sheer amount of space and special features – such as the Remote Transfer option – have propelled ADrive near the top of my favorites list for online storage. I can see myself paying the $69.50 per year for the addition of SLL, WebDAV, and file history recovery.

That said, I highly recommend the free edition, though I also suggest using it with Google Chrome to avoid the Java-seizing-the-browser issue.

Happy storage!

Stealth Submit: Using AJAX to Save Form Data Without Submitting the Form

Ah, this is sneaky. You may think that a web site can’t read form fields until you hit the submit button, but this is not the case. Using AJAX, a site can read form data at any time. This could be used for nefarious purposes, but I’m presenting here for two reasons: 1) to let people know that it can be done and 2) to show people how to do it for legitimate purposes. What’s a legitimate use of this? Logging, mostly… a lot of work goes into studying why users may fill out only the first page of a form. If you log the data regardless of whether a user clicked submit, you can study user behavior and possibly improve your form.

This tutorial assumes the following: you have a web server running PHP 5 (or greater) and MySQL 5 (or greater) with the mysqli extension installed. There are several parts to how this works:

1. savedata.php: A processing page that grabs posted variables (e.g. savedata.php?variable=value).
2. db.php: A database interface file (usually contained above the document root, contains passwords and save logic).
3. index.php: The HTML page containing the form.
4. The prototype JavaScript library. This is a very handy library that’s pretty easy to use.

Here’s an image showing how these files are organized in their folder structure. /html is the document root of the site: all browser requests are directed in there. /lib is above the document root… only PHP can make calls inside that folder. That’s were we put our database connection logic, including usernames and passwords.

Folder structure used for Stealth Submit Files
Folder structure used for Stealth Submit Files

The files used in this demo are listed below, but because scripts tend to get buggy when they’ve undergone conversion to/from html-entities, I’m zipping up the files and uploading them here.
Stealth Submit Sample Files.zip

You should be able to unload the html and lib directories to your web server. Point your DocumentRoot at the html directory; be sure to run the SQL commands included at the top of the db.php file so your database looks the way that this script expects it to.

For the use of visibility, the contents of these files is included below:

html/savedata.php : the PHP Page that grabs and stores variables


<?php
/*
Test this page by hitting it in a browser with variables:
http://your_domain/savedata.php?first_name=Bart&last_name=Simpson&age=11&home_town=Springfield&job=Punk

*Add &debug=1 to the url to print out verbose messages.
*/

include_once($_SERVER['DOCUMENT_ROOT'] . "/../lib/db.php");
$debug = $_REQUEST['debug'];
$debug_msg ="<p>The following variables were passed:</p><hr/>";

// Harvest all form data: this works for posts and gets.
foreach ($_REQUEST as $var => $value) {
$debug_msg .= "<b>$var</b>: $value<br/>";
$form_data[$var] = $value;
}

if ($debug) {
echo $debug_msg . "<hr/>";
}

$result = save_user_data($form_data);

if ($debug) {
if ($result) {
echo "Data saved successfully. Id: $result";
} else {
echo "Error saving data.";
}
}

?>

lib/db.php : Here’s the Database Interface Page


<?php
/*
Contains database handle (username/password) and saving functions

Here's the table definition for the table used in this demo:

CREATE DATABASE ajax_demo;

CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`first_name` char(64) default NULL,
`last_name` char(64) default NULL,
`age` tinyint(3) default NULL,
`home_town` char(64) default NULL,
`job` char(64) default NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM;

GRANT ALL PRIVILEGES ON ajax_demo.* TO 'peter'@'%'
IDENTIFIED BY 'abc123';
*/

// Test regex's here by uncommenting this line and executing this file.
// echo get_name_regex('Bob');
/*-------------------------------------------------------------------------
DEFINE Database constants here
---------------------------------------------------------------------------*/
define("DATABASE_HOST", 'localhost');
define("DATABASE", 'ajax_demo');
define("DEFAULT_USER", 'peter');
define("DEFAULT_USER_PASSWORD", 'abc123');

function connect_db ($user = DEFAULT_USER) {
/*
INPUT: $user
This function allows for multiple handles to be called, e.g. handles for
read-only, write-only, etc. Each user has its own permissions.
mysqli format is mysqli(DATABASE_HOST, USER, PASSWORD, DATABASE);
*/
switch($user) {
case DEFAULT_USER:
$link = new mysqli(DATABASE_HOST, DEFAULT_USER, DEFAULT_USER_PASSWORD, DATABASE);
break;
}

return $link;

}

/*-------------------------------------------------------------------------*/
function save_user_data ($input) {
/*
INPUT:
Hash with values from form, e.g. $input['first_name'].
OUTPUT:
id from database if successful insert; otherwise null.
*/

$link = connect_db();
/* check connection */
if ( mysqli_connect_errno() ) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

$sql = "INSERT INTO user
(
first_name,
last_name,
home_town,
job,
age
) VALUES (
?,
?,
?,
?,
?
)";

$statement = $link->prepare($sql);

if (!$statement) {
printf('Error - SQLSTATE %s.\n', mysqli_sqlstate($db_connection));
exit();
};

// Filter data (regex's, validate, etc)
$first_name = get_name_regex($input['first_name']);
$last_name = get_name_regex($input['last_name']);
$home_town = get_name_regex($input['home_town']);
$job = get_name_regex($input['job']);
$age = get_integers_only_regex($input['age']);

// Bind-parameters: s=string, i=integer, d=double, b=blob
$statement->bind_param('ssssi', $first_name, $last_name, $home_town, $job, $age);

$statement->execute();

if ($link->error) {
echo $link->error;
}

if ($link->insert_id) {
$result = $link->insert_id;
}

echo

$link->close();

return $result;
}

/*====== DATA FILTERING and VALIDATION =============================*/
function get_name_regex ($input) {
$pattern = '/(;|\||`|=|--|\/|\.|>|<|&|^|"|'."\n|\r".'|{|}|[|]|\)|\(|[0-9])/i';
$input = preg_replace($pattern, ' ', $input);
return trim(ucfirst($input));
}

// Given any input, we only want a valid integer here, e.g. 2.24 --> 2
// Specify the length desired.
function get_integers_only_regex ($input, $len = 100) {
// $input = (int)$input; // typecast will fail if you have a zip w/ a leading 0, e.g. 09921
if ($len > 0) {
$pattern = '/\D/';
$input = preg_replace($pattern, '', $input);
$input = substr($input, 0, $len);
}
return $input;
}
?>

html/index.php : the HTML Page Containing the Form

<html>
<head><title>Stealth Submit</title>

<script src="/js/prototype-1.6.0.3.js"></script>
<script language = "Javascript">
function saveData() {
new Ajax.Request('savedata.php', {
method: 'post',
parameters: {
// $('form_id').serialize(true)
first_name: document.getElementById('first_name').value,
last_name: document.getElementById('last_name').value,
home_town: document.getElementById('home_town').value,
age: document.getElementById('age').value,
job: document.getElementById('job').value
}
});
}

</script>

</head>
<body onunload="saveData()">
<form id="form_id" method="post" action="action.php">
First Name: <input type="text" id="first_name" name="first_name"><br/>
Last Name: <input type="text" id="last_name" name="last_name"><br/>
Age: <input type="text" id="age" name="age"><br/>
Hometown: <input type="text" id="home_town" name="home_town"><br/>
Job: <input type="text" id="job" name="job"><br/>
<input type="submit" value="Submit" />
</form>

<a href="http://www.google.com/">Arbitrary Other Page... FORM NOT SUBMITTED</a>

</body>
</html>

VirtualBox Walkthrough – Easily Run Other Operating Systems Virtually

In the land of virtual machines, there are a few big names, such as VMware and VirtualPC. However, there is a slightly lesser-known contender worth examining – VirtualBox.

I have no intention of pitting the various virtualization tools head-to-head, or to label any one of them as the subjective best, but if all you’re looking for is a free and easy way to run virtual copies of operating systems, VirtualBox has you covered.

VirtualBox runs on Windows, Mac OS X, Linux, and OpenSolaris, and can support a massive number of guest operating systems. DOS? Check! OS/2? Yep! Vista? Of course.

Best of all, VirtualBox is completely free. You can choose to download either a compiled binary or the open-source edition.

Walkthrough

I’m going to walk through the process of setting up a new virtual machine. The host OS is Mac OS X, using VirtualBox 2.0.4.

Once you install and launch VirtualBox, it’s time to create a new virtual machine. Click the New button in the top-left corner.

Next, choose a name for your virtual machine and select the appropriate guest OS type. In my case, I’m planning to install Damn Small Linux, which uses a Linux 2.4 kernel.

In the next step, select the amount of system RAM that you wish the guest OS to use. You can always adjust this later, and the amount to choose largely depends on the type of guest OS. I have 1.25 GB available in my Macbook, but Damn Small Linux only needs a little bit. I’ll be generous and give it 256 MB.

Now it’s time to create a virtual hard drive for the guest OS. After all, it has to install somewhere, and a virtual hard disk ensures that the new installation does not somehow trash your existing hard drive! Click the New button to launch the New Virtual Disk Wizard.

Create a name and choose a size for the new virtual drive. You have a choice here with regard to the size of the virtual disk:

  1. Dynamically expanding image
  2. Fixed-size image

If you choose option 1, the size that you specify for the disk is the maximum potential size. The disk will actually consume only as much space as is needed, and will grow larger automatically until it hits the maximum. The benefit here is in reduced file size on your real hard disk.

If you choose option 2, VirtualBox will go ahead and allocate the entire specified space for the disk. The benefit here is in slightly better performance of the virtual machine, at the expense of a larger file size now. It’s a trade off. If you can spare the disk space, I suggest choosing the fixed-size option.

Once you have chosen the type of disk image, go ahead and type a name for the disk. You can use the slider to manipulate the disk size.

Created your virtual disk yet? Great, let’s continue with the installation.

Alright, now that you have completed the wizard, VirtualBox will show you the details of your soon-to-be-running virtual machine. Before you get excited and hit the Start button, let’s take a look at a few more details.

Click the Settings button in the top-right corner. Here, we can adjust settings for the new virtual machine, including networking, USB, and access to the CD/DVD-ROM. Feel free to edit any parameters that you like. You can always adjust them later.

You will almost certainly have to adjust the CD/DVD-ROM settings. In my case, I have an ISO that I want to boot, so I’m going to choose that option and select the location of my Damn Small Linux ISO.

Another option you may want to explore is setting up Shared Folders. In essence, you can use these to allow file transfers between the host and guest operating systems.

Hint: Don’t put any spaces in the shared folder name. Also, you will need to install the VirtualBox Guest Additions on the guest OS before you can access shared folders. Guest Additions can be installed once the virtual OS is running.

Are you ready to get this guest OS running? Once you’ve adjusted all the settings that you like, hit the big, green Start button at the top. Your guest OS should launch and start the booting process.

Here, Damn Small Linux is starting to boot:

And here, Damn Small Linux is running in its full glory on my Macbook. Click to enlarge.

And just for kicks, here’s a screenshot of Ubuntu 8.10 running as a guest OS on my Macbook. Click to enlarge.

And this concludes our installation walkthrough. If your guest OS supports it, I strongly recommend installing the VirtualBox Guest Additions. Benefits include, better video support, mouse pointer integration, time syncronization, and access to shared folders. To install Guest Additions, take a look under the Devices menu.

One of my favorite features of VirtualBox is the ability to create multiple snapshots of the guest OS. This is useful for purposes of software testing or tweaking. Oops! Make a terrible mistake? Just revert to a previous snapsot and the guest OS will be restored to a previous state. Nice!

Happy virtualizing!

VirtualBox website – http://www.virtualbox.org

VirtualBox downloads – http://www.virtualbox.org/wiki/Downloads

FREE Book – Definitive Guide to Linux Network Programming (PDF)

To continue in the spirit of free products, Apress.com is giving away digital downloads of The Definitive Guide to Linux Network Programming.

The book has a list price of $49.99, and is available for free download here.

Update: the download link appears to be down on Apress right now (due to massive traffic). Here is a temporary download link.

For those of you who don’t like staring at computer screens too long, you can purchase a hard copy on Amazon for $35 (Amazon link). It has pretty good reviews on Amazon so far, so this 400-page book is certainly worth adding to your arsenal.

Enjoy.