Home » Questions » Computers [ Ask a new question ]

Remotely make the computer beep on built-in speaker

Remotely make the computer beep on built-in speaker

How can I remotely (SSH) make my Linux Computer Beep (built-in speaker, as there are no external ones)? I have ubuntu 9.04 and can install extra packages if need be. This would be good for finding a certain box if you have more than one standing around and forgot which IP is which box.

Asked by: Guest | Views: 70
Total answers/comments: 5
Guest [Entry]


sudo sh -c ""echo -e '\a' > /dev/console""

You may have to load the kernel module for the built-in speaker first (e.g. if the module was blacklisted from auto-loading):

sudo modprobe pcspkr"
Guest [Entry]

"From the beep man page on my Ubuntu machine:


Some users will encounter a
situation where beep dies with a
complaint from ioctl(). The reason
for this, as Peter Tirsek was nice
enough to point out to me,
stems from how the kernel handles
beep’s attempt to poke at (for
non-programmers: ioctl is a sort of
catch-all function that lets you
poke at things that have no other
predefined poking-at mechanism) the
tty, which is how it beeps. The
short story is, the kernel
checks that either:

you are the superuser
you own the current tty

What this means is that root can
always make beep work (to the best of
my knowledge!), and that any local
user can make beep work, BUT a non-root remote user cannot use beep in
it’s natural state.

This could well be the reason why beep refuses to work remotely. You can check if this is the root cause by invoking ssh with the -t option, which forces pseudo-tty allocation.

A less desirable solution would be to create a wrapper script that executes beep, and grant this script root permissions. If executing this script over ssh duly produces a beep, you'll know that the issue is the lack of a controlling terminal."
Guest [Entry]

"This command will do the trick:

modprobe pcspkr; echo -e ""\a"" > /dev/console;"
Guest [Entry]

"Run a remote command to the remote machine:

rsh hostname /usr/bin/echo '\a' or ssh
user@remotehost /usr/bin/echo '\a'"
Guest [Entry]

"Or, you could simply run the following once:

chmod o+x `which beep`

This will allow all users to use the beep executable, which probably is safe enough in most cases."