As a result of a long-running cron job, I have over 1,000 messages in my user's mailbox. What's the easiest way to delete them?


If you want to delete all the messages, you can simply truncate the mailbox file for a user with the following command:

> /var/mail/username

(the greater than sign is not a prompt: you are in effect redirecting the output of nothing to the file, which will truncate it).

| improve this answer | |

Run mail in a terminal. Press d 1-. This will delete those messages.

Removing files for managing mail is like adjust the volume of your tv with a hammer. It may work, but it is not optimal and far too brutal.

| improve this answer | |
  • This is the correct answer. It also allows deleting just some emails, if it's unclear from the command. E.g. d 1-100 will delete the first 100 email messages. – texnic May 20 '17 at 7:19
  • I had to install mailutils and then use d * on Ubuntu 12.04 – Leslie Viljoen Jul 22 '19 at 3:19

It depends if you have ftp access. If so, just use Nautilus to do a good deal more than any other ftp client. I also use it and Bluefish to edit pages on my websites.

There should be a Mail folder where you can view and delete any and all files.

I find it so much easier than File Manager in cPanel.

| improve this answer | |
  • 2
    You make a lot of assumptions here - like cPanel, ftp access and so on. What do you base these on? – vidarlo May 20 '17 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.