Tuesday, April 10, 2012
Application Deployment Guide.
@ Linux Administration Blog.!
Monday, April 9, 2012
How to replicate only one table from mysql database.
Install Ruby 1.9.2
Install gem rubyrep (1.2.0) using command
gem install rubyrep
Then create conf file with name /etc/myrubyrep.conf and with following content.
-------------------------------------------------------------
RR::Initializer::run do |config|
config.left = {
:adapter => 'mysql', # or 'pgsql'
:database => 'c11',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}
config.right = {
:adapter => 'mysql', # or 'pgsql'
:database => 'c12',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}
config.include_tables 'table name' # e.g. 'email_list_subscribers' only this will replicate
#config.include_tables /^e/ # regexp matches all tables starting with e
# config.include_tables /./ # regexp matches all tables
#config.options[:auto_key_limit] = 2
end
---------------------------------------------
Using this command you can replicate only one table from database.
[root@localhost ]# rubyrep replicate -c /etc/myrubyrep.conf
Verifying RubyRep tables
Checking for and removing rubyrep triggers from unconfigured tables
Verifying rubyrep triggers of configured tables
Starting replication..
For only scan and sync to check status use following commands:
[root@localhost tmp]# rubyrep scan -c /etc/myrubyrep.conf
email_list_subscribers 100% ......................... 0
[root@localhost tmp]# rubyrep sync -c /etc/myrubyrep.conf
email_list_subscribers 100% ......................... 0
If modified it will change to 0 to 1.
Cool thing... Please let me know if you guys have any questions.
@ Linux Administration Blog.!
Install gem rubyrep (1.2.0) using command
gem install rubyrep
Then create conf file with name /etc/myrubyrep.conf and with following content.
-------------------------------------------------------------
RR::Initializer::run do |config|
config.left = {
:adapter => 'mysql', # or 'pgsql'
:database => 'c11',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}
config.right = {
:adapter => 'mysql', # or 'pgsql'
:database => 'c12',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}
config.include_tables 'table name' # e.g. 'email_list_subscribers' only this will replicate
#config.include_tables /^e/ # regexp matches all tables starting with e
# config.include_tables /./ # regexp matches all tables
#config.options[:auto_key_limit] = 2
end
---------------------------------------------
Using this command you can replicate only one table from database.
[root@localhost ]# rubyrep replicate -c /etc/myrubyrep.conf
Verifying RubyRep tables
Checking for and removing rubyrep triggers from unconfigured tables
Verifying rubyrep triggers of configured tables
Starting replication..
For only scan and sync to check status use following commands:
[root@localhost tmp]# rubyrep scan -c /etc/myrubyrep.conf
email_list_subscribers 100% ......................... 0
[root@localhost tmp]# rubyrep sync -c /etc/myrubyrep.conf
email_list_subscribers 100% ......................... 0
If modified it will change to 0 to 1.
Cool thing... Please let me know if you guys have any questions.
@ Linux Administration Blog.!
Wednesday, January 11, 2012
Benchmarking with Frameworks.
Framework for Development.
Ruby:
1.Ruby on Rails is on the TOP.
PHP:
2.FuelPHP fuelphp.com for the perfect mixture of CI, Kohana, Rails and others.
If you check following URL:
http://ilikekillnerds.com/2011/04/codeigniter-vs-fuelphp
http://www.reddit.com/r/webdev/comments/fmy6i/why_is_fuelphp_better_than_codeigniter/
http://www.beyondcoding.com/2008/05/26/ruby-on-rails-passenger-modrails-vs-codeigniter-and-kohana/
Thanks-
Shrii
Ruby:
1.Ruby on Rails is on the TOP.
PHP:
2.FuelPHP fuelphp.com for the perfect mixture of CI, Kohana, Rails and others.
If you check following URL:
http://ilikekillnerds.com/2011/04/codeigniter-vs-fuelphp
http://www.reddit.com/r/webdev/comments/fmy6i/why_is_fuelphp_better_than_codeigniter/
http://www.beyondcoding.com/2008/05/26/ruby-on-rails-passenger-modrails-vs-codeigniter-and-kohana/
Thanks-
Shrii
Tuesday, January 3, 2012
SMTP check script in ruby.
Create ruby script to check SMTP with login credential.
You can test two authentication in this script i.e. plain and login.
vi /opt/rubymailtest.rb
require 'net/smtp'
message = <
From: info@homework.do
To: sbtoalerts@gmail.com
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
This is a test message.
END_OF_MESSAGE
#Net::SMTP.start('mail.exmaple.com') do |smtp|
# smtp.send_message message, 'info@homework.do',
# 'sbtoalerts@gmail.com'
# PLAIN
#Net::SMTP.start('mail.example.com', 25, 'mail.example.com',
# 'Your Account', 'Your Password', :plain)
# LOGIN
Net::SMTP.start('mail.example.com', 25, 'mail.example.com', 'username', 'passwd', :login) do |smtp|
smtp.send_message message, 'info@homework.do',
'sbtoalerts@gmail.com'
#puts " done"
end
You can test two authentication in this script i.e. plain and login.
vi /opt/rubymailtest.rb
require 'net/smtp'
message = <
From: info@homework.do
To: sbtoalerts@gmail.com
Subject: test message
Date: Sat, 23 Jun 2001 16:26:43 +0900
This is a test message.
END_OF_MESSAGE
#Net::SMTP.start('mail.exmaple.com') do |smtp|
# smtp.send_message message, 'info@homework.do',
# 'sbtoalerts@gmail.com'
# PLAIN
#Net::SMTP.start('mail.example.com', 25, 'mail.example.com',
# 'Your Account', 'Your Password', :plain)
# LOGIN
Net::SMTP.start('mail.example.com', 25, 'mail.example.com', 'username', 'passwd', :login) do |smtp|
smtp.send_message message, 'info@homework.do',
'sbtoalerts@gmail.com'
#puts " done"
end
Tuesday, October 11, 2011
Remove extra spaces from file in linux.
If you found spaces and non-ASCII characters with in files, remove all from a file in place.
Solution is:
perl -i.bak -pe 's/[^[:ascii:]]//g' filename
Thanks-
Solution is:
perl -i.bak -pe 's/[^[:ascii:]]//g' filename
Thanks-
Wednesday, September 28, 2011
My New Writeup.
I am not good writer, still i am writing things which is need to me and people who find needful for them.
This is my another Tech Blog. I hope its useful for all of us.
Please visit: http://linux-fundamentals.blogspot.com/
Thanks-
This is my another Tech Blog. I hope its useful for all of us.
Please visit: http://linux-fundamentals.blogspot.com/
Thanks-
Tuesday, September 27, 2011
Shell Script To Monitor Mysql.
[root@ 17_johnson]# cat /usr/bin/monitor-mysql
#!/bin/bash
# mysql root/admin username
MUSER="root"
# mysql admin/root password
MPASS="im#secure"
# mysql server hostname
MHOST="localhost"
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
# Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS.
MSTART="/etc/init.d/mysqld start"
# Email ID to send notification
EMAILID="shrikant.lokhande@example.com, lokhande.shrikant@gmail.com"
# path to mail program
MAILCMD="$(which mail)"
# path mysqladmin
MADMIN="$(which mysqladmin)"
#### DO NOT CHANGE anything BELOW ####
MAILMESSAGE="/tmp/mysql.fail.$$"
# see if MySQL server is alive or not
# 2&1 could be better but i would like to keep it simple and easy to
# understand stuff :)
$MADMIN -h $MHOST -u $MUSER -p${MPASS} ping 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
echo "" >$MAILMESSAGE
echo "Error: MySQL Server is not running/responding ping request">>$MAILMESSAGE
echo "Hostname: $(hostname)" >>$MAILMESSAGE
echo "Date & Time: $(date)" >>$MAILMESSAGE
# try to start mysql
$MSTART>/dev/null
# see if it is started or not
o=$(ps cax | grep -c ' mysqld$')
if [ $o -eq 1 ]; then
sMess="MySQL Server MySQL server successfully restarted"
else
sMess="MySQL server FAILED to restart"
fi
# Email status too
echo "Current Status: $sMess" >>$MAILMESSAGE
echo "" >>$MAILMESSAGE
echo "*** This email generated by $(basename $0) shell script ***" >>$MAILMESSAGE
echo "*** Please don't reply this email, this is just notification email ***" >>$MAILMESSAGE
# send email
$MAILCMD -s "MySQL server" $EMAILID < $MAILMESSAGE
else # MySQL is running :) and do nothing
:
fi
# remove file
rm -f $MAILMESSAGE
#!/bin/bash
# mysql root/admin username
MUSER="root"
# mysql admin/root password
MPASS="im#secure"
# mysql server hostname
MHOST="localhost"
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
# Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS.
MSTART="/etc/init.d/mysqld start"
# Email ID to send notification
EMAILID="shrikant.lokhande@example.com, lokhande.shrikant@gmail.com"
# path to mail program
MAILCMD="$(which mail)"
# path mysqladmin
MADMIN="$(which mysqladmin)"
#### DO NOT CHANGE anything BELOW ####
MAILMESSAGE="/tmp/mysql.fail.$$"
# see if MySQL server is alive or not
# 2&1 could be better but i would like to keep it simple and easy to
# understand stuff :)
$MADMIN -h $MHOST -u $MUSER -p${MPASS} ping 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
echo "" >$MAILMESSAGE
echo "Error: MySQL Server is not running/responding ping request">>$MAILMESSAGE
echo "Hostname: $(hostname)" >>$MAILMESSAGE
echo "Date & Time: $(date)" >>$MAILMESSAGE
# try to start mysql
$MSTART>/dev/null
# see if it is started or not
o=$(ps cax | grep -c ' mysqld$')
if [ $o -eq 1 ]; then
sMess="MySQL Server MySQL server successfully restarted"
else
sMess="MySQL server FAILED to restart"
fi
# Email status too
echo "Current Status: $sMess" >>$MAILMESSAGE
echo "" >>$MAILMESSAGE
echo "*** This email generated by $(basename $0) shell script ***" >>$MAILMESSAGE
echo "*** Please don't reply this email, this is just notification email ***" >>$MAILMESSAGE
# send email
$MAILCMD -s "MySQL server" $EMAILID < $MAILMESSAGE
else # MySQL is running :) and do nothing
:
fi
# remove file
rm -f $MAILMESSAGE
Saturday, September 24, 2011
Script To Check Disk Usage and Send Alert URGENT/WARNING.
[root@ 17_johnson]# cat /usr/bin/DiskUsage
#!/bin/bash
#filesystems="/dev/sda1 /dev/sda2 /dev/sda5"
filesystems="/data /log /app /backup /home /"
for fs in $filesystems
do
size=`df -k $fs |grep $fs |awk '{ print $3 }'`
if [ $size -le 2500000 ] ;then
# mail -b "URGENT: Low disk space for $fs ($size)"
echo "$fs ($size) URGENT" | mail -s "Alert: Disk Usage for Ishy $fs ($size) " shrikant.lokhande@example.com
echo "URGENT"
break
fi
if [ $size -le 5000000 ] ;then
# mail -b "WARNING: Low disk space for $fs ($size)
echo "$fs ($size) WARNING" | mail -s "Alert: Disk Usage for Ishy(LOW) $fs ($size) " shrikant.lokhande@example.com
echo "WRANING"
fi
done
#!/bin/bash
#filesystems="/dev/sda1 /dev/sda2 /dev/sda5"
filesystems="/data /log /app /backup /home /"
for fs in $filesystems
do
size=`df -k $fs |grep $fs |awk '{ print $3 }'`
if [ $size -le 2500000 ] ;then
# mail -b "URGENT: Low disk space for $fs ($size)"
echo "$fs ($size) URGENT" | mail -s "Alert: Disk Usage for Ishy $fs ($size) " shrikant.lokhande@example.com
echo "URGENT"
break
fi
if [ $size -le 5000000 ] ;then
# mail -b "WARNING: Low disk space for $fs ($size)
echo "$fs ($size) WARNING" | mail -s "Alert: Disk Usage for Ishy(LOW) $fs ($size) " shrikant.lokhande@example.com
echo "WRANING"
fi
done
Friday, September 23, 2011
Shell script to taking MySql Dump/Backup.
[root@17_johnson]# cat /usr/bin/mybackupsql
#!/bin/bash
# USER VARIABLES
TIMESTAMP=$(date +%Y-%m-%d)
MYSQLUSER=root
MYSQLPWD=im#secure
MYSQLHOST=localhost
# PATH VARIABLES
MK=/bin/mkdir
GREP=/bin/grep
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
# CREATE MYSQL BACKUP
# Create new backup dir
$MK /backup/mysqlback_$TIMESTAMP
#Dump new files
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
$MYSQLDUMP -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST $i >/backup/mysqlback_$TIMESTAMP/$i.sql
sleep 30
echo "$i"
done
#!/bin/bash
# USER VARIABLES
TIMESTAMP=$(date +%Y-%m-%d)
MYSQLUSER=root
MYSQLPWD=im#secure
MYSQLHOST=localhost
# PATH VARIABLES
MK=/bin/mkdir
GREP=/bin/grep
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
# CREATE MYSQL BACKUP
# Create new backup dir
$MK /backup/mysqlback_$TIMESTAMP
#Dump new files
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
$MYSQLDUMP -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST $i >/backup/mysqlback_$TIMESTAMP/$i.sql
sleep 30
echo "$i"
done
Thursday, September 22, 2011
MysqlDump with Exclude database or perticuler table Options.
[root@linux_johnson]# cat /usr/bin/imdbbackup
#!/bin/bash
# USER VARIABLES
TIMESTAMP=$(date +%Y-%m-%d)
MYSQLUSER=root
MYSQLPWD=im#secure
MYSQLHOST=localhost
# PATH VARIABLES
MK=/bin/mkdir
GREP=/bin/grep
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
# CREATE MYSQL BACKUP
# Create new backup dir
$MK /backup/mysqlback_$TIMESTAMP
#Dump new files
DBname=db_production
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
if [ "$i" == "$DBname" ]; then
echo " Dump taken"
mysqldump -u$MYSQLUSER -p$MYSQLPWD $DBname --ignore-table=db_production.clicks --ignore-table=db_production.addresses > /backup/mysqlback_$TIMESTAMP/$i.sql
else
$MYSQLDUMP -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST $i >/backup/mysqlback_$TIMESTAMP/$i.sql
echo "$i"
fi
done
/etc/init.d/httpd reload
#!/bin/bash
# USER VARIABLES
TIMESTAMP=$(date +%Y-%m-%d)
MYSQLUSER=root
MYSQLPWD=im#secure
MYSQLHOST=localhost
# PATH VARIABLES
MK=/bin/mkdir
GREP=/bin/grep
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
# CREATE MYSQL BACKUP
# Create new backup dir
$MK /backup/mysqlback_$TIMESTAMP
#Dump new files
DBname=db_production
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
if [ "$i" == "$DBname" ]; then
echo " Dump taken"
mysqldump -u$MYSQLUSER -p$MYSQLPWD $DBname --ignore-table=db_production.clicks --ignore-table=db_production.addresses > /backup/mysqlback_$TIMESTAMP/$i.sql
else
$MYSQLDUMP -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST $i >/backup/mysqlback_$TIMESTAMP/$i.sql
echo "$i"
fi
done
/etc/init.d/httpd reload
Wednesday, September 21, 2011
How To Clear Active record base Sessions.
[root@17_johnson]# cat current/lib/clear_sessions_data.rb
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password =>"tm#secure",
:database => "tm_production",
:socket => "/var/lib/mysql/mysql.sock"
)
sql = 'DELETE FROM sessions WHERE updated_at < DATE_SUB(NOW(), INTERVAL 1 DAY);'
ActiveRecord::Base.connection.execute(sql)
------------------
NOTE # Set script As cron at Every day 12.00 AM.
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:username => "root",
:password =>"tm#secure",
:database => "tm_production",
:socket => "/var/lib/mysql/mysql.sock"
)
sql = 'DELETE FROM sessions WHERE updated_at < DATE_SUB(NOW(), INTERVAL 1 DAY);'
ActiveRecord::Base.connection.execute(sql)
------------------
NOTE # Set script As cron at Every day 12.00 AM.
Tuesday, September 20, 2011
To check exact PID of running process in linux.
To check exact PID of process.
Command:
ps -efa | grep httpd | grep -v grep | awk '{print $2}'
-----------------------------------------------------------------------------------------
#! /bin/bash
PROCNAME=$1
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk '{ print $2 }'`
for ff in $PIDS
do
echo "$ff"
done
------------------------------------------------------------------------------------------
do chmod 777 filename
Now you can run the command like:
e.g.
filename httpd or filename processname.
Command:
ps -efa | grep httpd | grep -v grep | awk '{print $2}'
-----------------------------------------------------------------------------------------
#! /bin/bash
PROCNAME=$1
PIDS=`ps -efa | grep $PROCNAME | grep -v grep | awk '{ print $2 }'`
for ff in $PIDS
do
echo "$ff"
done
------------------------------------------------------------------------------------------
do chmod 777 filename
Now you can run the command like:
e.g.
filename httpd or filename processname.
Tuesday, September 13, 2011
Last_IO_Error: error connecting to master 'repl@12.18.46.78:3666' - retry-time: 10 retries: 86400
This error you get when you check " show slave status\G;"
Solution as follows:
Do Telnet:
[root@sj ~]# telnet 12.18.46.78 3666
Trying 12.18.46.78...
Connected to 12.18.46.78.
Escape character is '^]'.
uHost '12.18.46.78' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
Do Flush host:
[root@sj ~]# mysqladmin -uroot -ppassword flush-hosts
Lets check " show slave status\G;" again.
Done.
Solution as follows:
Do Telnet:
[root@sj ~]# telnet 12.18.46.78 3666
Trying 12.18.46.78...
Connected to 12.18.46.78.
Escape character is '^]'.
uHost '12.18.46.78' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'Connection closed by foreign host.
Do Flush host:
[root@sj ~]# mysqladmin -uroot -ppassword flush-hosts
Lets check " show slave status\G;" again.
Done.
Wednesday, August 24, 2011
start-stop-daemon script for Centos 5.!
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
tar -xvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps
cd sys-utils/start-stop-daemon-IR1_9_18-2/
cat Makefile
---------------------------------------------
# comment this Two line for centos build.
#AXIS_USABLE_LIBS = GLIBC UCLIBC
#include $(AXIS_TOP_DIR)/tools/build/Rules.axis
PROG = start-stop-daemon
all: $(PROG)
install: all
$(INSTALL) -m 0755 -o root -g root $(PROG) $(prefix)/sbin
clean:
rm -f $(PROG)
-----------------------------------------------
-bash-3.2# make
cc start-stop-daemon.c -o start-stop-daemon
-bash-3.2# ls
a.out Makefile start-stop-daemon start-stop-daemon.c
* Copy the daemon to bin path:
cp start-stop-daemon /usr/bin/
* How to Use this script Please see.
http://svn.ez.no/svn/extensions/ezfind/ezp4/trunk/extension/ezfind/bin/scripts/gentoo/solr
tar -xvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps
cd sys-utils/start-stop-daemon-IR1_9_18-2/
cat Makefile
---------------------------------------------
# comment this Two line for centos build.
#AXIS_USABLE_LIBS = GLIBC UCLIBC
#include $(AXIS_TOP_DIR)/tools/build/Rules.axis
PROG = start-stop-daemon
all: $(PROG)
install: all
$(INSTALL) -m 0755 -o root -g root $(PROG) $(prefix)/sbin
clean:
rm -f $(PROG)
-----------------------------------------------
-bash-3.2# make
cc start-stop-daemon.c -o start-stop-daemon
-bash-3.2# ls
a.out Makefile start-stop-daemon start-stop-daemon.c
* Copy the daemon to bin path:
cp start-stop-daemon /usr/bin/
* How to Use this script Please see.
http://svn.ez.no/svn/extensions/ezfind/ezp4/trunk/extension/ezfind/bin/scripts/gentoo/solr
Monday, June 20, 2011
Add Branch to Git.
--------------------------------------------------------
vi /usr/bin/addbranch <---Create the file with name, and copy the following code.
#!/bin/bash
# git-create-branch
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
set branch_name = $1
#git push origin origin:refs/heads/${branch_name}
#git fetch origin
git checkout --track -b ${branch_name} origin/${branch_name}
git pull
--------------------------------------------------------------
Do
chmod 777 /usr/bin/addbranch
and create new branch like:
from checkouted code.
addbranch
vi /usr/bin/addbranch <---Create the file with name, and copy the following code.
#!/bin/bash
# git-create-branch
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
set branch_name = $1
#git push origin origin:refs/heads/${branch_name}
#git fetch origin
git checkout --track -b ${branch_name} origin/${branch_name}
git pull
--------------------------------------------------------------
Do
chmod 777 /usr/bin/addbranch
and create new branch like:
from checkouted code.
addbranch
Monday, May 30, 2011
Find Command in Linux With Options.
If you find root only
find /. -size +100M
-size n[cwbkMG]
File uses n units of space. The following suffixes can be used:
‘b’ for 512-byte blocks (this is the default if no suffix is used)
‘c’ for bytes
‘w’ for two-byte words
‘k’ for Kilobytes (units of 1024 bytes)
‘M’ for Megabytes (units of 1048576 bytes)
‘G’ for Gigabytes (units of 1073741824 bytes)
The size does not count indirect blocks, but it does count blocks in sparse files that are not
actually allocated. Bear in mind that the ‘%k’ and ‘%b’ format specifiers of -printf handle
sparse files differently. The ‘b’ suffix always denotes 512-byte blocks and never 1 Kilobyte
blocks, which is different to the behaviour of -ls.
-true Always true.
If you want to find in perticuler other directory.
find /usr/local/ -size +100M
find /var/ -size +100M
find /mnt/ -size +100M
find /opt/ -size +100M
Daywise find.file modified 6 days ago.
find /var/ -mtime 6
Show all files which is modified with in 24 hours.
find /. -atime +1
TESTS
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
-amin n
File was last accessed n minutes ago.
-anewer file
File was last accessed more recently than file was modified. If file is a symbolic link and the
-H option or the -L option is in effect, the access time of the file it points to is always used.
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the
file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have
been accessed at least two days ago.
-cmin n
File’s status was last changed n minutes ago.
-cnewer file
File’s status was last changed more recently than file was modified. If file is a symbolic link
and the -H option or the -L option is in effect, the status-change time of the file it points to
is always used.
-ctime n
File’s status was last changed n*24 hours ago. See the comments for -atime to understand how
rounding affects the interpretation of file status change times.
-empty File is empty and is either a regular file or a directory.
-false Always false.
-fstype type
File is on a filesystem of type type. The valid filesystem types vary among different versions of
Unix; an incomplete list of filesystem types that are accepted on some version of Unix or another
-ilname pattern
Like -lname, but the match is case insensitive. If the -L option or the -follow option is in
effect, this test returns false unless the symbolic link is broken.
-iname pattern
Like -name, but the match is case insensitive. For example, the patterns ‘fo*’ and ‘F??’ match
the file names ‘Foo’, ‘FOO’, ‘foo’, ‘fOo’, etc. In these patterns, unlike filename expansion by
the shell, an initial ’.’ can be matched by ’*’. That is, find -name *bar will match the file
‘.foobar’. Please note that you should quote patterns as a matter of course, otherwise the shell
will expand any wildcard characters in them.
-inum n
File has inode number n. It is normally easier to use the -samefile test instead.
-ipath pattern
Behaves in the same way as -iwholename. This option is deprecated, so please do not use it.
-iregex pattern
Like -regex, but the match is case insensitive.
-iwholename pattern
Like -wholename, but the match is case insensitive.
-links n
File has n links.
-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not
treat ‘/’ or ‘.’ specially. If the -L option or the -follow option is in effect, this test
returns false unless the symbolic link is broken.
-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not
treat ‘/’ or ‘.’ specially. If the -L option or the -follow option is in effect, this test
returns false unless the symbolic link is broken.
-mmin n
File’s data was last modified n minutes ago.
-mtime n
File’s data was last modified n*24 hours ago. See the comments for -atime to understand how
rounding affects the interpretation of file modification times.
-name pattern
Base of file name (the path with the leading directories removed) matches shell pattern pattern.
The metacharacters (‘*’, ‘?’, and ‘[]’) match a ‘.’ at the start of the base name (this is a
change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and
the files under it, use -prune; see an example in the description of -wholename. Braces are not
recognised as being special, despite the fact that some shells including Bash imbue braces with a
special meaning in shell patterns. The filename matching is performed with the use of the
fnmatch(3) library function. Don’t forget to enclose the pattern in quotes in order to protect
it from expansion by the shell.
-newer file
File was modified more recently than file. If file is a symbolic link and the -H option or the -L
option is in effect, the modification time of the file it points to is always used.
-nouser
No user corresponds to file’s numeric user ID.
-nogroup
No group corresponds to file’s numeric group ID.
-path pattern
See -wholename. The predicate -path is also supported by HP-UX find.
-perm mode
File’s permission bits are exactly mode (octal or symbolic). Since an exact match is required, if
you want to use this form for symbolic modes, you may have to specify a rather complex mode
string. For example ’-perm g=w’ will only match files which have mode 0020 (that is, ones for
which group write permission is the only permission set). It is more likely that you will want to
use the ’/’ or ’-’ forms, for example ’-perm -g=w’, which matches any file with group write per-
:
find /. -size +100M
-size n[cwbkMG]
File uses n units of space. The following suffixes can be used:
‘b’ for 512-byte blocks (this is the default if no suffix is used)
‘c’ for bytes
‘w’ for two-byte words
‘k’ for Kilobytes (units of 1024 bytes)
‘M’ for Megabytes (units of 1048576 bytes)
‘G’ for Gigabytes (units of 1073741824 bytes)
The size does not count indirect blocks, but it does count blocks in sparse files that are not
actually allocated. Bear in mind that the ‘%k’ and ‘%b’ format specifiers of -printf handle
sparse files differently. The ‘b’ suffix always denotes 512-byte blocks and never 1 Kilobyte
blocks, which is different to the behaviour of -ls.
-true Always true.
If you want to find in perticuler other directory.
find /usr/local/ -size +100M
find /var/ -size +100M
find /mnt/ -size +100M
find /opt/ -size +100M
Daywise find.file modified 6 days ago.
find /var/ -mtime 6
Show all files which is modified with in 24 hours.
find /. -atime +1
TESTS
Numeric arguments can be specified as
+n for greater than n,
-n for less than n,
n for exactly n.
-amin n
File was last accessed n minutes ago.
-anewer file
File was last accessed more recently than file was modified. If file is a symbolic link and the
-H option or the -L option is in effect, the access time of the file it points to is always used.
-atime n
File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the
file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have
been accessed at least two days ago.
-cmin n
File’s status was last changed n minutes ago.
-cnewer file
File’s status was last changed more recently than file was modified. If file is a symbolic link
and the -H option or the -L option is in effect, the status-change time of the file it points to
is always used.
-ctime n
File’s status was last changed n*24 hours ago. See the comments for -atime to understand how
rounding affects the interpretation of file status change times.
-empty File is empty and is either a regular file or a directory.
-false Always false.
-fstype type
File is on a filesystem of type type. The valid filesystem types vary among different versions of
Unix; an incomplete list of filesystem types that are accepted on some version of Unix or another
-ilname pattern
Like -lname, but the match is case insensitive. If the -L option or the -follow option is in
effect, this test returns false unless the symbolic link is broken.
-iname pattern
Like -name, but the match is case insensitive. For example, the patterns ‘fo*’ and ‘F??’ match
the file names ‘Foo’, ‘FOO’, ‘foo’, ‘fOo’, etc. In these patterns, unlike filename expansion by
the shell, an initial ’.’ can be matched by ’*’. That is, find -name *bar will match the file
‘.foobar’. Please note that you should quote patterns as a matter of course, otherwise the shell
will expand any wildcard characters in them.
-inum n
File has inode number n. It is normally easier to use the -samefile test instead.
-ipath pattern
Behaves in the same way as -iwholename. This option is deprecated, so please do not use it.
-iregex pattern
Like -regex, but the match is case insensitive.
-iwholename pattern
Like -wholename, but the match is case insensitive.
-links n
File has n links.
-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not
treat ‘/’ or ‘.’ specially. If the -L option or the -follow option is in effect, this test
returns false unless the symbolic link is broken.
-lname pattern
File is a symbolic link whose contents match shell pattern pattern. The metacharacters do not
treat ‘/’ or ‘.’ specially. If the -L option or the -follow option is in effect, this test
returns false unless the symbolic link is broken.
-mmin n
File’s data was last modified n minutes ago.
-mtime n
File’s data was last modified n*24 hours ago. See the comments for -atime to understand how
rounding affects the interpretation of file modification times.
-name pattern
Base of file name (the path with the leading directories removed) matches shell pattern pattern.
The metacharacters (‘*’, ‘?’, and ‘[]’) match a ‘.’ at the start of the base name (this is a
change in findutils-4.2.2; see section STANDARDS CONFORMANCE below). To ignore a directory and
the files under it, use -prune; see an example in the description of -wholename. Braces are not
recognised as being special, despite the fact that some shells including Bash imbue braces with a
special meaning in shell patterns. The filename matching is performed with the use of the
fnmatch(3) library function. Don’t forget to enclose the pattern in quotes in order to protect
it from expansion by the shell.
-newer file
File was modified more recently than file. If file is a symbolic link and the -H option or the -L
option is in effect, the modification time of the file it points to is always used.
-nouser
No user corresponds to file’s numeric user ID.
-nogroup
No group corresponds to file’s numeric group ID.
-path pattern
See -wholename. The predicate -path is also supported by HP-UX find.
-perm mode
File’s permission bits are exactly mode (octal or symbolic). Since an exact match is required, if
you want to use this form for symbolic modes, you may have to specify a rather complex mode
string. For example ’-perm g=w’ will only match files which have mode 0020 (that is, ones for
which group write permission is the only permission set). It is more likely that you will want to
use the ’/’ or ’-’ forms, for example ’-perm -g=w’, which matches any file with group write per-
:
Monday, May 23, 2011
ERROR 2003 (HY000): Can't connect to MySQL server on '10.677.32.43' (111)
root@124:/etc# mysql -uroot -priva#secure -h10.677.32.43
ERROR 2003 (HY000): Can't connect to MySQL server on '10.677.32.43' (111)
If you go this error. Check your /etc/my.cnf ( for centos), /etc/mysql/my.cnf ( for ubuntu)
Comment this two line.
#skip-external-locking
#bind-address = 127.0.0.1
Restart Mysql. Now you should able to connnect remotely.
ERROR 2003 (HY000): Can't connect to MySQL server on '10.677.32.43' (111)
If you go this error. Check your /etc/my.cnf ( for centos), /etc/mysql/my.cnf ( for ubuntu)
Comment this two line.
#skip-external-locking
#bind-address = 127.0.0.1
Restart Mysql. Now you should able to connnect remotely.
Tuesday, May 3, 2011
Security for Linux Server.
All the Security for Linux Server.
1. Firewall APF/Iptables
* Block the all ports which is unnecessary open on server.
* There is Spammer Database will be add IP pool in firewall.
2. Change SSH port
3. Update and scans for rootkits, backdoor and possible local exploits. wrong permissions for /usr/bin and system commands, hidden files, suspicious strings in kernel modules, and special tests for Linux. With some
tools. Check Malware and malicious scripts.
4. Mail Security:
* Spamming: if your Application is sending mails more than 100-200 mails in day.
then you need Proper Mail server setup. else your server Ip will get block in spam list.
* Check SPF records for domain.
5. Add Google webmaster tool for all our Website/Domain which is use. It will quick detect Malware and if there is Malicious scripts. It will notified if there is any hidden scripts running script or attack on our code.
1. Firewall APF/Iptables
* Block the all ports which is unnecessary open on server.
* There is Spammer Database will be add IP pool in firewall.
2. Change SSH port
3. Update and scans for rootkits, backdoor and possible local exploits. wrong permissions for /usr/bin and system commands, hidden files, suspicious strings in kernel modules, and special tests for Linux. With some
tools. Check Malware and malicious scripts.
4. Mail Security:
* Spamming: if your Application is sending mails more than 100-200 mails in day.
then you need Proper Mail server setup. else your server Ip will get block in spam list.
* Check SPF records for domain.
5. Add Google webmaster tool for all our Website/Domain which is use. It will quick detect Malware and if there is Malicious scripts. It will notified if there is any hidden scripts running script or attack on our code.
Wednesday, April 20, 2011
Can't umount on RHEL/CENTOS Error: device is busy
[root@sandbox1 ~]# umount /dev/sdb1
umount: /mnt/pen: device is busy
umount: /mnt/pen: device is busy
Solution :
[root@sandbox1 ~]# lsof | grep /mnt/pen
esd 23711 root cwd DIR 8,17 4096 1228794 /mnt/pen/720p BRRip x264 - HDMiCRO by Mr. KickASS
esd 23711 root 3r REG 8,17 942758269 1229005 /mnt/pen/ - HDMiCRO by Mr. KickASS/ Mr. KickASS.mp4
[root@sandbox1 ~]# kill -9 23711
[root@sandbox1 ~]# umount /dev/sdb1
Done.
umount: /mnt/pen: device is busy
umount: /mnt/pen: device is busy
Solution :
[root@sandbox1 ~]# lsof | grep /mnt/pen
esd 23711 root cwd DIR 8,17 4096 1228794 /mnt/pen/720p BRRip x264 - HDMiCRO by Mr. KickASS
esd 23711 root 3r REG 8,17 942758269 1229005 /mnt/pen/ - HDMiCRO by Mr. KickASS/ Mr. KickASS.mp4
[root@sandbox1 ~]# kill -9 23711
[root@sandbox1 ~]# umount /dev/sdb1
Done.
Wednesday, April 13, 2011
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
While compiling any sources in linux if you got above Error.
----------------------------------------------------
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make[2]: *** [boot.o] Error 1
make[2]: Leaving directory `/mnt/resin-4.0.16/modules/c/src/resin_os'
make[1]: *** [plugins] Error 2
make[1]: Leaving directory `/mnt/resin-4.0.16/modules/c/src'
make: *** [all] Error 2
--------------------------------------------------
Please do install following lib package from YUM:
yum -y install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.stanford.edu
* base: mirrors.kernel.org
* extras: mirrors.kernel.org
* updates: mirrors.kernel.org
Setting up Install Process
Package glibc-devel-2.5-58.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package glibc-devel.i386 0:2.5-58 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================
Installing:
glibc-devel i386 2.5-58 base 2.0 M
Transaction Summary
===========================================================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
----------------------------------------------------
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make[2]: *** [boot.o] Error 1
make[2]: Leaving directory `/mnt/resin-4.0.16/modules/c/src/resin_os'
make[1]: *** [plugins] Error 2
make[1]: Leaving directory `/mnt/resin-4.0.16/modules/c/src'
make: *** [all] Error 2
--------------------------------------------------
Please do install following lib package from YUM:
yum -y install glibc-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirror.stanford.edu
* base: mirrors.kernel.org
* extras: mirrors.kernel.org
* updates: mirrors.kernel.org
Setting up Install Process
Package glibc-devel-2.5-58.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package glibc-devel.i386 0:2.5-58 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================
Installing:
glibc-devel i386 2.5-58 base 2.0 M
Transaction Summary
===========================================================================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Subscribe to:
Posts (Atom)
