beep

system utilslinux
The beep command is one of the most frequently used commands in Linux/Unix-like operating systems. beep The beep command generates a beep sound through the PC speaker or sound card. It's useful for providing audio notifications or alerts in scripts or terminal applications.

Quick Reference

Command Name:

beep

Category:

system utils

Platform:

linux

Basic Usage:

beep [options] [arguments]

Common Use Cases

  • 1

    System alerts

    Generate audio alerts for system events

  • 2

    Script feedback

    Provide audio feedback in automated scripts

  • 3

    Testing audio

    Test audio system functionality

  • 4

    User notifications

    Notify users of completed tasks or errors

Syntax

beep [options]

Options

Option Description
-f, --frequency Specify the frequency in Hz (default: 440Hz)
-l, --length Specify the length in milliseconds (default: 200ms)
-r, --repetitions Number of times to repeat the beep (default: 1)
-d, --delay Delay in milliseconds between repetitions (default: 100ms)
-n, --new Start a new tone specification after this option
-s, --server Connect to the specified PC speaker server
-D, --device Specify the device to use (default: /dev/input/by-path/platform-pcspkr-event-spkr)
-e, --stderr Generate output to stderr as well as the speaker
-h, --help Display help information
-v, --version Output version information

Examples

How to Use These Examples

The examples below show common ways to use the beep command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

Basic Examples:

Simple beep with default settings
beep
Beep with specific frequency (1000 Hz) and duration (500 ms)
beep -f 1000 -l 500
Multiple beeps with delay between them
beep -r 3 -d 100
Play a simple melody by specifying multiple frequencies
beep -f 262 -l 200 -n -f 294 -l 200 -n -f 330 -l 200

Advanced Examples:

Play "SOS" in Morse code
beep -f 1000 -l 100 -r 3 -d 50 -n -f 1000 -l 300 -r 3 -d 50 -n -f 1000 -l 100 -r 3 -d 50
Play a scale
beep -f 262 -l 200 -n -f 294 -l 200 -n -f 330 -l 200 -n -f 349 -l 200 -n -f 392 -l 200 -n -f 440 -l 200 -n -f 494 -l 200 -n -f 523 -l 400
Use an alternative method with console bell (if beep command is not available)
echo -e "\a"
# Create a notification beep in a script
Example: Beep when a long-running command finishes
long_running_command; beep
Alarm clock example
sleep 300 && beep -r 5 -f 2000 -l 100

Try It Yourself

Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

Understanding Syntax

Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

Notes

Key Features:

The beep command is a versatile tool for generating system sounds:

  • Control over frequency, duration, and repetition of beeps
  • Ability to create sequences of different tones
  • Useful for scripts that need to provide audio notifications
  • Works with the built-in PC speaker on most systems
  • Can be used for simple alerts or more complex patterns like melodies

System Requirements:

  • Requires the pcspkr kernel module to be loaded (modprobe pcspkr)
  • On some systems, you may need to install the beep package (apt install beep)
  • User needs appropriate permissions to access the sound device
  • May require root privileges on some systems

Common Use Cases:

  • Script notifications: Alert when a long-running process completes
  • Error notifications: Audible alerts for error conditions
  • Alarms and timers: Create countdown timers with audio alerts
  • Simple audio feedback: Confirmation of user actions in terminal applications
  • Morse code: Generate SOS or other Morse code patterns

Alternatives:

  • If beep is not available, you can use echo -e "\a" for a simple console bell
  • For more complex sounds, consider using play from the sox package
  • On desktop environments, consider using notify-send with a sound playing utility
  • On modern systems, using paplay or aplay with sound files may be more reliable

Security Notes:

  • The pcspkr module is disabled by default on many distributions for security reasons
  • In shared environments, excessive use can be disruptive to other users
  • Some systems may block access to the PC speaker for non-privileged users

Troubleshooting:

  • If beep doesn't work, check if the pcspkr module is loaded: lsmod | grep pcspkr
  • To load the module: sudo modprobe pcspkr
  • On some systems, you may need to use the -e option to see if the command is working properly
  • Check permissions on the device file if you get permission denied errors

Common Use Cases

System alerts

Generate audio alerts for system events

Script feedback

Provide audio feedback in automated scripts

Testing audio

Test audio system functionality

User notifications

Notify users of completed tasks or errors

System monitoring

Alert administrators to system events or issues

Related Commands

These commands are frequently used alongside beep or serve similar purposes:

Use Cases

1

System alerts

Generate audio alerts for system events

2

Script feedback

Provide audio feedback in automated scripts

3

Testing audio

Test audio system functionality

4

User notifications

Notify users of completed tasks or errors

5

System monitoring

Alert administrators to system events or issues

Learn By Doing

The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the beep command works in different scenarios.

$ beep
View All Commands