Linux

How to configure postfix virtual domains

I will assume that your postfix configuration directory is /etc/postfix and your postfix version is around 2.0.14 1. Edit /etc/postfix/virtual This is a plaintext file where you can specify the domains and users to accept mail for. Each virtual domain should begin with a single line containing the domain name. The subsequent lines define addresses […]

Read More
Linux

Script to backup MySql database

#!/bin/bash # Shell script to backup MySql database # To backup Nysql databases file to /backup dir and later pick up by your # script. You can skip few databases from backup too. MyUSER=”SET-MYSQL-USER-NAME” # USERNAME MyPASS=”SET-PASSWORD” # PASSWORD MyHOST=”localhost” # Hostname # Linux bin paths, change this if it can’t be autodetected via which […]

Read More
Scripting

Find domain expiration date

To get expiration date use grep command: $ whois nixcraft.com | egrep -i ‘Expiration|Expires on’ Output: Expiration Date: 10-may-2009 NOTICE: The expiration date displayed in this record is the date the currently set to expire. This date does not necessarily reflect the expiration view the registrar’s reported date of expiration for this registration. Expires on: […]

Read More
Linux

Debug a bash shell script

Shell scripting debugging can be boring job (read as not easy). There are various ways to debug a shell script. Method # 1: Use -x option Run a shell script with -x option. $ bash -x script-name $ bash -x domains.sh Method # 2: Use of set builtin command Bash shell offers debugging options which […]

Read More
Linux

Execute commands on multiple hosts using ssh

#!/bin/bash # Linux/UNIX box with ssh key based login SERVERS=”192.168.1.1 192.168.1.2 192.168.1.3″ # SSH User name USR=”jadmin” # Email SUBJECT=”Server user login report” EMAIL=”admin@somewhere.com” EMAILMESSAGE=”/tmp/emailmessage.txt” # create new file >$EMAILMESSAGE # connect each host and pull up user listing for host in $SERVERS do echo “——————————–” >>$EMAILMESSAGE echo “* HOST: $host ” >>$EMAILMESSAGE echo “——————————–” […]

Read More