[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to empty Email of an User in redhat

Posted on 2006-05-31
8
Medium Priority
?
304 Views
Last Modified: 2013-12-06
Need to empty the email box of a user on a Red Hat 8 Server.

Servers using Sendmail.

Access: SSH

Dont know what commands to execute and know how much email does that account  has.




0
Comment
Question by:speednow
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 16805040
The incoming mail is usually saved in /var/mail or /var/spool for /var/spool/mail  in file names after the login.

So you can run a
ssh your_remote_login@remote_location "sh -c > /var/mail/login_name"
or
ssh your_remote_login@remote_location rm -f /var/mail/login_name

Of course you need an account which is allowed to write that, it's IMHO not a good idea to allow root login (even with ssh) so you could setup sudo on the remote machine to do the actual delting.

Friedrich
0
 
LVL 14

Expert Comment

by:ppfoong
ID: 16805487

By default, the email files are in /var/spool/mail directory, one file per user, filename follows the username.

You can remove the mails by either of the below:

cp /dev/null /var/spool/mail/username
cat /dev/null /var/spool/mail/username
rm -f /var/spool/mail/username

0
 
LVL 14

Expert Comment

by:ppfoong
ID: 16805490

Sorry, the cat command should be:

cat /dev/null > /var/spool/mail/username

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Accepted Solution

by:
fpintos earned 1200 total points
ID: 16806048
The simplest way is use ssh to login to the server and type:

 : >/var/spool/mail/user_login_name

This will empty the user mailbox and leave an empty file behind.
0
 
LVL 24

Expert Comment

by:fridom
ID: 16806323
fpintos
what do you think my use of ssh does?

Friedrich

0
 
LVL 13

Expert Comment

by:prashsax
ID: 16806505
Just one thing to remember, don't just delete all the mails, if possible move them and store it somewhere else for few days. You never know, when the user or someone else will ask for those mails.


0
 
LVL 2

Expert Comment

by:fpintos
ID: 16812760
Friedrich,

ssh your_remote_login@remote_location "sh -c > /var/mail/login_name"

will give sh: -c: option requires an argument........

0
 
LVL 2

Expert Comment

by:fpintos
ID: 16812858
Friedrich,

FYI, you don't need to fork another shell "sh -c" in your remote ssh to empty a file, using the immediate shell (spawn by sshd) and  ":" syntax is faster and more efficient.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question