Vim: vim behaves as vi and drives you nuts – how to fix

For some reason vim on Debian went crazy and stopped worked as vim. This is how to make it work like vim instead of vi.

cp /usr/share/vim/vim74/vimrc_example.vim ~/.vimrc

and change

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif

to

" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=r
endif

Hooray.

Postfix: send email using another Postfix

Some host providers block all email ports (like TCP/25 and TCP/587). Here’s  simple of example of how to setup two STMP servers, where SMTP1 is a relay server (forwarder), and SMTP2 uses SMTP1 to send email. Both are using default configuration files with slight changes.

SMTP1 (smart host) 

This config line allows SMTP2 to send email without SMTP authorization. For the sake of security it would make sense to restrict access to port 2525 using iptabes.

mynetworks = 127.0.0.1 <IP_of_SMTP2>

This goes to /etc/postfix/main.cf.

And the following

2525 inet n - n - - smtpd

goes to /etc/postfix/master.cf on SMTP1. So that Postfix opens TCP port 2525.

SMTP2

Add this to /etc/postfix/main.cf on SMTP2.

smtp_always_send_ehlo = yes<br />relayhost = 199.101.134.4:2527<br /><br />

After restart you should be able to send emails from SMTP2 via SMTP1‘s using port 2525.

mysql: backup from remote host using ssh

Sometimes you need to dump a mysql database, and there’s no free space on the server. Here’s you can do to back up the database:

ssh -p <ssh port> user@host "mysqldump -u dbuser -ppassword dbname | gzip -9" > database.sql.gz

At the end you will get mysq database on a local server. Although ssh is slow and it would take some time to transfer the database.

Solving “Can’t locate File/Which.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)”

To solve this problem:

 Can't locate File/Which.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) 
 BEGIN failed--compilation aborted

you just need to install perl-File-Which package:

yum install perl-File-Which