/etc/aliases: Explanation & Insights
Defines email aliases
In a Linux or Unix-based operating system, /etc/aliases is a file that contains a list of email aliases, which are
used to redirect email messages from one user or address to another. The /etc/aliases file is read by the
mail transfer agent (MTA) on the system and allows for the creation of custom email addresses without having to
create a new user account.
Here are some examples of how the /etc/aliases file can be used:
Redirecting email to another user:
root: user@example.com
In this example, all email messages that would normally be sent to the root user will be redirected to the
user@example.com address instead.
Creating a mailing list:
sales: user1@example.com, user2@example.com, user3@example.com
In this example, any email messages sent to the sales address will be forwarded to the three listed email addresses.
Creating a custom email address:
support: user@example.com
In this example, any email messages sent to the support address will be forwarded to the user@example.com address.
Creating an email filter:
junk: /dev/null
In this example, any email messages sent to the junk address will be deleted without being delivered to any user.
It's important to note that after making changes to the /etc/aliases file, the newaliases command must be run in
order for the changes to take effect. This command rebuilds the alias database used by the MTA.