root tips

Delete all root mail / inbox on Linux / Unix from a shell prompt

install mail command on Linux

Type the following yum command on a CentOS/RHEL to install the same:

sudo yum install mailx


Use the following dnf command on a Fedora Linux to install it:

sudo dnf install mailx


Try the following apt command/apt-get command on an Ubuntu or Debian system:

sudo apt install mailutils

How do I read my mail messages from the CLI on Linux?

Simply type the following command:

mail

OR

mailx

delete root user’s mailbox/inbox file in Linux or Unix

Simply type the following command at shell prompt to delete all root mail:

> /var/spool/mail/root


Verify it with the following command or cat command or ls command:

mail

cat /var/spool/mail/root

ls -l /var/spool/mail/root


 Remove root user’s email every day using cron job

Simply run the following cron job:

@daily > /var/spool/mail/root