Bash: mail: command not found (CentOS, Redhat, Ubuntu and Debian)

Channel: Linux
Abstract: send a test email using the below command. echo "Message Body" | mail -s "Message Subject" [email protected]Sending Test Email After installing mail c

With the minimum installation of any Linux operating system, you will not see most of the commands in your system. In minimum operating system installation only required packages are installed for running an operating system and skipped unnecessary packages are. mail command is useful for sending emails from the Linux command line which is used for almost Linux operating systems. Most Debian-based systems will show errors like 「The program ‘mail’ is currently not installed. You can install it by typing」

There are many other alternatives to mail command for sending emails from Linux command line interface.

Installing mail Command

Let’s use one of the below commands to install the mail command as per your operating system. For RHEL based systems, this command installed from mailx rpm packages and on Debian based system this command found in mailutils package.

Execute one the following command based on the operating system:

  • Install mail command on CentOS/Redhat 7/6
    sudo yum install mailx 
    
  • Install mail command on Fedora 22+ and CentOS/RHEL 8
    sudo dnf install mailx 
    
  • Install mail command on Ubuntu/Debian/LinuxMint
    sudo apt-get install mailutils 
    
  • Sending Test Email

    After installing mail command packages in your system, send a test email using the below command.

echo "Message Body" | mail -s "Message Subject" [email protected]  

Ref From: tecadmin
Channels: mailbash

Related articles