bash

Bash shortcuts

Enable color prompt

Edit .bashrc, add following

SendGrid API key

Configure postfix to relay mails using SendGrid

To use postfix to send email using sendgrid, you first you need to install postfix on your server. Edit main.cf

Find

Delete the line. Go to end of the file and add following

Create API Key in SendGrid

Next you need to create an API key in sendgrid. To do this, go to Settings > API Key.

https://app.sendgrid.com/settings/api_keys

SendGrid API key

Click “Create API Key” button.

Sendgrid create api key

For this test, i just give the new API key Full Access. On next page you will get API key. Copy it and keep it safe as you won’t be seeing it again.

sendgrid api key created

Now you have the SendGrid.com API key, that you can use with postfix.

Add API Key to postfix

Edit file

Add

Here is what i have

[email protected]:~# cat /etc/postfix/sasl_passwd
[smtp.sendgrid.net]:587 apikey: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
[email protected]:~#

Now run

To test email, run

fping

fping can be used to ping multiple IP and get report.

If you just want to show if hosts are up or not

DirectAdmin CustomBuild versions.txt is getting old

I got following email from DirectAdmin server.

New Message: CustomBuild versions.txt is getting old on s1.serverok.in

A new message or response with subject:

CustomBuild versions.txt is getting old on s1.serverok.in

has arrived for you to view.
Follow this link to view it:

http://s1.serverok.in:2222/CMD_TICKET?action=view&number=000000967&type=ticket

================================
Automated Message Generated by DirectAdmin 1.52.1

Do Not Reply.

DirectAdmin is telling you to update your server.

You need to login to SSH as user root. Then run following commands.

postfix no local interface found

When starting postfix it failed with following error

To fix, edit /etc/postfix/main.cf

Find

Replace with

See postfix

tmux

CTRL+B % Split window vertically
CTRL+B “ Split window horizontally
CTRL+B c Create new window
CTRL+B d Detach tmux session
CTRL+B $ Rename session
CTRL+B n Next window.
CTRL+B p Previous window.
CTRL+B arrow keys switch between panes.

.tmux.conf

.tmux.conf file is used to configure tmux

Here is the .tmux.conf i use

https://gist.github.com/serverok/f8f729e2c22a5ab1fa6b0d82765bcddc

If you change this file, you need to restart the terminal or run

Scroll Mode in tmux

To scroll, you need to enter scroll mode by pressing

To exit scroll mode, press q

rsync

rsync command with exclude option, full server backup to remote server.

Transfer a file

I normally use scp to do single file transfer. It may be better to it with rsync as you will be able to resume.

-P == –partial –progress

If you use non standard SSH port, then replace -e ssh with “-e ssh -p PORT_NUMBER”.

Example

See backup