Archives for Quick Tips & Tricks category

There are ways to sync two MySQL tables in a non-GUI method such as mysql triggers or by Maatkit’s MySQL Table Sync, but it’s not that user-friendly.

Of course, if  you want the GUI-type, there’s always the ever dependable phpMyAdmin or the NaviCat program.

On this tutorial, I will be implementing the “TableSyncer” tool, a ruby gem built that was originally detailed on http://code.google.com/p/ruby-roger-useful-functions/wiki/TableSyncer

This was tested on CentOS 5.3 32-bit running in Pentium4@3.0GHz 1G machine.

Here are the step-by-step procedure:

1. Download rubygem by “yum” or by source. This is how I built the rubygem
#wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz
tar zxvf rubygems-1.3.5.tgz

I had the chance to work as a systems administrator in an e-commerce company and they have Linux dedicated servers leased/purchase from a hosting provider.
Dedicated servers compared to a shared hosting is you have full control of the box. You can do whatever you want with the box, implement services and of course a full root access with the machine.

In this tutorial, we will be cloning PC desktop machines using an opensource tool called “G4U”.

g4u (“ghosting for unix”) is a NetBSD-based bootfloppy/CD-ROM that allows easy cloning of PC harddisks to deploy a common setup on a number of PCs using FTP. The floppy/CD offers two functions. more details on –>   http://www.feyrer.de/g4u/

Here’s one trick to do that:
Step 1. Install  FreeTDS

FreeTDS Website: http://www.freetds.org/ choose FreeTDS source distribution

Compile parameter: –prefix=/usr/local/freetds –enable-msdblib

Then, copy /etc/ld.so.conf, to /usr/local/freetds/lib; and then run ldconfig

Step 2. Change /usr/local/freetds/etc/freetds.conf


host = your.mssql.server.ip
port = 1433
client charset = cp950
tds version = 8.0

b. tds version: 4.2 (for MS SQL Server 6.x); 7.0 (for 7.x); 8.0 (for 2000)

Step 3. Test FreeTDS connect to MS SQL Server

#cd /usr/local/freetds/bin
#./tsql -S sql2k -U sa
1> use mydatabase
2> select * from mytable
3> go

Want to test your Asterisk PBX system if it can sustain load and large traffic? Then you can use this tool.
Sipp is a performance testing tool for the SIP protocol. Its main features are basic SIPStone scenarios, TCP/UDP transport, customizable (xml based) scenarios, dynamic adjustement of call-rate and a comprehensive set of real-time statistics.
Sipp can be used to test real SIP equipments and very useful to emulate thousands of user agents calling your SIP system.


1.    Download the stable version of Sipp ( sipp-xxx.tar.gz)
2.    Uncompress the tarball file
#tar zxvf sipp-xxx.tar.gz
#cd sipp

These are the steps on adding additional hard drives on a pre-installed Linux server.

Drives will be detected and can be checked thru the “dmesg” command.

[root@localhost ~]#fdisk /dev/cciss/c0d1

press n to create partition, just use the default settings for it
press w to write exit

3.    Create ext3 filesystem

[root@localhost ~]# mkfs.ext3 /dev/cciss/c0d1p1

4.    Mount that drive to test but first create a directory where to mount it.

[root@localhost ~]#mkdir /data
[root@localhost ~]#mount -t auto /dev/cciss/c0d1p1 /data

1.compile cronolog (http://cronolog.org) and install it on /usr/local/sbin
2. backup orig /usr/local/apache-tomcat-5.5.20/bin/catalina.sh  on /root
3. edit lines on catalina.sh from
org.apache.catalina.startup.Bootstrap “$@” start \
>> “$CATALINA_BASE”/logs/catalina.out 2>&1 &


org.apache.catalina.startup.Bootstrap “$@” start 2>&1 \
| /usr/local/sbin/cronolog “$CATALINA_BASE”/logs/catalina.out.%Y-%m-%d >> /dev/null &

4. Removed the line
touch “$CATALINA_BASE”/logs/catalina.out

5. Restart web service
# service httpd stop
# /usr/local/tomcat/bin/startup.sh
#service httpd start


1.    Check tomcat logs to see generated Catalina.out per day
# ls -la /usr/local/tomcat/logs

-rw-r–r–   1 root root      65607 Nov  6 14:55 catalina.out.2007-11-06

2.    browse ww2.freelinuxtutorials.com and login using test account to see if tomcat is working

Quick tip in backing up and restore your MySQL database:

Backing up and Restoring MySQL database

Backing up database:
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
o    [username] -database username
o    [password] -password for your database
o    [databasename] – the name of your database
o    [backupfile.sql] – the file to which the backup should be written.
mysqldump -u root -p asterisk > asteriskbackupmarch3.sql
(just input the password when prompt for password)

Multiple database:

mysqldump -u [username] -p [password] –databases  [databasename1] [databasename2] > [backupfile.sql]

mysqldump -u asteriskuser -p –databases asterisk asteriskcdrdb > multibackup.sql
(then input db password)

Setting up mysql password is one of the essential task in systems administration

Note: Linux/Unix login root account for your operating system and MySQL root are different

You can use the built-in “mysqladmin” command to change MySQL root password. It can be executed anywhere as long the binary path is set on your Linux or Windows environment

Condition 1: If you have never set a root password for MySQL, the server does not require a password at all for connecting as root. To setup root password for first time, use mysqladmin command at shell prompt as follows:

Finding CPU utilization is one of the important tasks in systems administration. There are built-in and 3rd party tools that you can use to perform this task.

1. top – displays Linux tasks
this is the most common command used in getting CPU usage


2. mpstat – display CPU individually and processors related stats.
In order to use this, package “sysstat” should be installed. you can use apt-get (debian-based) or yum (red-hat based) command to install it via internet

#yum install sysstat


#mpstat -P ALL

3. sar – Collect, report, or save system activity information.


About FLT

This site is dedicated to everyone who likes to learn and explore the beautiful world of Linux. If you have comments and suggestions, please feel free to email at freelinuxtutorials@gmail.com. I am happy to serve and share things esp. that is free and enjoyable as Linux.