[sf-lug] system beep (& console & sudo & at/batch & shell)

Michael Paoli Michael.Paoli at cal.berkeley.edu
Sun Jan 24 00:16:58 PST 2010


These work (presuming relevant sudo access privileges):
$ sudo sh -c 'echo -ne '\''\007'\'' >> /dev/console'
$ echo -ne '\007' | sudo sh -c '>>/dev/console exec cat'

The privileged bit needed, is opening /dev/console for writing
(or appending) by UID (e.g. 0) that can open /dev/console for writing.

If that's to be done via sudo and shell redirection,
that redirection needs to be part of the sudo command, not
something that's interpreted by the shell before sudo is executed.

Also (from earlier bits on the topic/thread), I wouldn't recommend
making /dev/console world writable.  One could set up
specific script or program, and sudo configuration to have
something that writes a single ^G charater to /dev/console, and
does nothing else.

Of the examples I gave, something that only permits:
$ sudo sh -c 'echo -ne '\''\007'\'' >> /dev/console'
is more secure and would be a preferred approach.

http://en.wikipedia.org/wiki/Principle_of_least_privilege

> Date: Tue, 12 Jan 2010 11:45:09 -0800 (PST)
> From: Alex Kleider <a_kleider at yahoo.com>
> Subject: Re: [sf-lug] system beep
> To: sf-lug at linuxmafia.com, Akkana Peck <akkana at shallowsky.com>
>
> running echo $'\a' >/dev/console is the answer I was looking for.
> The fact that redirection to /dev/console requires root privileges  
> is a fly in the ointment unfortunately.
>
> In the process of playing with this I've discovered that
> sudo echo $'\a' >/dev/console
> DOES NOT work! Somehow the sudo seems only to apply to the echo  
> command, not to the redirection to /dev/console.
> sudo <script that contains the same (redirected) command> does work





More information about the sf-lug mailing list