How to Set Email Addresses for a Linux User

Sometimes you may receive email failure messages when your computer tries to send a mail to a linux user regarding things like errors in cron jobs, etc. and the email address is not a valid one , e.g. root@your-computer-name. To fix this, set up forwarding of emails or aliases for your linux users. Here are the steps to setting up aliases, assuming we want to do this for the user root.

  • Open the aliases file :
    $ sudo vim /etc/aliases
  • Enter the new alias you want on a new line in the following format
    root: youremail@address.com
  • Save and close the file
  • Run the newaliases command
    $ newaliases

Now that this is done, the computer will send all root’s future emails to youremail@address.com

How to Edit Multiple files with VIM

This tutorial is a simple technique for editing multiple files in VIM which I stumbled upon very recently.

Suppose you have 3 files you want to edit at a go, you can simply run

$ vim file1.txt file2.txt file3.txt

If you want to edit all the files in a directory, you can cd to that directory and run

$ vim *

While editing the files, you can switch to the next file using the command :next of :n. :wnext can be used to write changes and move to the next file in one go.

To move to previous file run :previous . To save and move to previous file in one go run :wprevious.

To see where you are in the list of files open, run :args