beep
Emit a short audible tone
TLDR
Play a beep
Play a beep that repeats
Play a beep at a specified frequency (Hz) and duration (milliseconds)
Play each new frequency and duration as a distinct beep
Play the C major scale
SYNOPSIS
beep [options]
PARAMETERS
-f, --frequency <Hz>
Specifies the frequency of the beep in Hertz (Hz). Default is 440 Hz (A4 note).
-l, --length <ms>
Sets the duration of the beep in milliseconds (ms). Default is 100 ms.
-r, --repetitions <n>
Determines how many times the beep should repeat. Default is 1.
-d, --delay <ms>
Specifies the delay in milliseconds (ms) between repetitions of the beep. Default is 100 ms.
-n, --no-beep
Prevents the beep from sounding, only printing the calculated parameters to standard output. Useful for testing scripts.
-s, --stdin
Reads parameters from standard input, allowing complex sequences of beeps to be piped to the command.
-c, --continuous
Enables continuous beep mode, ignoring length and delay parameters until interrupted by a signal.
-v, --verbose
Enables verbose output, showing more details about the execution and parameters.
-h, --help
Displays a help message and exits.
-V, --version
Prints version information and exits.
DESCRIPTION
The beep command allows users to generate audible signals through the computer's internal PC speaker. Unlike modern audio playback utilities that rely on sound cards and complex audio drivers, beep directly interacts with the rudimentary PC speaker, producing simple square wave tones. It's often used in shell scripts for basic notifications or alerts in environments where a graphical user interface is not present or desired, such as servers or embedded systems. Users can control the frequency, duration, number of repetitions, and delays between beeps, offering a surprising degree of customization for such a basic output device. Despite its simplicity, beep remains a useful tool for system administrators and scripters needing a straightforward, audible cue without external dependencies on complex audio setups.
Historically, the PC speaker was the only built-in audio output on many early computers, making beep a standard way to provide auditory feedback. While less common on modern laptops and desktops that often lack a physical PC speaker or have it disabled, its functionality persists via kernel modules like `pcspkr` that emulate or provide access to this legacy hardware.
CAVEATS
The beep command relies on the presence and accessibility of a PC speaker. Many modern computers, especially laptops, do not have a physical PC speaker installed, or it might be disabled in the BIOS. Furthermore, beep typically requires access to specific kernel modules (like `pcspkr`) and device files (e.g., `/dev/console` or `/dev/input/by-path/platform-pcspkr-event`), which may necessitate root privileges or specific `udev` rules for non-root users. The sound quality is rudimentary (a simple square wave) and not suitable for complex audio playback.
KERNEL MODULE AND PERMISSIONS
For beep to function, the `pcspkr` kernel module must typically be loaded. You can check its status with `lsmod | grep pcspkr`. If it's not loaded, you might need `sudo modprobe pcspkr`. Permissions can also be an issue; ensure the user has write access to the relevant device file (often `/dev/console` or an event device under `/dev/input`). On some systems, `sudo beep` might be required due to these access restrictions.
DISABLING THE PC SPEAKER
If unwanted beeps occur, you can often disable the PC speaker. This can be done in your system's BIOS settings or by blacklisting the `pcspkr` kernel module. To blacklist, create or edit a file like `/etc/modprobe.d/blacklist.conf` and add `blacklist pcspkr`.
HISTORY
The beep command's lineage traces back to early Unix and DOS systems, where the internal PC speaker was often the sole audio output device. It provided a simple, universal mechanism for system alerts and user feedback. Its design reflects the minimalist approach common in command-line utilities: direct interaction with hardware for a specific, straightforward task. As graphical user interfaces and advanced sound cards became standard, beep's prominence waned, but it has maintained its niche for system administration, scripting, and accessibility in console-only environments. Modern implementations often rely on the Linux kernel's `pcspkr` module, which virtualizes or accesses the speaker device, allowing compatibility even on systems where direct hardware access is restricted or managed differently.
SEE ALSO
setterm(1), speaker-test(1), aplay(1), play(1), xset(1)