Remotely make the computer beep on built-in speaker

28

9

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.

wsd

Posted 2009-09-27T16:30:57.150

Reputation: 403

1@CiroSantilli新疆改造中心六四事件法轮功 this question is older than any of those. – wsd – 2018-10-22T23:20:54.847

@wsd I did not imply duplicate and the current consensus is to close by "quality": http://meta.stackexchange.com/questions/147643/should-i-vote-to-close-a-duplicate-question-even-though-its-much-newer-and-ha Since "quality" is not measurable, I just go by upvotes. ;-) Likely it comes down to which question hit the best newbie Google keywords on the title.

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2018-10-23T06:40:23.020

@CiroSantilli新疆改造中心六四事件法轮功 thank you for the clarification :) – wsd – 2018-10-23T20:15:30.777

11

I hope your question isn't really this cartoon at work: http://xkcd.com/530/

– Telemachus – 2009-09-27T19:44:05.527

Answers

24

Try:

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

John T

Posted 2009-09-27T16:30:57.150

Reputation: 149 037

This is the easiest solution! Also, sorry for only accepting 9 years late. – wsd – 2018-10-22T23:23:54.380

This works well on CentOS / RHEL, I couldn't find any beep packages. – plasmid87 – 2012-03-29T15:38:04.237

This worked while the beep command did not. I just set this to run on a coworkers machine. for i in seq 1 10000; do echo -e '\a' > /dev/console; sleep 1; done – Nick Stinemates – 2009-09-28T21:08:14.903

Didn't make a sound. – Nick Stinemates – 2009-09-28T23:07:09.123

@NickStinemates Make sure you have a PC speaker on your motherboard – dykeag – 2013-03-28T23:15:02.103

14

first:

modprobe pcspkr

then solutions from topic, like

ssh user@host
beep

maizy

Posted 2009-09-27T16:30:57.150

Reputation: 140

(As for the modprobe: see how to get beep working? for some details.)

– Arjan – 2011-01-13T12:56:56.020

I needed to sudo modprobe pcskr – IanVaughan – 2014-02-17T22:29:06.510

6

From the beep man page on my Ubuntu machine:

IOCTL WACKINESS

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.

user4358

Posted 2009-09-27T16:30:57.150

Reputation:

3

This command will do the trick:

modprobe pcspkr; echo -e "\a" > /dev/console;

Sayajin

Posted 2009-09-27T16:30:57.150

Reputation: 31

3

You can use:

ssh user@remote-machine
sudo sh -c "echo -e '\a' > /dev/tty1"


Note that the following would not work. It fails before even prompting for the sudo password because the (bash) shell is doing the redirection, and that shell still runs as the normal user, not as root:

ssh user@remote-machine
sudo echo -e '\a' > /dev/tty1
-bash: /dev/tty1: Permission denied
ls -la /dev/tty1
crw------- 1 root root 4, 1 2009-09-28 16:33 /dev/tty1

Thomas

Posted 2009-09-27T16:30:57.150

Reputation: 423

3

Just type

ssh user@remote-machine
beep

Tested on Ubuntu Desktop 8.x, this will beep on the remote server, even if no local session on that server is active (thus: even if the GNOME login screen is shown on the monitor attached to the server).

Have a look at

man beep

for more details. On Debian/Ubuntu, the beep package has to be installed and the speakers must not be muted.

Kim

Posted 2009-09-27T16:30:57.150

Reputation: 2 238

I wonder why you wrote "the speakers must not be muted". My Ubuntu Desktop box has no sound drivers installed, and indeed both beep and the echo options all use my built-in speaker. Though man beep clearly states "beep the pc speaker any number of ways", I have not verified what happens if one has sound drivers installed. – Arjan – 2009-09-27T22:36:18.143

At least on my pc I can mute the speakers with gnome-volume-control. And since I can't stand the beeping, I usually do. – Kim – 2009-09-28T03:15:06.373

So, then beep does not use the built-in speaker on your system? Or does the volume control (which is disabled on my Ubuntu box) also control the built-in speaker? Might be fun to see if the echo solutions behave different than. – Arjan – 2009-09-28T09:19:38.773

gnome-volume-control can be used to control the built-in speaker separately. What do you mean by disabled? What happens when you run gnome-volume-control from a command line? – Kim – 2009-09-28T16:14:40.830

Sorry, just wiped out that 10.8 install. Disabled as in: no sound drivers installed, and therefore a stop-sign on top of the sound-icon in the GNOME menu. – Arjan – 2009-09-28T21:23:49.877

0

Run a remote command to the remote machine:

rsh hostname /usr/bin/echo '\a'
or
ssh user@remotehost /usr/bin/echo '\a'

harrymc

Posted 2009-09-27T16:30:57.150

Reputation: 306 093

Wouldn't one need the redirection to some remote terminal like Thomas suggested, to get the remote server to beep, rather than the local SSH client? – Arjan – 2009-09-27T20:19:37.560

One can also do : echo "\a" > 'tty'. – harrymc – 2009-09-28T06:18:17.093

echo -e "\a" > /dev/tty surely would beep on the SSH client, not on the built-in speaker on the server :-) tty0, tty1 and console seem to work, as shown in other answers. – Arjan – 2009-09-28T14:05:36.753

0

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.

dangelov

Posted 2009-09-27T16:30:57.150

Reputation: