Archive

Posts Tagged ‘Linux’

Disable the System Beep in Ubuntu Linux

November 5, 2010 Leave a comment
  • Materials Needed: A computer running Ubuntu Linux (may work with other distros)
  • Time: 5 minutes

There are three four simple ways to disable the system beep in Ubuntu. They are: Permanently for all users with a blacklisted module, Permanently for all users using inputrc, Permanently for a specific user, and Temporarily disable the beep. I will go over each of these three methods in this Wiki entry. If you are not sure which method you wish to use, I recommend permanently disabling the speaker for all users with a blacklisted module.

Permanently, for All Users (Blacklisted Module)

After initially writing this guide, I learned that Ubuntu allows you to use a text file in the /etc/modprobe.d/ directory to blacklist or enable modules as needed. I found this way to be the easiest and most robust way to turn off the system beep, and will be turned off from the moment your system boots up. To create a blacklisted module, simply open up a terminal (its under accessories in Ubuntu’s Applications menu) and type:

sudo echo blacklist pcspkr > /etc/modprobe.d/blacklist-pcspkr.conf

Here’s what this command does:

  • sudo: Use this command to perform a task as the Super User. This gives us permission to create a file in the modprobe.d directory. You will probably have to put in your password before it will execute the command. If you don’t have access to the sudo command, you’ll have to contact your system administrator.
  • echo: This command will print whatever follows it to the terminal screen (or as we’ll see in a moment, to a file).
  • blacklist pcspkr: This is the command that tells linux to blacklist (aka. do not load) the pcspkr module on startup. In other words, this will keep the system speaker from ever starting up, which means there is no way for Ubuntu to beep at you.
  • >: This symbol says to take the output of whatever command is on the left-hand side of it (in this case, our echo command) and write it to a file specified on the right-hand side of it (in this case /etc/modprobe.d/blacklist-pcspkr.conf).
  • /etc/modprobe.d/blacklist-pcspkr.conf: The file path where we will be storing our command to blacklist the pc speaker module.

With this one command, you will never have to deal with a system beep again. Some of you may be wondering if this will also turn off your speakers that you use to listen to sounds/music on your computer. The answer is no. They should continue working without any problems.

Permanently, for All Users (inputrc)

If you want to permanently disable the beep for all users on the system, you will need to edit the system’s inputrc file. To do this, open a terminal and type:

sudo nano /etc/inputrc

For those of you not familiar with bash commands, we’ll take a moment to explain what’s going on here:

  • sudo: This allows you to execute this command as a Super User. Since we are editing the system’s version of this file, we will need Super User privileges.
  • nano: This is a really simple command-line text editor. You can substitute this editor for any other text editor that you would prefer to use (I like Vim myself). If you don’t know about any other text editors, or if you have no idea what I’m talking about, you should probably stick to nano.
  • /etc/inputrc: This is the path to the file you are going to edit.

Once the editor opens your inputrc file, type the following command:

set bell-style visible

Again, we’ll go over this command:

  • set bell-style: This tells the system that we are going to change the way the system notifies us of an error. By default, it is set to beep at you.
  • visible: This tells the system what to do instead of beeping at you. Visible will cause the system to cause the window you are in to flash instead of beep. If you don’t want it to do anything, substitute the word none.

One should also note that in later versions of Ubuntu, this line of code is already in the file and is just commented out (made so it won’t run) by a # at the beginning of the line. Instead of typing the command, you can simply find the correct line and delete the # at the beginning.

Save the file (in nano, you push ctl-x, then enter y to indicate you want to save the changes) and restart your computer.

Permanently, for a Specific User

Follow the same steps for the “All Users” method as specified above, but instead of typing the command to edit the generic /etc/inputrc file as previously mentioned, edit/create the one in the user’s home directory. To do this, type:

nano ~/.inputrc

This file will override the generic file previously mentioned, but only for the user that is logged in when you edit the file, so you can have the default bell-style be set to one type, and your current user to another. Again, the rest of the steps are exactly the same as above.

Temporarily Disabled

If you only want to disable this temporarily (only when you go to the library for example), you can use this method. Open a terminal and type the following two commands:

xset b off
xset b 0 0 0

These two commands together will basically tell the system to turn off the bell, but it will be turn back on the next time you restart your computer.

Advertisements