speednow
asked on
How to empty Email of an User in redhat
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.
Servers using Sendmail.
Access: SSH
Dont know what commands to execute and know how much email does that account has.
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
Sorry, the cat command should be:
cat /dev/null > /var/spool/mail/username
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
fpintos
what do you think my use of ssh does?
Friedrich
what do you think my use of ssh does?
Friedrich
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.
Friedrich,
ssh your_remote_login@remote_l ocation "sh -c > /var/mail/login_name"
will give sh: -c: option requires an argument........
ssh your_remote_login@remote_l
will give sh: -c: option requires an argument........
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.
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.
So you can run a
ssh your_remote_login@remote_l
or
ssh your_remote_login@remote_l
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