Using Find in Linux

The following examples illustrate typical uses of the command find for finding files on a computer. 

 find / -name game
Looks for a file named "game" starting at the root directory (searching all directories including mounted filesystems). The `-name' option makes the search case sensitive. You can use the `-iname' option to find something regardless of case. 

 find /home -user joe
Find every file under the directory /home owned by the user joe. 

 find /usr -name *stat
Find every file under the directory /usr ending in "stat". 

 find /var/spool -mtime +60
Find every file under the directory /var/spool that was modified more than 60 days ago. 

 find /tmp -name core -type f -print | xargs /bin/rm -f
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines, single or double quotes, or spaces. 

 find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f

MYSQL TUNER SCRIPT


#!/usr/bin/perl -w
# mysqltuner.pl - Version 1.2.0
# High Performance MySQL Tuning Script
# Copyright (C) 2006-2011 Major Hayden - major@mhtx.net
#
# For the latest updates, please visit http://mysqltuner.com/
# Git repository available at http://github.com/rackerhacker/MySQLTuner-perl
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# This project would not be possible without help from:
#   Matthew Montgomery     Paul Kehrer          Dave Burgess
#   Jonathan Hinds         Mike Jackson         Nils Breunese
#   Shawn Ashlee           Luuk Vosslamber      Ville Skytta
#   Trent Hornibrook       Jason Gill           Mark Imbriaco
#   Greg Eden              Aubin Galinotti      Giovanni Bechis
#   Bill Bradford          Ryan Novosielski     Michael Scheidell
#   Blair Christensen      Hans du Plooy        Victor Trac
#   Everett Barnes         Tom Krouper          Gary Barrueto
#   Simon Greenaway        Adam Stein           Isart Montane
#   Baptiste M.
#
# Inspired by Matthew Montgomery's tuning-primer.sh script:
# http://forge.mysql.com/projects/view.php?id=44
#
use strict;
use warnings;
use diagnostics;
use File::Spec;
use Getopt::Long;

# Set up a few variables for use in the script
my $tunerversion = "1.2.0";
my (@adjvars, @generalrec);


Hot Add Disk RHEL with LVM

Hot Add Disk RHEL

# echo ‘- – -’ > /sys/class/scsi_host/host0/scan
# pvcreate /dev/your_new_disk
# vgextend VolGroup01 /dev/your_new_disk
# lvextend -l 100%FREE /dev/Your_VG/Your_LV
# lvextend -L+1G /dev/myvg/homevol
# resize2fs /dev/mapper/VolGroup01-LogVol00

Kill Port Linux

# netstat -plten |grep java
tcp6       0      0 :::8080                 :::*                    LISTEN    
1000       30070621    16085/java

# kill -9 16085
# fuser -n tcp <port_number>
# fuser -n tcp <port_number> 2> /dev/null
# kill $(fuser -n tcp <port_number> 2> /dev/null)

IPTABLES BLOCK PORT part 1

Block Port : In/Out

Incoming :
iptables -A INPUT -p tcp --destination-port 80 -j DROP
In Specific interface :
iptables -A INPUT -i eth1 -p tcp --dport 80 -j DROP

Exception IP :
iptables -A INPUT -p tcp -i eth1 -s ! 122.222.80.xx --dport 80 -j DROP

Outgoing :
/sbin/iptables -A OUTPUT -p tcp --dport 25 -j DROP



CLAMAV CENTOS 6

     
[root@assp assp]# yum install clamav-db.x86_64 clamav-devel.x86_64 perl-ClamAV-Client.noarch clamav.x86_64 clamav-milter.x86_64 clamd.x86_64 perl-Mail-ClamAV.x86_64

[root@assp assp]# /etc/init.d/clamd start
Starting Clam AntiVirus Daemon: LibClamAV Error: cl_cvdhead: Can't read CVD header in /var/clamav/daily.cld
LibClamAV Error: cli_loaddbdir(): error parsing header of /var/clamav/daily.cld
ERROR: Malformed database
                                                           [FAILED]
[root@assp assp]# freshclam
ClamAV update process started at Fri Sep 14 19:54:14 2012
WARNING: DNS record is older than 3 hours.
WARNING: Invalid DNS reply. Falling back to HTTP mode.
Reading CVD header (main.cvd): OK

INSTALL PERL FROM SOURCE

