Setting up USB on Linux

It's easy to get a Linux kernel that supports USB now. But that's only part of what you need in order to use USB; the rest of the operating environment needs updates, of various types, to make it usable. At this writing, only a few GNU/Linux distributions support even statically configured USB ... yet USB is about hotplugging and dynamic configuration. What does your Linux system need to really run USB?

Kernel Configuration for USB
You'll need a 2.4.0 or 2.2.18 kernel; some other USB ports also exist. Configure all (!) USB features as modules, and enable the USB "device" file system. You may prefer non-modular versions of some key USB modules so that you can boot with a USB keyboard and mouse. Install the kernel as usual.
USB Initialization
Part of this may be done as the Linux kernel bootstraps. The more modular your kernel USB configuration is, the more initialization needs to be done in scripts after the kernel starts to run. USB initialization needs to be run from your system's equivalent of /etc/rc.d/rc.sysinit, ideally without needing to set up lots of system config files and without overlooking anything important.
Hotplugging: USB Daemon (USBD) and Policy Agent
A basic design goal for USB is Plug'n'Play operation: Linux should react when users plug in new devices, making such devices usable without requiring administrative action. Some notifier (conceptually a "USB Daemon") reports new devices to a policy agent which can choose and start a driver for the device. Such agents can also tell other subsystems (networking, print spooling, etc.) about new devices which concern them. At this writing, the only supported "USB Daemon" is enabled by a kernel configuration option (CONFIG_HOTPLUG), but similar functionality has also been written with pure user-mode support. Configure a USB Daemon, as listed later, to invoke those agent scripts.
Other System Updates
File system device nodes for USB devices need to get created. Recent GNU/Linux distribution have been taught about USB. Otherwise, you'll likely need to follow the /usr/src/linux/Documentation/usb files distributed with your kernel. You may also need to update X11 configuration files to tell the server about /dev/input/mice or other devices. (And surely there are lots of other updates that we just don't understand yet. Cardbus, print spooling, and networking just for starters...) The USB Guide is the best resource for information about such sysadmin topics.
Tools and Troubleshooting
If you aren't running in an automated Plug'n'Play mode, you will require tools. They don't really exist, except for classic (wetware-enhanced) text editors. For troubleshooting, configure "usbdevfs" into your USB; it's the main way to determine USB status. Basic diagnostic scripts ("rc.usb status") exist.

The short version of the rest of this document is this: download and install the Linux-USB tools, so that USB is fully set up and so that you can use your kernel HOTPLUG support.

USB Initialization: /etc/rc Scripts

The assumption here is that Plug'n'Play operation is the design center for USB on Linux. Some sites may still prefer manual administration, perhaps to learn more about how USB runs under Linux or because that's what their GNU/Linux distribution supports. For example, several distributions have begun to ship with partial (no hotplugging) USB support enabled, with their own /etc/rc scripts:

USB initialization scripts need to interact with any other tools (and hidden configuration data) in use. This of course includes working with all combinations of kernel configuration options (including being more or less modular) and hardware setups. It may also affect configuration of other subsystems (e.g. to make a professional USB synthesizer the default, not the midi on the cheap sound card). So it may be to your advantage to work with the USB tools in your Linux distribution ... keeping in mind that all the tools are in early stages, and may not yet support what you need!

At this writing only the Linux-USB "usbd tools" (next) support USB hotplugging.

Linux Hotplug Tools

The current software is at the linux-hotplug project site. There's an RPM version (soon, APT), and also a tarball (with installation instructions) if you need that. This includes USB hotplugging support, and also handles PCI.

Hotplugging: USB Daemon and Policy Agents

To use USB in anything like a natural way, Linux needs a "USB Daemon", or USBD. A USBD reacts to users adding and removing devices, setting things up so they work correctly. That is, it handles essential parts of "Hot Plug" processing. It has two parts:

The same approach can work with other kernel subsystems that need to dynamically react to device addition and removal. The /sbin/hotplug program (typically a shell script; see the reference code in CVS above) handles USB the same way it can handle other types of hotplug events.

The Linux-USB Tools package provides an implementation of a USB Hotplug agent; more intelligent implementations will likely appear. Documentation exists. The most recent release leverages USB "modutils" support with Linux 2.4.0 kernel series. (The expectation is that such support will replace earlier support that relied exclusively on driver configuration scripts.)

Kernel USB Daemon (kUSBD)

The only currently supported USB Daemon is the Kernel USB Daemon. You get it when you enable HOTPLUG with USB; it is "light weight" in that it doesn't require "usbdevfs" support (a design requirement) and adds only a very small amount of kernel code. (Previous daemons required "usbdevfs" and a user mode process scanning it for changes. That was a much larger system footprint.) Most of the work is punted to user mode, by invoking a user mode helper program (/sbin/hotplug by default) that knows how to find the USB policy agent that does the real work. The modutils support is targeted at 2.4.0 but the 2.2.18 kernel also works.

When you boot a kUSBD-enabled kernel, you will see a file /proc/sys/kernel/hotplug if you're running with procfs (as you probably should be). It will name the program /sbin/hotplug by default. Whenever a USB device is added or removed, that program will be invoked (if it exists). To change the program name, write to /proc/sys/kernel/hotplug. Use the hotplug script and USB policy agent provided with the Linux-USB tools (see above).

If you use kUSBD, the Linux-USBD scripts can be a single-download solution for "USB Plug'n'Play". If you're using a 2.4 kernel with USB modutils support, you can make do with just the "/sbin/hotplug" script, which handles most module loading and driver-specific setup tasks using only common /sbin programs. You can install a more functional policy agent in /etc/hotplug/usb.agent if you prefer.

Other USB Daemons

The first USB Daemon to fully support USB hotplugging was the Java USB Daemon (jUSBD); it has since been desupported in favor of the kernel support (which doesn't require usbdevfs). This relied on /etc/usb/policy scripts, which were then used as kUSBD policy agents.

Thomas Sailer provided the first usbdevfs based daemon with his usbd 0.1 release. It wasn't very flexible about policies.

Recently, another usbdevfs based effort was reported: the USB Manager defines a custom configuration file and driver database format which somewhat resembles the PCMCIA support. It provides a usbdevfs based notification service.

A devfs based prototype required an experimental usbdevfs-to-devfs merge patch (not part of Linux 2.4); mostly it's listed here for historical knowledge. It successfully invoked the /etc/usb/policy scripts to cause driver loading and configuration.

There are several "USB View" tools available; for example, Corel Linux bundles one version, another is written in Java/Swing. The key difference between those and most shell script listers ("usbtree" etc) is just that they automatically rescan, like a USBD.

It's worth mentioning that Microsoft documentation uses the term "USBD" to refer to a shared library that is part of the Win32 USB device driver API. Try to avoid being confused by that; on Linux, that "d" suffix normally indicates a "daemon".