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.
2 Comments
Thanks for such a beautiful post, very informative and useful article
Sometimes I first run commands by hand (on a test system) to find out the right ones, the right order, etc. In cases, I find it useful to automatically document what I type and be able to ‘replay’ it later on.