echo color text

bash convert string to lower case, upper case

echo $x  # HELLO

echo $y  # hello

echo $z  # HELLO
  • Use only one , or ^ to make the first letter lowercase or uppercase


# -F是指定分隔符
$ awk  -F: '{print $1,$3,$6}' /etc/passwd
# 指定多个分隔符
awk -F '[;:]'
awk  -F: '{print $1,$3,$6}' OFS="\t" /etc/passwd

diff 2 dirs

diff -bur folder1/ folder2/
## -b:不检查空格字符的不同;
## -u:以合并的方式来显示文件内容的不同
## -r或——recursive:比较子目录中的文件





 1) screen -L -d -RR -S buildmaster;  -> Start a screen as the buildmaster user;
 1) screen -S buildmaster -> also start new screen
 2) screen -x;  -> resume to last screen;
 2) screen -list -> show available screen list
 3) ctrl-a d;   -> quit current screen, Detached;
 4) ctrl-a 1/2/3/4...;   -> switch in different window;
 5) ctrl-a c;   -> Create a new window in the screen;
 6) ctrl-a shift-A;  -> Change the window name in the screen;
 7) ctrl-a "  -> list all window
 8) ctrl-a [ + arrow key -> copy mode, can roll screen, press "Esc" exit from copy mode
 10)ctrl-a + K -> kill current window
 11)ctrl-a + ctrl-n -> move to next window
 12)ctrl-a + ctrl-Backspace -> move to previous window
 13)ctrl-a + a, move cursor to the line begin
 14)ctrl-a + F, resize screen size.

screen config

  • specify screen config on file ~/.screenrc
#set this up for convenience
defscrollback 8000
hardstatus alwayslastline "%Lw"
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'


  • vi tips
common mode : move cursor
Ctrl + f equals page down, cursor move down 1 page
Ctrl + b equals page up, cursor move up 1 page
Ctrl + d move down half page
ctrl + u move up half page
0 cursor move to first char of current line
$ cursor move to last char of current line
G cursor move to last line of current file
nG cursor move to No. n line of current file,such as 2G, move to second line
gg cursor move to first line, equals 1G
n<Enter> cursor move down n lines
common mode : search & replace
:n1,n2s/word1/word2/g eplace "word1" with "word2", between n1 line and n2 line
:1,$s/word1/word2/gc replace "word1" with "word2", with all content, with confirm whether need replace
/word from current cursor, forward search "word" string.
?word from current cursor, upward search "word" string.
n search next, for /word search forward next , for ?word search upward next
N search reverse next, for /word search upward next, for ?word search forward next
x, X "x" delete behind 1 character, X delete front 1 character
dd delete current cursor line
ndd delete n lines from cursor position
d1G delete content from current cursor to first line
dG delete content from current cursor to last line
d$ delete characters from cursor to current line last character
d0 delete characters from cursor to current line first character
yy copy cursor line
nyy copy n lines from cursor line
y1G copy from cursor to first line
yG copy form cursor to last line
y0 copy from cursor to first character, current line
y$ copy from cursor to last character, current line
p, P "p" paste copy content after cursor line, "P" paste before cursor line
:set number show line number
:set nonumber hide line number
u Undo the latest change
U Undo all changes on a line, while not having
ctrl + r Redo last change
:e! Re-edit a messed-up file.

vi highlight syntax

:syntax on
:syntax off
  • add file ~/.vimrc with current line for default hight light
syntax on
  • add set number to ~/.vimrc for default number
set number

zip & unzip

  • unzip file *.tar.xz
>tar Jxvf filename.tar.xz
  • 解压 .tar.gz
shell>tar -zxvf file.tar.gz
  • unzip to specify folder (/tmp)
