Linux

Back to the TOC =Administration=

How to set up a Linux email .forward file correctly

(by Eddie)

1. Create a file called “.forward” in your home directory. If your username is “billg”, the file should (likely) be created at “/home/billg/.forward”. Stick the email address you’d like to forward emails to in that file. You can accomplish this quickly from the command line using the command “echo ‘billg@microsoft.com’ > /home/billg/.forward”

2. After you’ve done this, make sure you set the file so that it’s not world-writeable! (This is the step I overlooked). “chmod 644 /home/billg/.forward”

That’s it – your email should be forwarded correctly.

The reason it doesn’t work when the permissions aren’t set correctly is a security thing – just imagine the risks if anyone was able to write to your .forward file. As a precaution, the system will ignore the .forward file if it is world writeable.''

''Note by Colin: Not only does the file have to have restricted permissions, but the directory containing the file has to have restricted permissions. Sendmail’s log was very helpful in figuring that out.''

=Commands=

Archiving & Compression

 * zip/unzip

Extract excluding a folder
 * tar

tar -exclude -xzf file.tar.gz

Copying and moving files
To include hidden files * .[^.]*

Sort rows in a text alphabetically
cat file |sort > filealphabetical

Parsing text with vim commands
From Vim: How do I paste a column of text after a different column of text?

I have two columns full of text, and I want to get them side-by-side. For example, I have

abc def ghi and

123 456 789 and I want

123 abc 456 def 789 ghi All I can find is how to paste the same line onto the end of every line in a column. I can't figure out how to paste a multi-line block of text on the end of another column.

Solution from user clime:

Use visual block (ctrl-v) to cut the letter column. Then move to the first line of the number column. Move to the end and make one space. Then paste the letter column.

From Vim search for a pattern and if occurs delete to end of line

From user mirod


 * %s/{pattern}.*//

or from user 55400

Alternatively, the following also works


 * g/{pattern}/normal nd$

For what you want, I would go with mirod's suggestion. What I posted is a bit more flexible and might come in handy in similar situations.

Explanation:

On each line, where pattern matches, execute the following normal mode commands 'nd$'. With the cursor at the start of the line, 'n' jumps to the pattern, and 'd$' deletes to the end of the line.

From Column (block) insert/delete on VIM

I know this is not new information at all, but every time I have to insert some text at some specific index for a group of consecutive strings I have to google something like “column insert VIM” (surprisingly, the title of this post) and search through the first 5 results for the correct solution. Well, the one I happen to understand, anyway…

So, here’s how it’s done:

1) move the cursor to the uppermost character (if you’re selecting lines the way down, bottom if you’re going up) before which you want to insert text

2) enter Visual Block Mode by pressing Ctrl+v (unless you mapped the paste action to it, in which case you probably already know how to column insert)

3) select the column using the arrow keys

4) press Shift+i (switching into Insert Mode)

5) type the text you want to insert (will be displayed only on the first line)

6) press esc two times