3 ms·
Nitpick: on my machine, that's: sudo echo -e "\07"
by dblotsky 9y ago
Nitpick: on my machine, that's:
sudo echo -e "\07"
- FreeFull 9y agoSimply displaying a character doesn't need sudo at all anyway, so just echo -e "\07"
- laumars 9y ago`sudo` isn't there for displaying the character, it's there for ioctl to have permissions to play the beep on remote terminals[1]. I think some terminal emulators (eg Konsole) will just read char 7 and play a system defined WAV or other workaround but your more classic terminals (eg xterm) would potentially have difficulties calling the system bell. [1] for reference: Xorg terminals are also classed as remote terminals (eg check the TTY column in `w` to see how Linux assigns pseudo-tty's to terminal emulators inside X).
- FreeFull 9y agoEven in that case, you'd have to run the terminal as root. Running echo as root won't do anything. X11 also has beep functionality built in, which is what I'd expect xterm to use.
- laumars 9y ago> Even in that case, you'd have to run the terminal as root. Running echo as root won't do anything. To be honest that was my assumption as well but I didn't test that theory so was only reporting on the rationale of the GPs post > X11 also has beep functionality built in, which is what I'd expect xterm to use X11 runs as root though (that said Xorg may not anymore now as there were talks about patching Linux so it didn't have to be) so Xorg could easily still use the standard ioctl bell (that's possibly all Xorg is doing behind the scenes in fact?) But as I said earlier, some GUI terminal emulators avoid ioctl entirely and play a WAV tone instead.
- jwilk 9y ago"echo -e" is not portable, and neither are any escape sequences for echo. The portable way to print ASCII BEL is: printf '\a'