shell>tar -zxvf file.tar.gz -C /tmp
  • unzip part contents (abc/mm/*) to specify folder (/tmp)
shell>tar -zxvf file.tar.gz -C /tmp abc/mm/* 
  • 解压 .tar.bz2
shell>tar -jxvf file.tar.bz2
  • 打包 tar , 不压缩
shell>tar -cvf /tmp/file.tar /tmp/folder1
  • uppack .tar file
shell>tar xopf foo.tar
  • 压缩 .tar.gz
shell>tar -zcvf /tmp/file.tar.gz /tmp/folder2
  • 压缩 .tar.bz2
shell>tar -jcvf /tmp/file.tar.bz2 /tmp/folder3


  • find by name
shell>find .m2 -name "*.jar"
  • find in multi folders
shell>find /home .m2 -name "*.jar"
  • find case insensitive
shell>find . -iname "hello*"

run last find command

  • "!find" repeat last find command. In fact "!" can use to any command to invoke previous run of that command

find file modified less than 1 day

## find file modified time less than 1 day, this very useful for finding some production issue
## to check which files have been modified recently
shell>find . -mtime -1
## last modified time larger than 1 day
shell>find . -mtime +1
## last modified time less than 60 mintues
shell>find . -mmin -60
## find size > 1000 bytes , < 5000 bytes
shell>find . -size +1000c -size -5000c
## find file size > 50 M , < 100M
shell>find / -size +50M -size -100M

find file with specify permission

shell>find . -perm 644

find temp file and delete

shell>find . -name "*.tmp" | xargs rm -f
shell>find . -name "*.tmp" -exec rm -rf {} \
## delete all mp3 files which size > 100M
shell>find . -size +100M -type f -name "*.mp3" -exec rm -rf {} \

find directory or file

## find directory name "test"
shell>find . -type d -name "test"
## find all php files
shell>find . -type f -name "*.php"
## find all empty file
shell>find /tmp -type f -empty
## find all empty dir
shell>find /tmp -type d -empty

find by user and group

## find all files under /home which belong to user yufei
shell>find /home -user yufei
## find all files under / belong to root and name is "*.java"
shell>find / -user root -name "*.java"
## find all files under /tmp which belong to rcom group
shell>find /tmp -group rcom

short cut key

  1. ctrl + a , move cursor to begin of line
  2. ctrl + e , move cursor to end of line
  3. opt + left / right arrow , move about one word
  4. ctrl + u , cut from begin to the cursor
  5. ctrl + k , cut from curson to the end
  6. ctrl + w , cut 1 word before cursor
  7. ctrl + y , paste previous cut
  • mac terminal short cut
  1. cmd + t , open new terminal tab
  2. cmd + w, close current tab
  3. cmd + n , open new terminal window
  4. cmd + q , close window

  1. cmd + c, copy in terminal
  2. cmd + v, paste in terminal

  1. cmd + , zoom in terminal
  2. cmd - , zoom out terminal
  3. cmd + 0 (zero), normal size terminal
  4. ctrl + shift + arrow , switch between tab

Atom short cut

  1. platformio-ide-terminal, ctrl + ` , show terminal (show)

file privilege


r:4, w:2, x:1
r + w + x = 7
r + w = 6
r + x = 5


  • 修改用户所属 group , chgrp
shell>chgrp -R users dirnmae/filename 


  • 修改文件拥有者 chown
shell> chown -R 用户 dirname/filename 
shell> chown -R 用户:组 install.log


  • 修改文件的权限 chmod
//-R 是递归 recursive
  • 数字权限法
shell> chmod -R 777 dirname/filename
  • u,g,o,a 权限法, + (加入), - (减去), = (设置)
shell> chmod u=rwx,go=rx filename 
shell> chmod a+w filename
shell> chmod a-w filename


//check install rpm name
shell>rpm -qa|grep -i tib

check rpm architecture

rpm -qa --qf "%{n}-%{version}-%{release}-%{arch}\n" | grep tomcat

[distuser@qa2-app-01 ~]$ rpm -qa --qf "%{n}-%{version}-%{release}-%{arch}\n" | grep tomcat

//查看rpm 包的 info 信息
shell> rpm -pqi mysql.rpm
//查看rpm 包的 目标安装路径
shell> rpm -pql mysql.rpm
//查询 rpm 包的安装位置
shell> sudo rpm -ql libevent
//安装rpm 包
shell> rpm -ivh mysql.rpm
//安装/升级 rpm 包 
shell>rpm -Uvh foo.rpm
//删除 rpm 包
shell> rpm -e rpm-package-name

//打开 rpm 包,查看内容 
shell> rpm2cpio some.rpm | cpio -div

check system info


  • uname - print system information
shell>uname -a
[iphone@bjsit1iphonedev01 ~]$ uname -a
Linux bjsit1iphonedev01 #1 SMP Thu May 6 18:27:11 UTC 2010 i686 i686 i386 GNU/Linux
  • check linux release version

shell>cat /etc/redhat-release

[iphone@bjsit1iphonedev01 ~]$ cat /etc/redhat-release 
Fedora release 13 (Goddard)
  • show first line of /etc/issue file
[yufei@localhost ~]$ head -n 1 /etc/issue
Fedora release 18 (Spherical Cow)

check cup info

shell>cat /proc/cpuinfo

check memory info

shell>cat /proc/meminfo
shell>grep MemTotal /proc/meminfo


  • free - Display amount of free and used memory in the system
[yufei@localhost ~]$ free -h
            total       used       free     shared    buffers     cached
Mem:          3.7G       3.5G       228M         0B       239M       1.6G
-/+ buffers/cache:       1.7G       2.0G
Swap:         3.7G        75M       3.6G


  • top - display Linux processes


  • uptime - Tell how long the system has been running.
[yufei@localhost ~]$ uptime
13:22:39 up 12 days,  3:08,  6 users,  load average: 0.24, 0.16, 0.14


  • netstat -el | grep 23723
[distuser@qa5-trtaupdbmaster-01 ~]$ netstat -el | grep 23723
tcp        0      0 *:23723                     *:*                         LISTEN      activemq   2811678  
  • sudo netstat -lptn --- List listening tcp process and port
#  -l : listen process , -p: process, -t: TCP, -n: not use name resolved
$ sudo netstat -lptn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0  *               LISTEN      6283/java           
tcp        0      0 *               LISTEN      2483/synergys       
tcp        0      0 *               LISTEN      2094/mysqld         
tcp        0      0 *               LISTEN      2164/memcached      
tcp        0      0   *               LISTEN      2218/rpcbind
  • find which process listen port 80 --- sudo netstat -lptn | grep 80
[yufei@us ~]$ sudo netstat -lptn | grep 80
tcp6       0      0 :::80                   :::*                    LISTEN      2378/httpd  

  • sudo netstat -lpte --- List listening tcp process and user
[yufei@us ~]$ sudo netstat -lpte
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name    
tcp        0      0 *:irdmi                 *:*                     LISTEN      root       1407395    6283/java           
tcp        0      0 *:24800                 *:*                     LISTEN      root       25483      2483/synergys       
tcp        0      0 *:23306                 *:*                     LISTEN      mysql      24100      2094/mysqld         
tcp        0      0 *:memcache              *:*                     LISTEN      nobody     24636      2164/memcached      
tcp        0      0 *:sunrpc                *:*                     LISTEN      root       25644      2218/rpcbind        
tcp        0      0 *:ssh                   *:*                     LISTEN      root       25715      2212/sshd           
tcp        0      0 localhost:ipp           *:*                     LISTEN      root       22127      1573/cupsd          
tcp        0      0 localhost:smtp          *:*                     LISTEN      root       25723      2223/sendmail: acce


  • route - show / manipulate the IP routing table


  • w - Show who is logged on and what they are doing.
[yufei@localhost ~]$ w
13:30:48 up 12 days,  3:16,  6 users,  load average: 0.08, 0.11, 0.13
yufei    :0        12Dec13 ?xdm?   3:49m  0.13s gdm-session-worker [pam/gdm-password]
yufei    pts/0     Thu13    2:20m  2.77s  2.71s ssh distuser@


  • show listing of last logged in users
yufei    pts/2        :0               Mon Dec 23 17:03 - 19:03  (02:00)    
yufei    pts/1        :0               Mon Dec 23 15:22 - 19:03  (03:41)


  • env - run a program in a modified environment
  • print all or part of environment
>sudo printenv

show all user name

[yufei@localhost ~]$ cut -d: -f1 /etc/passwd

show all group name

[yufei@localhost ~]$ cut -d: -f1 /etc/group


  • hostname - show or set the system's host name
[yufei@localhost ~]$ hostname
# -s , show short hostname
[yufei@localhost ~]$ hostname -s

change linux hostname

vi /etc/sysconfig/network
vi /etc/hosts
reboot system

check dns

host -t TXT qa2-iphoneapp-info
host -i qa2-admindb-vip

check disk usage

  • df - report file system disk space usage
# -h, human readable
# -T, print file system type
[iphone@bjsit1iphonedev01 ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             107G   17G   85G  17% /
tmpfs                 974M  4.7M  969M   1% /dev/shm
[yufei@localhost ~]$ df -Th
Filesystem              Type      Size  Used Avail Use% Mounted on
devtmpfs                devtmpfs  1.9G     0  1.9G   0% /dev
tmpfs                   tmpfs     1.9G  1.4M  1.9G   1% /dev/shm
tmpfs                   tmpfs     1.9G   20M  1.9G   2% /run
  • du - estimate file space usage
[iphone@bjsit1iphonedev01 ~]$ du -sh *
192K    Desktop
40K     Documents
57M     jmeter-2.3.4
12K     memcached
4.0K    Music
#current folder diskusage
[yufei@localhost ~]$ du -sh
1.8G	.

check your shell

shell> echo $SHELL

check dns

[hudson@HPGQA2AGENCY01 ~]$ cat /etc/resolv.conf 
[hudson@HPGQA2AGENCY01 ~]$ host
;; connection timed out; no servers could be reached
[hudson@HPGQA2AGENCY01 ~]$ nslookup
Non-authoritative answer:

network related command


  • query Internet name servers interactively
>nslookup	canonical name =


  • Transfer a url
# -d, --data <data>
# (HTTP) Sends the specified data in a POST request to the HTTP server
curl -d 'hi, the content' http://localhost:3003
  • curl get method
curl http://localhost:3003
  • curl -i , get header info
curl -i http://localhost:9200
# -D - , dump header to standard output
# -# , progress bar
# -o, --output <file> , Write output to <file> instead of stdout. 
lokvins-MacBook-Pro:yufei lokvin$ curl -# -D - -o /dev/null -H "User-Agent:iphone" "" 
HTTP/1.1 302 Moved Temporarily
Server: AkamaiGHost
Content-Length: 0
Date: Wed, 02 Jul 2014 14:26:32 GMT
Connection: keep-alive
Vary: User-Agent
  • curl with multi Header
curl -H "Content-Type: application/json" -H "X-TR-Signature: .."   -d "hi, this is test" ""
  • curl use PUT method
curl -H "Content-Type: application/json" -H "X-TR-Timestamp: "  -X PUT -d "apple"  ""
  • curl get response time
time curl > /dev/null 2>&1


  • non-interactive network downloader, supports http, https, ftp
# -O file, if - used as file, documents will be printed to standard output
wget -O- ""
# wget use proxy
wget -O- -e use_proxy=yes -e http_proxy=

wget with response time

time wget -q --output-document=/dev/null


  • use dig command to find the domain ip

ctrl + r

  • search history command
shell> ctrl + r

ps aux | grep

  • 查找类似名称的 process
#bsd style
shell> ps aux | grep firefox
#unix/linux stype
shell> ps -ef | grep firefox
  • ps aux --sort=-pcpu,+pmem , sort by cpu , memory, - is desc order, + is asc order
 ## find memory consumed top 5 process
 ps aux --sort=-pmem | head -6


  • grep content from file name
[distuser@qa6-ftp-01 apache22]$ grep -H 23381 conf/**/**/**
  • -v , grep invert-match
cat /etc/passwd | grep -v "^#"


  • /etc/bashrc 是全局的环境配置文件

一般引用顺序 /etc/basrc --> ~/.basrc --> ~/.bash_profile


//Check specify process open files count
shell>sudo /usr/sbin/lsof -p 16508 |wc -l
//查找监听 3306 port 的 process
shell>lsof -i:3306

commons use command


  • cat 将文件输出到标准输出
shell>cat .bash_profile
  • 将 file1 , file2 的内容合并放入 file3
shell> cat file1 file2 > file3
  • 将 foo.txt 内容追加到 love.txt 之后
shell> cat foo.txt >> love.txt
  • > write to a file
  • >> append to a file


  • ls 列出的文件类型

[ d ]是目录
[ - ]是文件
[ l ]表示link file(软链接)
[ b ]表示随机读取的存储设备;
[ c ]表示顺序读取设备,如键盘、鼠标


shell> pwd  //显示当前目录
shell> pwd -P //显示当前目录,将 soft link 转为真实目录


shell> mkdir -m 711 dir1 //建立目录,并指定目录的 r,w,x 权限
shell> mkdir -p dir2/child //建立多级目录


  • more 分页显示
shell>ls -al | more
shell> cat foo.txt  | more


set variable

# no empty before/after =, 
# var name should character and number, can NOT start with number
# 可以使用 "",  将空格内容组合起来。 "$var" is variable value, '$var' 是字面量
# `command`, 可以执行 command
# export var, 使成为环境变量,可以在 child process 中使用 var
# unset var, 取消变量设置
# 一般环境变量upper case, 自定义变量 lower case
shell>echo $myname
shell>echo ${myname}
# 显示环境变量 env
# set 显示其他所有环境变量
# 重要的几个 PS1, 提示符设置
PS1='\h:\W \u\$ '
# $ 当前shell pid
ldev:example renyufei$ echo $$
# ?上条命令的 return code
shell>echo $?

manul of set

 ; && ||

  • run multi shell command in one line use ';' separate
shell>sync; sync; shutdonw -h now


  • tee - read from standard input and write to standard output and files


ssh with config file

ssh no password login

  • enter the ~/.ssh directory
[iphone@bjsit1iphonedev01 .ssh]$ ll
total 24
-rw------- 1 iphone iphone   406 Jun 29  2010 authorized_keys
-rw------- 1 iphone iphone  1679 Jun 29  2010 id_rsa
-rw-r--r-- 1 iphone iphone   406 Jun 29  2010
-rw-r--r-- 1 iphone iphone 11773 Dec 14 17:00 known_hosts
  • id_rsa and were create by command ssh-keygen -t rsa. is your public key, put it's content to the remote machine ~/.ssh/authorized_keys
then you can ssh without password.

 [iphone@bjsit1iphonedev01 .ssh]$ssh-keygen -t rsa -C ""


  • -N "show line number"
  • -n "hide line number"
  •  :GG "to last line"
  •  :1G "to first line"
  •  :100G "to no. 100 line"
  • /searchString "search string"
  • n "find next"
  • N "find reverse netxt"


  • locate a program file in the user's path
Rens-MacBook-Pro:~ renyufei$ which node


  • find a command path
ldev:mex-webdistribution-common renyufei$ whereis mvn

telnet tips

telent telnet port
Connected to (
Escape character is '^]'.
ctrl + ] // 结束http 消息
telnet> quit

cron tab

crontab doc

cron file in folder, use user name as file name

[distuser@qa2-admin-01 ~]$ sudo ls -l /var/spool/cron/
total 16
-rw------- 1 root      root  477 Sep 12 20:53 lisa
-rw------- 1 root      root  217 Sep 24 08:45 rmg
-rw------- 1 root      root  300 Oct  5 10:08 root
-rw------- 1 runnerman root 1134 Jan  8  2014 runnerman
[distuser@qa2-admin-01 ~]$ sudo cat /var/spool/cron/root
00 23 * * * /root/scripts/
0 * * * * cat /dev/null > /usr/local/mysql/data/mysqld/mysqld-slow.log
0 * * * * cat /dev/null > /usr/local/mysql/data/mysqld2/mysqld-slow.log
00 17 * * * mysql -u root -pr00t --port=23308 --socket=/rt/db/tmp/mysqld.sock3 -e 'purge binary logs before now();'

crontab -u user -l
[distuser@qa2-admin-01 ~]$ sudo crontab -u root -l
00 23 * * * /root/scripts/
##remove cron job
crontab -r


  • chkconfig - updates and queries runlevel information for system services
## list chkconfig
shell>sudo /sbin/chkconfig --list

## del chkconfig
shell>/sbin/chkconfig --del memcached_145-trta


kill a batch of process with same name pattern.

[distuser@qa2-iphoneweb-01 ~]$ sudo killall
  • kill all process for specify user
>sudo killall -u runnerman


alias 设置别名,可以设置在文件 ~/.bash_profile 中
直接输入 alias ,查询当前可用别名

alias ll='ls -al'
  • some time you need add shell file under /etc/profile.d , such as:
[yufei@localhost profile.d]$ cat /etc/profile.d/ 
alias jumpfoo='ssh jump@10.xx'


  • use rsync copy file with exlude
rsync -rv --progress --exclude=.git demo demo_bkp

disable selinux

Disabled SELinux first

sudo vi /etc/selinux/config

reboot the system please.

common install from source

  • 一般的从源码安装步骤
#--with-prefix 指定安装位置 
shell> ./configure --with-prefix=/usr/local/dirname 
shell> make 
shell> make install

VNC settings

set vnc server with display rate, edit file /etc/sysconfig/vncservers

shell>sudo vi /etc/sysconfig/vncservers

VNCSERVERARGS[1]="-geometry 1280x800"


你所输入过的 命令,记录在文件 ~/.bash_history 中


系统可用的 shell 在 /etc/shells 文件中记录

localhost:bin lokvin$ cat /etc/shells 
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.


set path variable

shell >vi /home/${user}/.bash_profile

add to path variable following entries:


stop firewalld

  1. stop firewall
sudo systemctl stop firewalld.service

user management

add user

# 新建用户 
shell> sudo adduser lokvin 
# 新建用户,并指定用户组 
shell> sudo adduser -g newgroup lokvin


  • change pass word

check user, group exist

shell>cat /etc/group | grep xxx
shell>id groupname
shell>cat /etc/passwd | grep xxx
shell>id username

check user belong group

$ groups yufei
yufei : yufei adm cdrom sudo dip plugdev lpadmin sambashare docker

add sudo privilege

su root
chmod +w /etc/sudoers
echo '${username} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
chmod -w /etc/sudoers
  • check current user sudo privilege info
shell>sudo -l


yum proxy

shell> sudo vi /etc/yum.conf
#add correct proxy for your env

install by yum

shell> sudo yum install memcached

yum repo dir


yum clean cache

  • clean yum cache
sudo yum clean all

yum on caching

  • edit file /etc/yum.conf, add follow line for no cache

yum list

  • yum list
sudo yum list memcached_145_config

yum error: Metadata file does not match checksum

#add "http_caching=packages" to /etc/yum.conf (the default is "http_caching=all")
#http_caching = { all, none, packages }
>sudo yum clean metadata

set github proxy

ssh proxy

  • Add below two lines to your ~/.ssh/config
  ProxyCommand ssh distuser@ "nc %h %p"
  • Config file previlege should be:
[yufei@localhost project]$ ls -al ~/.ssh/config 
-r--r--r-- 1 root root 69 Oct 30 11:31 /home/yufei/.ssh/config

For http,https protocol (eg:

  • Run below command to add corresponding configs to ~/.gitconfig.
$ git config --global http.proxy



why regexp doesn't work

  • In your bash REGEX, you should remove quotes. That's why that doesn't work.

fc18 install VNC

shell>yum -y install tigervnc-server
# change the user you want to vnc
shell>su john
shell>vncserver :1 -geometry 1600x900 -depth 24
  • create shell for start vnc under ~/bin/ , content like below:
vncserver :1 -geometry 1600x900 -depth 24
[yufei@us bin]$ vncserver help
vncserver -list
vncserver -kill <X-display>
vncserver -kill :1
  • vnc viewer change screen size, ctrl + alt + shift + f

add icon to fe18

gnome-desktop-item-edit /usr/share/applications/ --create-new

fe18 show desktop icons

gsettings set org.gnome.desktop.background show-desktop-icons true

Chinese input (Fedor 18)

  1. Activity --> System Setting --> Region & Language --> Input Sources --> add "Chinese (Intelligence Pinyin)" --> in shortcut setting, add shortcut for "Switch to next source" eg. ctrl+space

install jdk

download a new version jdk ,such as jdk-6u16-linux-i586.bin

shell >sudo chmod a+x jdk-6u16-linux-i586.bin
shell >./jdk-6u16-linux-i586.bin 
shell >sudo mkdir /usr/java
shell >sudo mv jdk1.6.0_16 /usr/java/jdk1.6.0_16 

add /usr/java/jdk1.6.0_16/bin to path

shell >vi ~/.bash_profile

create soft link for java and javac

shell >sudo ln -s /usr/java/jdk1.6.0_16/bin/java /usr/bin/java 
shell >sudo ln -s /usr/java/jdk1.6.0_16/bin/javac /usr/bin/javac 
shell >java -version

install ant

download apache-ant-1.7.1-bin.tar.gz

shell >tar -zxvf apache-ant-1.7.1-bin.tar.gz 
shell >mv apache-ant-1.7.1 ~/ant-1.7.1  
#add ant/bin to .bash_profile 
shell >ant -version 
Apache Ant version 1.7.1 compiled on June 27 2008