Disable PC speaker

If you recycle an old desktop machine into a ‘home’ server, maybe you have a machine with a PC speaker. To disable this annoying little thing:

  • unload the pcspkr module: rmmod pcspkr
  • blacklist the module to prevent udev from loading it:
# echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf

[Bash] PS1 eye-candy

Bash has several prompts which can be customized:

  • PS1 is the primary prompt which is displayed before each command
  • PS2 is the prompt displayed when a command needs more input (e.g. a multi-line command)
  • PS3 is the prompt displayed for Bash’s select built-in which displays interactive menus
  • PS4 is the prompt displayed when debugging bash scripts to indicate levels of indirection

Customizing PS1

Personally i like the change the PS1 color depending the type of the machine i’m logged on. Green for ‘standard’ host, red for ‘production’, purple for ‘production VM’, etc…

vi /root/.bashrc
# add the following snippet:

########################
# Customize PS1 Prompt #

# Bold Red
# COLOR='01;31m'
# Red
# COLOR='00;31m'
# Green
# COLOR='00;32m'
# Bold Green
COLOR='01;32m'
# Yellow
# COLOR='00;33m'
# Purple
# COLOR='00;35m'
# Light blue
# COLOR='00;36m'

# Debian stuff - Add a tag if we are in a chroot
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
fi

# PS1 variable
PS1="${debian_chroot:+($debian_chroot)}\[\033["$COLOR"\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "