linux通过打开或关闭beep来允许是否让其通过命令行控制发出beep sound。
加载pcspkr模块打开beep
[root@localhost ~]# lsmod |grep pcspkr [root@localhost ~]# echo -en "\a" [root@localhost ~]# echo -en "\a" > /dev/console [root@localhost ~]# modprobe pcspkr [root@localhost ~]# lsmod |grep pcspkr pcspkr 2000 0 [root@localhost ~]# echo -en "\a" [root@localhost ~]# echo -en "\a" > /dev/console
卸载pcspkr模块关闭beep
[root@localhost ~]# rmmod -v pcspkr rmmod pcspkr, wait=no [root@localhost ~]# rmmod -v pcspkr ERROR: Module pcspkr does not exist in /proc/modules
永久禁止加载pcspkr模块
[root@localhost ~]# tail -1 /etc/modprobe.d/blacklist.conf blacklist pcspkr 下面是可选步骤 [root@localhost ~]# tail -1 /etc/rc.d/rc.local /sbin/rmmod pcspkr
试验:
可在加载或卸载pcspkr模块后,进行下面试验,你会得到不一样的效果。(当然,你也可以把数字加大,如把10000变为20000或者是一个你想要的数字)
[root@localhost ~]# for i in {1..10000};do echo -en "\a" >/dev/console;done [root@localhost ~]# for i in {1..10000};do echo -en "\a";done