[root@spam ~]# wget http://www.cpan.org/src/5.0/perl-5.12.3.tar.gz
--2012-09-12 05:40:13--  http://www.cpan.org/src/5.0/perl-5.12.3.tar.gz
Resolving www.cpan.org... 199.15.176.140, 212.117.177.118, 2620:101:d000:8::140:1, ...
Connecting to www.cpan.org|199.15.176.140|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14933787 (14M) [application/x-gzip]
Saving to: `perl-5.12.3.tar.gz'



[root@spam ~]# tar -xvf perl-5.12.3.tar.gz
[root@spam ~ perl-5-12xxxx]# Sh Configure -de -Dusethreads
 

CALCULATOR COMMAND LINE


hafiz ~ $ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.


2x3
(standard_in) 3: syntax error
2*3
6
10*3:5
(standard_in) 5: illegal character: :
(standard_in) 5: syntax error
10*3/5
6


CHECK PERL MODULE LINUX CENTOS


[root@spam ~]# perldoc -m Mail::Send

specify a minimum module version

( categories:  )
Sometimes you must use a specific module version in your programs. To avod using earlier version of that module, append the minimum version number you want in the use 'module' statement:
Example:
#-- Use version 5.8 of later of module LWP
use LWP 5.8
Your program will exit with an appropriate error message if the installed module version is lower than the version you specified

execute commands on remote machines using ssh

( categories:  |  )
You can execute commands on remote machines from a Perl script using the Net::SSH::Perl module.
This module allows you to execute a command remotely and receive the STDOUT, STDERR, and exit status of that remote command.
One big advantage of Net::SSH::Perl over other methods is that you can automate the login process, that way you can write fully automated perl scripts, no console interaction is required in order to authenticate in the remote machine.
Example:

list the installed modules

( categories:  |  )
There are several ways to obtain the list of perl modules installed in a system:

Linux and Windows FireFox issues : Error code: sec_error_reused_issuer_and_serial


It took me a while to figure it out from googling, but the solution is simply to delete the cert8.db from your FireFox profile, usually found in  /home/hafiz/.mozilla/firefox/t5q6cggf(some-name).default and Easier still just search for cert8.db in your computer and delete that file. Close and Start again your firefox


Windows:

It took me a while to figure it out from googling, but the solution is simply to delete the cert8.db from your FireFox profile, usually found in C:\Documents and Settings\<yourname>\Application Data\Mozilla\Firefox\Profiles\<yourprofile>. Easier still just search for cert8.db in your computer and delete that file.
Oh….. you need close FireFox first

Got this information somewhere in net and worked fine for me.

LDAPSEARCH Per-User

[root@xdc2 ~]# ldapsearch -x -H ldap://10.10.1.119:389 "(cn=Muhammad Hafiz)"

Renaming Mail Server Zimbra

1. set your /etc/hosts
the /etc/hosts for lookup your new hostname mail system zimbra

2. set in your DNS
for new hostname mail system, the DNS must can be resolve a new fqdn / hostname zimbra with mx record

3. Step for changing a new hostname server zimbra

su - zimbra
/opt/zimbra/libexec/zmsetservername -n <servername>


for example:
[zimbra@hafiz ~]$ /opt/zimbra/libexec/zmsetservername -n newhostname.hafiz.com

set webmail zimbra http to https

set webmail zimbra http to https:
as a user zimbra follow the steps

changing the webmail over https
$ zmtlsctl https

restart the mail server zimbra for perform a new configuration
$ zmcontrol restart 

now if you want to go  the webmail point your browser to
https://your.webmail.com

How to install Apache-Tomcat

first-step
download JDK disini
# chmod +x jdk-1_5_0_22-linux-amd64-rpm.bin
# sh jdk-1_5_0_22-linux-amd64-rpm.bin
# ln -s /usr/java/jdk1.5.0_22/ /usr/lib/jdk
# export JAVA_HOME=/usr/lib/jdk/

download apache-tomcat
http://archive.apache.org/dist/tomcat
download tomcat-administration 
download apache-tomcat disini
karena menggunakan JDK download juga
apache-tomcat-compact 

kemudian ekstrak
# tar xvf apache-tomcat-7.0.12.tar.gz
# mv apache-tomcat-7.0.12/* /usr/tomcat/
mkdir /usr/tomcat
export CATALINA_PID=/var/run/tomcat.pid
vim /etc/init.d/tomcat
chmod a+x /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on

bridging network IP

Redhat base

paket yang diinstall

# rpm -qa|grep bridge
bridge-utils-1.1-2
# cd /etc/sysconfig/network-scripts
# vi ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
BRIDGE=br0
ONBOOT=yes

# vi ifcfg-br0
DEVICE=br0
TYPE=bridge
BOOTPROTO=static
IPADDR=192.168.1.99
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes

setelah configure selesai
restart network
# /etc/init.d/network restart

ubuntu base
paket yang diinstall
$ sudo dpkg -l |grep bridge
ii  bridge-utils      1.4-5ubuntu2    Utilities for configuring the Linux Ethernet bridge

$ sudo vim /etc/network/interfaces
auto eth0
iface eth0 inet static
        address 192.168.1.99
        netmask 255.255.255.0
        gateway 192.168.1.1

auto br0
iface br0 inet static
        address 192.168.1.99
        netmask 255.255.255.0
        gateway 192.168.1.1
        bridge_ports eth0

restart network
$ sudo /etc/init.d/networking restart
atau
$ sudo /etc/init.d/networking force-reload