How to emit sound using built-in speaker from a command line in Windows and Linux?

  • 3
    What operating system? – arathorn Jul 24 '09 at 16:08
up vote 9 down vote accepted

You can call the Win32 MessageBeep operating system function.

On Windows XP or later, type:

rundll32 user32.dll,MessageBeep

I tried it years ago and at first I didn't believe it would work. But that's Microsoft suggested way, as according to their MSDN website:

"...MessageBeep attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker."

With bash on Unix:

echo $'\007'

On *nix operating systems beep used to do it.


beep [ -v ] [ -X | -T | -S ]


beep is a command-line utility for making a computer go beep.

Under normal circumstances, you should be able to use it just by typing ‘beep’, with no options.

Echo ^g 

where ^ is the ctrl key. Note this doesn't work on Windows 7 - The beep is redirected to the audio system.

  • hey, it works on Windows 7!!!! I think for some motherboards that does not have internal speaker or that it is disabled on sound properties it will not beep. but I tested and functioned!!! but use CTRL instead of "^" character. I don't know the difference, but... – kokbira May 10 '11 at 20:08

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.