Enabling the ASCII Bell or System Beep

D

DevynCJohnson

Guest
I noticed that many Linux users report having problems making their motherboard beep. The motherboard speaker is entirely different than the regular speakers that users would use for music and other sounds. Sometimes, it may be helpful to know how to make the motherboard speaker beep when running shell scripts and other programs.

The "\a" represents the ASCII character for the bell (or "BEL"). The ASCII BEL character can also be represented as "^G". Therefore, users can press Ctrl+G in a terminal to cause a beep. Any or nearly any programming language that supports character escapes can use "\a" to produce a motherboard beep.

Use and Enable Beeping
The easiest way to make the motherboard beep is to open a terminal and type "echo -e \\a". However, that may not work on some Linux systems. To fix the issue, try running "modprobe pcspkr" in a terminal with Root privileges. Now, try running "echo -e \\a". If that fails, then try inserting the "snd_pcsp" kernel module instead of the "pcspkr" module.

There are other ways to make the motherboard beep via a terminal/shell. Some of the commands are listed below.
  • echo -e \\a
  • echo -e "\a"
  • echo -e \\007
  • echo -e "\007"
  • echo -en "\a" > /dev/tty5
  • printf "\a"
  • tput bel

If the above methods still do not work, then ensure that the motherboard has a speaker.

Beep Utility
Alternately, users can install the "beep" utility which is usually found in the default repos. Users will need Root privileges to install "beep".
  • Debian: apt-get install beep
  • Fedora: yum install beep
  • Gentoo: emerge -s beep

Disable Motherboard Speaker
Users can disable the motherboard beep for tab-completions by editing the /etc/inputrc file. Comment or remove the "set bell-style visible" line and replace it with "set bell-style none".

The motherboard speaker can be disabled entirely by executing "rmmod pcspkr" and/or "rmmod snd_pcsp". However, after rebooting, the speaker may be re-enabled. Users can make this change permanent across reboots by running the below command.
Code:
echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
Further Reading
Disable the Motherboard Speaker - https://wiki.archlinux.org/index.php/Disable_PC_speaker_beep
 

Attachments

  • slide.jpg
    slide.jpg
    66 KB · Views: 37,781
Last edited:

Members online


Top