Question. I am running a Linux system (Ubuntu) system. Its root user has 100K emails to their mailbox. How do I remove all emails from the root mailbox? How can I remove all emails using shell prompt on Linux system?

This tutorial will help you delete all root user emails from the shell in the Linux system. Here you will find two methods to remove user emails in a Linux system with a single command.

Method 1:

You can simply remove all emails of root or any other user on the Linux system using the following command.

echo 'd *' | mail -N

Method 2:

You can also empty the mailbox file for any user. Generally the Linux system keeps the email under /var/mail/root or /var/spool/mail/root (for root account).

> /var/mail/root
> /var/spool/mail/root

For any other user on the Linux system, Simply change the root with the other username.