Friday, December 14, 2012

Force shutdown hang vm on XenServer 6.1



1. xe vm-list

Look carefully at uuid and check name-label of the hang vm

2. list_domains

Get the id of of the hang vm by checking the uuid

3. /opt/xensource/debug/destroy_domain -domid xx(ID)

Kill the hang vm. Refer to image if you dont understand.


Thursday, September 6, 2012

Using echo command on linux


To empty file 

 echo -n > filename

To insert text into file

 echo "hello" > filename 


Bind multiple ip address to NIC in Debian



First, back up your working interface to somewhere.
# cp /etc/network/interfaces /root/bak.interface
Then edit file
# vi /etc/network/interfaces

## This is how to bind multiple ip to NIC

auto eth0
auto eth0:0
auto eth0:1

iface eth0 inet static
address 192.168.20.31
netmask 255.255.255.0
gateway 192.168.20.1

iface eth0:0 inet static
address 192.168.20.32
netmask 255.255.255.0
gateway 192.168.20.1

iface eth0:1 inet static
address 192.168.20.33
netmask 255.255.255.0
gateway 192.168.20.1

##save and quit
##restart network service

How to add mysql user


To create a super user to local host

mysql> create user 'dunhill'@'localhost' identified by 'password';
mysql>grant all privileges on *.* to 'dunhill'@'localhost' with grant option;

To create a super user to any host

mysql> create user 'dunhill'@'%' identified by 'password';
mysql> grant all privileges on *.* to 'dunhill'@'%' with grant option;

To create a normal user with limited access

mysql> create user 'admin'@'localhost';
mysql> grant reload,process on *.* to 'admin'@'localhost';

Monday, May 9, 2011

Using rsync to make a backup

The rsync utility is a very well-known piece of GPL'd software, written originally by Andrew Tridgell and Paul Mackerras. If you have a common Linux or UNIX variant, then you probably already have it installed; if not, you can download the source code from rsync.samba.org. Rsync's specialty is efficiently synchronizing file trees across a network, but it works fine on a single machine too.

Basics
Suppose you have a directory called source, and you want to back it up into the directory destination. To accomplish that, you'd use:
rsync -a source/ destination/
(Note: I usually also add the -v (verbose) flag too so that rsync tells me what it's doing). This command is equivalent to:
cp -a source/. destination/
except that it's much more efficient if there are only a few differences.
Just to whet your appetite, here's a way to do the same thing as in the example above, but with destination on a remote machine, over a secure shell:
rsync -a -e ssh source/ username@remotemachine.com:/path/to/destination/


source : http://www.mikerubel.org
thanks dude!

Sunday, May 8, 2011

Keepalived.conf <-- simple conf



vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 151
priority 100
authentication {
auth_type PASS
auth_pass cnetgdb-password
}
virtual_ipaddress {
10.10.13.18/24 dev eth0
}


notify_backup "/opt/cimb_backupmode.sh"
notify_master "/opt/cimb_mastermode.sh"
notify_fault "/opt/cimb_faultmode.sh"

}


Wednesday, December 30, 2009

Solaris 10 hardening

a few step..

1.NTP

To configure NTP on a Solaris server:

1. Create the file /etc/inet/ntp.conf with the following entries: ( using VI )
server 128.83.185.40
server 128.83.185.41
driftfile /etc/ntp.drift
2. Create the file /etc/ntp.drift with the following entry:
0.0
3. Restart the NTP service by issuing the following commands:
/etc/rc2.d/S74xntd stop
/etc/rc2.d/S74xntd start

2.SSH
sshd config file for the entire server is in /etc/ssh/sshd_config
like linux disable the permitrootlogin
also IgnoreRhosts yes


To stop and start sshd:

svcadm disable ssh
svcadm enable ssh

3.Terminal Audit trail1. Login as root
2. Type "touch /var/adm/loginlog" and press Return.
3. Type "chmod 700 /var/adm/loginlog" and press Return.
4. Type "chgrp sys /var/adm/loginlog" and press Return.
5. Make sure the log works by trying to log in to the system six times with the wrong password.
6. Type "more /var/adm/loginlog" and review the output to make sure the login attempts are being logged successfully