mail command not found in Red Hat CentOS Ubuntu Debian

You may have encounter with mail command not found in Red hat, CentOS, Rocky Linux, Ubuntu, Debian .Whenever any message says while hitting the command as Command Not Found , it means the package is not installed or script is not present.

We use mail command to send the email from the terminal. It is quite useful command and we often use in bash scripting.

Install Mail Command In Redhat / CentOS /Rocky

Login to terminal and run the given below command. You must have super user permission to run the given below command.

sudo yum install mailx
OR
sudo dnf install mailx

Install Mail Command In Debian / Ubuntu

sudo apt-get update
sudo apt-get install mailutils
OR
sudo apt update
sudo apt install mailutils

You can verify installed package by finding its absolute path. Use the command –

which mail

Test Mail Command By Sending E-Mail

Now in this example we will show how you can use the mail command to send the e-mail from the terminal. If you have not found the e-mail in inbox, probably it is in spam folder(This is a quite different and security related discussion but for test just use it).

echo "MessageThis is a test mail" | mail -s "Subject: This is a test email by mail command" email-id-receiver@example.com

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.