1. Introduction

The integrated computer loudspeaker, also known as the PC speaker, is a device that emits a beep in certain conditions. Although these might be critical, there are times when we want a system to be silent.

In this tutorial, we discuss ways to prevent the integrated computer speaker from producing sounds when using Linux. First, we provide a brief overview of the PC speaker device. Then, we handle terminal, shell, and input beeps in particular. After that, we turn to audio drivers as a possible solution. Next, at a lower level, we try to disable beeping via the core of the operating system. Finally, we go outside Linux and tackle ways to prevent the machine itself from producing an audible notification from the PC speaker.

We tested the code in this tutorial on Debian 12 (Bookworm) with GNU Bash 5.1.4. It should work in most POSIX-compliant environments unless otherwise specified.

2. PC Speaker

While high-fidelity sound systems have been around for a long time, the first use of general-purpose computers for audio production isn’t far back in the past. In particular, the first integrated computer loudspeaker, i.e., personal computer (PC) speaker, didn’t appear until around 1981. Since then, similar motherboard components have been part of configurations for many reasons, especially when no visual feedback is available:

  • fault notifications
  • device issue signals
  • keyboard problem
  • failure code signaling
  • user-driven notifications

Even if the sound produced by the PC speaker is usually no more than a beep, also called a bell, there are times when we might prefer to avoid any noise coming out of the system. Although pre-boot procedures doing so is up to the hardware, Basic Input/Output System (BIOS), or Unified Extensible Firmware Inteface (UEFI) configuration, like any other device, we can also control the PC speaker from the operating system (OS).

3. Using Shells and Terminals to Control Beeps

While interfaces can have their own triggers, to produce a beep, we can get a raw terminal to output a certain character, thereby producing a beep: bell, i.e., \a, \007.

Owing to the fact that it’s a character, the bell can be intercepted at several levels when using interactive terminals and interfaces.

3.1. X Server xset

The Xorg server has its own configuration for many features. One example is the beeping, which can be controlled via xset:

$ xset b off

Here, we use the b subcommand to turn off the [b]ell. Using this option, we can even control the volume, pitch, and duration of the sound if needed.

3.2. Terminal Emulators

Due to the nature and function of a terminal emulator, it can preliminarily interpret and change the effect of a . Because of this, many terminal emulators include a setting that can control the bell or beeping within the application.

Specific settings are usually available in the manual or from the interface of the chosen emulator.

For example, the GNOME Terminal has the Preferences > Profiles > myprofile > Text (tab) > Terminal bell setting.

3.3. setterm

At the TTY level, we can use a command like setterm to modify the bell:

$ setterm --bfreq=0
$ setterm --blength=0

In particular, we can employ –bfreq to set the frequency of the bell sound to 0, effectively disabling it. Alternatively, we can do the same for the length with –blength.

3.4. inputrc and bell-style

Shells employ specific libraries to handle input. In fact, the keyboard or stdout are often the source of PC speaker activation. Using the shell libraries to modify the effect of the character is at least a partial solution to disable beeping altogether.

Like other rc files, inputrc is a configuration file with runnable commands that usually gets sourced automatically. In particular, inputrc contains settings for the readline library, which handles input in Bash and other shells:

$ cat $HOME/.inputrc
$include /etc/inputrc
"\C-p":history-search-backward
"\C-n":history-search-forward

set colored-stats On

In this case, we include several commands in the local $HOME/.inputrc:

To be clear, there is usually a base global version of inputrc at /etc/inputrc, but each user is free to ignore that within their local $HOME/.inputrc file.

Among the options that we can place in inputrc is bell-style with several possible values to control its behavior when it comes to readline:

  • none – disable beeping
  • visible – show only a visible icon, if available
  • audible – produce a beep when requested

So, we can choose our preference and add it to our local inputrc file:

$ echo 'set bell-style none' >> $HOME/.inputrc

This way, we control what does for sessions within a given user’s environment. Now, let’s explore a more global and permanent solution.

4. Using ALSA to Control Bell Volume

The Advanced Linux Sound Architecture (ALSA) driver framework controls many aspects of sound production within Linux.

To leverage its functionality, we can install the alsa-utils package via apt:

$ apt install alsa-utils

After doing so, we should have the alsamixer command available:

$ alsamixer
[...]
┌──────────────────────────── AlsaMixer v1.2.8 ─────────────────────────────────┐
│ Card: HDA Intel                                  F1:  Help               │
│ Chip: Realtek ALC666                             F2:  System information │
│ View: F3:[Playback] F4: Capture  F5: All         F6:  Select sound card  │
│ Item: Master [dB gain: -30.00, -30.00]           Esc: Exit               │
│                                                                          │
│     ┌──┐        ┌──┐         ┌──┐        ┌──┐        ┌──┐        ┌──┐      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │  │        │  │        │  │        │  │        │  │        │  │      │
│     │▒▒│        │▒▒│        │▒▒│         │▒▒│        │▒▒│        │  │      │
│     │▒▒│        │▒▒│        │▒▒│         │▒▒│        │▒▒│        ├──┤      │
│     │▒▒│        │▒▒│        │▒▒│         │▒▒│        │▒▒│        │MM│      │
│     └──┘        └──┘        └──┘         └──┘        └──┘        └──┘      │
│    17<>17      17<>17      15<>15      17<>17      15<>15       0<>0     │
│  < Master >     Synth       Line         CD          Mic        Beep     │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────────────┘

Depending on the configuration, alsamixer can show a Beep component, which controls the volume of the PC speaker beep.

After using the arrow keys to change the Beep volume, we can store our settings with alsactl:

$ alsactl store

Usually run as root, the store subcommand of alsactl ensures sound driver settings persist on reboots.

Since this solution depends on the audio device and driver, we might not always be able to limit beeping with alsamixer.

5. Using Kernel Modules to Disable Linux Bell

Perhaps one of the most extreme measures to disable any functionality is to uproot it from the kernel.

In particular, we can unload a kernel module:

$ modprobe --remove pcspkr

In this case, we –remove (-r) the pcspkr module via modprobe to disable any use of the device. While there are alternative names for the module, like snd_pcsp, the choice depends on the kernel version and Linux distribution.

To persist these settings even after a restart, we can automate the module handling at boot:

$ echo 'blacklist pcspkr' > /etc/modprobe.d/nobeep.conf

At this point, we disabled and added the pcspkr module to the blacklist of modules that the kernel shouldn’t load, thereby disabling beeping for any reason after the kernel loads.

6. Using BIOS and UEFI to Disable Machine Beep

Of course, at the lowest level, any device is controlled by the motherboard. In fact, the BIOS or UEFI code and settings can prevent devices from being used within the operating system.

While there are varying interfaces and settings to control and disable the PC speaker in particular, most contain specific keywords:

  • Power Beep
  • Power Control Beep
  • System Beep

In many cases, these settings are under sections like Configuration or Others.

Yet, even if we disable the bell pre-boot, fatal problems when starting a machine would probably still be indicated by beeping since that can remain as the only notification mechanism for failure codes.

7. Summary

In this article, we talked about the PC speaker, its audio notification, and how to turn it off.

In conclusion, even though the rudimentary motherboard beeping can be very helpful, we might sometimes want to disable or replace its behavior within Linux.