template:motd

Ever have a system where the admin is required to post a company MOTD

or privacy notice and/or copyright notice?

Those things are pretty pesky and take up a lot of screen real estate in your scroll buffer.

Here's how to remove them.

Place this function in your .profile (or .bashrc, .bash_profile, etc…) and execute it:

os=$(uname -s)
remove_notices() {
  if [ -f /etc/copyright ] ;then
    cr_size=$(cat /etc/copyright | wc -l)
  else
    cr_size=0
  fi
  if [ -f /etc/motd ] ;then
    motd_size=$(cat /etc/motd | wc -l)
  else
    motd_size=0
  fi
  tot_size=$((${cr_size}+${motd_size}))
  blank_lines=''
  i=0
  while [ "${i}" != "${tot_size}" ] ;do
    if [ "${os}" = 'Linux' ] ;then
      blank_lines=`echo -e "${blank_lines}\ncuu1"`
    else
      blank_lines=`echo "${blank_lines}\ncuu1"`
    fi
    i=$((${i}+1))
  done
  tput -S <<-EOF
  ${blank_lines}
  ed
EOF
}
remove_notices

Feel free to place other if conditions for other files like the ones at the top of the function.

  • Your system may call them something else.
  • You might look at /etc/profile to see what gets called at startup.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License