HOBALL 筆記簿

October 22, 2009

Enable Num Lock on Gnome startup

Filed under: Linux — Tags: , , , , — hoball @ 10:30 pm

Run the following command:

Explanation: install numlockx, generate a backup file for /etc/gdm/Init/Default, edit it

su -c 'yum install numlockx'  su -c 'cp /etc/gdm/Init/Default /etc/gdm/Init/Default_backup'  su -c 'gedit /etc/gdm/Init/Default'

When the text editor is launched, go to the bottom part of the file, add the following before exit 0

if [ -x /usr/bin/numlockx ]; then
    /usr/bin/numlockx on
fi

Save and restart Gnome or reboot system to see if it works!

Source:

  1. http://www.unixmen.com/linux-tutorials/documentations-a-howto/118-how-to-enable-num-lock-on-gnome-startup-
  2. http://www.cyberciti.biz/faq/how-to-linux-turn-on-num-lock-on-gnome-startup/

October 14, 2009

Useful Linux commands #2

Filed under: Linux — Tags: , , — hoball @ 5:21 pm
ps -efww|grep sqlr-listener|grep -v grep|cut -c 9-15|xargs kill -9
实 时查看正在执行的sql语句
/usr/sbin/tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | egrep -i 'SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL'
查看http连接
netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"t",state[key]}'
查看SYN状态的http连接
netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more

查看TIME_WAIT状态的http连接

netstat -tna | cut -b 49- |grep TIME_WAIT | sort |morenetstat -an | grep TIME_WAIT | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more

查看ESTABLISHED状态的http连接

netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | morenetstat -an | grep ":80" | grep ESTABLISHED | sort | more

批量kill进程

ps -efww|grep sqlr-listener|grep -v grep|cut -c 9-15|xargs kill -9

查看活动的php-cgi连接数

netstat -anpo|grep php-cgi|wc -l
Source: http://www.quit8.com/read.php/18.htm

Useful Linux commands

Filed under: Linux — Tags: , , — hoball @ 5:17 pm

Find files older than 60 days
find * -mtime +60

Delete files in backup folder which are older than 60 days
rm -f `find /backup/ -mtime +60`

Search for a string inside files
grep -H -r “search me” /var/www

Find files owned by apache user
find /var/www/ -user apache

Find directories owned by apache user
find /var/www/ -user apache –type d

Listing files in a directory
ls -lh

Copy an entire directory (files + subdirectories)
cp -R existingdir/ newdir/

Zip up an entire directory
zip -r zipefilename foldername

Count total number of files in a directory
ls -1 | wc -l
find . -type f | wc -l

Get directory size
du -hs /var/www

Get amount of free disk space available
df -h

Get Linux version details
uname -a
cat /proc/version

Source: http://eisabainyo.net/weblog/useful-linux-commands/

September 29, 2009

HTML Tidy on linux under XAMPP

Filed under: PHP — Tags: , , , — hoball @ 11:53 pm

Installing tidy on PHP5 under linux is pain. The manual says  “compile with –with-tidy”, but it is not really happening.

Finally I made it work on my fedora (using XAMPP) by this method:

# Install libtidy
yum -y install tidy

# Download PHP 5 source
http://www.php.net/downloads.php

# Unpack the source
tar xvzf php-5.3.0.tar.gz

# Configure tidy for installed php5 API
cd php-5.3.0/ext/tidy
/opt/lampp/bin/phpize

# Stay at the same folder, Configure & Compile the source
./configure --with-php-config=/opt/lampp/bin/php-config --with-tidy
make clean    <-- Without this the compile builds a bad module for some reason
make
make install

# Install module into php.ini - Add:: extension="tidy.so"
vi /opt/lampp/etc/php.ini

References:

ubuntuforums.org: LAMP: php5-tidy doesn’t exist!

newsn.net 给AndLinux下面的xampp装tidy模块的经验 (Chinese)

/opt/lampp/etc/php.i

October 23, 2008

Restart SCIM

Filed under: Linux — Tags: , , , — hoball @ 9:11 pm

To restart SCIM, input the command below in terminal

pkill ^scim && scim -d

September 10, 2008

Enabling NTFS read/write in CentOS 5.2

Filed under: Linux — Tags: , , — hoball @ 10:34 pm

http://wiki.centos.org/TipsAndTricks/NTFSPartitions#note_for_cplus

You will also need to have the same version of

kernel kernel-devel

Check the versioning by

rpm -q kernel

rpm -q kernel-devel

If not, you have to install the same version

September 9, 2008

Linux Network Commands

Filed under: Linux — Tags: , , — hoball @ 2:32 pm

Quoted from Here
(more…)

July 23, 2008

Linux Command – kill

Filed under: Linux — Tags: , — hoball @ 11:33 pm

kill -1 [pid]     Re-read configuration file, similar to restart process [SIGHUP]

kill -2 [pid]     Equals to Ctrl+C  [SIGINT]

kill -9 [pid]     Terminate the process forcefully [SIGKILL]

kill -15 [pid]    Gracefully terminate the process  [SIGTERM]

Linux – Restarting Services

Filed under: Linux — Tags: , , — hoball @ 11:30 pm

Restarting cPanel

/etc/rc.d/init.d/cpanel restart

Blog at WordPress.com.