วันศุกร์ที่ 14 กันยายน พ.ศ. 2555

Java JRE for ubuntu, Debian, Mint

Since the java are under the oracle control, some license policy changed. Linux distro are also move away from original java(sun/oracle) to openjdk. I found this link that help you install java whether openjdk or oracle java.

https://sites.google.com/site/easylinuxtipsproject/java

วันอังคารที่ 11 กันยายน พ.ศ. 2555

[link] Nginx "how to" - Fast and Secure Web Server

I found useful link describe nginx configuration. For newbie, this could be a starting guide for nginx. There are examples config for various common nginx usage  : static files, ssl, reverse proxy. And some explanation of directives are also provided.

Let's have a look ! https://calomel.org/nginx.html

วันอังคารที่ 24 กรกฎาคม พ.ศ. 2555

ssh with out password

Are you boring with entering password every times logging in to linux via ssh? The followings are time saving and secure without storing user password in clear text.

HOST_SRC = Your system.
HOST_DEST = The system you want to login.

1. On HOST_SRC
-generating key (/.ssh/id_rsa.pub) when you are prompted to enter pass pharse just press enter.
$ssh-keygen -t rsa


-transfer id_rsa.pub to HOST_DEST use scp.
$scp ~/.ssh/id_rsa.pub username@ip:/home/username/
(this will be the last time you enter password :) ) 


2. On HOST_DEST 

$ cat id_rsa.pub >>~/.ssh/authorized_keys
$ chmod 700 ~/.ssh/authorized_keys






refer: https://blogs.oracle.com/jkini/entry/how_to_scp_scp_and

วันอังคารที่ 22 พฤษภาคม พ.ศ. 2555

Install nginx with php

Hey, Nginx gain popularity because it lightweight and scalability. Here I will provide a short how to set up nginx running php with php5-fpm(fastcgi process manager) in ubuntu 12.04

#apt-get install nginx php-fpm

Config file for php is at /etc/php5/fpm/pool.d/
This you can control how php process run, tcp or unix socket


The config file for nginx to run php is you need the following configuration to location block :

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }



For configuration optimizing please see this link :
http://www.if-not-true-then-false.com/2011/nginx-and-php-fpm-configuration-and-optimizing-tips-and-tricks/

วันศุกร์ที่ 11 พฤษภาคม พ.ศ. 2555

PHP5.2 for ubuntu


New ubuntu come with PHP5.3. If you need php5.2 to run your old application you have 3 ways.

1) use karmic repository
http://randyfay.com/node/63

2) use .deb
http://thejibe.com/blog/10/10/php-5210-debs-ubuntu-1010-maverick

3) use launchpad respository
https://launchpad.net/~txwikinger/+archive/php5.2


วันพฤหัสบดีที่ 26 เมษายน พ.ศ. 2555

memcached-tool


Memcached : memcached-tool display/manage memcached server information


memcached-tool  localhost -h
Usage: memcached-tool [mode]

       memcached-tool 10.0.0.5:11211 display    # shows slabs
       memcached-tool 10.0.0.5:11211            # same.  (default is display)
       memcached-tool 10.0.0.5:11211 stats      # shows general stats
       memcached-tool 10.0.0.5:11211 dump       # dumps keys and values
       memcached-tool 10.0.0.5:11211 move 7 9   # takes 1MB slab from class #7
                                                # to class #9.

You can only move slabs around on a server that supports 'slabs reassign'
messages and only once slab memory is totally allocated, and only
once the target class is full.  (So you can't move from #6 to #9 and #7
to #9 at the same itme, since you'd have to wait for #9 to fill from
the first reassigned page)

วันพฤหัสบดีที่ 19 เมษายน พ.ศ. 2555

Installing virtual box guest addition on ubuntu server

#apt-get install dkms 
#apt-get install build-essential
#apt-get install linux-headers-'uname-r'

reboot

#cd /mnt
#mkdir cdrom 
#mount /dev/cdrom /mnt/cdrom
#cd /mnt/cdrom
#./VBoxLinuxAddition.run 

file system performance : drop caches

#hdparm -tT /dev/sda
#hdparm -I /dev/sda

create test file on the disk
#dd if=/dev/zero of=/home/file.img bs=8k count=256

measuring performance
#iotop -b -n 1 -o
#cat /proc/slabinfo

Before start new test, restart system or clear disk caches
#sync; echo 3 > /proc/sys/vm/drop_caches
#sync; echo 0 > /proc/sys/vm/drop_caches


http://www.linuxinsight.com/proc_sys_vm_drop_caches.html

วันอังคารที่ 3 เมษายน พ.ศ. 2555

LiveCD software raid starting at md125


If you boot existing with live cd it may change the device name (/dev/mdx) starting from 125. This can prevent system from starting up normally.(/etc/fstab still use the old /dev/mdx name starting from md1). To rename software raid, stop and assemble it. :

This will rename md125 ... 127 to md1 ... md3 respectively

#mdadm --stop /dev/md125
#mdadm --assemble /dev/md1 /dev/sda1 /dev/sdb1
#mdadm --stop /dev/md126
#mdadm --assemble /dev/md2 /dev/sda2 /dev/sdb2
#mdadm --stop /dev/md127
#mdadm --assemble /dev/md3 /dev/sda3 /dev/sdb3

วันพุธที่ 14 มีนาคม พ.ศ. 2555

mysql user copy/migration



gensqluser.sh  : this script will gen sql statement for creating new user
---
mygrants()
{
  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
    'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
    ) AS query FROM mysql.user" | \
  mysql $@ | \
  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}

mygrants --host=localhost --user=username--password=password
---

host1# ./gensqluser.sh >> user.sql

host2# mysql -u -p < user.sql


bash script read file line by line

#/bin/bash

while read myline
do
  echo $myline
done < inputfile

วันพฤหัสบดีที่ 12 มกราคม พ.ศ. 2555

awk basic

awk is very useful tool for linux user.
For example, you have output from ps aux like this :

#ps aux 

root      2213  0.0  0.4   6596  2428 pts/2    S    12:08   0:00 bash
root      2235  0.0  0.1   4848   952 pts/2    S+   12:08   0:00 /bin/bash xxx
root      2236  0.0  0.6   7132  3236 pts/2    S+   12:08   0:04 ssh xxx

The second column is PID, and 8th is process state.
To find the zombie process you just execute the following command  :

# ps aux | awk '{ print $8 " " $2 }' | grep -w Z


See just use $th of the column, you will get the value of that column. Also, you can apply even you have comma separated field with -F option.

For more usage of this command please consult
#man awk

:)