Ubuntu – Beep in shell script not working

command linescriptssound

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?

Best Answer

  • 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