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