4

I've found on a couple servers that have the following entry in /etc/aliases:

root: \root,email@example.com

You can send mail to /dev/null like this:

root: /dev/null

I can't find \root used in any documentation.

  1. Does \root do anything?
  2. Could it be a syntax error?
David
  • 376
  • 1
  • 3
  • 9
  • 1
    You seem to be right that the backslash syntax does not appear to be documented in "man 5 aliases" where one would expect it to be mentioned (or at least I cannot find it in my section 5 aliases man page) but this is a longstanding feature of the mail aliases file. – Michael McNally Jan 23 '13 at 06:29

4 Answers4

8
 but I can't find what the \ does

The backslash "escapes" the token following, preventing further interpretation.

It's an important mechanism in defining aliases like the example in your post, where "root" is aliased to include both the account of that name AND other addresses. Without the \ a loop would be created when the program interpreting the alias tried to dereference "root", which includes as a member "root" (which includes as a member "root", and so on..)

Michael McNally
  • 1,500
  • 9
  • 14
  • Just to be clear: it is used when an account forwards to itself, as root does above? (And the purpose is to prevent a loop?) – felwithe May 03 '21 at 15:26
3

I believe that \root prevents that id from being passed through aliases again and (instead is) delivered to the LOCAL root account.

David
  • 376
  • 1
  • 3
  • 9
mdpc
  • 11,856
  • 28
  • 53
  • 67
2

\root will save the message to (for example) /var/mail/root and forward it to email@example.com. Without it, only email@example.com will receive the message. The \user, other@address notation is very common for users that use ~/.forward files.

adamo
  • 6,925
  • 3
  • 30
  • 58
1

Putting a backslash (\) in front of the username in the first recipient is a special syntax for delivering mail to the local mail spool with no further aliasing.

root: \root,email@example.com

Here, user root is forwarding mails to two different places:

  1. One copy of the message goes to the mail spool
  2. The second recipient, email@example.com, sends another copy of message to MX servers of example.com

Please find details here.

sundeep
  • 146
  • 3