Daily Site Tools

Site you can use for domain info, IP, mx records, Blacklist etc..

http://www.intodns.com – DNS lookup
http://www.mxtoolbox.com – Mx lookup, Blacklist & other info
http://cqcounter.com/whois – IP lookup
http://www.dnsbl.info – Blacklist lookup
whois.domaintools.com – DNS lookup

Suggest your daily site lookup that can help us.
Thanks

Advertisements

Delete user and directory

This script check the user if available if yes will prompt to delete the user and the directory.

#***********************************************************************

#!/bin/bash
#Script by Jeffrey Dante

#Check User if available

if [ $(id -u) -eq 0 ]; then
echo “Checking user $1″
cat /etc/passwd | awk -F: ‘{print $1}’ | grep -w $1
if [ $? -eq 0 ]; then

#Check User Disk Usage
LETTER=`/bin/echo $1 | /bin/awk ‘BEGIN{FS=””}{print $1}’`
DU=/usr/bin/du
echo “Disk Usage:”
$DU -msh /mnt/emaildata/$LETTER/$1/Maildir | awk ‘{print $1}’

while true;
do
read -p “Do you wish to delete this user $1 ? ”  yn
case $yn in
[Yy]* ) userdel $1; rm -r /mnt/emaildata/$LETTER/$1; echo “User $1 has been deleted”; exit;;
[Nn]* ) exit;;
* ) echo “Please answer yes or no.”;;
esac
done

exit 1

else
echo “$1 does not exists!”
fi

else
echo “Only root may delete a user”
exit 2
fi

#***********************************************************************

Script to add user and alias

I have seen similar script like this, I just added some arguments to make it suffice.

#**************************************************************************

#!/bin/bash
# Script to add a user with password and alias
# Jeffrey Dante

ADDUSER=/usr/sbin/adduser

if [ $(id -u) -eq 0 ]; then
read -p “Enter username : ” username
read -p “Enter email address: ” email
read -s -p “Enter password : ” password
egrep “^$username” /etc/passwd >/dev/null
egrep “^$email” /etc/aliases >/dev/null
if [ $? -eq 0 ]; then
echo “$username already exists!”
echo “$email already exist!”
echo “Make it sure that you do not have desame username and emaill address!”
exit 1
else
pass=$(perl -e ‘print crypt($ARGV[0], “password”)’ $password)
$ADDUSER -s /sbin/nologin -m -p $pass $username -G 100 $1
echo -e “$email:\t$username” >> /etc/aliases
echo -e “$email” >> /usr/files/addresses.txt
[ $? -eq 0 ] && echo “User has been added to system!” || echo “Failed to add a user!”

fi
else
echo “Only root may add a user to the system”
exit 2
fi
#**************************************************************************

Check User Script

I have created check user script to list the username, email alias, and the disk usage of the user. I hope this will give you some ideas preparing your own check user script.

#***********************************************************************
#!/bin/bash
#Script by Jeffrey Dante
#Check User if available
#List the email alias
#Show the directory usage

if [ $(id -u) -eq 0 ]; then
cat /etc/passwd | awk -F: ‘{print $1}’ | grep -w $1
if [ $? -eq 0 ]; then

# email: username
cat /etc/aliases | grep -w $1 | awk -F: ‘{print $1}’

# Check User Disk Usage

LETTER=`/bin/echo $1 | /bin/awk ‘BEGIN{FS=””}{print $1}’`
DU=/usr/bin/du
echo “Disk Usage:”
$DU -msh /mnt/emaildata/$LETTER/$1/Maildir | awk ‘{print $1}’

exit 1

else
echo “$1 does not exists!”
fi

else
echo “User verification Done!”
exit 2
fi

#***********************************************************************

Output should look like this
user
email/s
usage

[root@test.com jedscripts]# ./usercheck.sh jepdante
jepdante
jeffrey.dante@test.com
jeffrey_dante@test.com
Disk Usage:
55M

Installing openssl

To install openssl you can just do

yum install openssl

Or to update or do it manually:

1. check version
[root@test ]# openssl version
OpenSSL 0.9.7a Feb 19 2003

or

[root@test ]# openssl
OpenSSL> version
OpenSSL 0.9.7a Feb 19 2003

2. download latest openssl
3. extract

tar -zxvf openssl-1.0.0d.tar.gz

4. go to directory

cd openssl-1.0.0d

5. configure

./config shared –prefix=/usr –openssldir=/usr/local/openssl
make && make test
make install

6. if ask perl 5

yum install perl-DBI

Grep & Tar Linux Command for email on selected user

A. GREP

To grep the email by year and ouput its total email

ls –full-time | grep “2010\\-” | wc -l

To grep the email by year and month. ex 2010-01

ls –full-time | grep “2010\\-01\\-”

To grep the email by year, month and date. ex 2010-01-22

ls –full-time | grep “2010\\-01\\-22”

To grep the email by year, month, date and hour. ex 2010-01-22 10am

ls –full-time | grep “2010\\-01\\-22\\ 10”


B. TAR – backup

To Tar it with extension of .tar.gz

tar -cvzf 2010-04-27-18h.tar.gz `ls –full-time | grep “2010\\-04\\-27\\ 18” | awk ‘{print $9}’`
C. Untar

To Untar it, just go to the directory you want to extract it.

tar -xvf 2010-04-27-18h.tar.gz