As Marius says: hardware is detected by the kernel at boot time, or later if it's "pluggable" (USB, etc.). When the hardware is recognized, the related kernel module (driver) will be loaded and in most cases userspace will be notified via dbus/udev to determine what to do with that hardware; udev has a set of "rules" that specify what to do with certain types of hardware. E.g. "if the detected hardware is an USB printer, add it to the print server (CUPS)" is an example of such rule, and it would look something like this:
# Low-level USB device add trigger
ACTION=="add", SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="07", ATTR{bInterfaceSubClass}=="01", RUN+="udev-configure-printer add %p"
# usblp device add trigger (needed when usblp is already loaded)
ACTION=="add", KERNEL=="lp*", RUN+="udev-configure-printer add %p"
The above is part of /lib/udev/rules.d/70-printers.rules
(at least, on 10.10), which also includes a rule for removing the printer from CUPS if you unplug it.
BTW: USB class 7 are USB printers.
In some cases you might have to change some configuration files, but that would be considered a bug or a necessary workaround (some hardware is impossible or difficult to detect).
You could use hardware compatibility databases. You can even set Ubuntu Linux as a search attribute.
When I buy new hardware I usually google for that hardware. Let's say I want to buy a graphic card from nvidia, the gtx260. I would google for "gtx 260 ubuntu" and then I see if other people have any problems. I do that for all the hardware. I always prefer hardware from companies who have open-source drivers or generally a good reputation in the linux community.
Best Answer
You could use the MAC address of
eth0
(assuming this exists on each machine). You can get that on its own (there may be a simpler way) with this:That will give you something like
6cf04954aaaa
.These are supposed to be unique but they're not always. If all your network hardware comes from the same manufacturer, you might find some crossover, so be careful with it.
Failing that, you could generate your own unique string and store it in
/etc/computer-id
(or another path of your choosing).Will generate something as random as possible eg:
52a85807-35fe-409e-8983-87eb58c02ece
Uses time and
eth0
's MAC to make something like:eb8280dc-b5ec-11e0-90dd-6cf04954aaaa
Both are fairly unique but, as with anything random, there is always the possibility of a clash. Keep a central list to avoid problems like this.