Many FreeBSD system administrators using bash as their login shell encounter the "You have new mail in /var/mail/root" notification repeatedly, even after attempting standard solutions. This message appears at login or periodically during shell sessions when the system mail directory contains messages.
The most common solution found in documentation suggests adding:
unset MAILCHECK
to either ~/.bashrc
or ~/.profile
. However, in FreeBSD specifically, this often doesn't work because:
- FreeBSD's bash configuration loads files in a specific order
- System-wide settings might override user configurations
- The mail notification system is handled differently than in Linux
Method 1: Complete Mail Check Disable
For permanent disabling across all sessions:
echo "unset MAILCHECK" >> /root/.bash_profile
echo "unset MAIL" >> /root/.bash_profile
Then reload your shell or source the file:
source ~/.bash_profile
Method 2: Empty the Mail File
To both clear existing notifications and prevent future ones:
> /var/mail/root
Make this permanent by adding to root's crontab:
@daily > /var/mail/root
Method 3: System-wide Configuration
For affecting all users on the system:
echo "MAILCHECK=0" >> /etc/profile
echo "MAIL=/dev/null" >> /etc/profile
If you actually need system mail but want it elsewhere:
echo "root: your@email.com" >> /etc/aliases
newaliases
This forwards all root mail to your specified address while keeping the local mailbox empty.
After implementing any solution, test by:
# Send a test mail
echo "Test" | mail -s "Test" root
# Log out and back in
# Should no longer see mail notification
Many FreeBSD administrators encounter the annoying system message "You have new mail in /var/mail/root" upon login. This notification originates from the system's mail checking mechanism, which persists even after attempting standard Bash configuration changes.
FreeBSD's mail notification system operates at multiple levels:
- System-wide settings in
/etc/login.conf
- User-specific shell configurations
- Terminal initialization scripts
Method 1: Disable via Bash Configuration
For a user-specific solution in Bash:
# Add to ~/.bashrc or ~/.profile
unset MAIL
unset MAILCHECK
Method 2: System-wide Disable in FreeBSD
To completely disable mail checking system-wide:
# Edit /etc/login.conf
default:\
:path=/usr/bin /bin:\
:umask=022:\
:mail=/dev/null:\ # This is the critical change
:ignoretime@:\
:datasize-max=512M:\
:datasize-cur=512M:\
:maxproc-max=256:\
:maxproc-cur=128:
After editing, rebuild the login database:
cap_mkdb /etc/login.conf
Method 3: Empty the Mail File
For immediate relief with existing mail:
# Clear root's mail file
cat /dev/null > /var/mail/root
After making changes:
# Log out and log back in
# Check environment variables
env | grep MAIL
# Should return no output if properly unset
For production systems, consider proper mail redirection:
# Add to /etc/aliases
root: yourrealemail@domain.com
Then rebuild aliases:
newaliases