In Linux operating system such as Red Hat Enterprise Linux (RHEL), CentOS and Ubuntu, the following error may occur mail when running mail command to access a mailbox, maildir, mail file:

-bash: mail: command not found

The error simply means that the mail package is not installed or the mail script is not present on the system. To resolve the issue, install the mailx or mailutils package. Mailx is an enhanced mail command, which provides the functionality of the POSIX mailx command, as well as SysV mail and Berkeley Mail from which it is derived. Mailx is available for RHEL, CentOS, Scientific Linux or their variants. Meanwhile, Mailutils provides a set of useful mail libraries, daemons, clients and servers for delivering and reading electronic mail, and is available in Debian, Ubuntu or their variants.

Depending on the Linux distribution you’re using, use one of the following command to install the mailx.

Red Hat / CentOS / Scientific Linux

yum -y install mailx

Debian / Ubuntu

sudo apt-get install mailutils

Mail Command Not Found