Disable Terminal Beep/Bell Sound on CentOS 7 and RHEL 7

Shahriar Shovon

Supported OS

  • CentOS 7 - CentOS
  • RHEL 7 - Maipo

Categories

Share this post with your friends

In this article, I will show you how to disable the annoying Terminal beep/bell sound on CentOS 7 and Red Hat Enterprise Linux 7 (RHEL 7). Let's get started.

Disable Terminal Beep/Bell Sound Using the ~/.inputrc File

Using the ~/.inputrc file, you can disable terminal beep sound or the audible bell for your login user. Most of the time, it is enough. If you don't want to turn off audible bell or the terminal beep sound system wide, then this is the best approach that you can take. On a later section of this article, I will show you how to disable the audible bell or terminal beep sound system wide. An ~/.inputrc file may already exist in your users HOME directory. If it doesn't exist, then you can easily create it with the following command. touch ~/.inputrc Now add the following line to the end of the file to disable the audible bell or the annoying beep sound on CentOS 7 and RHEL 7: set bell-style none You can run the following command to easily add the above line to the end of the ~/.inputrc file: echo 'set bell-style none' >> ~/.inputrc Now open a new terminal or reboot your computer for the changes to take effect. The command to reboot your computer is: sudo reboot

Enable Terminal Beep/Bell Sound Using the ~/.inputrc File:

If you've disabled the terminal beep/bell sound using the ~/.inputrc file, you can enable the terminal beep/bell sound again very easily. If your ~/.inputrc file only contains the terminal bell disabling command, then you can simply remove the ~/.inputrc file with the following command: rm -v ~/.inputrc If your ~/.inputrc file contains other configuration commands, then you can just edit the ~/.inputrc file and remove the following line: set bell-style none Edit the ~/.inputrc file with the following command: vi ~/.inputrc Now go to the line that you want to delete, and press dd Now type in the following command and press enter to save the file: :wq! Now reboot your computer with the following command: sudo reboot The terminal bell should be enabled again.

Disable Terminal Beep/Bell Sound System Wide

pcspkr kernel module is responsible for the terminal beep sound. You can stop the pcspkr module from loading when your computer boots to disable terminal beep sound system wide. There are 2 approaches you can take, you can either blacklist the pcspkr kernel module, or you can install the kernel module to /dev/null. Either approach will work and I will show you both in this section. Way 1: Blacklisting the pcspkr Kernel Module: First create a new file /etc/modprobe.d/bell.conf with the following command: sudo touch /etc/modprobe.d/bell.conf Now to blacklist the kernel module run the following command: echo 'blacklist pcspkr' | sudo tee /etc/modprobe.d/bell.conf Now reboot your computer with the following command: sudo reboot Way 2: Installing pcspkr Kernel Module to /dev/null: First create a new file /etc/modprobe.d/bell.conf with the following command: sudo touch /etc/modprobe.d/bell.conf Now run the following command: echo 'install pcspkr /dev/null' | sudo tee /etc/modprobe.d/bell.conf Now reboot your computer with the following command: sudo reboot The terminal beep sound should never annoy you anymore.

Enable Terminal Beep Sound System Wide:

If you've disabled the terminal beep sound system wide by disabling the pcspkr kernel module, then enabling it is as simple as deleting the /etc/modprobe.d/bell.conf modprobe configuration file. Remove the /etc/modprobe.d/bell.conf file with the following command: sudo rm -v /etc/modprobe.d/bell.conf Now reboot your computer with the following command: sudo reboot The terminal beep sound should be enabled system wide. Thanks for reading this article.