Introduction
This lesson is about the basic mail plumbing available on many Linux systems.
The main question is:
What is an MTA, and how do aliases and forwarding work on a Linux host without turning this into a full mail-server lesson?
What you should be able to do after this lesson:
- Understand what an MTA does.
- Recognize the names
postfix,sendmail, andexim. - Understand mail aliases and user forwarding.
- Use
mail,mailq,newaliases, and sendmail-compatible commands at a basic level. - Tell the difference between LPIC exam knowledge and full mail-server administration.
Big Idea: The MTA Moves Mail Around
An MTA is a Mail Transfer Agent. Its job is to accept mail and move it toward the next destination.
At beginner level, keep these roles separate:
- MUA: the mail user agent, such as a mail client
- MTA: the program that transfers mail
- aliasing/forwarding: rules that redirect mail locally
For LPIC, you do not need full production mail-server tuning. You need the basic concepts and the simple local tools.
Common MTA Names
You should recognize these names:
postfixsendmailexim
In real life, postfix is very common.
For the exam, the important part is that all three are MTAs you may encounter.
Local Mail and System Mail
Linux systems often use local mail for:
- root notifications
- cron job output
- automated reports
This is why an MTA still appears in LPIC material even if beginners mostly think about webmail and cloud mail services.
Mail Aliases
An alias maps one local mail name to another destination.
Typical example:
- mail to
rootgets redirected to a real admin account
Common alias file:
/etc/aliases
Example idea:
root: admin
After changing aliases, rebuild the alias database:
sudo newaliases
This is one of the most important commands in this objective.
User Forwarding with ~/.forward
A user can forward mail by creating:
~/.forward
Example:
[email protected]
Simple idea:
- aliases are often system-level
.forwardis user-level
Sending or Reading Mail
Basic mail tools vary by distribution, but LPIC expects awareness of commands like:
mail
mailq
mail
This can be used to read or send simple text mail on systems where local mail is configured.
mailq
This shows the mail queue. If messages are waiting, they may be listed there instead of already delivered.
Sendmail Compatibility
Many tools use a sendmail-compatible interface even when the actual MTA is not classic Sendmail.
That is why you may see scripts or commands that call:
sendmail
The key beginner idea is:
- the command interface may be named
sendmail - the actual MTA behind it may be
postfixor another program
A Practical Mental Model
When local mail does not behave as expected, think in this order:
- is an MTA installed?
- is mail being queued?
- does an alias redirect it?
- does
~/.forwardredirect it? - is the host intended to deliver mail locally only, or also externally?
That is enough reasoning for LPIC-1 level troubleshooting.
Practice Step by Step
1) Check which mail tools exist
- Run:
command -v mailcommand -v sendmailcommand -v postfixcommand -v exim - Do not worry if some are missing. Different systems install different mail tools.
2) Inspect aliases
- If the file exists, run:
sudo sed -n '1,80p' /etc/aliases - Look for entries such as
root. - If you change aliases on a test system, rebuild them with:
sudo newaliases
3) Check the mail queue
- Run:
mailq - If there are queued messages, note that they are waiting for delivery.
- If the queue is empty, that is also normal on many small systems.
4) Inspect user forwarding
- Check whether a forward file exists:
ls -la ~/.forward - If it exists, view it:
cat ~/.forward - This tells you whether local mail for the user is redirected elsewhere.
Cheat Sheet
command -v mail
command -v sendmail
mail
mailq
sudo sed -n '1,80p' /etc/aliases
sudo newaliases
ls -la ~/.forward
cat ~/.forward
Test Your Knowledge
Complete the quiz to assess your understanding of this course's concepts.
