My laptop doesn't have a PC speaker, so I needed a software-only solution. I found an article about setting up GNOME to play an audio file for the system beep.
The idea is to set up xkbevd(1) to run a command when a certain event occurs; in this case, the event
Bell. For Ubuntu 9.04 Jaunty (and possibly previous versions as well), many of the sound files provided are in ogg vorbis format instead of wave, so depending on which sound you want to play on a terminal bell, using aplay(1) may not work. If you don't already have it, you'll need to install the vorbis-tools package:
sudo aptitude install vorbis-tools
After that, you'll need to create
~/.xkb/xkbevd.cf (note the spelling, the article has a typo here) and insert the following:
In order to have the daemon run on login, you can edit your profile as the article suggests, or you can add it to your Startup Applications (System -> Preferences ->Startup Applications). Click on Add to create a new startup program, set the Name to
XKB Event Daemon, the command to
xkbevd -bg, and the comment to
Software terminal bell.