A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded



  • Mail filter
    • Procmail filters electronic mail
    • It's control file is ˜/.procmailrc
    • The control file sets some environment variables and contains recipes
    • Control file recipes do the filtering along with any post filtering action

    Sample control file - .procmailrc

    # routes incoming mail to appropriate mailboxes
    # Assignment (variable declaration) part
    MAILDIR=$HOME/.mailspool                   # All mailboxes are in .mailspool/
    LOGFILE=/dev/null                          # LOGFILE=$MAILDIR/log.`date +%y-%m-%d`
    # Recipe part
    # Put mail from DC-Linux mailing list into
    # mailbox dclinux
    * ^(From|Cc|To).*dc-linux                  # Match 'dc-linux' in the From, Cc, or To lines
    dclinux                                    # Name of folder to deliver/put mail in

    Recipe format

    :0 [flags] [: [lock-file] ]          Recipe start followed by
    Zero or more conditions            
    One action line


     H              Egrep the header (default).
     B              Egrep the body.
     D              Egrep to be case sensitive.
     A              Execute if preceding recipe (same block level) without the 'A' or 
                    'a'is matched.
     a              'A' but preceding recipe must successfully complete before executing
                    this recipe.
     E              Execute if preceding recipe was not executed. Disable any following
                    recipes with 'E' flag.
     e              Execute if preceding recipe failed.
     h              Feed the header to the pipe, file or mail destination (default).
     b              Feed the body to the pipe, file or mail destination (default).
     f              Consider the pipe as a filter.
     c              Generate  a carbon copy of this mail.
     w              Wait  for  the filter or program to finish and check its exitcode 
                    (normally ignored).
     W              'w' but suppress any 'Program failure' message.
     i              Ignore any write errors on this recipe (i.e., usually due to an 
                    early closed pipe).
     r              Raw mode, do not try to ensure the mail ends with an empty line, 
                    write it out as is.


     *              Identifies the start of a condition. Followed by
                    <white-space><regular expression>
     ^              Start of a line.
     $              End of a line.
     .              Any character except a newline.
     a*             Any sequence of zero or more a's.
     a+             Any sequence of one or more a's.
     a?             Either zero or one a.
     [^-a-d]        Any character which is not either a dash, a, b, c, d or newline.
     de|abc         Either the sequence 'de' or 'abc'.
     (abc)*         Zero or more times the sequence 'abc'.
     \.             Matches a single dot;  \ to quote any 'magic characters' to get 
                    rid of their special meaning.

    Tokens special to procmail extensions

     ^ or $         Match a newline (for multiline matches).
     ^^             Anchor the expression at the very start of the search area, or 
                    if encountered at the end of the expression, anchor it at the 
                    very end of the search area
     \       Match the character before or after a word. They are merely a 
                    shorthand for '[^a-zA-Z0-9_]', but can also match newlines. Since
                    they match actual characters, they are only suitable to delimit
                    words, not to delimit inter-word space
     \/             Splits the expression in two parts. Everything matching the right
                    part will be assigned to the MATCH environment variable.

    Recipe action line

    !              Forwards to all the specified mail addresses
    |              Starts the specified program
    {              Followed by at least one space, tab or newline will mark the start
                   of a nesting block
  • Example procmail recipes

    All recipes go in ~/.procmailrc.


    Suppose two messages destined for the same mailbox arrive at about the same time. It's possible the mail system would fire up two copies of Procmail, each would try to write its message to the destination mailbox folder.

    Using a lockfile, the first Procmail that gets to run will lock the folder so only it can write to it.

    Again, I got these from somewhere on the net, apologies to the originator.

    (a) Automatically place all mail from israeline into a separate folder

    # Filter Incoming Mail address format like so <>
    :0:                           # The last colon means use a lockfile
    * ^To:.*israeline             # Match "a line starting with 'To:' and containing 'israeline'"
    israel                        # put these messages in the 'israel' folder

    Don't put any comments on a condition line. Procmail will think the comment is part of the pattern.

    I HAVE (for all examples) since these are only DEMOs and the coments are there to help explain, remind what is going on.

    (b) Match text, recipients name and forward to another account

    :0                            # Do not need a lockfile when forwarding mail
    * ^From.*bob                  # No : after From, some headers use others do not
    * ^Subject:.*(joke|funny)

    Matches 'joke' or 'funny' and recipients name and forwards to another account.

    (c) Print and forward the mail

    :0:                           # Use a lockfile
    * ^From.*bob                  # Match on Bob as being the sender
    * ^Subject:.*(joke|funny)     # Match 'joke' or 'funny' in the subject line
    {                             # Start of block, can contain any number of recipies and 
                                  # is run if the parent recipe applies
      :0 c                        # c flag => copy the mail (so next recipe also gets a copy)
      !      # Forward the mail
      | lpr -Pacsps               # Print the mail
    }                             # End of block

    Ordinarily, mail only goes to the first recipe that fits it. The 'c' flag allows two recipes to be applied to a single message.

    (d) Archive messages in the 'junk' mailing list

    :0 bc:                        # 'b' flag => action line will just use the body of the message
    * ^To:.*junk
    | gzip >> junk-archive.gz

    (e) Forward specific mail and keep a copy

    * ^From.*peter
    * ^Subject:.*compilers
          :0 c

    Forward all mail from peter about compilers to william and keep a copy of it here in petcompil.

    (f) An equivalent solution that accomplishes the same as (e)

    :0 c
    * ^From.*peter
    * ^Subject:.*compilers
         :0 A    # Only process this recipe if conditions in the previous recipe are met and
                 # that the previous recipe does not use 'A' or 'a' flags
  • Invoking procmail

    Using ~/.forward files

    "|exec /usr/bin/procmail"             # Most MTAs
                                          # or
    |/usr/bin/procmail                    # exim

    Qmail - ~/.qmail or .qmail-default

    | preline procmail -p -m /path/to/procmailrc

    Sendmail -

    dnl Change Mlocal from /usr/lib/mail.local to point to /usr/local/bin/procmail.

    Postfix - /etc/postfix/

    mailbox_command = /usr/bin/procmail

    Exim - file(1) /etc/exim4/conf.d/router/router-procmail

      debug_print = "R: procmail for $local_part@$domain"
      driver = accept
      domains = +local_domains
      transport = procmail_pipe
      # emulate OR with "if exists"-expansion
      require_files = ${local_part}:${if exists{/etc/procmailrc} \
         {/etc/procmailrc}{${home}/.procmailrc}}: +/usr/bin/procmail

    Exim - file(2) /etc/exim4/conf.d/transport/transport-procmail

      debug_print = "T: procmail_pipe for $local_part@$domain"
      driver = pipe
      path = "/bin:/usr/bin:/usr/local/bin"
      command = "/usr/bin/procmail"