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

‮.www‬lautturi.com
Delete all root mail / inbox on Linux / Unix from a shell prompt

To delete all the emails in the root mailbox on a Linux or Unix system, you can use the mail command and the d flag to delete each email one by one, or you can use the rm command to delete the entire mailbox file.

Here's an example of how to delete all the emails in the root mailbox using the mail command:

$ mail
& mail
No mail for root
&

If the root mailbox is not empty, you will see a list of the emails in the mailbox. To delete an email, type d followed by the number of the email you want to delete, and then press Enter. Repeat this process for each email in the mailbox until it is empty.

Here's an example of how to delete all the emails in the root mailbox using the rm command:

$ rm /var/spool/mail/root

This will delete the entire root mailbox file, including all the emails it contains. Be aware that this will permanently delete the emails and there is no way to recover them.

Note that the exact location of the root mailbox file may vary depending on your system configuration. In some systems, it may be located in a different directory, such as /var/mail/root or /var/spool/mail/root. You will need to use the correct path for your system.

Created Time:2017-10-28 14:02:27  Author:lautturi