Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use a beep sound in a shell script. Unfortunately none of the methods I found via Google work for me.

I tried

echo -e '\a'

echo -ne '\007'

and the command beep after I installed it via apt.

What could be the reason?

share|improve this question
up vote 46 down vote accepted

First run sudo modprobe pcspkr and then beep should work.

The reason this doesn't is because by default Ubuntu no longer loads the hardware driver that produce beeps.

If this works for you then to enable the loading of pcspkr permanently edit the /etc/modprobe.d/blacklist.conf file (using gksudo gedit perhaps) and comment out line that says blacklist pcspkr so it looks like this:

# ugly and loud noise, getting on everyone's nerves; this should be done by a
# nice pulseaudio bing (Ubuntu: #77010)
# blacklist pcspkr
share|improve this answer
yes, tried that and it works. how can i force ubuntu to load pcspkr at boot? – NES Jan 3 '11 at 20:52
@NES Have updated my answer – 8128 Jan 3 '11 at 21:06
thanks a lot, works fine. – NES Jan 3 '11 at 21:11
If I comment blacklist pcspkr I have to do modprobe -r pcspkr && modprobe pcspkr to get it to work. Also getting beep to work is not the same as getting the audible bell to work and thus should still be open. – daithib8 Jul 28 '11 at 11:37

Not being a fan of the pcspkr beep, I use a beep from one of the system sounds with the installed pulseaudio server's paplay command.

First find a sound you like (you can browse /usr/share/sounds for some available ones for example) and create a reference to it

export BEEP=/usr/share/sounds/ubuntu/ringtones/Harmonics.ogg

Then have it available as a command

alias beep='paplay $BEEP'

Now just run beep whenever you need it. For example, to alert you when a command is finished:

find . | grep treasure ; beep
share|improve this answer
Very cool! It works! – Hengjie Feb 19 '13 at 3:22
Thanks, this was useful for me! – h3nr1x Jun 12 '13 at 3:57
This wasn't the answer I expected, but I like it better. – isaaclw Jun 20 '13 at 16:55
This is a great solution! Now I can do; beep and read stackoverflow until the system is ready. – jamesc Mar 30 '15 at 10:17
Nice! I use export BEEP=/usr/share/sounds/ubuntu/stereo/dialog-information.ogg and alias beep='paplay $BEEP --volume=32768' now, that works well for me. (Note that you can override the volume with the beep alias, e.g. beep --volume=15000 plays at volume of -12dB.) – leftaroundabout Dec 6 '15 at 12:57

Since this is a very high rated question on google, I'll add the steps I did to re-enable beep in both console and X11:

- For the Linux Console (CTRL+ALT+F1...F6):

Why it does not work by default:

As already answered, the pcspkr kernel driver for the PC Speaker is blacklisted in Ubuntu.

Temporarily enable until reboot:

sudo modprobe pcspkr

Automatically enable on boot:

sudo nano /etc/modprobe.d/blacklist.conf -> uncomment #pcspkr line

- For X11 terminals (such as the default gnome-terminal):

Why it does not work by default:

Under X, like when using Unity, KDE, Gnome Shell, the beep events are captured by PulseAudio thanks to module-x11-bell, which is loaded by default at /usr/bin/start-pulseaudio-x11. And the sound sample PulseAudio plays on beep, bell.ogg, is blank by default. Additionally, the bell volume may be muted.

Temporarily enable for current session:

xset b 100  # perhaps not needed, on my system it was 40 by default
pactl upload-sample /usr/share/sounds/ubuntu/stereo/bell.ogg bell.ogg

There are other suitable samples you can try at /usr/share/sounds, for example check the ones at /usr/share/sounds/gnome/default/alerts/

Note that the beep program is not really necessary. But if installed, it uses the PC Speaker. It was the only way I could find to enable the buzzer under X:

sudo apt-get install beep

Automatically enable on boot:

Just add the above lines in your ~/.profile, or system-wide at /etc/profile

- To test it:

printf '\a'




share|improve this answer

As far as I can tell, this is a bug: System beep broken in Karmic despite heroic efforts to fix it.

share|improve this answer
"Not enabled by default" does not mean broken, and no "heroic effort" is needed: just modprobe pcsprk (in console) or pactl upload-sample ... in X11 and the annoying beep is back :) – MestreLion Feb 19 '15 at 11:03

If you have actual speakers connected to the computer and you're not getting a beep it's likely because you are using compiz. Compiz is relying on pulseaudio catching the beeps and playing them while metacity bypasses the usual setup and uses libcanberra to play a beep sound. If it works with metacity and not compiz that is your problem, otherwise the answer htorque gave is corrent.

share|improve this answer

This answer is what worked for me.

I think it was specifically the bit to remove the pulseaudio-module-x11 package.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.