Enable and Use the Linux System Beep

Tagged: , , , ,

This topic was published by and viewed 1427 times since "". The last page revision was "".

Viewing 1 post (of 1 total)
  • Author
    Posts
  • DevynCJohnson
    DevynCJohnson
    Keymaster
    • Topics - 444
    • @devyncjohnson

    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.

    • [CODE]echo -e \\a[/CODE]
    • [CODE]echo -e "\a"[/CODE]
    • [CODE]echo -e \\007[/CODE]
    • [CODE]echo -e "\007"[/CODE]
    • [CODE]echo -en "\a" > /dev/tty5[/CODE]
    • [CODE]printf "\a"[/CODE]
    • [CODE]tput bel[/CODE]

    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: [CODE]apt-get install beep[/CODE]
    • Fedora: [CODE]yum install beep[/CODE]
    • Gentoo: [CODE]emerge -s beep[/CODE]

    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 "[CODE]rmmod pcspkr[/CODE]" and/or "[CODE]rmmod snd_pcsp[/CODE]". 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[/CODE]

    Further Reading

Viewing 1 post (of 1 total)